Skip to contentSkip to conversation

wifi: rtw89: fix some incorrect settings

PATCH In review Ping-Ke Shih 2 participants 6 messages Jan 13, 2023 – Jan 16, 2023 Realtek wireless driver (rtw89)

lore
Share & tools
lore

Ping-Ke Shih

author maintainer
#0 lore raw

cover wifi: rtw89: fix some incorrect settings

The patches in this patchset are not functional related, but all are to correct register settings. In fact, they doesn't obvious affect user experience, but still need to correct them as expected.

Chih-Kang Chang (1):
wifi: rtw89: 8852c: rfk: correct ADC clock settings

Eric Huang (1):
wifi: rtw89: correct register definitions of digital CFO and spur
elimination

Zong-Zhe Yang (2):
wifi: rtw89: fix assignation of TX BD RAM table
wifi: rtw89: 8852b: fill the missing configuration about queue empty
checking

 drivers/net/wireless/realtek/rtw89/pci.c      | 15 +++++-
 drivers/net/wireless/realtek/rtw89/pci.h      | 15 +++---
 drivers/net/wireless/realtek/rtw89/reg.h      |  9 +++-
 drivers/net/wireless/realtek/rtw89/rtw8852a.c |  6 +--
 .../net/wireless/realtek/rtw89/rtw8852ae.c    |  1 +
 drivers/net/wireless/realtek/rtw89/rtw8852b.c |  2 +
 .../net/wireless/realtek/rtw89/rtw8852be.c    |  1 +
 .../net/wireless/realtek/rtw89/rtw8852c_rfk.c | 51 ++++++++++++++-----
 .../net/wireless/realtek/rtw89/rtw8852ce.c    |  1 +
 9 files changed, 77 insertions(+), 24 deletions(-)
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH 1/4 wifi: rtw89: correct register definitions of digital CFO and spur elimination

From: Eric Huang <[email protected]>

This change fixes the precision of CFO and TX EVM, and it could imporve performance in some cases. Also, use the correctted definition for 8852A.

---
 drivers/net/wireless/realtek/rtw89/reg.h      | 4 ++--
 drivers/net/wireless/realtek/rtw89/rtw8852a.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/realtek/rtw89/reg.h +2 -2
index 578a1969afd61..412a6918efd6c 100644
@@ -4102,9 +4102,9 @@
 #define R_MUIC 0x40F8
 #define B_MUIC_EN BIT(0)
 #define R_DCFO 0x4264
-#define B_DCFO GENMASK(1, 0)
+#define B_DCFO GENMASK(7, 0)
 #define R_SEG0CSI 0x42AC
-#define B_SEG0CSI_IDX GENMASK(11, 0)
+#define B_SEG0CSI_IDX GENMASK(10, 0)
 #define R_SEG0CSI_EN 0x42C4
 #define B_SEG0CSI_EN BIT(23)
 #define R_BSS_CLR_MAP 0x43ac
drivers/net/wireless/realtek/rtw89/rtw8852a.c +3 -3
index 1875c2537ddbd..9f1b134ec8590 100644
@@ -1035,7 +1035,7 @@ static void rtw8852a_spur_elimination(struct rtw89_dev *rtwdev, u8 central_ch)
 				       0x210);
 		rtw89_phy_write32_mask(rtwdev, R_P1_NBIIDX, B_P1_NBIIDX_VAL,
 				       0x210);
-		rtw89_phy_write32_mask(rtwdev, R_SEG0CSI, 0xfff, 0x7c0);
+		rtw89_phy_write32_mask(rtwdev, R_SEG0CSI, B_SEG0CSI_IDX, 0x7c0);
 		rtw89_phy_write32_mask(rtwdev, R_P0_NBIIDX,
 				       B_P0_NBIIDX_NOTCH_EN, 0x1);
 		rtw89_phy_write32_mask(rtwdev, R_P1_NBIIDX,
@@ -1047,7 +1047,7 @@ static void rtw8852a_spur_elimination(struct rtw89_dev *rtwdev, u8 central_ch)
 				       0x210);
 		rtw89_phy_write32_mask(rtwdev, R_P1_NBIIDX, B_P1_NBIIDX_VAL,
 				       0x210);
-		rtw89_phy_write32_mask(rtwdev, R_SEG0CSI, 0xfff, 0x40);
+		rtw89_phy_write32_mask(rtwdev, R_SEG0CSI, B_SEG0CSI_IDX, 0x40);
 		rtw89_phy_write32_mask(rtwdev, R_P0_NBIIDX,
 				       B_P0_NBIIDX_NOTCH_EN, 0x1);
 		rtw89_phy_write32_mask(rtwdev, R_P1_NBIIDX,
@@ -1059,7 +1059,7 @@ static void rtw8852a_spur_elimination(struct rtw89_dev *rtwdev, u8 central_ch)
 				       0x2d0);
 		rtw89_phy_write32_mask(rtwdev, R_P1_NBIIDX, B_P1_NBIIDX_VAL,
 				       0x2d0);
-		rtw89_phy_write32_mask(rtwdev, R_SEG0CSI, 0xfff, 0x740);
+		rtw89_phy_write32_mask(rtwdev, R_SEG0CSI, B_SEG0CSI_IDX, 0x740);
 		rtw89_phy_write32_mask(rtwdev, R_P0_NBIIDX,
 				       B_P0_NBIIDX_NOTCH_EN, 0x1);
 		rtw89_phy_write32_mask(rtwdev, R_P1_NBIIDX,
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/4] wifi: rtw89: correct register definitions of digital CFO and spur elimination

Quoted 7 lines · Ping-Ke Shih

From: Eric Huang <[email protected]>

This change fixes the precision of CFO and TX EVM, and it could imporve performance in some cases. Also, use the correctted definition for 8852A.

4 patches applied to wireless-next.git, thanks.

15423743ae84 wifi: rtw89: correct register definitions of digital CFO and spur elimination 3aa83062c3ec wifi: rtw89: 8852c: rfk: correct ADC clock settings 7f495de6ae7d wifi: rtw89: fix assignation of TX BD RAM table
a3edb20146f0 wifi: rtw89: 8852b: fill the missing configuration about queue empty checking

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
author maintainer
#3 lore raw

PATCH 2/4 wifi: rtw89: 8852c: rfk: correct ADC clock settings

In reply to Ping-Ke Shih

From: Chih-Kang Chang <[email protected]>

Some hardware modules don't have good RF characteristic as regular. It could get ADC abnormal in low temperature, and it causes bad RX performance and affects calibration result of DPK.

---
 drivers/net/wireless/realtek/rtw89/reg.h      |  5 ++
 .../net/wireless/realtek/rtw89/rtw8852c_rfk.c | 51 ++++++++++++++-----
 2 files changed, 44 insertions(+), 12 deletions(-)
drivers/net/wireless/realtek/rtw89/reg.h +5 -0
index 412a6918efd6c..036953f0ec464 100644
@@ -4738,6 +4738,7 @@
 #define R_DRCK_FH 0xC094
 #define B_DRCK_LAT BIT(9)
 #define R_DRCK 0xC0C4
+#define B_DRCK_MUL GENMASK(21, 17)
 #define B_DRCK_IDLE BIT(9)
 #define B_DRCK_EN BIT(6)
 #define B_DRCK_VAL GENMASK(4, 0)
@@ -4755,9 +4756,13 @@
 #define B_PATH0_SAMPL_DLY_T_MSK_V1 GENMASK(27, 26)
 #define R_P0_CFCH_BW0 0xC0D4
 #define B_P0_CFCH_BW0 GENMASK(27, 26)
+#define B_P0_CFCH_EN GENMASK(14, 11)
+#define B_P0_CFCH_CTL GENMASK(10, 7)
 #define R_P0_CFCH_BW1 0xC0D8
 #define B_P0_CFCH_EX BIT(13)
 #define B_P0_CFCH_BW1 GENMASK(8, 5)
+#define R_ADCMOD 0xC0E8
+#define B_ADCMOD_LP GENMASK(31, 16)
 #define R_ADDCK0D 0xC0F0
 #define B_ADDCK0D_VAL2 GENMASK(31, 26)
 #define B_ADDCK0D_VAL GENMASK(25, 16)
drivers/net/wireless/realtek/rtw89/rtw8852c_rfk.c +39 -12

122 lines not on this page · raw message

Signature · 1 line
2.25.1
author maintainer
#4 lore raw

PATCH 3/4 wifi: rtw89: fix assignation of TX BD RAM table

In reply to Ping-Ke Shih

From: Zong-Zhe Yang <[email protected]>

TX BD's RAM table describes how HW allocates usable buffer section for each TX channel at fetch time. The total RAM size for TX BD is chip-dependent. For 8852BE, it has only half size (32) for TX channels of single band. Original table arrange total size (64) for dual band. It will overflow on 8852BE circuit and cause section conflicts between different TX channels.

So, we do the changes below.
* add another table for single band chip and export both kind of tables
* point to the expected one in rtw89_pci_info by chip

---
 drivers/net/wireless/realtek/rtw89/pci.c       | 15 ++++++++++++++-
 drivers/net/wireless/realtek/rtw89/pci.h       | 15 +++++++++------
 drivers/net/wireless/realtek/rtw89/rtw8852ae.c |  1 +
 drivers/net/wireless/realtek/rtw89/rtw8852be.c |  1 +
 drivers/net/wireless/realtek/rtw89/rtw8852ce.c |  1 +
 5 files changed, 26 insertions(+), 7 deletions(-)
drivers/net/wireless/realtek/rtw89/pci.c +14 -1
index 1c4500ba777c6..0ea734c81b4f0 100644
@@ -1384,7 +1384,7 @@ static int rtw89_pci_ops_tx_write(struct rtw89_dev *rtwdev, struct rtw89_core_tx
 	return 0;
 }
 
-static const struct rtw89_pci_bd_ram bd_ram_table[RTW89_TXCH_NUM] = {
+const struct rtw89_pci_bd_ram rtw89_bd_ram_table_dual[RTW89_TXCH_NUM] = {
 	[RTW89_TXCH_ACH0] = {.start_idx = 0,  .max_num = 5, .min_num = 2},
 	[RTW89_TXCH_ACH1] = {.start_idx = 5,  .max_num = 5, .min_num = 2},
 	[RTW89_TXCH_ACH2] = {.start_idx = 10, .max_num = 5, .min_num = 2},
@@ -1399,11 +1399,24 @@ static const struct rtw89_pci_bd_ram bd_ram_table[RTW89_TXCH_NUM] = {
 	[RTW89_TXCH_CH11] = {.start_idx = 55, .max_num = 5, .min_num = 1},
 	[RTW89_TXCH_CH12] = {.start_idx = 60, .max_num = 4, .min_num = 1},
 };
+EXPORT_SYMBOL(rtw89_bd_ram_table_dual);
+
+const struct rtw89_pci_bd_ram rtw89_bd_ram_table_single[RTW89_TXCH_NUM] = {
+	[RTW89_TXCH_ACH0] = {.start_idx = 0,  .max_num = 5, .min_num = 2},
+	[RTW89_TXCH_ACH1] = {.start_idx = 5,  .max_num = 5, .min_num = 2},
+	[RTW89_TXCH_ACH2] = {.start_idx = 10, .max_num = 5, .min_num = 2},
+	[RTW89_TXCH_ACH3] = {.start_idx = 15, .max_num = 5, .min_num = 2},
+	[RTW89_TXCH_CH8]  = {.start_idx = 20, .max_num = 4, .min_num = 1},
+	[RTW89_TXCH_CH9]  = {.start_idx = 24, .max_num = 4, .min_num = 1},
+	[RTW89_TXCH_CH12] = {.start_idx = 28, .max_num = 4, .min_num = 1},
+};
+EXPORT_SYMBOL(rtw89_bd_ram_table_single);
 
 static void rtw89_pci_reset_trx_rings(struct rtw89_dev *rtwdev)
 {
 	struct rtw89_pci *rtwpci = (struct rtw89_pci *)rtwdev->priv;
 	const struct rtw89_pci_info *info = rtwdev->pci_info;
+	const struct rtw89_pci_bd_ram *bd_ram_table = *info->bd_ram_table;
 	struct rtw89_pci_tx_ring *tx_ring;
 	struct rtw89_pci_rx_ring *rx_ring;
 	struct rtw89_pci_dma_ring *bd_ring;
drivers/net/wireless/realtek/rtw89/pci.h +9 -6
index 7d033501d4d95..1e19740db8c54 100644
@@ -750,6 +750,12 @@ struct rtw89_pci_ch_dma_addr_set {
 	struct rtw89_pci_ch_dma_addr rx[RTW89_RXCH_NUM];
 };
 
+struct rtw89_pci_bd_ram {
+	u8 start_idx;
+	u8 max_num;
+	u8 min_num;
+};
+
 struct rtw89_pci_info {
 	enum mac_ax_bd_trunc_mode txbd_trunc_mode;
 	enum mac_ax_bd_trunc_mode rxbd_trunc_mode;
@@ -785,6 +791,7 @@ struct rtw89_pci_info {
 	u32 tx_dma_ch_mask;
 	const struct rtw89_pci_bd_idx_addr *bd_idx_addr_low_power;
 	const struct rtw89_pci_ch_dma_addr_set *dma_addr_set;
+	const struct rtw89_pci_bd_ram (*bd_ram_table)[RTW89_TXCH_NUM];
 
 	int (*ltr_set)(struct rtw89_dev *rtwdev, bool en);
 	u32 (*fill_txaddr_info)(struct rtw89_dev *rtwdev,
@@ -798,12 +805,6 @@ struct rtw89_pci_info {
 				struct rtw89_pci_isrs *isrs);
 };
 
-struct rtw89_pci_bd_ram {
-	u8 start_idx;
-	u8 max_num;
-	u8 min_num;
-};
-
 struct rtw89_pci_tx_data {
 	dma_addr_t dma;
 };
@@ -1057,6 +1058,8 @@ static inline bool rtw89_pci_ltr_is_err_reg_val(u32 val)
 extern const struct dev_pm_ops rtw89_pm_ops;
 extern const struct rtw89_pci_ch_dma_addr_set rtw89_pci_ch_dma_addr_set;
 extern const struct rtw89_pci_ch_dma_addr_set rtw89_pci_ch_dma_addr_set_v1;
+extern const struct rtw89_pci_bd_ram rtw89_bd_ram_table_dual[RTW89_TXCH_NUM];
+extern const struct rtw89_pci_bd_ram rtw89_bd_ram_table_single[RTW89_TXCH_NUM];
 
 struct pci_device_id;
 
drivers/net/wireless/realtek/rtw89/rtw8852ae.c +1 -0
index 0cd8c0c44d19d..d835a44a1d0d0 100644
@@ -44,6 +44,7 @@ static const struct rtw89_pci_info rtw8852a_pci_info = {
 	.tx_dma_ch_mask		= 0,
 	.bd_idx_addr_low_power	= NULL,
 	.dma_addr_set		= &rtw89_pci_ch_dma_addr_set,
+	.bd_ram_table		= &rtw89_bd_ram_table_dual,
 
 	.ltr_set		= rtw89_pci_ltr_set,
 	.fill_txaddr_info	= rtw89_pci_fill_txaddr_info,
drivers/net/wireless/realtek/rtw89/rtw8852be.c +1 -0
index 0ef2ca8efeb0e..ecf39d2d9f81f 100644
@@ -46,6 +46,7 @@ static const struct rtw89_pci_info rtw8852b_pci_info = {
 				  BIT(RTW89_TXCH_CH10) | BIT(RTW89_TXCH_CH11),
 	.bd_idx_addr_low_power	= NULL,
 	.dma_addr_set		= &rtw89_pci_ch_dma_addr_set,
+	.bd_ram_table		= &rtw89_bd_ram_table_single,
 
 	.ltr_set		= rtw89_pci_ltr_set,
 	.fill_txaddr_info	= rtw89_pci_fill_txaddr_info,
drivers/net/wireless/realtek/rtw89/rtw8852ce.c +1 -0
index 35901f64d17de..80490a5437df6 100644
@@ -53,6 +53,7 @@ static const struct rtw89_pci_info rtw8852c_pci_info = {
 	.tx_dma_ch_mask		= 0,
 	.bd_idx_addr_low_power	= &rtw8852c_bd_idx_addr_low_power,
 	.dma_addr_set		= &rtw89_pci_ch_dma_addr_set_v1,
+	.bd_ram_table		= &rtw89_bd_ram_table_dual,
 
 	.ltr_set		= rtw89_pci_ltr_set_v1,
 	.fill_txaddr_info	= rtw89_pci_fill_txaddr_info_v1,
Signature · 1 line
2.25.1
author maintainer
#5 lore raw

PATCH 4/4 wifi: rtw89: 8852b: fill the missing configuration about queue empty checking

In reply to Ping-Ke Shih

From: Zong-Zhe Yang <[email protected]>

The configurations, wde_qempty_acq_num and wde_qempty_mgq_sel, are used when MAC checks if TX queues are empty. Fill the corresponding setting for 8852B.

---
 drivers/net/wireless/realtek/rtw89/rtw8852b.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/wireless/realtek/rtw89/rtw8852b.c +2 -0
index b9e5363e524b3..caa0887db8a3c 100644
@@ -2437,6 +2437,8 @@ const struct rtw89_chip_info rtw8852b_chip_info = {
 	.rsvd_ple_ofst		= 0x2f800,
 	.hfc_param_ini		= rtw8852b_hfc_param_ini_pcie,
 	.dle_mem		= rtw8852b_dle_mem_pcie,
+	.wde_qempty_acq_num	= 4,
+	.wde_qempty_mgq_sel	= 4,
 	.rf_base_addr		= {0xe000, 0xf000},
 	.pwr_on_seq		= NULL,
 	.pwr_off_seq		= NULL,
Signature · 1 line
2.25.1