blob: 52924255b305abadba14b6e51d1d0b001d2b5863 [file] [log] [blame]
developer69759902023-12-01 08:55:59 +08001From 794343847530aaa70165e8d764afee1236d6048a Mon Sep 17 00:00:00 2001
developer29808952023-11-18 07:50:06 +08002From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Sat, 18 Nov 2023 07:36:45 +0800
4Subject: [PATCH] wifi: mt76: ACS channel time too long on duty channel
5
developer69759902023-12-01 08:55:59 +08006Issue:
7There's a chance that the channel time for duty channel is zero in ACS
8scan.
developer29808952023-11-18 07:50:06 +08009
10Root cause:
developer69759902023-12-01 08:55:59 +080011The chan_stat may be reset when restore to duty channel.
12Mac80211 will notify to hostapd when scan done and then restore to duty
13channel.
14And mt76 will clear scan flag after restore done.
15If hostapd get the chan_stat before channel_restore, will get the
16correct channel time;
17If hostapd get the chan_stat after channel_restore, will get zero
18channel time;
developer29808952023-11-18 07:50:06 +080019
20Solution:
developer69759902023-12-01 08:55:59 +080021When channel switch, will check the mac80211 scan state but not the mt76 scan flag.
22Mac80211 scan state will be set in scanning, and will be reset after
23scan done and before restore to duty channel.
developer29808952023-11-18 07:50:06 +080024---
developer69759902023-12-01 08:55:59 +080025 mac80211.c | 3 ++-
26 1 file changed, 2 insertions(+), 1 deletion(-)
developer29808952023-11-18 07:50:06 +080027
28diff --git a/mac80211.c b/mac80211.c
developer69759902023-12-01 08:55:59 +080029index aaaf6a9..3a7ec88 100644
developer29808952023-11-18 07:50:06 +080030--- a/mac80211.c
31+++ b/mac80211.c
developer69759902023-12-01 08:55:59 +080032@@ -917,6 +917,7 @@ void mt76_set_channel(struct mt76_phy *phy)
33 struct cfg80211_chan_def *chandef = &hw->conf.chandef;
34 bool offchannel = hw->conf.flags & IEEE80211_CONF_OFFCHANNEL;
35 int timeout = HZ / 5;
36+ unsigned long was_scanning = ieee80211_get_scanning(hw);
37
38 wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(phy), timeout);
39 mt76_update_survey(phy);
40@@ -931,7 +932,7 @@ void mt76_set_channel(struct mt76_phy *phy)
developer29808952023-11-18 07:50:06 +080041 if (!offchannel)
42 phy->main_chan = chandef->chan;
43
44- if (chandef->chan != phy->main_chan)
developer69759902023-12-01 08:55:59 +080045+ if (chandef->chan != phy->main_chan || was_scanning)
developer29808952023-11-18 07:50:06 +080046 memset(phy->chan_state, 0, sizeof(*phy->chan_state));
47 }
48 EXPORT_SYMBOL_GPL(mt76_set_channel);
49--
502.18.0
51