From: Sean Wang <sean.wang@kernel.org>
To: nbd@nbd.name, lorenzo.bianconi@kernel.org
Cc: yu-ching.liu@mediatek.com, chengwei.yu@mediatek.com,
jacobs.wu@mediatek.com, posh.sun@mediatek.com,
clifford.hsu@mediatek.com, linux-wireless@vger.kernel.org,
linux-mediatek@lists.infradead.org,
Sean Wang <sean.wang@mediatek.com>
Subject: [PATCH v2 13/19] wifi: mt76: mt7925: defer the NAN joined-cluster event out of NAN_START
Date: Mon, 16 Nov 2026 17:16:24 -0600 [thread overview]
Message-ID: <20261116231630.1733906-14-sean.wang@kernel.org> (raw)
In-Reply-To: <20261116231630.1733906-1-sean.wang@kernel.org>
From: Jacobs Wu <jacobs.wu@mediatek.com>
The firmware can join an existing cluster from inside the passive scan it
runs at the start of NAN_START, so NAN_EVENT_ID_JOINED_CLUSTER lands while
the start path is still executing and ieee80211_vif_nan_started() is not
true yet. The handler dropped the event with a warning, leaving userspace
unaware of the cluster it had joined, and service discovery then never
completed: measured 4 failures in 12 NDP bring-ups on an MT7925 pair, each
one accompanied by exactly one dropped event on the joining side and none
on the side that created the cluster.
NAN_EVENT_ID_STARTED_CLUSTER already defers past NAN_START through
nan_deferred_work for the same reason; JOINED_CLUSTER is the other exit of
the same firmware warm-up branch and needs the same treatment. Queue it on
that work with its own cluster id, so a started and a joined event pending
at once cannot overwrite each other.
Fixes: a5487a682406 ("wifi: mt76: mt7925: add NAN MCU helpers")
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Jacobs Wu <jacobs.wu@mediatek.com>
---
.../net/wireless/mediatek/mt76/mt7925/nan.c | 20 ++++++++++++++++++-
.../net/wireless/mediatek/mt76/mt7925/nan.h | 1 +
drivers/net/wireless/mediatek/mt76/mt792x.h | 1 +
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/nan.c b/drivers/net/wireless/mediatek/mt76/mt7925/nan.c
index 2d6760c50fc5..0fe8ae6c0d26 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/nan.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/nan.c
@@ -706,8 +706,20 @@ mt7925_nan_mcu_handle_de_event(struct mt792x_dev *dev, struct tlv *tlv)
return;
}
+ /* JOINED_CLUSTER has the same race as STARTED_CLUSTER above: the
+ * firmware joins an existing cluster from inside its start-up passive
+ * scan, so the event can land while NAN_START is still running and
+ * nan.started is not set yet. Defer it the same way instead of
+ * dropping it - a lost join leaves userspace unaware of the cluster it
+ * is in and service discovery never completes.
+ */
if (!dev->nan_vif || !ieee80211_vif_nan_started(dev->nan_vif)) {
- dev_warn(dev->mt76.dev, "nan: joined-cluster event but NAN not started\n");
+ spin_lock_bh(&dev->nan_deferred_lock);
+ memcpy(dev->nan_joined_cluster_id, cluster_id, ETH_ALEN);
+ set_bit(MT7925_NAN_DEFERRED_JOINED_CLUSTER,
+ &dev->nan_deferred_pending);
+ spin_unlock_bh(&dev->nan_deferred_lock);
+ ieee80211_queue_work(dev->mt76.hw, &dev->nan_deferred_work);
return;
}
@@ -729,6 +741,7 @@ mt7925_nan_deferred_work(struct work_struct *work)
{
struct mt792x_dev *dev = container_of(work, struct mt792x_dev,
nan_deferred_work);
+ u8 joined_cluster_id[ETH_ALEN];
struct ieee80211_vif *vif;
unsigned long pending;
u8 cluster_id[ETH_ALEN];
@@ -737,6 +750,7 @@ mt7925_nan_deferred_work(struct work_struct *work)
pending = dev->nan_deferred_pending;
dev->nan_deferred_pending = 0;
memcpy(cluster_id, dev->nan_started_cluster_id, ETH_ALEN);
+ memcpy(joined_cluster_id, dev->nan_joined_cluster_id, ETH_ALEN);
spin_unlock_bh(&dev->nan_deferred_lock);
if (!pending)
@@ -750,6 +764,10 @@ mt7925_nan_deferred_work(struct work_struct *work)
if (test_bit(MT7925_NAN_DEFERRED_STARTED_CLUSTER, &pending))
ieee80211_nan_cluster_joined(vif, cluster_id, true, GFP_KERNEL);
+ if (test_bit(MT7925_NAN_DEFERRED_JOINED_CLUSTER, &pending))
+ ieee80211_nan_cluster_joined(vif, joined_cluster_id, false,
+ GFP_KERNEL);
+
if (test_bit(MT7925_NAN_DEFERRED_SCHED_UPDATE_DONE, &pending))
ieee80211_nan_sched_update_done(vif);
out:
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/nan.h b/drivers/net/wireless/mediatek/mt76/mt7925/nan.h
index 165cf21b787b..94d8d4bc445e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/nan.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/nan.h
@@ -144,6 +144,7 @@ enum mt7925_nan_key_type {
*/
enum mt7925_nan_deferred_event {
MT7925_NAN_DEFERRED_STARTED_CLUSTER,
+ MT7925_NAN_DEFERRED_JOINED_CLUSTER,
MT7925_NAN_DEFERRED_SCHED_UPDATE_DONE,
};
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index 78901585d784..c46b88467193 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -424,6 +424,7 @@ struct mt792x_dev {
spinlock_t nan_deferred_lock;
unsigned long nan_deferred_pending;
u8 nan_started_cluster_id[ETH_ALEN];
+ u8 nan_joined_cluster_id[ETH_ALEN];
struct {
void *va;
--
2.43.0
next prev parent reply other threads:[~2026-11-16 23:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 23:16 [PATCH v2 00/19] wifi: mt76: mt7925: add NAN security and improve NDP reliability (part 2) Sean Wang
2026-11-16 23:16 ` [PATCH v2 01/19] wifi: mt76: mt7925: add NAN low power event control on suspend/resume Sean Wang
2026-11-16 23:16 ` [PATCH v2 02/19] wifi: mt76: mt7925: implement NAN key management MCU command Sean Wang
2026-11-16 23:16 ` [PATCH v2 03/19] wifi: mt76: mt7925: add per-peer RX IGTK/BIGTK and RX GTK WTBLs Sean Wang
2026-11-16 23:16 ` [PATCH v2 04/19] wifi: mt76: mt7925: implement mt7925_nan_set_key for NAN security Sean Wang
2026-11-16 23:16 ` [PATCH v2 05/19] wifi: mt76: mt7925: install NAN BIP keys standalone in sta_key_tlv Sean Wang
2026-11-16 23:16 ` [PATCH v2 06/19] wifi: mt76: mt7925: do not disable RX NAPI twice on unload Sean Wang
2026-11-16 23:16 ` [PATCH v2 07/19] wifi: mt76: mt7925: assign the interface WTBL to the NAN management TXQ Sean Wang
2026-11-16 23:16 ` [PATCH v2 08/19] wifi: mt76: mt7925: do not deactivate shared NAN BSS on peer STA removal Sean Wang
2026-11-16 23:16 ` [PATCH v2 09/19] wifi: mt76: gate NAN unicast mgmt by peer availability via STA queues Sean Wang
2026-11-16 23:16 ` [PATCH v2 10/19] wifi: mt76: mt7925: hold NAN mgmt TX to the discovery window Sean Wang
2026-11-16 23:16 ` [PATCH v2 11/19] wifi: mt76: mt7925: double the retry budget for NAN unicast management Sean Wang
2026-11-16 23:16 ` [PATCH v2 12/19] wifi: mt76: mt7925: let TX status of DW-held NAN frames outlive the DW period Sean Wang
2026-11-16 23:16 ` Sean Wang [this message]
2026-11-16 23:16 ` [PATCH v2 14/19] wifi: mt76: mt7925: steer NAN handshake frames by committed-bitmap state Sean Wang
2026-11-16 23:16 ` [PATCH v2 15/19] wifi: mt76: mt7925: disable only the RX NAPI instances that exist Sean Wang
2026-11-16 23:16 ` [PATCH v2 16/19] wifi: mt76: mt7925: stop queueing resets once the device is being removed Sean Wang
2026-11-16 23:16 ` [PATCH v2 17/19] wifi: mt76: mt7925: bound the lifetime of NAN unicast management frames Sean Wang
2026-11-16 23:16 ` [PATCH v2 18/19] wifi: mt76: mt7925: always deliver the joined-cluster event through the deferred work Sean Wang
2026-11-16 23:16 ` [PATCH v2 19/19] wifi: mt76: mt792x: allow three channels in the NAN combination Sean Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116231630.1733906-14-sean.wang@kernel.org \
--to=sean.wang@kernel.org \
--cc=chengwei.yu@mediatek.com \
--cc=clifford.hsu@mediatek.com \
--cc=jacobs.wu@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@kernel.org \
--cc=nbd@nbd.name \
--cc=posh.sun@mediatek.com \
--cc=sean.wang@mediatek.com \
--cc=yu-ching.liu@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox