[PATCH v2] wifi: mac80211: don't reconfigure when the last emulated chanctx is removed

Nerijus Bendžiūnas posted 1 patch an hour ago
net/mac80211/main.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
[PATCH v2] wifi: mac80211: don't reconfigure when the last emulated chanctx is removed
Posted by Nerijus Bendžiūnas an hour ago
ieee80211_emulate_remove_chanctx() calls _ieee80211_hw_conf_chan() after
the last channel context has been removed. With no context left,
ieee80211_calc_hw_conf_chan() falls back to the default channel, so the
driver is switched to a channel nobody asked for, and the next context
switches it again.

A monitor interface retunes by removing its context and adding a new
one, so every retune costs the driver two channel changes. Nothing is
transmitting or receiving without a context, and the new context sets
the channel, so the extra reconfiguration is unnecessary. Keep clearing
radar_enabled so the next configuration starts clean.

Measured on an AR9271 (ath9k_htc), where a channel change is a full chip
reset over USB, hopping across the 13 channels in 2.4 GHz, 1000 hops:

                  drv_config calls   median hop   p95 hop
  before                     2006      123.5 ms    183 ms
  after                      1006       92.0 ms    105 ms

Delivery of injected frames to a second card was 99.1% before and 98.3%
after (3863 and 3835 of 3900).

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Nerijus Bendžiūnas <nerijus.bendziunas@gmail.com>
---
Changes in v2:
- Add the Assisted-by tag.
- Rewrite the commit message and shorten the in-code comment. No change
  to the code.

 net/mac80211/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index a59837b9f480..643d59e878c9 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -289,9 +289,12 @@ void ieee80211_emulate_remove_chanctx(struct ieee80211_hw *hw,
 {
 	struct ieee80211_local *local = hw_to_local(hw);
 
+	/*
+	 * No context is left, so there is nothing to configure; the next
+	 * context sets the channel. Reconfiguring here would switch the
+	 * driver to the default channel only to switch it again.
+	 */
 	local->hw.conf.radar_enabled = false;
-
-	_ieee80211_hw_conf_chan(local, NULL);
 }
 EXPORT_SYMBOL(ieee80211_emulate_remove_chanctx);
 

base-commit: ca800a9302764c445de0da0e84d2252400a770ee
-- 
2.55.0