mt7921e: backport two mt76 fixes to 6.12.y
Subsystems (3)
Hi,
Please consider backporting the following two upstream commits to the 6.12.y stable tree. Both are in Linus' tree and both cherry-pick cleanly onto 6.12.y:
2425dc7beaadc ("wifi: mt76: mt7921: avoid undesired changes of the preset regulatory domain") 5ed54896b6bd4 ("wifi: mt76: mt7921: fix a potential scan no APs")
Together they fix a hard-to-reproduce MT7921e (MT7921 PCIe) lockup we have been tracking on ALT Linux: after a disconnect (signal loss / AP deauth) or repeated reconnects the chip ends up in a wrong firmware state and stops scanning/associating to any network, recoverable only by a chip reset or a module reload. The symptom is reproducible on 6.12.y and gone on 7.1. We could not bisect the symptom to a single upstream commit, but these two are the relevant fixes on the mt7921e path:
- 5ed54896b6bd4 aborts the granted ROC channel before station removal, so the firmware is not left in a wrong state that makes subsequent scans return no APs.
- 2425dc7beaadc stops a connected AP's country IE from re-triggering regulatory/CLC reprogramming once the user has already set a regdomain, which we observed leaving the firmware power/regulatory tables in a bad state.
Neither commit carries a Cc: stable tag, which is why they were not picked up automatically.
Both have been tested on real MT7921e hardware (Acer Aspire 5 A517-52, ASUS VivoBook S14, Lenovo IdeaPad Slim 5 14AHP9) running the 6.12 kernel.
Thanks,
Ajrat Makhmutov
Sasha Levin
maintainerQuoted 3 lines · Ajrat Makhmutov
Please backport to 6.12.y:
2425dc7beaadwifi: mt76: mt7921: avoid undesired changes of the preset regulatory domain5ed54896b6bdwifi: mt76: mt7921: fix a potential scan no APs
I'm going to hold off on this one. The second commit, 5ed54896b6bd, introduces a reachable dev->mutex self-deadlock on STA-remove-while-ROC; the follow-up that cures it (d5059e52) isn't in any stable tree and was never marked for stable (it's only in linux-next so far).
So taking these two alone would queue a deadlock. If d5059e52 lands upstream (or you can confirm it's headed to stable), please resend the request as all three together and I'll take them for 6.12.y.
--
Thanks,
Sasha
Hi Sasha,
Quoted 4 lines
I'm going to hold off on this one. The second commit,
5ed54896b6bd, introduces a reachabledev->mutexself-deadlock on STA-remove-while-ROC; the follow-up that cures it (d5059e52) isn't in any stable tree and was never marked for stable (it's only in linux-next so far).
Thanks, and good catch.
I'll resend the request for all three together as soon as it lands in Linus' tree.
Note for whenever it does: when applied to 6.12.y, d5059e52 needs one trivial change - keep del_timer_sync() instead of timer_delete_sync(), as the timer API rename is not present in 6.12.y.
Thanks,
Ajrat
Hi Sasha,
Quoted 3 lines
So taking these two alone would queue a deadlock. If
d5059e52lands upstream (or you can confirm it's headed to stable), please resend the request as all three together and I'll take them for 6.12.y.
d5059e52 is in mainline - it's already in v7.1-rc6, not just linux-next - so here is the full set; please apply all three to 6.12.y together:
2425dc7beaadc ("wifi: mt76: mt7921: avoid undesired changes of the preset regulatory domain") 5ed54896b6bd4 ("wifi: mt76: mt7921: fix a potential scan no APs") d5059e52fd8bc ("wifi: mt76: mt7921: fix potential deadlock in mt7921_roc_abort_sync")
One note for the 6.12.y backport of d5059e52: keep del_timer_sync() instead of timer_delete_sync() - the timer API rename is not present in 6.12.y. The other two cherry-pick cleanly.
Tested together on real MT7921e hardware (Acer Aspire 5 A517-52, ASUS VivoBook S14, Lenovo IdeaPad Slim 5 14AHP9) on 6.12.
Thanks,
Ajrat
PATCH v3 1/3 wifi: mt76: mt7921: avoid undesired changes of the preset regulatory domain
In reply to Ajrat MakhmutovFrom: Leon Yen <[email protected]>
commit 2425dc7beaadc39c2636f97f8bdc22dc3cf88149 upstream.
Some countries have strict RF restrictions where changing the regulatory domain dynamically based on the connected AP is not acceptable. This patch disables Beacon country IE hinting when a valid country code is set from usersland (e.g., by system using iw or CRDA).
--- drivers/net/wireless/mediatek/mt76/mt7921/init.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/init.c +7 -0
@@ -137,6 +137,13 @@ mt7921_regd_notifier(struct wiphy *wiphy, dev->mt76.region = request->dfs_region; dev->country_ie_env = request->country_ie_env; +if (request->initiator ==NL80211_REGDOM_SET_BY_USER ) { +if (dev->mt76.alpha2[0 ] =='0' && dev->mt76.alpha2[1 ] =='0' ) + wiphy->regulatory_flags &= ~REGULATORY_COUNTRY_IE_IGNORE ; +else + wiphy->regulatory_flags |=REGULATORY_COUNTRY_IE_IGNORE ; + } +if (pm->suspended)return ;
Signature · 1 line
2.50.1
PATCH v3 2/3 wifi: mt76: mt7921: fix a potential scan no APs
From: Quan Zhou <[email protected]>
commit 5ed54896b6bd444223092cab361b0785932119ab upstream.
In multi-channel scenarios, the granted channel must be aborted before station remove. Otherwise, the firmware will be put into a wrong state, resulting in have chance to make subsequence scan no APs. With this patch, the granted channel will be always aborted before station remove.
--- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +4 -3
@@ -368,9 +368,9 @@ void mt7921_roc_abort_sync(struct mt792x_dev *dev)del_timer_sync (&phy->roc_timer);cancel_work_sync (&phy->roc_work);if (test_and_clear_bit (MT76_STATE_ROC , &phy->mt76->state)) -ieee80211_iterate_active_interfaces (mt76_hw (dev), -IEEE80211_IFACE_ITER_RESUME_ALL , - mt7921_roc_iter, (void *)phy); +ieee80211_iterate_interfaces (mt76_hw (dev), +IEEE80211_IFACE_ITER_RESUME_ALL , + mt7921_roc_iter, (void *)phy); }EXPORT_SYMBOL_GPL (mt7921_roc_abort_sync);
@@ -881,6 +881,7 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; +mt7921_roc_abort_sync (dev);mt76_connac_free_pending_tx_skbs (&dev->pm, &msta->deflink.wcid);mt76_connac_pm_wake (&dev->mphy, &dev->pm);
Signature · 1 line
2.50.1
PATCH v3 3/3 wifi: mt76: mt7921: fix potential deadlock in mt7921_roc_abort_sync
In reply to Ajrat MakhmutovFrom: Sean Wang <[email protected]>
commit d5059e52fd8bc624ec4255c9fa01a266513d126b upstream.
roc_abort_sync() can deadlock with roc_work(). roc_work() holds dev->mt76.mutex, while cancel_work_sync() waits for roc_work() to finish. If the caller already owns the same mutex, both sides block and no progress is possible.
This deadlock can occur during station removal when mt76_sta_state() -> mt76_sta_remove() -> mt7921_mac_sta_remove() -> mt7921_roc_abort_sync() invokes cancel_work_sync() while roc_work() is still running and holding dev->mt76.mutex.
This avoids the mutex deadlock and preserves exactly-once work ownership.
[ALT: keep del_timer_sync() instead of timer_delete_sync() — the
timer API rename is not present in 6.12.y. ]
--- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +8 -5
@@ -365,12 +365,15 @@ void mt7921_roc_abort_sync(struct mt792x_dev *dev) {struct mt792x_phy *phy = &dev->phy; +if (!test_and_clear_bit (MT76_STATE_ROC , &phy->mt76->state)) +return ; +del_timer_sync (&phy->roc_timer); -cancel_work_sync (&phy->roc_work); -if (test_and_clear_bit (MT76_STATE_ROC , &phy->mt76->state)) -ieee80211_iterate_interfaces (mt76_hw (dev), -IEEE80211_IFACE_ITER_RESUME_ALL , - mt7921_roc_iter, (void *)phy); +cancel_work (&phy->roc_work); + +ieee80211_iterate_interfaces (mt76_hw (dev), +IEEE80211_IFACE_ITER_RESUME_ALL , + mt7921_roc_iter, (void *)phy); }EXPORT_SYMBOL_GPL (mt7921_roc_abort_sync);
Signature · 1 line
2.50.1
PATCH v2 1/3 wifi: mt76: mt7921: avoid undesired changes of the preset regulatory domain
In reply to Ajrat MakhmutovFrom: Leon Yen <[email protected]>
commit 2425dc7beaadc39c2636f97f8bdc22dc3cf88149 upstream.
Some countries have strict RF restrictions where changing the regulatory domain dynamically based on the connected AP is not acceptable. This patch disables Beacon country IE hinting when a valid country code is set from usersland (e.g., by system using iw or CRDA).
---
v2: drop redundant "cherry picked from" trailer; add backporter
Signed-off-by. No code change.
drivers/net/wireless/mediatek/mt76/mt7921/init.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/init.c +7 -0
@@ -137,6 +137,13 @@ mt7921_regd_notifier(struct wiphy *wiphy, dev->mt76.region = request->dfs_region; dev->country_ie_env = request->country_ie_env; +if (request->initiator ==NL80211_REGDOM_SET_BY_USER ) { +if (dev->mt76.alpha2[0 ] =='0' && dev->mt76.alpha2[1 ] =='0' ) + wiphy->regulatory_flags &= ~REGULATORY_COUNTRY_IE_IGNORE ; +else + wiphy->regulatory_flags |=REGULATORY_COUNTRY_IE_IGNORE ; + } +if (pm->suspended)return ;
Signature · 1 line
2.50.1
PATCH v2 2/3 wifi: mt76: mt7921: fix a potential scan no APs
From: Quan Zhou <[email protected]>
commit 5ed54896b6bd444223092cab361b0785932119ab upstream.
In multi-channel scenarios, the granted channel must be aborted before station remove. Otherwise, the firmware will be put into a wrong state, resulting in have chance to make subsequence scan no APs. With this patch, the granted channel will be always aborted before station remove.
---
v2: drop redundant "cherry picked from" trailer; add backporter
Signed-off-by. No code change.
drivers/net/wireless/mediatek/mt76/mt7921/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +4 -3
@@ -368,9 +368,9 @@ void mt7921_roc_abort_sync(struct mt792x_dev *dev)del_timer_sync (&phy->roc_timer);cancel_work_sync (&phy->roc_work);if (test_and_clear_bit (MT76_STATE_ROC , &phy->mt76->state)) -ieee80211_iterate_active_interfaces (mt76_hw (dev), -IEEE80211_IFACE_ITER_RESUME_ALL , - mt7921_roc_iter, (void *)phy); +ieee80211_iterate_interfaces (mt76_hw (dev), +IEEE80211_IFACE_ITER_RESUME_ALL , + mt7921_roc_iter, (void *)phy); }EXPORT_SYMBOL_GPL (mt7921_roc_abort_sync);
@@ -881,6 +881,7 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; +mt7921_roc_abort_sync (dev);mt76_connac_free_pending_tx_skbs (&dev->pm, &msta->deflink.wcid);mt76_connac_pm_wake (&dev->mphy, &dev->pm);
Signature · 1 line
2.50.1
PATCH v2 3/3 wifi: mt76: mt7921: fix potential deadlock in mt7921_roc_abort_sync
In reply to Ajrat MakhmutovFrom: Sean Wang <[email protected]>
commit d5059e52fd8bc624ec4255c9fa01a266513d126b upstream.
roc_abort_sync() can deadlock with roc_work(). roc_work() holds dev->mt76.mutex, while cancel_work_sync() waits for roc_work() to finish. If the caller already owns the same mutex, both sides block and no progress is possible.
This deadlock can occur during station removal when mt76_sta_state() -> mt76_sta_remove() -> mt7921_mac_sta_remove() -> mt7921_roc_abort_sync() invokes cancel_work_sync() while roc_work() is still running and holding dev->mt76.mutex.
This avoids the mutex deadlock and preserves exactly-once work ownership.
[Ajrat: keep del_timer_sync() instead of timer_delete_sync() — the
timer API rename is not present in 6.12.y. ]
---
v2: drop redundant "cherry picked from" trailer; tag the 6.12.y
adaptation note as [Ajrat] and add backporter Signed-off-by. No code change.
drivers/net/wireless/mediatek/mt76/mt7921/main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +8 -5
@@ -365,12 +365,15 @@ void mt7921_roc_abort_sync(struct mt792x_dev *dev) {struct mt792x_phy *phy = &dev->phy; +if (!test_and_clear_bit (MT76_STATE_ROC , &phy->mt76->state)) +return ; +del_timer_sync (&phy->roc_timer); -cancel_work_sync (&phy->roc_work); -if (test_and_clear_bit (MT76_STATE_ROC , &phy->mt76->state)) -ieee80211_iterate_interfaces (mt76_hw (dev), -IEEE80211_IFACE_ITER_RESUME_ALL , - mt7921_roc_iter, (void *)phy); +cancel_work (&phy->roc_work); + +ieee80211_iterate_interfaces (mt76_hw (dev), +IEEE80211_IFACE_ITER_RESUME_ALL , + mt7921_roc_iter, (void *)phy); }EXPORT_SYMBOL_GPL (mt7921_roc_abort_sync);
Signature · 1 line
2.50.1
v3 cover mt7921e: backport three mt76 fixes to 6.12.y
In reply to Ajrat MakhmutovThis series backports three mt76/mt7921 fixes to 6.12.y. All three are in mainline; none carried Cc: stable, so they were not auto-selected for 6.12.y.
Per your earlier reply, resending as a three-patch series:
https://lore.kernel.org/all/[email protected]/
d5059e52 is already in the v6.18.y and v7.0.y stable trees:
https://github.com/gregkh/linux/commit/91e77840bf13de3add125060cf8b32ca24a52c8c
https://github.com/gregkh/linux/commit/35180c772f5e11e2fa4d80d3dfd50906cb6d9646
The three must go together. 5ed54896 adds mt7921_roc_abort_sync() on the sta-remove path, which runs under dev->mt76.mutex (taken by mt76_sta_remove()); d5059e52 then turns cancel_work_sync() inside roc_abort_sync() into cancel_work() to avoid a self-deadlock with roc_work(). Applying 5ed54896 alone queues a reachable deadlock.
6.12.y note: d5059e52 keeps del_timer_sync() -- the timer_delete_sync() rename is not in 6.12.y. The other two cherry-pick cleanly.
Tested on MT7921e: Acer Aspire 5 A517-52, ASUS VivoBook S14, Lenovo IdeaPad Slim 5 14AHP9.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v3:
* subject prefix now carries target branch (6.12.y)
* cover letter added with stable backport status of d5059e52
* no code changes
PATCH v3 1/3 wifi: mt76: mt7921: avoid undesired changes of the preset regulatory domain
From: Leon Yen <[email protected]>
commit 2425dc7beaadc39c2636f97f8bdc22dc3cf88149 upstream.
Some countries have strict RF restrictions where changing the regulatory domain dynamically based on the connected AP is not acceptable. This patch disables Beacon country IE hinting when a valid country code is set from usersland (e.g., by system using iw or CRDA).
---
v2: drop redundant "cherry picked from" trailer; add backporter
Signed-off-by. No code change.
v3: add cover letter with upstream/stable references; mark target 6.12.y.
drivers/net/wireless/mediatek/mt76/mt7921/init.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/init.c +7 -0
@@ -137,6 +137,13 @@ mt7921_regd_notifier(struct wiphy *wiphy, dev->mt76.region = request->dfs_region; dev->country_ie_env = request->country_ie_env; +if (request->initiator ==NL80211_REGDOM_SET_BY_USER ) { +if (dev->mt76.alpha2[0 ] =='0' && dev->mt76.alpha2[1 ] =='0' ) + wiphy->regulatory_flags &= ~REGULATORY_COUNTRY_IE_IGNORE ; +else + wiphy->regulatory_flags |=REGULATORY_COUNTRY_IE_IGNORE ; + } +if (pm->suspended)return ;
Signature · 1 line
2.50.1
PATCH v3 2/3 wifi: mt76: mt7921: fix a potential scan no APs
In reply to Ajrat MakhmutovFrom: Quan Zhou <[email protected]>
commit 5ed54896b6bd444223092cab361b0785932119ab upstream.
In multi-channel scenarios, the granted channel must be aborted before station remove. Otherwise, the firmware will be put into a wrong state, resulting in have chance to make subsequence scan no APs. With this patch, the granted channel will be always aborted before station remove.
---
v2: drop redundant "cherry picked from" trailer; add backporter
Signed-off-by. No code change.
v3: add cover letter with upstream/stable references; mark target 6.12.y.
drivers/net/wireless/mediatek/mt76/mt7921/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +4 -3
@@ -368,9 +368,9 @@ void mt7921_roc_abort_sync(struct mt792x_dev *dev)del_timer_sync (&phy->roc_timer);cancel_work_sync (&phy->roc_work);if (test_and_clear_bit (MT76_STATE_ROC , &phy->mt76->state)) -ieee80211_iterate_active_interfaces (mt76_hw (dev), -IEEE80211_IFACE_ITER_RESUME_ALL , - mt7921_roc_iter, (void *)phy); +ieee80211_iterate_interfaces (mt76_hw (dev), +IEEE80211_IFACE_ITER_RESUME_ALL , + mt7921_roc_iter, (void *)phy); }EXPORT_SYMBOL_GPL (mt7921_roc_abort_sync);
@@ -881,6 +881,7 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; +mt7921_roc_abort_sync (dev);mt76_connac_free_pending_tx_skbs (&dev->pm, &msta->deflink.wcid);mt76_connac_pm_wake (&dev->mphy, &dev->pm);
Signature · 1 line
2.50.1
PATCH v3 3/3 wifi: mt76: mt7921: fix potential deadlock in mt7921_roc_abort_sync
In reply to Ajrat MakhmutovFrom: Sean Wang <[email protected]>
commit d5059e52fd8bc624ec4255c9fa01a266513d126b upstream.
roc_abort_sync() can deadlock with roc_work(). roc_work() holds dev->mt76.mutex, while cancel_work_sync() waits for roc_work() to finish. If the caller already owns the same mutex, both sides block and no progress is possible.
This deadlock can occur during station removal when mt76_sta_state() -> mt76_sta_remove() -> mt7921_mac_sta_remove() -> mt7921_roc_abort_sync() invokes cancel_work_sync() while roc_work() is still running and holding dev->mt76.mutex.
This avoids the mutex deadlock and preserves exactly-once work ownership.
[Ajrat: keep del_timer_sync() instead of timer_delete_sync() -- the
timer API rename is not present in 6.12.y. ]
---
v2: drop redundant "cherry picked from" trailer; tag the 6.12.y
adaptation note as [Ajrat] and add backporter Signed-off-by. No code change.
v3: add cover letter with upstream/stable references; mark target 6.12.y.
drivers/net/wireless/mediatek/mt76/mt7921/main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +8 -5
@@ -365,12 +365,15 @@ void mt7921_roc_abort_sync(struct mt792x_dev *dev) {struct mt792x_phy *phy = &dev->phy; +if (!test_and_clear_bit (MT76_STATE_ROC , &phy->mt76->state)) +return ; +del_timer_sync (&phy->roc_timer); -cancel_work_sync (&phy->roc_work); -if (test_and_clear_bit (MT76_STATE_ROC , &phy->mt76->state)) -ieee80211_iterate_interfaces (mt76_hw (dev), -IEEE80211_IFACE_ITER_RESUME_ALL , - mt7921_roc_iter, (void *)phy); +cancel_work (&phy->roc_work); + +ieee80211_iterate_interfaces (mt76_hw (dev), +IEEE80211_IFACE_ITER_RESUME_ALL , + mt7921_roc_iter, (void *)phy); }EXPORT_SYMBOL_GPL (mt7921_roc_abort_sync);
Signature · 1 line
2.50.1
Sasha Levin
maintainerQuoted 4 lines
Please backport the following mt76/mt7921 fixes to 6.12.y:
- avoid undesired changes of the preset regulatory domain
- fix a potential scan no APs
- fix potential deadlock inmt7921_roc_abort_sync
All three are now queued for 6.12, thanks. The roc_abort_sync fix was adapted to keep del_timer_sync(), since the timer rename is absent in 6.12.
--
Thanks,
Sasha