mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 23:19:34 +02:00
wifi: mt76: mt7921: refactor regd update to fix recursive mutex deadlock
Split mt7921_mcu_regd_update() into two functions to prevent recursive
mutex acquisition. Introduce __mt7921_mcu_regd_update() as the internal
implementation that assumes the mutex is already held by the caller,
while mt7921_mcu_regd_update() remains as the external interface that
handles mutex acquisition and release.
This fixes a deadlock issue when mt7921_regd_set_6ghz_power_type() is
called with the device mutex already held. Without this change, calling
mt7921_mcu_regd_update() would attempt to acquire the same mutex again,
causing a recursive lock deadlock.
The __mt7921_mcu_regd_update() function can be safely called when the
caller has already acquired the device mutex, avoiding the deadlock
while maintaining proper synchronization for regulatory domain updates.
Fixes: e88098133e ("wifi: mt76: mt7921: refactor regulatory notifier flow")
Signed-off-by: Charlie-cy Wu <Charlie-cy.Wu@mediatek.com>
Link: https://patch.msgid.link/20260629083543.153564-1-jb.tsai@mediatek.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
committed by
Felix Fietkau
parent
808f2767d4
commit
1f83a8378e
@@ -802,7 +802,7 @@ mt7921_regd_set_6ghz_power_type(struct ieee80211_vif *vif, bool is_add)
|
||||
|
||||
out:
|
||||
if (vif->bss_conf.chanreq.oper.chan->band == NL80211_BAND_6GHZ)
|
||||
mt7921_mcu_regd_update(dev, dev->mt76.alpha2, dev->country_ie_env);
|
||||
__mt7921_mcu_regd_update(dev, dev->mt76.alpha2, dev->country_ie_env);
|
||||
}
|
||||
|
||||
int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
|
||||
|
||||
@@ -71,36 +71,45 @@ mt7921_regd_channel_update(struct wiphy *wiphy, struct mt792x_dev *dev)
|
||||
}
|
||||
}
|
||||
|
||||
int mt7921_mcu_regd_update(struct mt792x_dev *dev, u8 *alpha2,
|
||||
enum environment_cap country_ie_env)
|
||||
int __mt7921_mcu_regd_update(struct mt792x_dev *dev, u8 *alpha2,
|
||||
enum environment_cap country_ie_env)
|
||||
{
|
||||
struct mt76_dev *mdev = &dev->mt76;
|
||||
struct ieee80211_hw *hw = mdev->hw;
|
||||
struct wiphy *wiphy = hw->wiphy;
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
dev->regd_in_progress = true;
|
||||
lockdep_assert_held(&dev->mt76.mutex);
|
||||
|
||||
mt792x_mutex_acquire(dev);
|
||||
if (!dev->regd_change)
|
||||
goto err;
|
||||
return 0;
|
||||
|
||||
ret = mt7921_mcu_set_clc(dev, alpha2, country_ie_env);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
return ret;
|
||||
|
||||
mt7921_regd_channel_update(wiphy, dev);
|
||||
|
||||
ret = mt76_connac_mcu_set_channel_domain(hw->priv);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
return ret;
|
||||
|
||||
ret = mt7921_set_tx_sar_pwr(hw, NULL);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int mt7921_mcu_regd_update(struct mt792x_dev *dev, u8 *alpha2,
|
||||
enum environment_cap country_ie_env)
|
||||
{
|
||||
int ret;
|
||||
|
||||
dev->regd_in_progress = true;
|
||||
|
||||
mt792x_mutex_acquire(dev);
|
||||
ret = __mt7921_mcu_regd_update(dev, alpha2, country_ie_env);
|
||||
mt792x_mutex_release(dev);
|
||||
|
||||
dev->regd_change = false;
|
||||
dev->regd_in_progress = false;
|
||||
wake_up(&dev->wait);
|
||||
|
||||
@@ -10,6 +10,8 @@ struct regulatory_request;
|
||||
|
||||
int mt7921_mcu_regd_update(struct mt792x_dev *dev, u8 *alpha2,
|
||||
enum environment_cap country_ie_env);
|
||||
int __mt7921_mcu_regd_update(struct mt792x_dev *dev, u8 *alpha2,
|
||||
enum environment_cap country_ie_env);
|
||||
void mt7921_regd_notifier(struct wiphy *wiphy,
|
||||
struct regulatory_request *request);
|
||||
bool mt7921_regd_clc_supported(struct mt792x_dev *dev);
|
||||
|
||||
Reference in New Issue
Block a user