git: baf8561bdc3f - main - mt76: ensure net80211 com instance before returning from driver load
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 14 Jun 2026 23:15:24 UTC
The branch main has been updated by bz:
URL: https://cgit.FreeBSD.org/src/commit/?id=baf8561bdc3f39c542a82cd1235fbf4bf97b4310
commit baf8561bdc3f39c542a82cd1235fbf4bf97b4310
Author: Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2026-06-08 06:50:30 +0000
Commit: Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-06-14 22:55:14 +0000
mt76: ensure net80211 com instance before returning from driver load
Do as we have done for iwlwifi (f808c43ad923, bee60c989745) add a
completion event for device registration which calls into 802.11
and creates the wifi "device" (net80211 com instance).
This is needed as otherwise the deferred work in the mt76 drivers
(mt7915, mt7921, mt7925, mt7996; but not the 7615 [*]) would make
driver loading return before the wifi device is there. We would then
continue, e.g., during rc startup and race possibly trying to create
a vap (wlan interface) with the underlying device not being registered
yet and fail.
[*] the 7615 does not seem to do this asynchronously so is fine.
Sponsored by: The FreeBSD Foundation
Tested on: 7921, others to be tested at time
MFC after: 3 days
---
sys/contrib/dev/mediatek/mt76/mac80211.c | 4 ++++
sys/contrib/dev/mediatek/mt76/mt76.h | 3 +++
sys/contrib/dev/mediatek/mt76/mt7915/init.c | 6 ++++++
sys/contrib/dev/mediatek/mt76/mt7921/init.c | 7 +++++++
sys/contrib/dev/mediatek/mt76/mt7925/init.c | 7 +++++++
sys/contrib/dev/mediatek/mt76/mt7996/init.c | 6 ++++++
6 files changed, 33 insertions(+)
diff --git a/sys/contrib/dev/mediatek/mt76/mac80211.c b/sys/contrib/dev/mediatek/mt76/mac80211.c
index bd7aaeb4398e..1f38b7ad6697 100644
--- a/sys/contrib/dev/mediatek/mt76/mac80211.c
+++ b/sys/contrib/dev/mediatek/mt76/mac80211.c
@@ -814,6 +814,10 @@ int mt76_register_device(struct mt76_dev *dev, bool vht,
set_bit(MT76_STATE_REGISTERED, &phy->state);
sched_set_fifo_low(dev->tx_worker.task);
+#if defined(__FreeBSD__)
+ complete(&dev->drv_start_complete);
+#endif
+
return 0;
}
EXPORT_SYMBOL_GPL(mt76_register_device);
diff --git a/sys/contrib/dev/mediatek/mt76/mt76.h b/sys/contrib/dev/mediatek/mt76/mt76.h
index 840725b8b020..ca26a4e43b92 100644
--- a/sys/contrib/dev/mediatek/mt76/mt76.h
+++ b/sys/contrib/dev/mediatek/mt76/mt76.h
@@ -1026,6 +1026,9 @@ struct mt76_dev {
} test_mtd;
#endif
struct workqueue_struct *wq;
+#if defined(__FreeBSD__)
+ struct completion drv_start_complete;
+#endif
union {
struct mt76_mmio mmio;
diff --git a/sys/contrib/dev/mediatek/mt76/mt7915/init.c b/sys/contrib/dev/mediatek/mt76/mt7915/init.c
index 4128942361ff..d87878f9a86e 100644
--- a/sys/contrib/dev/mediatek/mt76/mt7915/init.c
+++ b/sys/contrib/dev/mediatek/mt76/mt7915/init.c
@@ -862,6 +862,9 @@ mt7915_init_hardware(struct mt7915_dev *dev, struct mt7915_phy *phy2)
mt76_wr(dev, MT_INT_SOURCE_CSR, ~0);
INIT_WORK(&dev->init_work, mt7915_init_work);
+#if defined(__FreeBSD__)
+ init_completion(&dev->mt76.drv_start_complete);
+#endif
ret = mt7915_dma_init(dev, phy2);
if (ret)
@@ -1298,6 +1301,9 @@ int mt7915_register_device(struct mt7915_dev *dev)
}
ieee80211_queue_work(mt76_hw(dev), &dev->init_work);
+#if defined(__FreeBSD__)
+ wait_for_completion(&dev->mt76.drv_start_complete);
+#endif
dev->recovery.hw_init_done = true;
diff --git a/sys/contrib/dev/mediatek/mt76/mt7921/init.c b/sys/contrib/dev/mediatek/mt76/mt7921/init.c
index dbbc9e945fe2..ece84a826ea4 100644
--- a/sys/contrib/dev/mediatek/mt76/mt7921/init.c
+++ b/sys/contrib/dev/mediatek/mt76/mt7921/init.c
@@ -308,6 +308,9 @@ int mt7921_register_device(struct mt792x_dev *dev)
INIT_WORK(&dev->reset_work, mt7921_mac_reset_work);
INIT_WORK(&dev->init_work, mt7921_init_work);
+#if defined(__FreeBSD__)
+ init_completion(&dev->mt76.drv_start_complete);
+#endif
INIT_WORK(&dev->phy.roc_work, mt7921_roc_work);
timer_setup(&dev->phy.roc_timer, mt792x_roc_timer, 0);
@@ -359,6 +362,10 @@ int mt7921_register_device(struct mt792x_dev *dev)
queue_work(system_percpu_wq, &dev->init_work);
+#if defined(__FreeBSD__)
+ wait_for_completion(&dev->mt76.drv_start_complete);
+#endif
+
return 0;
}
EXPORT_SYMBOL_GPL(mt7921_register_device);
diff --git a/sys/contrib/dev/mediatek/mt76/mt7925/init.c b/sys/contrib/dev/mediatek/mt76/mt7925/init.c
index 31592775feb3..3b7c1668dc61 100644
--- a/sys/contrib/dev/mediatek/mt76/mt7925/init.c
+++ b/sys/contrib/dev/mediatek/mt76/mt7925/init.c
@@ -228,6 +228,9 @@ int mt7925_register_device(struct mt792x_dev *dev)
INIT_WORK(&dev->reset_work, mt7925_mac_reset_work);
INIT_WORK(&dev->init_work, mt7925_init_work);
+#if defined(__FreeBSD__)
+ init_completion(&dev->mt76.drv_start_complete);
+#endif
INIT_WORK(&dev->phy.roc_work, mt7925_roc_work);
timer_setup(&dev->phy.roc_timer, mt792x_roc_timer, 0);
@@ -282,6 +285,10 @@ int mt7925_register_device(struct mt792x_dev *dev)
queue_work(system_percpu_wq, &dev->init_work);
+#if defined(__FreeBSD__)
+ wait_for_completion(&dev->mt76.drv_start_complete);
+#endif
+
return 0;
}
EXPORT_SYMBOL_GPL(mt7925_register_device);
diff --git a/sys/contrib/dev/mediatek/mt76/mt7996/init.c b/sys/contrib/dev/mediatek/mt76/mt7996/init.c
index 34f1df207f19..6568f77bba37 100644
--- a/sys/contrib/dev/mediatek/mt76/mt7996/init.c
+++ b/sys/contrib/dev/mediatek/mt76/mt7996/init.c
@@ -1222,6 +1222,9 @@ static int mt7996_init_hardware(struct mt7996_dev *dev)
}
INIT_WORK(&dev->init_work, mt7996_init_work);
+#if defined(__FreeBSD__)
+ init_completion(&dev->mt76.drv_start_complete);
+#endif
INIT_WORK(&dev->wed_rro.work, mt7996_wed_rro_work);
INIT_LIST_HEAD(&dev->wed_rro.poll_list);
spin_lock_init(&dev->wed_rro.lock);
@@ -1736,6 +1739,9 @@ int mt7996_register_device(struct mt7996_dev *dev)
#endif
ieee80211_queue_work(mt76_hw(dev), &dev->init_work);
+#if defined(__FreeBSD__)
+ wait_for_completion(&dev->mt76.drv_start_complete);
+#endif
dev->recovery.hw_init_done = true;