git: 652e22d39562 - main - LinuxKPI: 802.11: defer workq allocation until we have a name

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Wed, 16 Feb 2022 03:27:19 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=652e22d39562ec396d12860313677599becbc749

commit 652e22d39562ec396d12860313677599becbc749
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-02-16 03:20:29 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2022-02-16 03:26:30 +0000

    LinuxKPI: 802.11: defer workq allocation until we have a name
    
    Turned out all the workq's taskqueues were named "wlanNA" if you had
    more then one card in a machine as by the time we called wiphy_name()
    the device name was not set yet and we returned the fallback.
    
    Move the alloc_ordered_workqueue() from linuxkpi_ieee80211_alloc_hw()
    to linuxkpi_ieee80211_ifattach() at which time the device name has
    to be set to give us a unique name.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 5cbbf269172f..1bed7de0c454 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -2748,11 +2748,7 @@ linuxkpi_ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops)
 
 	lhw = wiphy_priv(wiphy);
 	lhw->ops = ops;
-	lhw->workq = alloc_ordered_workqueue(wiphy_name(wiphy), 0);
-	if (lhw->workq == NULL) {
-		wiphy_free(wiphy);
-		return (NULL);
-	}
+
 	mtx_init(&lhw->mtx, "lhw", NULL, MTX_DEF | MTX_RECURSE);
 	TAILQ_INIT(&lhw->lvif_head);
 
@@ -2841,6 +2837,11 @@ linuxkpi_ieee80211_ifattach(struct ieee80211_hw *hw)
 	lhw = HW_TO_LHW(hw);
 	ic = lhw->ic;
 
+	/* We do it this late as wiphy->dev should be set for the name. */
+	lhw->workq = alloc_ordered_workqueue(wiphy_name(hw->wiphy), 0);
+	if (lhw->workq == NULL)
+		return (-EAGAIN);
+
 	/* XXX-BZ figure this out how they count his... */
 	if (!is_zero_ether_addr(hw->wiphy->perm_addr)) {
 		IEEE80211_ADDR_COPY(ic->ic_macaddr,