wifi: mt76: mt7921: fix missing mutex protection in multiple paths#1034
Open
zbowling wants to merge 1 commit intoopenwrt:masterfrom
Open
wifi: mt76: mt7921: fix missing mutex protection in multiple paths#1034zbowling wants to merge 1 commit intoopenwrt:masterfrom
zbowling wants to merge 1 commit intoopenwrt:masterfrom
Conversation
The MT7921 driver has the same mutex protection bugs as MT7925 - they were inherited when MT7925 was forked from MT7921. Several code paths iterate over active interfaces and call MCU functions without proper mutex protection. Add mutex protection in the following locations: 1. mt7921_set_runtime_pm() in main.c: Called when runtime PM settings change. The callback mt7921_pm_interface_iter() calls MCU functions that require the device mutex to be held. 2. mt7921_regd_set_6ghz_power_type() in main.c: Called during VIF add/remove for 6GHz power type determination. Uses ieee80211_iterate_active_interfaces() without mutex. 3. mt7921_mac_reset_work() in mac.c: After firmware recovery, iterates interfaces to reconnect them. The mt7921_vif_connect_iter() callback calls MCU functions. 4. mt7921_roc_abort_sync() in main.c: The function iterates interfaces and calls MCU functions via mt7921_roc_iter() callback. The mutex must be held during the iteration, not at call sites, to avoid nested mutex acquisition deadlocks in suspend paths. These bugs can cause system hangs during: - Power management state transitions - WiFi reset/recovery - Suspend/resume cycles - 6GHz regulatory power type changes The fix follows the same pattern used in the MT7925 patches, with the mutex protection moved inside mt7921_roc_abort_sync() to avoid deadlocks when called from suspend paths. Suspend paths (pci.c, sdio.c) are updated to remove the outer mutex since mt7921_roc_abort_sync() now handles mutex internally. Signed-off-by: Zac Bowling <zac@zacbowling.com>
49fffc2 to
5cf8e47
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The MT7921 driver has the same mutex protection bugs as MT7925 - they were inherited when MT7925 was forked from MT7921. Several code paths iterate over active interfaces and call MCU functions without proper mutex protection.
Changes
Add mutex protection in the following locations:
mt7921_set_runtime_pm() in main.c:
Called when runtime PM settings change. The callback
mt7921_pm_interface_iter() calls MCU functions that require
the device mutex to be held.
mt7921_regd_set_6ghz_power_type() in main.c:
Called during VIF add/remove for 6GHz power type determination.
Uses ieee80211_iterate_active_interfaces() without mutex.
mt7921_mac_reset_work() in mac.c:
After firmware recovery, iterates interfaces to reconnect them.
The mt7921_vif_connect_iter() callback calls MCU functions.
PCI/SDIO suspend paths (pci.c, sdio.c):
The mt7921_roc_abort_sync() call iterates interfaces without
mutex protection.
Impact
These bugs can cause system hangs during:
Testing
The fix follows the same pattern used in my MT7925 mutex patches (PR #1029 #1030 #1031 #1032).
Related to:
Signed-off-by: Zac Bowling zac@zacbowling.com