2022-11-08 19:12:32

by Bitterblue Smith

[permalink] [raw]
Subject: [PATCH 1/3] wifi: rtl8xxxu: Name some bits used in burst init

Names provided by Ping-Ke Shih.

Suggested-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Bitterblue Smith <[email protected]>
---
This patch should be applied after my older patch:
"[PATCH v2 1/3] wifi: rtl8xxxu: Move burst init to a function​"
---
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 10 +++++-----
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 6 ++++++
2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 839e0546f5ec..e4eb17d03cd7 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -3786,16 +3786,16 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv)
* For USB high speed set 512B packets
*/
val8 = rtl8xxxu_read8(priv, REG_RXDMA_PRO_8723B);
- val8 &= ~(BIT(4) | BIT(5));
- val8 |= BIT(4);
- val8 |= BIT(1) | BIT(2) | BIT(3);
+ u8p_replace_bits(&val8, 1, RXDMA_PRO_DMA_BURST_SIZE);
+ u8p_replace_bits(&val8, 3, RXDMA_PRO_DMA_BURST_CNT);
+ val8 |= RXDMA_PRO_DMA_MODE;
rtl8xxxu_write8(priv, REG_RXDMA_PRO_8723B, val8);

/*
* Enable single packet AMPDU
*/
val8 = rtl8xxxu_read8(priv, REG_HT_SINGLE_AMPDU_8723B);
- val8 |= BIT(7);
+ val8 |= HT_SINGLE_AMPDU_ENABLE;
rtl8xxxu_write8(priv, REG_HT_SINGLE_AMPDU_8723B, val8);

rtl8xxxu_write16(priv, REG_MAX_AGGR_NUM, 0x0c14);
@@ -3820,7 +3820,7 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv)

/* to prevent mac is reseted by bus. */
val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL);
- val8 |= BIT(5) | BIT(6);
+ val8 |= RSV_CTRL_WLOCK_1C | RSV_CTRL_DIS_PRST;
rtl8xxxu_write8(priv, REG_RSV_CTRL, val8);
}

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
index 04bf77959fba..5d4cac4f4c06 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
@@ -68,6 +68,8 @@
#define REG_SPS_OCP_CFG 0x0018
#define REG_8192E_LDOV12_CTRL 0x0014
#define REG_RSV_CTRL 0x001c
+#define RSV_CTRL_WLOCK_1C BIT(5)
+#define RSV_CTRL_DIS_PRST BIT(6)

#define REG_RF_CTRL 0x001f
#define RF_ENABLE BIT(0)
@@ -472,6 +474,9 @@
/* Presumably only found on newer chips such as 8723bu */
#define REG_RX_DMA_CTRL_8723B 0x0286
#define REG_RXDMA_PRO_8723B 0x0290
+#define RXDMA_PRO_DMA_MODE BIT(1) /* Set to 0x1. */
+#define RXDMA_PRO_DMA_BURST_CNT GENMASK(3, 2) /* Set to 0x3. */
+#define RXDMA_PRO_DMA_BURST_SIZE GENMASK(5, 4) /* Set to 0x1. */

#define REG_RF_BB_CMD_ADDR 0x02c0
#define REG_RF_BB_CMD_DATA 0x02c4
@@ -577,6 +582,7 @@
#define REG_STBC_SETTING 0x04c4
#define REG_QUEUE_CTRL 0x04c6
#define REG_HT_SINGLE_AMPDU_8723B 0x04c7
+#define HT_SINGLE_AMPDU_ENABLE BIT(7)
#define REG_PROT_MODE_CTRL 0x04c8
#define REG_MAX_AGGR_NUM 0x04ca
#define REG_RTS_MAX_AGGR_NUM 0x04cb
--
2.38.0


2022-11-08 19:16:32

by Bitterblue Smith

[permalink] [raw]
Subject: [PATCH 3/3] wifi: rtl8xxxu: Use u32_get_bits in *_identify_chip

It simplifies the code a bit.

Suggested-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Bitterblue Smith <[email protected]>
---
This patch should be applied after my older patch:
"[PATCH v2 2/3] wifi: rtl8xxxu: Split up rtl8xxxu_identify_chip"
---
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 3 +--
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 5 ++---
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 5 ++---
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 5 ++---
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 5 ++---
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 1 -
6 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
index ef38891ddbd1..2c4f403ba68f 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
@@ -335,8 +335,7 @@ static int rtl8188fu_identify_chip(struct rtl8xxxu_priv *priv)
priv->has_wifi = 1;

sys_cfg = rtl8xxxu_read32(priv, REG_SYS_CFG);
- priv->chip_cut = (sys_cfg & SYS_CFG_CHIP_VERSION_MASK) >>
- SYS_CFG_CHIP_VERSION_SHIFT;
+ priv->chip_cut = u32_get_bits(sys_cfg, SYS_CFG_CHIP_VERSION_MASK);
if (sys_cfg & SYS_CFG_TRP_VAUX_EN) {
dev_info(dev, "Unsupported test chip\n");
ret = -ENOTSUPP;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
index 6c443e4822d8..e7190cb2e5a3 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
@@ -333,8 +333,7 @@ int rtl8192cu_identify_chip(struct rtl8xxxu_priv *priv)
int ret = 0;

sys_cfg = rtl8xxxu_read32(priv, REG_SYS_CFG);
- priv->chip_cut = (sys_cfg & SYS_CFG_CHIP_VERSION_MASK) >>
- SYS_CFG_CHIP_VERSION_SHIFT;
+ priv->chip_cut = u32_get_bits(sys_cfg, SYS_CFG_CHIP_VERSION_MASK);
if (sys_cfg & SYS_CFG_TRP_VAUX_EN) {
dev_info(dev, "Unsupported test chip\n");
ret = -ENOTSUPP;
@@ -371,7 +370,7 @@ int rtl8192cu_identify_chip(struct rtl8xxxu_priv *priv)
rtl8xxxu_identify_vendor_1bit(priv, vendor);

val32 = rtl8xxxu_read32(priv, REG_GPIO_OUTSTS);
- priv->rom_rev = (val32 & GPIO_RF_RL_ID) >> 28;
+ priv->rom_rev = u32_get_bits(val32, GPIO_RF_RL_ID);

rtl8xxxu_config_endpoints_sie(priv);

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
index fc3336f18892..bdb79dc18f06 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
@@ -485,8 +485,7 @@ int rtl8192eu_identify_chip(struct rtl8xxxu_priv *priv)
int ret = 0;

sys_cfg = rtl8xxxu_read32(priv, REG_SYS_CFG);
- priv->chip_cut = (sys_cfg & SYS_CFG_CHIP_VERSION_MASK) >>
- SYS_CFG_CHIP_VERSION_SHIFT;
+ priv->chip_cut = u32_get_bits(sys_cfg, SYS_CFG_CHIP_VERSION_MASK);
if (sys_cfg & SYS_CFG_TRP_VAUX_EN) {
dev_info(dev, "Unsupported test chip\n");
ret = -ENOTSUPP;
@@ -512,7 +511,7 @@ int rtl8192eu_identify_chip(struct rtl8xxxu_priv *priv)
rtl8xxxu_identify_vendor_2bits(priv, vendor);

val32 = rtl8xxxu_read32(priv, REG_GPIO_OUTSTS);
- priv->rom_rev = (val32 & GPIO_RF_RL_ID) >> 28;
+ priv->rom_rev = u32_get_bits(val32, GPIO_RF_RL_ID);

rtl8xxxu_config_endpoints_sie(priv);

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
index c8ab71ed4ff4..707ac48ecc83 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
@@ -136,8 +136,7 @@ static int rtl8723au_identify_chip(struct rtl8xxxu_priv *priv)
int ret = 0;

sys_cfg = rtl8xxxu_read32(priv, REG_SYS_CFG);
- priv->chip_cut = (sys_cfg & SYS_CFG_CHIP_VERSION_MASK) >>
- SYS_CFG_CHIP_VERSION_SHIFT;
+ priv->chip_cut = u32_get_bits(sys_cfg, SYS_CFG_CHIP_VERSION_MASK);
if (sys_cfg & SYS_CFG_TRP_VAUX_EN) {
dev_info(dev, "Unsupported test chip\n");
ret = -ENOTSUPP;
@@ -165,7 +164,7 @@ static int rtl8723au_identify_chip(struct rtl8xxxu_priv *priv)
rtl8xxxu_identify_vendor_1bit(priv, vendor);

val32 = rtl8xxxu_read32(priv, REG_GPIO_OUTSTS);
- priv->rom_rev = (val32 & GPIO_RF_RL_ID) >> 28;
+ priv->rom_rev = u32_get_bits(val32, GPIO_RF_RL_ID);

rtl8xxxu_config_endpoints_sie(priv);

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
index ece82e613bf0..a0ec895b61a4 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
@@ -311,8 +311,7 @@ static int rtl8723bu_identify_chip(struct rtl8xxxu_priv *priv)
int ret = 0;

sys_cfg = rtl8xxxu_read32(priv, REG_SYS_CFG);
- priv->chip_cut = (sys_cfg & SYS_CFG_CHIP_VERSION_MASK) >>
- SYS_CFG_CHIP_VERSION_SHIFT;
+ priv->chip_cut = u32_get_bits(sys_cfg, SYS_CFG_CHIP_VERSION_MASK);
if (sys_cfg & SYS_CFG_TRP_VAUX_EN) {
dev_info(dev, "Unsupported test chip\n");
ret = -ENOTSUPP;
@@ -338,7 +337,7 @@ static int rtl8723bu_identify_chip(struct rtl8xxxu_priv *priv)
rtl8xxxu_identify_vendor_2bits(priv, vendor);

val32 = rtl8xxxu_read32(priv, REG_GPIO_OUTSTS);
- priv->rom_rev = (val32 & GPIO_RF_RL_ID) >> 28;
+ priv->rom_rev = u32_get_bits(val32, GPIO_RF_RL_ID);

rtl8xxxu_config_endpoints_sie(priv);

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
index 5d4cac4f4c06..3e79efdfb4c2 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
@@ -315,7 +315,6 @@
#define SYS_CFG_SPS_SEL BIT(24) /* 1:LDO regulator mode;
0:Switching regulator mode*/
#define SYS_CFG_CHIP_VERSION_MASK 0xf000 /* Bit 12 - 15 */
-#define SYS_CFG_CHIP_VERSION_SHIFT 12

#define REG_GPIO_OUTSTS 0x00f4 /* For RTL8723 only. */
#define GPIO_EFS_HCI_SEL (BIT(0) | BIT(1))
--
2.38.0

2022-11-08 19:16:39

by Bitterblue Smith

[permalink] [raw]
Subject: [PATCH 2/3] wifi: rtl8xxxu: Use strscpy instead of sprintf

Fill priv->chip_name and priv->chip_vendor with strscpy instead of
sprintf. This is just to prevent future bugs in case the name of a
chip/vendor becomes longer than the size of chip_name/chip_vendor.

Suggested-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Bitterblue Smith <[email protected]>
---
This patch should be applied after my older patch:
"[PATCH v2 2/3] wifi: rtl8xxxu: Split up rtl8xxxu_identify_chip"
---
.../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 2 +-
.../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 8 ++++----
.../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 4 ++--
.../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 2 +-
.../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 2 +-
.../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 12 ++++++------
6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
index 0f77312dd0ca..ef38891ddbd1 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
@@ -327,7 +327,7 @@ static int rtl8188fu_identify_chip(struct rtl8xxxu_priv *priv)
u32 sys_cfg, vendor;
int ret = 0;

- sprintf(priv->chip_name, "8188FU");
+ strscpy(priv->chip_name, "8188FU", sizeof(priv->chip_name));
priv->rtl_chip = RTL8188F;
priv->rf_paths = 1;
priv->rx_paths = 1;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
index 815c1e278e4e..6c443e4822d8 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
@@ -345,12 +345,12 @@ int rtl8192cu_identify_chip(struct rtl8xxxu_priv *priv)
bonding = rtl8xxxu_read32(priv, REG_HPON_FSM);
bonding &= HPON_FSM_BONDING_MASK;
if (bonding == HPON_FSM_BONDING_1T2R) {
- sprintf(priv->chip_name, "8191CU");
+ strscpy(priv->chip_name, "8191CU", sizeof(priv->chip_name));
priv->tx_paths = 1;
priv->usb_interrupts = 1;
priv->rtl_chip = RTL8191C;
} else {
- sprintf(priv->chip_name, "8192CU");
+ strscpy(priv->chip_name, "8192CU", sizeof(priv->chip_name));
priv->tx_paths = 2;
priv->usb_interrupts = 0;
priv->rtl_chip = RTL8192C;
@@ -358,7 +358,7 @@ int rtl8192cu_identify_chip(struct rtl8xxxu_priv *priv)
priv->rf_paths = 2;
priv->rx_paths = 2;
} else {
- sprintf(priv->chip_name, "8188CU");
+ strscpy(priv->chip_name, "8188CU", sizeof(priv->chip_name));
priv->rf_paths = 1;
priv->rx_paths = 1;
priv->tx_paths = 1;
@@ -451,7 +451,7 @@ static int rtl8192cu_parse_efuse(struct rtl8xxxu_priv *priv)
priv->power_base = &rtl8192c_power_base;

if (efuse->rf_regulatory & 0x20) {
- sprintf(priv->chip_name, "8188RU");
+ strscpy(priv->chip_name, "8188RU", sizeof(priv->chip_name));
priv->rtl_chip = RTL8188R;
priv->hi_pa = 1;
priv->no_pape = 1;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
index 7a182073832b..fc3336f18892 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
@@ -496,11 +496,11 @@ int rtl8192eu_identify_chip(struct rtl8xxxu_priv *priv)
bonding = rtl8xxxu_read32(priv, REG_HPON_FSM);
bonding &= HPON_FSM_BONDING_MASK;
if (bonding == HPON_FSM_BONDING_1T2R) {
- sprintf(priv->chip_name, "8191EU");
+ strscpy(priv->chip_name, "8191EU", sizeof(priv->chip_name));
priv->tx_paths = 1;
priv->rtl_chip = RTL8191E;
} else {
- sprintf(priv->chip_name, "8192EU");
+ strscpy(priv->chip_name, "8192EU", sizeof(priv->chip_name));
priv->tx_paths = 2;
priv->rtl_chip = RTL8192E;
}
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
index 33a1114a5853..c8ab71ed4ff4 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
@@ -144,7 +144,7 @@ static int rtl8723au_identify_chip(struct rtl8xxxu_priv *priv)
goto out;
}

- sprintf(priv->chip_name, "8723AU");
+ strscpy(priv->chip_name, "8723AU", sizeof(priv->chip_name));
priv->usb_interrupts = 1;
priv->rtl_chip = RTL8723A;

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
index 558572bdd2c8..ece82e613bf0 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
@@ -319,7 +319,7 @@ static int rtl8723bu_identify_chip(struct rtl8xxxu_priv *priv)
goto out;
}

- sprintf(priv->chip_name, "8723BU");
+ strscpy(priv->chip_name, "8723BU", sizeof(priv->chip_name));
priv->rtl_chip = RTL8723B;
priv->rf_paths = 1;
priv->rx_paths = 1;
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index e4eb17d03cd7..e8fcd531c437 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -1592,10 +1592,10 @@ static void rtl8xxxu_print_chipinfo(struct rtl8xxxu_priv *priv)
void rtl8xxxu_identify_vendor_1bit(struct rtl8xxxu_priv *priv, u32 vendor)
{
if (vendor) {
- sprintf(priv->chip_vendor, "UMC");
+ strscpy(priv->chip_vendor, "UMC", sizeof(priv->chip_vendor));
priv->vendor_umc = 1;
} else {
- sprintf(priv->chip_vendor, "TSMC");
+ strscpy(priv->chip_vendor, "TSMC", sizeof(priv->chip_vendor));
}
}

@@ -1603,18 +1603,18 @@ void rtl8xxxu_identify_vendor_2bits(struct rtl8xxxu_priv *priv, u32 vendor)
{
switch (vendor) {
case SYS_CFG_VENDOR_ID_TSMC:
- sprintf(priv->chip_vendor, "TSMC");
+ strscpy(priv->chip_vendor, "TSMC", sizeof(priv->chip_vendor));
break;
case SYS_CFG_VENDOR_ID_SMIC:
- sprintf(priv->chip_vendor, "SMIC");
+ strscpy(priv->chip_vendor, "SMIC", sizeof(priv->chip_vendor));
priv->vendor_smic = 1;
break;
case SYS_CFG_VENDOR_ID_UMC:
- sprintf(priv->chip_vendor, "UMC");
+ strscpy(priv->chip_vendor, "UMC", sizeof(priv->chip_vendor));
priv->vendor_umc = 1;
break;
default:
- sprintf(priv->chip_vendor, "unknown");
+ strscpy(priv->chip_vendor, "unknown", sizeof(priv->chip_vendor));
}
}

--
2.38.0

2022-11-09 00:44:23

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH 1/3] wifi: rtl8xxxu: Name some bits used in burst init


> -----Original Message-----
> From: Bitterblue Smith <[email protected]>
> Sent: Wednesday, November 9, 2022 2:54 AM
> To: [email protected]
> Cc: Jes Sorensen <[email protected]>; Ping-Ke Shih <[email protected]>
> Subject: [PATCH 1/3] wifi: rtl8xxxu: Name some bits used in burst init
>
> Names provided by Ping-Ke Shih.

Ha. That looks weird to see my name in commit message. Could you say
"use descriptive names instead of magic number" or something like that?

>
> Suggested-by: Ping-Ke Shih <[email protected]>
> Signed-off-by: Bitterblue Smith <[email protected]>
> ---
> This patch should be applied after my older patch:
> "[PATCH v2 1/3] wifi: rtl8xxxu: Move burst init to a function​"

For me, I have reviewed the former patchset, so it is fine to me.
But, I'm not sure if other people want you to change something
in the former patchset but you fix them in this patchset.

> ---
> drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 10 +++++-----
> drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 6 ++++++
> 2 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> index 839e0546f5ec..e4eb17d03cd7 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> @@ -3786,16 +3786,16 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv)
> * For USB high speed set 512B packets
> */
> val8 = rtl8xxxu_read8(priv, REG_RXDMA_PRO_8723B);
> - val8 &= ~(BIT(4) | BIT(5));
> - val8 |= BIT(4);
> - val8 |= BIT(1) | BIT(2) | BIT(3);
> + u8p_replace_bits(&val8, 1, RXDMA_PRO_DMA_BURST_SIZE);
> + u8p_replace_bits(&val8, 3, RXDMA_PRO_DMA_BURST_CNT);
> + val8 |= RXDMA_PRO_DMA_MODE;
> rtl8xxxu_write8(priv, REG_RXDMA_PRO_8723B, val8);
>
> /*
> * Enable single packet AMPDU
> */
> val8 = rtl8xxxu_read8(priv, REG_HT_SINGLE_AMPDU_8723B);
> - val8 |= BIT(7);
> + val8 |= HT_SINGLE_AMPDU_ENABLE;
> rtl8xxxu_write8(priv, REG_HT_SINGLE_AMPDU_8723B, val8);
>
> rtl8xxxu_write16(priv, REG_MAX_AGGR_NUM, 0x0c14);
> @@ -3820,7 +3820,7 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv)
>
> /* to prevent mac is reseted by bus. */
> val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL);
> - val8 |= BIT(5) | BIT(6);
> + val8 |= RSV_CTRL_WLOCK_1C | RSV_CTRL_DIS_PRST;
> rtl8xxxu_write8(priv, REG_RSV_CTRL, val8);
> }
>
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
> index 04bf77959fba..5d4cac4f4c06 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h
> @@ -68,6 +68,8 @@
> #define REG_SPS_OCP_CFG 0x0018
> #define REG_8192E_LDOV12_CTRL 0x0014
> #define REG_RSV_CTRL 0x001c
> +#define RSV_CTRL_WLOCK_1C BIT(5)
> +#define RSV_CTRL_DIS_PRST BIT(6)
>
> #define REG_RF_CTRL 0x001f
> #define RF_ENABLE BIT(0)
> @@ -472,6 +474,9 @@
> /* Presumably only found on newer chips such as 8723bu */
> #define REG_RX_DMA_CTRL_8723B 0x0286
> #define REG_RXDMA_PRO_8723B 0x0290
> +#define RXDMA_PRO_DMA_MODE BIT(1) /* Set to 0x1. */
> +#define RXDMA_PRO_DMA_BURST_CNT GENMASK(3, 2) /* Set to 0x3. */
> +#define RXDMA_PRO_DMA_BURST_SIZE GENMASK(5, 4) /* Set to 0x1. */
>
> #define REG_RF_BB_CMD_ADDR 0x02c0
> #define REG_RF_BB_CMD_DATA 0x02c4
> @@ -577,6 +582,7 @@
> #define REG_STBC_SETTING 0x04c4
> #define REG_QUEUE_CTRL 0x04c6
> #define REG_HT_SINGLE_AMPDU_8723B 0x04c7
> +#define HT_SINGLE_AMPDU_ENABLE BIT(7)
> #define REG_PROT_MODE_CTRL 0x04c8
> #define REG_MAX_AGGR_NUM 0x04ca
> #define REG_RTS_MAX_AGGR_NUM 0x04cb
> --
> 2.38.0
>
> ------Please consider the environment before printing this e-mail.

2022-11-09 00:47:28

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH 2/3] wifi: rtl8xxxu: Use strscpy instead of sprintf



> -----Original Message-----
> From: Bitterblue Smith <[email protected]>
> Sent: Wednesday, November 9, 2022 2:56 AM
> To: [email protected]
> Cc: Jes Sorensen <[email protected]>; Ping-Ke Shih <[email protected]>
> Subject: [PATCH 2/3] wifi: rtl8xxxu: Use strscpy instead of sprintf
>
> Fill priv->chip_name and priv->chip_vendor with strscpy instead of
> sprintf. This is just to prevent future bugs in case the name of a
> chip/vendor becomes longer than the size of chip_name/chip_vendor.
>
> Suggested-by: Ping-Ke Shih <[email protected]>
> Signed-off-by: Bitterblue Smith <[email protected]>

Reviewed-by: Ping-Ke Shih <[email protected]>

> ---
> This patch should be applied after my older patch:
> "[PATCH v2 2/3] wifi: rtl8xxxu: Split up rtl8xxxu_identify_chip"
> ---
> .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 2 +-
> .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 8 ++++----
> .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 4 ++--
> .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 2 +-
> .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 2 +-
> .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 12 ++++++------
> 6 files changed, 15 insertions(+), 15 deletions(-)
>

[...]

2022-11-09 00:52:05

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH 3/3] wifi: rtl8xxxu: Use u32_get_bits in *_identify_chip


> -----Original Message-----
> From: Bitterblue Smith <[email protected]>
> Sent: Wednesday, November 9, 2022 2:58 AM
> To: [email protected]
> Cc: Jes Sorensen <[email protected]>; Ping-Ke Shih <[email protected]>
> Subject: [PATCH 3/3] wifi: rtl8xxxu: Use u32_get_bits in *_identify_chip
>
> It simplifies the code a bit.
>
> Suggested-by: Ping-Ke Shih <[email protected]>
> Signed-off-by: Bitterblue Smith <[email protected]>

Reviewed-by: Ping-Ke Shih <[email protected]>

> ---
> This patch should be applied after my older patch:
> "[PATCH v2 2/3] wifi: rtl8xxxu: Split up rtl8xxxu_identify_chip"
> ---
> drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 3 +--
> drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 5 ++---
> drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 5 ++---
> drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 5 ++---
> drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 5 ++---
> drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 1 -
> 6 files changed, 9 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> index ef38891ddbd1..2c4f403ba68f 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> @@ -335,8 +335,7 @@ static int rtl8188fu_identify_chip(struct rtl8xxxu_priv *priv)
> priv->has_wifi = 1;
>
> sys_cfg = rtl8xxxu_read32(priv, REG_SYS_CFG);
> - priv->chip_cut = (sys_cfg & SYS_CFG_CHIP_VERSION_MASK) >>
> - SYS_CFG_CHIP_VERSION_SHIFT;
> + priv->chip_cut = u32_get_bits(sys_cfg, SYS_CFG_CHIP_VERSION_MASK);

Good to use u32_get_bits() instead of FIELD_GET().
I guess you see Kalle reminded me to use u32_encode_bits(), but I forget to
forward this message to you. Anyway, thanks for your works.

[...]

2022-11-09 16:42:00

by Bitterblue Smith

[permalink] [raw]
Subject: Re: [PATCH 1/3] wifi: rtl8xxxu: Name some bits used in burst init

On 09/11/2022 02:41, Ping-Ke Shih wrote:
>
>> -----Original Message-----
>> From: Bitterblue Smith <[email protected]>
>> Sent: Wednesday, November 9, 2022 2:54 AM
>> To: [email protected]
>> Cc: Jes Sorensen <[email protected]>; Ping-Ke Shih <[email protected]>
>> Subject: [PATCH 1/3] wifi: rtl8xxxu: Name some bits used in burst init
>>
>> Names provided by Ping-Ke Shih.
>
> Ha. That looks weird to see my name in commit message. Could you say
> "use descriptive names instead of magic number" or something like that?
>
Of course, I'll change that.