From nobody Fri Aug 29 13:18:57 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cCzPG2HYdz65W6B; Fri, 29 Aug 2025 13:18:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cCzPG0cZhz3V3C; Fri, 29 Aug 2025 13:18:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756473538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1uT9TYHt4usuFVw86JUVi8kzcHOiPWLeQXrr45P1Pg8=; b=usg3tFT1KWfVRZEMTNCzy9XQ1oHoxHX4lORS/5WbOa3Tbq0Qu3bXyx+dCAoj3k1EKmm/r9 pcgWxiJIP2umLIQWyfSUC4fTL8d0MOAne6sd+uqBZivTdlazHM5io4FVcQYlgJyE+FGQrj FqOQk21c4ASpGCPK/sfB9iEV4UcxyqhoAscT5wgUNwq2fY+1Thv8AsZtus+5pZdBLkIdiC DWYKsGAzmt3axS4jpjX0kswVXLSglXhyJTI2FmpE3ODSCM8wSUEApNhIRNt0N9Y4XplIX/ QnKHY9f/lvU8kMzHF0RcOi1W+LR5TiuZ5VaUItq8THGP6xU0LA4kOnKE3MqlMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756473538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1uT9TYHt4usuFVw86JUVi8kzcHOiPWLeQXrr45P1Pg8=; b=tEKcJd/IU+/rC0LQUhHuDVJEHyodS4FmLcnPTSH+sm62L3mKfUGJCkgOzBcb/AaND7tqS8 0e8weqYlC2u1UFnZrNU4wWLQ3ErYjOqSi7fl6dxYYakP7MZjnj6iaCN2dmouLYMfZgtYzB mitmjggf1reo+G5jIzyU3AHksGyHRYaz7DIlMYAsu7O7GeVT0kS5Z8awIebOPAIB/I+yf6 ZR9V1xZBE7N97nIBIRvCNaKIngBJB1Nu6RWQocVEmCvaVn6hbdt6n92A1+CssoJehMiK6T ECu7s45F2BgS1zxbR00qRz7uiXBI6reQuYOEK6uNky5LN2CaoftIfMGn1jyG8A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1756473538; a=rsa-sha256; cv=none; b=ndyWyuIgV6x/zpJ/oZ94/YxlljsPszBXkC6CMsW1BnSEo8RqK7Q8y/8ymB4jsJw383/C0p Xv5W7YMo3qVA/+pcvXZ+w9V42kwIt0hIRoiFi5OKJK8T2prWz2ruWDzBS0iU/eoeughS9B GlNNE+d+VTtOCMXz8sNBUcWHjGQ+s/GurugvfEvdws+Nf8HDiTvj5wxLHwp9VMyyGB81CE d/w5no2XmRMzvjfqneTw/Muh8Of9ORxlj6mLPeKZkzyf/Y36Mq9vPxbPj+nrnA9LXoRbOW CzI/NMn1japowg3EmARIghMt0j7/ZkBglcGo/lHq1RYO1uax0w95xdMfkhL0pg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cCzPF73QRzhn9; Fri, 29 Aug 2025 13:18:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 57TDIvPv072167; Fri, 29 Aug 2025 13:18:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57TDIvn0072164; Fri, 29 Aug 2025 13:18:57 GMT (envelope-from git) Date: Fri, 29 Aug 2025 13:18:57 GMT Message-Id: <202508291318.57TDIvn0072164@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: fc36de571f11 - main - LinuxKPI: 802.11: adjust lower wake_queue locking List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fc36de571f11abda5cc68a4abd963053f676f8c5 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=fc36de571f11abda5cc68a4abd963053f676f8c5 commit fc36de571f11abda5cc68a4abd963053f676f8c5 Author: Bjoern A. Zeeb AuthorDate: 2025-08-29 07:39:01 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-08-29 13:18:41 +0000 LinuxKPI: 802.11: adjust lower wake_queue locking In bc24342d96aa8 we added lower wake_queue locking. There are paths, such as in rtw89 from a (*hw_scan_cancel)() that we can get to there and then would recursively acquire the wiphy lock which is not allowed. Adjust locking to a spin lock to match Linux driver expectations. Sponsored by: The FreeBSD Foundation Fixes: bc24342d96aa8 MFC after: 3 days --- sys/compat/linuxkpi/common/src/linux_80211.c | 19 +++++++++++++++---- sys/compat/linuxkpi/common/src/linux_80211.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index e248588dd275..cf33a9e27788 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -6042,6 +6042,7 @@ linuxkpi_ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops) LKPI_80211_LHW_SCAN_LOCK_INIT(lhw); LKPI_80211_LHW_TXQ_LOCK_INIT(lhw); + spin_lock_init(&lhw->txq_lock); sx_init_flags(&lhw->lvif_sx, "lhw-lvif", SX_RECURSE | SX_DUPOK); LKPI_80211_LHW_MC_LOCK_INIT(lhw); TAILQ_INIT(&lhw->lvif_head); @@ -6147,6 +6148,7 @@ linuxkpi_ieee80211_iffree(struct ieee80211_hw *hw) LKPI_80211_LHW_MC_UNLOCK(lhw); /* Cleanup more of lhw here or in wiphy_free()? */ + spin_lock_destroy(&lhw->txq_lock); LKPI_80211_LHW_TXQ_LOCK_DESTROY(lhw); LKPI_80211_LHW_SCAN_LOCK_DESTROY(lhw); sx_destroy(&lhw->lvif_sx); @@ -8124,21 +8126,30 @@ lkpi_ieee80211_wake_queues_locked(struct ieee80211_hw *hw) void linuxkpi_ieee80211_wake_queues(struct ieee80211_hw *hw) { - wiphy_lock(hw->wiphy); + struct lkpi_hw *lhw; + unsigned long flags; + + lhw = HW_TO_LHW(hw); + + spin_lock_irqsave(&lhw->txq_lock, flags); lkpi_ieee80211_wake_queues_locked(hw); - wiphy_unlock(hw->wiphy); + spin_unlock_irqrestore(&lhw->txq_lock, flags); } void linuxkpi_ieee80211_wake_queue(struct ieee80211_hw *hw, int qnum) { + struct lkpi_hw *lhw; + unsigned long flags; KASSERT(qnum < hw->queues, ("%s: qnum %d >= hw->queues %d, hw %p\n", __func__, qnum, hw->queues, hw)); - wiphy_lock(hw->wiphy); + lhw = HW_TO_LHW(hw); + + spin_lock_irqsave(&lhw->txq_lock, flags); lkpi_ieee80211_wake_queues(hw, qnum); - wiphy_unlock(hw->wiphy); + spin_unlock_irqrestore(&lhw->txq_lock, flags); } /* This is just hardware queues. */ diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index eaf6d804af4c..581148a94aa4 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -236,6 +236,7 @@ struct lkpi_hw { /* name it mac80211_sc? */ struct mtx txq_mtx; uint32_t txq_generation[IEEE80211_NUM_ACS]; TAILQ_HEAD(, lkpi_txq) scheduled_txqs[IEEE80211_NUM_ACS]; + spinlock_t txq_lock; /* Deferred RX path. */ struct task rxq_task;