All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ath9k: fix QCA9561 PA bias
@ 2022-04-15 10:44 Thibaut VARÈNE
  2022-04-16 18:39 ` Felix Fietkau
  0 siblings, 1 reply; 7+ messages in thread
From: Thibaut VARÈNE @ 2022-04-15 10:44 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, Kalle Valo, linux-wireless
  Cc: Thibaut VARÈNE, Petr Štetiar, Clemens Hopfer

ath9k is setting the TX PA DC bias level differently on QCA9561 and
QCA9565 although they have the same radio IP-core, which results in a
very low output power and very low throughput as devices are further
away from the AP (compared to other 2.4GHz APs).

In real life testing, without this patch the 2.4GHz throughput on
Yuncore XD3200 is around 10Mbps sitting next to the AP, and close to
practical maximum with the patch applied.

Tested-by: Petr Štetiar <ynezz@true.cz>
Signed-off-by: Clemens Hopfer <openwrt@wireloss.net>
Signed-off-by: Thibaut VARÈNE <hacks+kernel@slashdirt.org>
---
 drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index b0a4ca355..8f8682f25 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -3606,9 +3606,10 @@ static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
 	int bias = ar9003_modal_header(ah, is2ghz)->xpaBiasLvl;
 
 	if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah) ||
-	    AR_SREV_9531(ah) || AR_SREV_9561(ah))
+	    AR_SREV_9531(ah))
 		REG_RMW_FIELD(ah, AR_CH0_TOP2, AR_CH0_TOP2_XPABIASLVL, bias);
-	else if (AR_SREV_9462(ah) || AR_SREV_9550(ah) || AR_SREV_9565(ah))
+	else if (AR_SREV_9462(ah) || AR_SREV_9550(ah) || AR_SREV_9561(ah) ||
+		 AR_SREV_9565(ah))
 		REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
 	else {
 		REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] ath9k: fix QCA9561 PA bias
  2022-04-15 10:44 [PATCH] ath9k: fix QCA9561 PA bias Thibaut VARÈNE
@ 2022-04-16 18:39 ` Felix Fietkau
  2022-04-17 14:46   ` Thibaut VARÈNE
  0 siblings, 1 reply; 7+ messages in thread
From: Felix Fietkau @ 2022-04-16 18:39 UTC (permalink / raw)
  To: Thibaut VARÈNE, Toke Høiland-Jørgensen,
	Kalle Valo, linux-wireless
  Cc: Petr Štetiar, Clemens Hopfer


On 15.04.22 12:44, Thibaut VARÈNE wrote:
> ath9k is setting the TX PA DC bias level differently on QCA9561 and
> QCA9565 although they have the same radio IP-core, which results in a
> very low output power and very low throughput as devices are further
> away from the AP (compared to other 2.4GHz APs).
> 
> In real life testing, without this patch the 2.4GHz throughput on
> Yuncore XD3200 is around 10Mbps sitting next to the AP, and close to
> practical maximum with the patch applied.
> 
> Tested-by: Petr Štetiar <ynezz@true.cz>
> Signed-off-by: Clemens Hopfer <openwrt@wireloss.net>
> Signed-off-by: Thibaut VARÈNE <hacks+kernel@slashdirt.org>
> ---
>   drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
> index b0a4ca355..8f8682f25 100644
> --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
> +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
> @@ -3606,9 +3606,10 @@ static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
>   	int bias = ar9003_modal_header(ah, is2ghz)->xpaBiasLvl;
>   
>   	if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah) ||
> -	    AR_SREV_9531(ah) || AR_SREV_9561(ah))
> +	    AR_SREV_9531(ah))
>   		REG_RMW_FIELD(ah, AR_CH0_TOP2, AR_CH0_TOP2_XPABIASLVL, bias);
> -	else if (AR_SREV_9462(ah) || AR_SREV_9550(ah) || AR_SREV_9565(ah))
> +	else if (AR_SREV_9462(ah) || AR_SREV_9550(ah) || AR_SREV_9561(ah) ||
> +		 AR_SREV_9565(ah))
>   		REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
The patch looks wrong to me. I'm pretty sure that AR_CH0_TOP2 is the 
correct register, the definition has an explicit check for 9561 as well.
I believe this patch works by accident because it avoids writing a wrong 
value to that register.
The value written to that register is wrong, because while the mask 
definition AR_CH0_TOP2_XPABIASLVL uses a different value for 9561, the 
shift definition AR_CH0_TOP2_XPABIASLVL_S is hardcoded to 12, which is 
wrong for 9561.
Please try adjusting it to this:
#define AR_CH0_TOP2_XPABIASLVL_S (AR_SREV_9561(ah) ? 9 : 12)

- Felix

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ath9k: fix QCA9561 PA bias
  2022-04-16 18:39 ` Felix Fietkau
@ 2022-04-17 14:46   ` Thibaut VARÈNE
  2022-04-17 14:51     ` [PATCH v2] ath9k: fix QCA9561 PA bias level Thibaut VARÈNE
  0 siblings, 1 reply; 7+ messages in thread
From: Thibaut VARÈNE @ 2022-04-17 14:46 UTC (permalink / raw)
  To: Felix Fietkau
  Cc: Toke Høiland-Jørgensen, Kalle Valo, linux-wireless,
	Petr Štetiar, Clemens Hopfer

> Le 16 avr. 2022 à 20:39, Felix Fietkau <nbd@nbd.name> a écrit :

> The patch looks wrong to me. I'm pretty sure that AR_CH0_TOP2 is the correct register, the definition has an explicit check for 9561 as well.
> I believe this patch works by accident because it avoids writing a wrong value to that register.
> The value written to that register is wrong, because while the mask definition AR_CH0_TOP2_XPABIASLVL uses a different value for 9561, the shift definition AR_CH0_TOP2_XPABIASLVL_S is hardcoded to 12, which is wrong for 9561.
> Please try adjusting it to this:
> #define AR_CH0_TOP2_XPABIASLVL_S (AR_SREV_9561(ah) ? 9 : 12)

This works, thanks. I’ll submit a v2 now.

Thibaut

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] ath9k: fix QCA9561 PA bias level
  2022-04-17 14:46   ` Thibaut VARÈNE
@ 2022-04-17 14:51     ` Thibaut VARÈNE
  2022-04-17 17:02       ` Felix Fietkau
                         ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Thibaut VARÈNE @ 2022-04-17 14:51 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, Kalle Valo, linux-wireless
  Cc: Felix Fietkau, Petr Štetiar, Clemens Hopfer, Thibaut VARÈNE

This patch fixes an invalid TX PA DC bias level on QCA9561, which
results in a very low output power and very low throughput as devices
are further away from the AP (compared to other 2.4GHz APs).

This patch was suggested by Felix Fietkau, who noted[1]:
"The value written to that register is wrong, because while the mask
definition AR_CH0_TOP2_XPABIASLVL uses a different value for 9561, the
shift definition AR_CH0_TOP2_XPABIASLVL_S is hardcoded to 12, which is
wrong for 9561."

In real life testing, without this patch the 2.4GHz throughput on
Yuncore XD3200 is around 10Mbps sitting next to the AP, and closer to
practical maximum with the patch applied.

[1] https://lore.kernel.org/all/91c58969-c60e-2f41-00ac-737786d435ae@nbd.name

Signed-off-by: Thibaut VARÈNE <hacks+kernel@slashdirt.org>
---
v2: Adjust #define per Felix's suggestion
---
 drivers/net/wireless/ath/ath9k/ar9003_phy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
index a171dbb29..ad949eb02 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
@@ -720,7 +720,7 @@
 #define AR_CH0_TOP2		(AR_SREV_9300(ah) ? 0x1628c : \
 					(AR_SREV_9462(ah) ? 0x16290 : 0x16284))
 #define AR_CH0_TOP2_XPABIASLVL		(AR_SREV_9561(ah) ? 0x1e00 : 0xf000)
-#define AR_CH0_TOP2_XPABIASLVL_S	12
+#define AR_CH0_TOP2_XPABIASLVL_S	(AR_SREV_9561(ah) ? 9 : 12)
 
 #define AR_CH0_XTAL		(AR_SREV_9300(ah) ? 0x16294 : \
 				 ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? 0x16298 : \
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ath9k: fix QCA9561 PA bias level
  2022-04-17 14:51     ` [PATCH v2] ath9k: fix QCA9561 PA bias level Thibaut VARÈNE
@ 2022-04-17 17:02       ` Felix Fietkau
  2022-04-17 19:00       ` Toke Høiland-Jørgensen
  2022-04-23  9:32       ` Kalle Valo
  2 siblings, 0 replies; 7+ messages in thread
From: Felix Fietkau @ 2022-04-17 17:02 UTC (permalink / raw)
  To: Thibaut VARÈNE, Toke Høiland-Jørgensen,
	Kalle Valo, linux-wireless
  Cc: Petr Štetiar, Clemens Hopfer

On 17.04.22 16:51, Thibaut VARÈNE wrote:
> This patch fixes an invalid TX PA DC bias level on QCA9561, which
> results in a very low output power and very low throughput as devices
> are further away from the AP (compared to other 2.4GHz APs).
> 
> This patch was suggested by Felix Fietkau, who noted[1]:
> "The value written to that register is wrong, because while the mask
> definition AR_CH0_TOP2_XPABIASLVL uses a different value for 9561, the
> shift definition AR_CH0_TOP2_XPABIASLVL_S is hardcoded to 12, which is
> wrong for 9561."
> 
> In real life testing, without this patch the 2.4GHz throughput on
> Yuncore XD3200 is around 10Mbps sitting next to the AP, and closer to
> practical maximum with the patch applied.
> 
> [1] https://lore.kernel.org/all/91c58969-c60e-2f41-00ac-737786d435ae@nbd.name
> 
> Signed-off-by: Thibaut VARÈNE <hacks+kernel@slashdirt.org>

Acked-by: Felix Fietkau <nbd@nbd.name>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ath9k: fix QCA9561 PA bias level
  2022-04-17 14:51     ` [PATCH v2] ath9k: fix QCA9561 PA bias level Thibaut VARÈNE
  2022-04-17 17:02       ` Felix Fietkau
@ 2022-04-17 19:00       ` Toke Høiland-Jørgensen
  2022-04-23  9:32       ` Kalle Valo
  2 siblings, 0 replies; 7+ messages in thread
From: Toke Høiland-Jørgensen @ 2022-04-17 19:00 UTC (permalink / raw)
  To: Thibaut VARÈNE, Kalle Valo, linux-wireless
  Cc: Felix Fietkau, Petr Štetiar, Clemens Hopfer, Thibaut VARÈNE

Thibaut VARÈNE <hacks+kernel@slashdirt.org> writes:

> This patch fixes an invalid TX PA DC bias level on QCA9561, which
> results in a very low output power and very low throughput as devices
> are further away from the AP (compared to other 2.4GHz APs).
>
> This patch was suggested by Felix Fietkau, who noted[1]:
> "The value written to that register is wrong, because while the mask
> definition AR_CH0_TOP2_XPABIASLVL uses a different value for 9561, the
> shift definition AR_CH0_TOP2_XPABIASLVL_S is hardcoded to 12, which is
> wrong for 9561."
>
> In real life testing, without this patch the 2.4GHz throughput on
> Yuncore XD3200 is around 10Mbps sitting next to the AP, and closer to
> practical maximum with the patch applied.
>
> [1] https://lore.kernel.org/all/91c58969-c60e-2f41-00ac-737786d435ae@nbd.name
>
> Signed-off-by: Thibaut VARÈNE <hacks+kernel@slashdirt.org>

Thank you for the fix!

Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ath9k: fix QCA9561 PA bias level
  2022-04-17 14:51     ` [PATCH v2] ath9k: fix QCA9561 PA bias level Thibaut VARÈNE
  2022-04-17 17:02       ` Felix Fietkau
  2022-04-17 19:00       ` Toke Høiland-Jørgensen
@ 2022-04-23  9:32       ` Kalle Valo
  2 siblings, 0 replies; 7+ messages in thread
From: Kalle Valo @ 2022-04-23  9:32 UTC (permalink / raw)
  To: Thibaut VARÈNE
  Cc: Toke Høiland-Jørgensen, linux-wireless, Felix Fietkau,
	Petr Štetiar, Clemens Hopfer, Thibaut VARÈNE

Thibaut VARÈNE <hacks+kernel@slashdirt.org> wrote:

> This patch fixes an invalid TX PA DC bias level on QCA9561, which
> results in a very low output power and very low throughput as devices
> are further away from the AP (compared to other 2.4GHz APs).
> 
> This patch was suggested by Felix Fietkau, who noted[1]:
> "The value written to that register is wrong, because while the mask
> definition AR_CH0_TOP2_XPABIASLVL uses a different value for 9561, the
> shift definition AR_CH0_TOP2_XPABIASLVL_S is hardcoded to 12, which is
> wrong for 9561."
> 
> In real life testing, without this patch the 2.4GHz throughput on
> Yuncore XD3200 is around 10Mbps sitting next to the AP, and closer to
> practical maximum with the patch applied.
> 
> [1] https://lore.kernel.org/all/91c58969-c60e-2f41-00ac-737786d435ae@nbd.name
> 
> Signed-off-by: Thibaut VARÈNE <hacks+kernel@slashdirt.org>
> Acked-by: Felix Fietkau <nbd@nbd.name>
> Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

Patch applied to ath-next branch of ath.git, thanks.

e999a5da28a0 ath9k: fix QCA9561 PA bias level

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20220417145145.1847-1-hacks+kernel@slashdirt.org/

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-04-23  9:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15 10:44 [PATCH] ath9k: fix QCA9561 PA bias Thibaut VARÈNE
2022-04-16 18:39 ` Felix Fietkau
2022-04-17 14:46   ` Thibaut VARÈNE
2022-04-17 14:51     ` [PATCH v2] ath9k: fix QCA9561 PA bias level Thibaut VARÈNE
2022-04-17 17:02       ` Felix Fietkau
2022-04-17 19:00       ` Toke Høiland-Jørgensen
2022-04-23  9:32       ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.