2024-01-12 23:43:35

by Bitterblue Smith

[permalink] [raw]
Subject: [PATCH] wifi: rtlwifi: rtl8192de: Don't read register in _rtl92de_query_rxphystatus

Instead of reading bit 9 of RFPGA0_XA_HSSIPARAMETER2 every time a frame
is received, just use rtlphy->cck_high_power, which is initialised in
_rtl92d_phy_bb_config(). That bit never changes anyway.

With this change _rtl92de_query_rxphystatus() can be shared with the
upcoming USB driver. The USB driver can't read registers in this
function because register reading can sleep.

Compile tested only.

Signed-off-by: Bitterblue Smith <[email protected]>
---
"That bit never changes anyway." <- I'm 99% sure this is true.
---
drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c
index 02ac69c08ed3..192982ec8152 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c
@@ -42,6 +42,7 @@ static void _rtl92de_query_rxphystatus(struct ieee80211_hw *hw,
bool packet_beacon)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
+ struct rtl_phy *rtlphy = &(rtlpriv->phy);
struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv);
struct phy_sts_cck_8192d *cck_buf;
s8 rx_pwr_all, rx_pwr[4];
@@ -62,9 +63,7 @@ static void _rtl92de_query_rxphystatus(struct ieee80211_hw *hw,
u8 report, cck_highpwr;
cck_buf = (struct phy_sts_cck_8192d *)p_drvinfo;
if (ppsc->rfpwr_state == ERFON)
- cck_highpwr = (u8) rtl_get_bbreg(hw,
- RFPGA0_XA_HSSIPARAMETER2,
- BIT(9));
+ cck_highpwr = rtlphy->cck_high_power;
else
cck_highpwr = false;
if (!cck_highpwr) {
--
2.43.0


2024-01-15 01:31:09

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH] wifi: rtlwifi: rtl8192de: Don't read register in _rtl92de_query_rxphystatus



> -----Original Message-----
> From: Bitterblue Smith <[email protected]>
> Sent: Saturday, January 13, 2024 7:42 AM
> To: [email protected]
> Cc: Ping-Ke Shih <[email protected]>; Larry Finger <[email protected]>
> Subject: [PATCH] wifi: rtlwifi: rtl8192de: Don't read register in _rtl92de_query_rxphystatus
>
> Instead of reading bit 9 of RFPGA0_XA_HSSIPARAMETER2 every time a frame
> is received, just use rtlphy->cck_high_power, which is initialised in
> _rtl92d_phy_bb_config(). That bit never changes anyway.
>
> With this change _rtl92de_query_rxphystatus() can be shared with the
> upcoming USB driver. The USB driver can't read registers in this
> function because register reading can sleep.
>
> Compile tested only.
>
> Signed-off-by: Bitterblue Smith <[email protected]>

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

> ---
> "That bit never changes anyway." <- I'm 99% sure this is true.

I can't find a RTL8192DE, but after checking RFPGA0_XA_HSSIPARAMETER2 and
its address 0x824, I believe you are right.

[...]

2024-01-18 09:35:03

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH] wifi: rtlwifi: rtl8192de: Don't read register in _rtl92de_query_rxphystatus

Bitterblue Smith <[email protected]> wrote:

> Instead of reading bit 9 of RFPGA0_XA_HSSIPARAMETER2 every time a frame
> is received, just use rtlphy->cck_high_power, which is initialised in
> _rtl92d_phy_bb_config(). That bit never changes anyway.
>
> With this change _rtl92de_query_rxphystatus() can be shared with the
> upcoming USB driver. The USB driver can't read registers in this
> function because register reading can sleep.
>
> Compile tested only.
>
> Signed-off-by: Bitterblue Smith <[email protected]>
> Acked-by: Ping-Ke Shih <[email protected]>

Patch applied to wireless-next.git, thanks.

0635d73d85c1 wifi: rtlwifi: rtl8192de: Don't read register in _rtl92de_query_rxphystatus

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

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches