git: 1656816506fa - stable/13 - LinuxKPI: 802.11: defer workq allocation until we have a name

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sun, 20 Feb 2022 18:15:48 UTC
The branch stable/13 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=1656816506fa27428dd9b2750d11bb37a5e2c3d8

commit 1656816506fa27428dd9b2750d11bb37a5e2c3d8
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-20 16:25: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
    
    (cherry picked from commit 652e22d39562ec396d12860313677599becbc749)
---
 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 fb113d770678..9000c8e62b3b 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -2732,11 +2732,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);
 
@@ -2823,6 +2819,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,