Skip to content

Conversation

@zbowling
Copy link

@zbowling zbowling commented Jan 1, 2026

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:

  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. 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:

  • Power management state transitions
  • WiFi reset/recovery
  • Suspend/resume cycles
  • 6GHz regulatory power type changes

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

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>
@zbowling zbowling force-pushed the mt7921-mutex-fixes branch from 49fffc2 to 5cf8e47 Compare January 7, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant