Skip to contentSkip to conversation

ath6kl: Allow the radio to report 0 dbm txpower without timing out

PATCH In review Eric Bentley 2 participants 3 messages Aug 30, 2016 – Sep 9, 2016 Atheros ATH6KL wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath6kl: Allow the radio to report 0 dbm txpower without timing out

The ath6kl driver attempts to get the txpower value from the radio by first clearing the existing stored value and then watching the value to become non-zero.

APs allow setting client power to values from -127..127, but this radio is not capable of setting values less then 0 and so will report txpower as 0dbm for both negative and 0 client power values.

When the radio has txpower set to 0dbm txpower (equivalent to 1mw) the ath6kl_cfg80211_get_txpower() function will remain in the wait_event_interruptible_timeout() loop waiting for the value to be non-zero, and will eventually timeout. This results in a 5 second delay in response. However, the correct value of zero is eventually returned.

The 6004 defaults to 63dbm which is then limited by regulatory and hardware limits with max of 18dbm (6003 max is 16dbm), therefore we can use values larger then these to be able to determine when the value has been updated.

To correct the issue, set the value to a nonsensical value (255) and wait for it to change to the valid value.

--
Tested on both 6003 and 6004 based radios. Return value of zero is correctly returned in an expected amount of time (similar to when returning non-zero values) when AP client power is set to both 0 and negative values.

---
 drivers/net/wireless/ath/ath6kl/cfg80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +2 -2
index 72e2ec6..b7fe0af 100644
@@ -1449,14 +1449,14 @@ static int ath6kl_cfg80211_get_txpower(struct wiphy *wiphy,
 		return -EIO;
 
 	if (test_bit(CONNECTED, &vif->flags)) {
-		ar->tx_pwr = 0;
+		ar->tx_pwr = 255;
 
 		if (ath6kl_wmi_get_tx_pwr_cmd(ar->wmi, vif->fw_vif_idx) != 0) {
 			ath6kl_err("ath6kl_wmi_get_tx_pwr_cmd failed\n");
 			return -EIO;
 		}
 
-		wait_event_interruptible_timeout(ar->event_wq, ar->tx_pwr != 0,
+		wait_event_interruptible_timeout(ar->event_wq, ar->tx_pwr != 255,
 						 5 * HZ);
 
 		if (signal_pending(current)) {
Signature · 1 line
2.6.0.GIT
#1 lore raw
Quoted 1 line · Eric Bentley

The ath6kl driver attempts to get the txpower value from the radio by fir=

st

Quoted 11 lines

clearing the existing stored value and then watching the value to become non-zero.

APs allow setting client power to values from -127..127, but this radio is not capable of setting values less then 0 and so will report txpower as 0dbm for both negative and 0 client power values.

When the radio has txpower set to 0dbm txpower (equivalent to 1mw) the ath6kl_cfg80211_get_txpower() function will remain in the wait_event_interruptible_timeout() loop waiting for the value to be non-zero, and will eventually timeout. This results in a 5 second delay i=

n

Quoted 10 lines

response. However, the correct value of zero is eventually returned.

The 6004 defaults to 63dbm which is then limited by regulatory and hardware limits with max of 18dbm (6003 max is 16dbm), therefore we can use values larger then these to be able to determine when the value has been updated.

To correct the issue, set the value to a nonsensical value (255) and wait for it to change to the valid value.

Quoted 7 lines

--
Tested on both 6003 and 6004 based radios. Return value of zero is correctly returned in an expected amount of time (similar to when returning non-zero values) when AP client power is set to both 0 and negative values.

This is perfect now, thanks. I'll just remove the "--" line from the commit log, that looks a bit weird.

--=20
Kalle Valo=

#2 lore raw
In reply to Eric Bentley
Quoted 14 lines · Eric Bentley

The ath6kl driver attempts to get the txpower value from the radio by first clearing the existing stored value and then watching the value to become non-zero.

APs allow setting client power to values from -127..127, but this radio is not capable of setting values less then 0 and so will report txpower as 0dbm for both negative and 0 client power values.

When the radio has txpower set to 0dbm txpower (equivalent to 1mw) the ath6kl_cfg80211_get_txpower() function will remain in the wait_event_interruptible_timeout() loop waiting for the value to be non-zero, and will eventually timeout. This results in a 5 second delay in response. However, the correct value of zero is eventually returned.

Quoted 7 lines

The 6004 defaults to 63dbm which is then limited by regulatory and hardware limits with max of 18dbm (6003 max is 16dbm), therefore we can use values larger then these to be able to determine when the value has been updated.

To correct the issue, set the value to a nonsensical value (255) and wait for it to change to the valid value.

Thanks, 1 patch applied to ath-next branch of ath.git:

cabd34d0e9c4 ath6kl: Allow the radio to report 0 dbm txpower without timing out

Signature · 2 lines
Sent by pwcli
https://patchwork.kernel.org/patch/9304907/