linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH mt76 0/4] wifi: mt76: mt7996: Fix some locking issues for MLO
@ 2025-11-14 13:16 Lorenzo Bianconi
  2025-11-14 13:16 ` [PATCH mt76 1/4] wifi: mt76: mt7996: grab mt76 mutex in mt7996_mac_sta_event() Lorenzo Bianconi
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2025-11-14 13:16 UTC (permalink / raw)
  To: Felix Fietkau, Ryder Lee, Shayne Chen, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Bo Jiao, Peter Chiu
  Cc: linux-wireless, linux-arm-kernel, linux-mediatek,
	Lorenzo Bianconi


---
Lorenzo Bianconi (4):
      wifi: mt76: mt7996: grab mt76 mutex in mt7996_mac_sta_event()
      wifi: mt76: mt7996: Move mt7996_update_beacons inside mt76 mutex critical section
      wifi: mt76: Move mt76_abort_scan out of mt76_reset_device()
      wifi: mt76: mt7996: skip deflink accounting for offchannel links

 drivers/net/wireless/mediatek/mt76/mac80211.c    |  2 --
 drivers/net/wireless/mediatek/mt76/mt7915/mac.c  |  2 ++
 drivers/net/wireless/mediatek/mt76/mt7996/mac.c  |  5 +++--
 drivers/net/wireless/mediatek/mt76/mt7996/main.c | 21 ++++++++++++++-------
 4 files changed, 19 insertions(+), 11 deletions(-)
---
base-commit: c99ebb6132595b4b288a413981197eb076547c5a
change-id: 20251114-mt76-fix-missing-mtx-db664ffcce1a

Best regards,
-- 
Lorenzo Bianconi <lorenzo@kernel.org>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH mt76 1/4] wifi: mt76: mt7996: grab mt76 mutex in mt7996_mac_sta_event()
  2025-11-14 13:16 [PATCH mt76 0/4] wifi: mt76: mt7996: Fix some locking issues for MLO Lorenzo Bianconi
@ 2025-11-14 13:16 ` Lorenzo Bianconi
  2025-11-14 13:16 ` [PATCH mt76 2/4] wifi: mt76: mt7996: Move mt7996_update_beacons inside mt76 mutex critical section Lorenzo Bianconi
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2025-11-14 13:16 UTC (permalink / raw)
  To: Felix Fietkau, Ryder Lee, Shayne Chen, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Bo Jiao, Peter Chiu
  Cc: linux-wireless, linux-arm-kernel, linux-mediatek,
	Lorenzo Bianconi

Grab mt76 mutex in mt7996_mac_sta_event routine in order to rely on
mt76_dereference() utility macro.

Fixes: ecd72f9695e7e ("wifi: mt76: mt7996: Support MLO in mt7996_mac_sta_event()")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/mt7996/main.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index 581314368c5ba566f6050bee86696c4654619176..ad8698cf16242489b92e23befab4d040abbdcac2 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -1160,12 +1160,15 @@ mt7996_mac_sta_event(struct mt7996_dev *dev, struct ieee80211_vif *vif,
 	unsigned long links = sta->valid_links;
 	struct ieee80211_link_sta *link_sta;
 	unsigned int link_id;
+	int err = 0;
+
+	mutex_lock(&dev->mt76.mutex);
 
 	for_each_sta_active_link(vif, sta, link_sta, link_id) {
 		struct ieee80211_bss_conf *link_conf;
 		struct mt7996_sta_link *msta_link;
 		struct mt7996_vif_link *link;
-		int i, err;
+		int i;
 
 		link_conf = link_conf_dereference_protected(vif, link_id);
 		if (!link_conf)
@@ -1185,12 +1188,12 @@ mt7996_mac_sta_event(struct mt7996_dev *dev, struct ieee80211_vif *vif,
 						 link, msta_link,
 						 CONN_STATE_CONNECT, true);
 			if (err)
-				return err;
+				goto unlock;
 
 			err = mt7996_mcu_add_rate_ctrl(dev, msta_link->sta, vif,
 						       link_id, false);
 			if (err)
-				return err;
+				goto unlock;
 
 			msta_link->wcid.tx_info |= MT_WCID_TX_INFO_SET;
 			break;
@@ -1199,7 +1202,7 @@ mt7996_mac_sta_event(struct mt7996_dev *dev, struct ieee80211_vif *vif,
 						 link, msta_link,
 						 CONN_STATE_PORT_SECURE, false);
 			if (err)
-				return err;
+				goto unlock;
 			break;
 		case MT76_STA_EVENT_DISASSOC:
 			for (i = 0; i < ARRAY_SIZE(msta_link->twt.flow); i++)
@@ -1219,8 +1222,10 @@ mt7996_mac_sta_event(struct mt7996_dev *dev, struct ieee80211_vif *vif,
 			break;
 		}
 	}
+unlock:
+	mutex_unlock(&dev->mt76.mutex);
 
-	return 0;
+	return err;
 }
 
 static void

-- 
2.51.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH mt76 2/4] wifi: mt76: mt7996: Move mt7996_update_beacons inside mt76 mutex critical section
  2025-11-14 13:16 [PATCH mt76 0/4] wifi: mt76: mt7996: Fix some locking issues for MLO Lorenzo Bianconi
  2025-11-14 13:16 ` [PATCH mt76 1/4] wifi: mt76: mt7996: grab mt76 mutex in mt7996_mac_sta_event() Lorenzo Bianconi
@ 2025-11-14 13:16 ` Lorenzo Bianconi
  2025-11-14 13:16 ` [PATCH mt76 3/4] wifi: mt76: Move mt76_abort_scan out of mt76_reset_device() Lorenzo Bianconi
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2025-11-14 13:16 UTC (permalink / raw)
  To: Felix Fietkau, Ryder Lee, Shayne Chen, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Bo Jiao, Peter Chiu
  Cc: linux-wireless, linux-arm-kernel, linux-mediatek,
	Lorenzo Bianconi

Move mt7996_update_beacons routine inside mt76 mutex critical section
in mt7996_mac_reset_work() in order to run mt7996_vif_conf_link() in
mt7996_mcu_add_beacon routine.

Fixes: f30906c55a400 ("wifi: mt76: mt7996: disable beacons when going offchannel")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index 9501def3e0e3e20132fdbcfe0b1f489694afdc5f..1fac3815c523c05643705b9b6b7263a7fdf2e3a4 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -2599,11 +2599,10 @@ void mt7996_mac_reset_work(struct work_struct *work)
 	local_bh_enable();
 
 	ieee80211_wake_queues(hw);
+	mt7996_update_beacons(dev);
 
 	mutex_unlock(&dev->mt76.mutex);
 
-	mt7996_update_beacons(dev);
-
 	mt7996_for_each_phy(dev, phy)
 		ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work,
 					     MT7996_WATCHDOG_TIME);

-- 
2.51.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH mt76 3/4] wifi: mt76: Move mt76_abort_scan out of mt76_reset_device()
  2025-11-14 13:16 [PATCH mt76 0/4] wifi: mt76: mt7996: Fix some locking issues for MLO Lorenzo Bianconi
  2025-11-14 13:16 ` [PATCH mt76 1/4] wifi: mt76: mt7996: grab mt76 mutex in mt7996_mac_sta_event() Lorenzo Bianconi
  2025-11-14 13:16 ` [PATCH mt76 2/4] wifi: mt76: mt7996: Move mt7996_update_beacons inside mt76 mutex critical section Lorenzo Bianconi
@ 2025-11-14 13:16 ` Lorenzo Bianconi
  2025-11-14 13:16 ` [PATCH mt76 4/4] wifi: mt76: mt7996: skip deflink accounting for offchannel links Lorenzo Bianconi
  2025-11-14 15:22 ` [PATCH mt76 0/4] wifi: mt76: mt7996: Fix some locking issues for MLO Ben Greear
  4 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2025-11-14 13:16 UTC (permalink / raw)
  To: Felix Fietkau, Ryder Lee, Shayne Chen, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Bo Jiao, Peter Chiu
  Cc: linux-wireless, linux-arm-kernel, linux-mediatek,
	Lorenzo Bianconi

Move mt76_abort_scan routine out of mt76_reset_device() in order to
avoid a possible deadlock since mt76_reset_device routine is running
with mt76 mutex help and mt76_abort_scan_complete() can grab mt76 mutex
in some cases.

Fixes: b36d55610215a ("wifi: mt76: abort scan/roc on hw restart")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/mac80211.c   | 2 --
 drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 2 ++
 drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index 5ceaf78c9ea064bf898c347c611a7ccdf9cb9ebc..5e75861bf6f990dc5745b81224faf705395e894d 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -847,8 +847,6 @@ void mt76_reset_device(struct mt76_dev *dev)
 	}
 	rcu_read_unlock();
 
-	mt76_abort_scan(dev);
-
 	INIT_LIST_HEAD(&dev->wcid_list);
 	INIT_LIST_HEAD(&dev->sta_poll_list);
 	dev->vif_mask = 0;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index 1c0d310146d63bc39357d604b549c83e37c8da35..5caf818e8283438ee3c79124384636cbdd641780 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -1451,6 +1451,8 @@ mt7915_mac_full_reset(struct mt7915_dev *dev)
 	if (ext_phy)
 		cancel_delayed_work_sync(&ext_phy->mac_work);
 
+	mt76_abort_scan(&dev->mt76);
+
 	mutex_lock(&dev->mt76.mutex);
 	for (i = 0; i < 10; i++) {
 		if (!mt7915_mac_restart(dev))
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index 1fac3815c523c05643705b9b6b7263a7fdf2e3a4..6fd732a924ab3a4bdc9224b8fd3cc53438e1db60 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -2420,6 +2420,8 @@ mt7996_mac_full_reset(struct mt7996_dev *dev)
 	mt7996_for_each_phy(dev, phy)
 		cancel_delayed_work_sync(&phy->mt76->mac_work);
 
+	mt76_abort_scan(&dev->mt76);
+
 	mutex_lock(&dev->mt76.mutex);
 	for (i = 0; i < 10; i++) {
 		if (!mt7996_mac_restart(dev))

-- 
2.51.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH mt76 4/4] wifi: mt76: mt7996: skip deflink accounting for offchannel links
  2025-11-14 13:16 [PATCH mt76 0/4] wifi: mt76: mt7996: Fix some locking issues for MLO Lorenzo Bianconi
                   ` (2 preceding siblings ...)
  2025-11-14 13:16 ` [PATCH mt76 3/4] wifi: mt76: Move mt76_abort_scan out of mt76_reset_device() Lorenzo Bianconi
@ 2025-11-14 13:16 ` Lorenzo Bianconi
  2025-11-14 15:22 ` [PATCH mt76 0/4] wifi: mt76: mt7996: Fix some locking issues for MLO Ben Greear
  4 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2025-11-14 13:16 UTC (permalink / raw)
  To: Felix Fietkau, Ryder Lee, Shayne Chen, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Bo Jiao, Peter Chiu
  Cc: linux-wireless, linux-arm-kernel, linux-mediatek,
	Lorenzo Bianconi

Do not take into account offchannel links for deflink accounting.

Fixes: a3316d2fc669f ("wifi: mt76: mt7996: set vif default link_id adding/removing vif links")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/mt7996/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index ad8698cf16242489b92e23befab4d040abbdcac2..d3cd2fed31cd55f1a949ae3f2e3ed5f488514b1d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -376,7 +376,8 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
 
 	ieee80211_iter_keys(mphy->hw, vif, mt7996_key_iter, &it);
 
-	if (mvif->mt76.deflink_id == IEEE80211_LINK_UNSPECIFIED)
+	if (!mlink->wcid->offchannel &&
+	    mvif->mt76.deflink_id == IEEE80211_LINK_UNSPECIFIED)
 		mvif->mt76.deflink_id = link_conf->link_id;
 
 	return 0;
@@ -407,7 +408,8 @@ void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif,
 
 	rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
 
-	if (mvif->mt76.deflink_id == link_conf->link_id) {
+	if (!mlink->wcid->offchannel &&
+	    mvif->mt76.deflink_id == link_conf->link_id) {
 		struct ieee80211_bss_conf *iter;
 		unsigned int link_id;
 

-- 
2.51.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH mt76 0/4] wifi: mt76: mt7996: Fix some locking issues for MLO
  2025-11-14 13:16 [PATCH mt76 0/4] wifi: mt76: mt7996: Fix some locking issues for MLO Lorenzo Bianconi
                   ` (3 preceding siblings ...)
  2025-11-14 13:16 ` [PATCH mt76 4/4] wifi: mt76: mt7996: skip deflink accounting for offchannel links Lorenzo Bianconi
@ 2025-11-14 15:22 ` Ben Greear
  4 siblings, 0 replies; 6+ messages in thread
From: Ben Greear @ 2025-11-14 15:22 UTC (permalink / raw)
  To: Lorenzo Bianconi, Felix Fietkau, Ryder Lee, Shayne Chen,
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno, Bo Jiao,
	Peter Chiu
  Cc: linux-wireless, linux-arm-kernel, linux-mediatek

Hello Lorenzo,

These 4 patches appear to fix some of the problems, but the mac802.11/key.c lockdep
splat remains.  I sent you email with the details.

The kernel crash due to NPE that I was previously hacking around appears gone now,
or at least harder to reproduce.

You are welcome to add:

Tested-by: Ben Greear <greearb@candelatech.com>

Thanks,
Ben


On 11/14/25 05:16, Lorenzo Bianconi wrote:
> 
> ---
> Lorenzo Bianconi (4):
>        wifi: mt76: mt7996: grab mt76 mutex in mt7996_mac_sta_event()
>        wifi: mt76: mt7996: Move mt7996_update_beacons inside mt76 mutex critical section
>        wifi: mt76: Move mt76_abort_scan out of mt76_reset_device()
>        wifi: mt76: mt7996: skip deflink accounting for offchannel links
> 
>   drivers/net/wireless/mediatek/mt76/mac80211.c    |  2 --
>   drivers/net/wireless/mediatek/mt76/mt7915/mac.c  |  2 ++
>   drivers/net/wireless/mediatek/mt76/mt7996/mac.c  |  5 +++--
>   drivers/net/wireless/mediatek/mt76/mt7996/main.c | 21 ++++++++++++++-------
>   4 files changed, 19 insertions(+), 11 deletions(-)
> ---
> base-commit: c99ebb6132595b4b288a413981197eb076547c5a
> change-id: 20251114-mt76-fix-missing-mtx-db664ffcce1a
> 
> Best regards,

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-14 15:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-14 13:16 [PATCH mt76 0/4] wifi: mt76: mt7996: Fix some locking issues for MLO Lorenzo Bianconi
2025-11-14 13:16 ` [PATCH mt76 1/4] wifi: mt76: mt7996: grab mt76 mutex in mt7996_mac_sta_event() Lorenzo Bianconi
2025-11-14 13:16 ` [PATCH mt76 2/4] wifi: mt76: mt7996: Move mt7996_update_beacons inside mt76 mutex critical section Lorenzo Bianconi
2025-11-14 13:16 ` [PATCH mt76 3/4] wifi: mt76: Move mt76_abort_scan out of mt76_reset_device() Lorenzo Bianconi
2025-11-14 13:16 ` [PATCH mt76 4/4] wifi: mt76: mt7996: skip deflink accounting for offchannel links Lorenzo Bianconi
2025-11-14 15:22 ` [PATCH mt76 0/4] wifi: mt76: mt7996: Fix some locking issues for MLO Ben Greear

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).