LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] ath9k: Handle txpower changes even when TPC is disabled
@ 2020-02-29 16:13 Remi Pommarel
  2020-03-11 16:53 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Remi Pommarel @ 2020-02-29 16:13 UTC (permalink / raw)
  To: Lorenzo Bianconi, Kalle Valo
  Cc: QCA ath9k Development, linux-wireless, linux-kernel,
	Remi Pommarel, stable

When TPC is disabled IEEE80211_CONF_CHANGE_POWER event can be handled to
reconfigure HW's maximum txpower.

This fixes 0dBm txpower setting when user attaches to an interface for
the first time with the following scenario:

ieee80211_do_open()
    ath9k_add_interface()
        ath9k_set_txpower() /* Set TX power with not yet initialized
                               sc->hw->conf.power_level */

    ieee80211_hw_config() /* Iniatilize sc->hw->conf.power_level and
                             raise IEEE80211_CONF_CHANGE_POWER */

    ath9k_config() /* IEEE80211_CONF_CHANGE_POWER is ignored */

This issue can be reproduced with the following:

  $ modprobe -r ath9k
  $ modprobe ath9k
  $ wpa_supplicant -i wlan0 -c /tmp/wpa.conf &
  $ iw dev /* Here TX power is either 0 or 3 depending on RF chain */
  $ killall wpa_supplicant
  $ iw dev /* TX power goes back to calibrated value and subsequent
              calls will be fine */

Fixes: 283dd11994cde ("ath9k: add per-vif TX power capability")
Cc: stable@vger.kernel.org
Signed-off-by: Remi Pommarel <repk@triplefau.lt>
---
 drivers/net/wireless/ath/ath9k/main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 0548aa3702e3..ef2b856670e1 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1457,6 +1457,9 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
 		ath_chanctx_set_channel(sc, ctx, &hw->conf.chandef);
 	}
 
+	if (changed & IEEE80211_CONF_CHANGE_POWER)
+		ath9k_set_txpower(sc, NULL);
+
 	mutex_unlock(&sc->mutex);
 	ath9k_ps_restore(sc);
 
-- 
2.25.0


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

* Re: [PATCH] ath9k: Handle txpower changes even when TPC is disabled
  2020-02-29 16:13 [PATCH] ath9k: Handle txpower changes even when TPC is disabled Remi Pommarel
@ 2020-03-11 16:53 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2020-03-11 16:53 UTC (permalink / raw)
  To: Remi Pommarel
  Cc: Lorenzo Bianconi, QCA ath9k Development, linux-wireless,
	linux-kernel, Remi Pommarel, stable

Remi Pommarel <repk@triplefau.lt> wrote:

> When TPC is disabled IEEE80211_CONF_CHANGE_POWER event can be handled to
> reconfigure HW's maximum txpower.
> 
> This fixes 0dBm txpower setting when user attaches to an interface for
> the first time with the following scenario:
> 
> ieee80211_do_open()
>     ath9k_add_interface()
>         ath9k_set_txpower() /* Set TX power with not yet initialized
>                                sc->hw->conf.power_level */
> 
>     ieee80211_hw_config() /* Iniatilize sc->hw->conf.power_level and
>                              raise IEEE80211_CONF_CHANGE_POWER */
> 
>     ath9k_config() /* IEEE80211_CONF_CHANGE_POWER is ignored */
> 
> This issue can be reproduced with the following:
> 
>   $ modprobe -r ath9k
>   $ modprobe ath9k
>   $ wpa_supplicant -i wlan0 -c /tmp/wpa.conf &
>   $ iw dev /* Here TX power is either 0 or 3 depending on RF chain */
>   $ killall wpa_supplicant
>   $ iw dev /* TX power goes back to calibrated value and subsequent
>               calls will be fine */
> 
> Fixes: 283dd11994cde ("ath9k: add per-vif TX power capability")
> Cc: stable@vger.kernel.org
> Signed-off-by: Remi Pommarel <repk@triplefau.lt>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

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

968ae2caad07 ath9k: Handle txpower changes even when TPC is disabled

-- 
https://patchwork.kernel.org/patch/11413917/

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

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

end of thread, other threads:[~2020-03-11 16:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-29 16:13 [PATCH] ath9k: Handle txpower changes even when TPC is disabled Remi Pommarel
2020-03-11 16:53 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).