From nobody Fri Jan 16 19:41:30 2026 X-Original-To: dev-commits-src-all@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 4dt9G25dSmz6NlsT for ; Fri, 16 Jan 2026 19:41:30 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dt9G22V7Hz3xsR for ; Fri, 16 Jan 2026 19:41:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768592490; 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=dHlvzYczWbkh5YpvvujJDv+ml7aUpk76V27nFlhrbx8=; b=IlDcjadT+LKFzSxGaMeDwQyoTR1m3wOyp4bMwAWwSMcKKGyFSwjuNzP9T+627N2qSPQX68 c0Ve+85fFSH3v7Wm6w4kB5Y4FHhSgd9tH2p0uD9hdKT94+6fnPFyIDBS8SNM7a8/ul3/4G BLX6xgtuqPtrpYoKBUm+kHsUSly1rTf1yhHJRmXs73ee5QHBbbT4/DpvN1SNqGdC2Cbn62 pI31t8LY87RX8S2zyViQOtt1eSvZvVgfteEhoRFI8BG/cGG1VnSuwn8pWIuDdVTIppDTbN X+FRElfo0U5ebqwItuG4eNQXsAnrjqNfcAUwnYkp0SpjcDV11EQMnXJdA2rLmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768592490; 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=dHlvzYczWbkh5YpvvujJDv+ml7aUpk76V27nFlhrbx8=; b=ml4vAwLRSCDdg9VmykorsFWw+hXgzhWd7Rjos4kc+ylatCiThDnpmKeK4nZdj8omXYd2Ek LEDpEAg9dLTN2l+TXQEMMIsayqzPu/F6fhjOJW5x1kFYwrcYEN/94kL/w43xlv+qmbNO69 tr0/UjslNvM/IuZhpEuusYLErzyRosQKTvBYrNlrakCceuA+U2HOw2K3mPriNCdSkyXzme uk0FxdvpSWlgDm2bidcDFvvgTwtaueZf/zBBuv5hOzzSE0+ocdsoSJRyDtfu18oxloH9pd c91oXL7p8G1ELdeoFhd8d1isvMNt5zOwmbge/xZCVsegYZTWMkflt65gLwPnOA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1768592490; a=rsa-sha256; cv=none; b=GK0dllivWSLpaR4cmIcM9DD1SAxITXquaLsR6I6SECFCvQAIU09aWcVYuxQ8gjdQ+kcfMN OR4FgqtH+TnzuJQXi8tPQ1hjEdABy1V2YEXnAqzmfFOPOJ4qg6i+NxSzp+iS5Fa+0cxJef gXPQXIucBD8Q1xDgx7xZPX3TYvh2zc3M0cr5i9lfWVPyvg6eFusQXWr4DZHsUwoK/C+npL sipMSMCC6cHHccrC91t05yMJCCOwBV1DRaBeeaOCQje+mdC4uBNa4j0V0kcmJn+mXxMXVF 4FvMtTiirmmm7cMAfOy79iDWEiDcrJDakGYb+LjNlPiu8XGNaCN0EoFuFFKqrw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dt9G21jYNzCZ3 for ; Fri, 16 Jan 2026 19:41:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id e144 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 16 Jan 2026 19:41:30 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Bjoern A. Zeeb Subject: git: 8fc0789a4dda - stable/14 - LinuxKPI: 802.11: lock down the "txq_scheduled" tailq List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 8fc0789a4dda595311bec566719ff3c2e2744ee2 Auto-Submitted: auto-generated Date: Fri, 16 Jan 2026 19:41:30 +0000 Message-Id: <696a946a.e144.2051a685@gitrepo.freebsd.org> The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=8fc0789a4dda595311bec566719ff3c2e2744ee2 commit 8fc0789a4dda595311bec566719ff3c2e2744ee2 Author: Bjoern A. Zeeb AuthorDate: 2025-12-10 20:29:23 +0000 Commit: Bjoern A. Zeeb CommitDate: 2026-01-16 19:37:55 +0000 LinuxKPI: 802.11: lock down the "txq_scheduled" tailq For consistency rename the "scheduled_txqs" tailq to "txq_scheduled" and add a lock per txq ("txq_scheduled_lock[]"). We use the "_bh" locking as this called from the device driver. This fixes panics due to concurrent access to the tailq, especially in between "first" and "remove" on the out-direction and between "insert" and "elem_init" on the in-direction. This was easily reproducible just running iperf3 at basic rates for a few seconds to minutes with multiple chipsets, not only rtw89. Sponsored by: The FreeBSD Foundation PR: 290636 Reported by: arved, and others before (cherry picked from commit 567a097c8ab60d9fcd68a87c3c5ad605fe8715cc) (cherry picked from commit 2e1156f75836a0e5a4026e13d72b54f272e705cb) --- sys/compat/linuxkpi/common/src/linux_80211.c | 51 ++++++++++++++++++++++------ sys/compat/linuxkpi/common/src/linux_80211.h | 3 +- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 96d9890beeb3..a92f3f75912d 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -6019,8 +6019,9 @@ linuxkpi_ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops) sx_init_flags(&lhw->lvif_sx, "lhw-lvif", SX_RECURSE | SX_DUPOK); TAILQ_INIT(&lhw->lvif_head); for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { + spin_lock_init(&lhw->txq_scheduled_lock[ac]); lhw->txq_generation[ac] = 1; - TAILQ_INIT(&lhw->scheduled_txqs[ac]); + TAILQ_INIT(&lhw->txq_scheduled[ac]); } /* Chanctx_conf */ @@ -6054,6 +6055,7 @@ linuxkpi_ieee80211_iffree(struct ieee80211_hw *hw) { struct lkpi_hw *lhw; struct mbuf *m; + int ac; lhw = HW_TO_LHW(hw); free(lhw->ic, M_LKPI80211); @@ -6114,6 +6116,9 @@ linuxkpi_ieee80211_iffree(struct ieee80211_hw *hw) } } + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) + spin_lock_destroy(&lhw->txq_scheduled_lock[ac]); + /* Cleanup more of lhw here or in wiphy_free()? */ spin_lock_destroy(&lhw->txq_lock); LKPI_80211_LHW_TXQ_LOCK_DESTROY(lhw); @@ -8121,7 +8126,12 @@ linuxkpi_ieee80211_wake_queue(struct ieee80211_hw *hw, int qnum) spin_unlock_irqrestore(&lhw->txq_lock, flags); } +/* -------------------------------------------------------------------------- */ + /* This is just hardware queues. */ +/* + * Being called from the driver thus use _bh() locking. + */ void linuxkpi_ieee80211_txq_schedule_start(struct ieee80211_hw *hw, uint8_t ac) { @@ -8129,10 +8139,16 @@ linuxkpi_ieee80211_txq_schedule_start(struct ieee80211_hw *hw, uint8_t ac) lhw = HW_TO_LHW(hw); - IMPROVE_TXQ("Are there reasons why we wouldn't schedule?"); - IMPROVE_TXQ("LOCKING"); + if (ac >= IEEE80211_NUM_ACS) { + ic_printf(lhw->ic, "%s: ac %u out of bounds.\n", __func__, ac); + return; + } + + spin_lock_bh(&lhw->txq_scheduled_lock[ac]); + IMPROVE("check AIRTIME_FAIRNESS"); if (++lhw->txq_generation[ac] == 0) lhw->txq_generation[ac]++; + spin_unlock_bh(&lhw->txq_scheduled_lock[ac]); } struct ieee80211_txq * @@ -8145,24 +8161,33 @@ linuxkpi_ieee80211_next_txq(struct ieee80211_hw *hw, uint8_t ac) lhw = HW_TO_LHW(hw); txq = NULL; - IMPROVE_TXQ("LOCKING"); + if (ac >= IEEE80211_NUM_ACS) { + ic_printf(lhw->ic, "%s: ac %u out of bounds.\n", __func__, ac); + return (NULL); + } + + spin_lock_bh(&lhw->txq_scheduled_lock[ac]); /* Check that we are scheduled. */ if (lhw->txq_generation[ac] == 0) goto out; - ltxq = TAILQ_FIRST(&lhw->scheduled_txqs[ac]); + ltxq = TAILQ_FIRST(&lhw->txq_scheduled[ac]); if (ltxq == NULL) goto out; if (ltxq->txq_generation == lhw->txq_generation[ac]) goto out; + IMPROVE("check AIRTIME_FAIRNESS"); + + TAILQ_REMOVE(&lhw->txq_scheduled[ac], ltxq, txq_entry); ltxq->txq_generation = lhw->txq_generation[ac]; - TAILQ_REMOVE(&lhw->scheduled_txqs[ac], ltxq, txq_entry); txq = <xq->txq; TAILQ_ELEM_INIT(ltxq, txq_entry); out: + spin_unlock_bh(&lhw->txq_scheduled_lock[ac]); + return (txq); } @@ -8175,8 +8200,6 @@ void linuxkpi_ieee80211_schedule_txq(struct ieee80211_hw *hw, ltxq = TXQ_TO_LTXQ(txq); - IMPROVE_TXQ("LOCKING"); - /* Only schedule if work to do or asked to anyway. */ LKPI_80211_LTXQ_LOCK(ltxq); ltxq_empty = skb_queue_empty(<xq->skbq); @@ -8184,20 +8207,26 @@ void linuxkpi_ieee80211_schedule_txq(struct ieee80211_hw *hw, if (!withoutpkts && ltxq_empty) goto out; + lhw = HW_TO_LHW(hw); + spin_lock_bh(&lhw->txq_scheduled_lock[txq->ac]); /* * Make sure we do not double-schedule. We do this by checking tqe_prev, * the previous entry in our tailq. tqe_prev is always valid if this entry * is queued, tqe_next may be NULL if this is the only element in the list. */ if (ltxq->txq_entry.tqe_prev != NULL) - goto out; + goto unlock; + + TAILQ_INSERT_TAIL(&lhw->txq_scheduled[txq->ac], ltxq, txq_entry); +unlock: + spin_unlock_bh(&lhw->txq_scheduled_lock[txq->ac]); - lhw = HW_TO_LHW(hw); - TAILQ_INSERT_TAIL(&lhw->scheduled_txqs[txq->ac], ltxq, txq_entry); out: return; } +/* -------------------------------------------------------------------------- */ + void linuxkpi_ieee80211_handle_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index eb7bae811695..ea5d1d72e78c 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -226,7 +226,8 @@ 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_scheduled_lock[IEEE80211_NUM_ACS]; + TAILQ_HEAD(, lkpi_txq) txq_scheduled[IEEE80211_NUM_ACS]; spinlock_t txq_lock; /* Deferred RX path. */