From nobody Wed Apr 22 21:08:43 2026 X-Original-To: dev-commits-src-branches@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 4g1BfM63Lvz6bKsr for ; Wed, 22 Apr 2026 21:08:43 +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" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g1BfM2WtPz3lSq for ; Wed, 22 Apr 2026 21:08:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776892123; 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=l4Un085lNx+DUrnwHif3LLGH6AWCBULFKRTpp/sSP+g=; b=TPv+3YqsGC+o/PqN8vUN7pjo08SazC/M3dmYwbfLEAdOsxzWDl/t7htgS4PaYI1Ty6MaFx J2efH7KiqHcARQORvIk4nTW6Dk+KHheTw0raZkBDV/siszEY6f70i6GUd8aMEBa9bX59UC 7p3da/sSXrxXlA6v3f3IpIya96l/zf7ElvRxfsX1zmDYXp4wMo63y1in/uwcdCLdYCs1T1 CbVxH2yOqe6l5r3F0Kukz/KMmhaHD3xCF1l/oFwROf0twXcuczse8go5WtcwkL6qNgL5GG jZjqfvKHPQwBWeDQMYgL1dYrYypJTqU8YhkULD9x84mLWSJ1VC25CXfYIL3DAA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776892123; a=rsa-sha256; cv=none; b=khJP3ApaN2c1UzsjFsTjfcavBmWVLu10leOpmYZqwB48w8cmCKsaFgNmT043m457fpNr+Y gEGGMTKh4ZrQ3+wXTSsXyKvm4m4ROI01SG6EptLcKBgiMYded0y1V1TAdD2bbfNk3tlrlP Tpb3YIuaP7+oe0TmL6Z7+gGXVad/njytDuSZO9HaTB8JcY6gej5xevNH4phro1t9duhUN1 ulNS3nYnK2vJ6aNSsNR0pUw/0bXNcoYRqCUiV3XTwFOpq/xwKFBd4TXtcZvmODYJAGxn9Q mSQxPcW1SAD2d0Fky27+VO+Dh91XBA0agfzQYN4A/R1uceNAZ80yVfVBPEkiog== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776892123; 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=l4Un085lNx+DUrnwHif3LLGH6AWCBULFKRTpp/sSP+g=; b=YQ59pKlB3njvvbnUayJWGmACw3TAcgrPSgy+b2bMSVeeyNkoVGhRFHqyeYPBFPd8ZGozL4 5BYP3lJm3j/M/qBwMunTdhzvFu3JHQTx5ASZ2M5ZTo2VGh8H10U0GoDwaFPbSGQPwyVwRf SXeeC9JwoD9psKiL2POD2xqS/d+NcPACj99f/pXIW3sRStONlV7N/Ab47OUQ5y4aNkFkDx ZQz7+pxVi/fWCKZRUC7m7mgx29SQaT13ieTDTrYK7kjaTFpeSNl9/jvgoKLEcf4UWIu7dq CMO9YhIsv4GA3EC24biFVjGoHaS7adcWWphA0/JY6Mo//qHMwU5piU739X724w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g1BfM1zw9zng4 for ; Wed, 22 Apr 2026 21:08:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27678 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 22 Apr 2026 21:08:43 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Bjoern A. Zeeb Subject: git: e99839ee7b7f - stable/15 - LinuxKPI: 802.11: keep chanctx on a reserved list List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/15 X-Git-Reftype: branch X-Git-Commit: e99839ee7b7f6c1751ef423821a423cecdbca614 Auto-Submitted: auto-generated Date: Wed, 22 Apr 2026 21:08:43 +0000 Message-Id: <69e938db.27678.2117a0d2@gitrepo.freebsd.org> The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=e99839ee7b7f6c1751ef423821a423cecdbca614 commit e99839ee7b7f6c1751ef423821a423cecdbca614 Author: Bjoern A. Zeeb AuthorDate: 2026-03-23 00:47:57 +0000 Commit: Bjoern A. Zeeb CommitDate: 2026-04-22 20:57:04 +0000 LinuxKPI: 802.11: keep chanctx on a reserved list Keep the chanctx around as we may swap them. In the future (11be) these lists likely need to be (a) limited to maximum number of chanctx possible (see struct ieee80211_iface_limit), and (b) with that also by radio. For the moment keep this simple and start with a single chanctx and build up from there when we get there. Sponsored by: The FreeBSD Foundation (cherry picked from commit e62c92c0a5cfc000cf3c200e43738834ccc6472e) --- sys/compat/linuxkpi/common/src/linux_80211.c | 69 ++++++++++++++++++++++++++-- sys/compat/linuxkpi/common/src/linux_80211.h | 2 + 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 92eccefca078..40a7dfa79fba 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -2280,13 +2280,54 @@ lkpi_init_chanctx_conf(struct ieee80211_hw *hw, return (changed); } +static struct lkpi_chanctx * +lkpi_alloc_lchanctx(struct ieee80211_hw *hw, struct lkpi_vif *lvif) +{ + struct lkpi_chanctx *lchanctx; + + lchanctx = malloc(sizeof(*lchanctx) + hw->chanctx_data_size, + M_LKPI80211, M_WAITOK | M_ZERO); + lchanctx->lvif = lvif; + + return (lchanctx); +} + +static struct lkpi_chanctx * +lkpi_find_lchanctx_reserved(struct ieee80211_hw *hw, struct lkpi_vif *lvif) +{ + struct lkpi_hw *lhw; + struct lkpi_chanctx *lchanctx; + bool found; + + lhw = HW_TO_LHW(hw); + + found = false; + rcu_read_lock(); + list_for_each_entry_rcu(lchanctx, &lhw->lchanctx_list_reserved, entry) { + if (lchanctx->lvif == lvif) { + found = true; + break; + } + } + rcu_read_unlock(); + + if (!found) { + lchanctx = lkpi_alloc_lchanctx(hw, lvif); + list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list_reserved); + } + + return (lchanctx); +} static void lkpi_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { + struct lkpi_hw *lhw; struct ieee80211_chanctx_conf *chanctx_conf; struct lkpi_chanctx *lchanctx; + lockdep_assert_wiphy(hw->wiphy); + chanctx_conf = rcu_dereference_protected(vif->bss_conf.chanctx_conf, lockdep_is_held(&hw->wiphy->mtx)); @@ -2305,7 +2346,8 @@ lkpi_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif) rcu_assign_pointer(vif->bss_conf.chanctx_conf, NULL); lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); list_del(&lchanctx->entry); - free(lchanctx, M_LKPI80211); + lhw = HW_TO_LHW(hw); + list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list_reserved); } /* -------------------------------------------------------------------------- */ @@ -2452,9 +2494,8 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); IMPROVE("diff changes for changed, working on live copy, rcu"); } else { - /* Keep separate alloc as in Linux this is rcu managed? */ - lchanctx = malloc(sizeof(*lchanctx) + hw->chanctx_data_size, - M_LKPI80211, M_WAITOK | M_ZERO); + lchanctx = lkpi_find_lchanctx_reserved(hw, lvif); + list_del(&lchanctx->entry); chanctx_conf = &lchanctx->chanctx_conf; } @@ -2535,7 +2576,7 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int rcu_assign_pointer(vif->bss_conf.chanctx_conf, NULL); lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); list_del(&lchanctx->entry); - free(lchanctx, M_LKPI80211); + list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list_reserved); goto out; } } @@ -3954,6 +3995,10 @@ lkpi_ic_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], /* Need to fill in other fields as well. */ IMPROVE(); + /* Create a chanctx to be used later. */ + IMPROVE("lkpi_alloc_lchanctx reserved as many as can be"); + (void) lkpi_find_lchanctx_reserved(hw, lvif); + /* XXX-BZ hardcoded for now! */ #if 1 RCU_INIT_POINTER(vif->bss_conf.chanctx_conf, NULL); @@ -6444,6 +6489,7 @@ linuxkpi_ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops) /* Chanctx_conf */ INIT_LIST_HEAD(&lhw->lchanctx_list); + INIT_LIST_HEAD(&lhw->lchanctx_list_reserved); /* Deferred RX path. */ LKPI_80211_LHW_RXQ_LOCK_INIT(lhw); @@ -6518,6 +6564,7 @@ linuxkpi_ieee80211_iffree(struct ieee80211_hw *hw) __func__, lhw, mbufq_len(&lhw->rxq))); LKPI_80211_LHW_RXQ_LOCK_DESTROY(lhw); + wiphy_lock(hw->wiphy); /* Chanctx_conf. */ if (!list_empty_careful(&lhw->lchanctx_list)) { struct lkpi_chanctx *lchanctx, *next; @@ -6530,9 +6577,21 @@ linuxkpi_ieee80211_iffree(struct ieee80211_hw *hw) lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); } list_del(&lchanctx->entry); + list_add_rcu(&lchanctx->entry, &lhw->lchanctx_list_reserved); + } + } + if (!list_empty_careful(&lhw->lchanctx_list_reserved)) { + struct lkpi_chanctx *lchanctx, *next; + + list_for_each_entry_safe(lchanctx, next, &lhw->lchanctx_list_reserved, entry) { + list_del(&lchanctx->entry); + if (lchanctx->added_to_drv) + panic("%s: lchanctx %p on reserved list still added_to_drv\n", + __func__, lchanctx); free(lchanctx, M_LKPI80211); } } + wiphy_unlock(hw->wiphy); LKPI_80211_LHW_MC_LOCK(lhw); lkpi_cleanup_mcast_list_locked(lhw); diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index a2945498e8df..e453cefa20f7 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -250,6 +250,7 @@ struct lkpi_hw { /* name it mac80211_sc? */ struct sx lvif_sx; struct list_head lchanctx_list; + struct list_head lchanctx_list_reserved; struct netdev_hw_addr_list mc_list; unsigned int mc_flags; struct sx mc_sx; @@ -330,6 +331,7 @@ struct lkpi_chanctx { struct list_head entry; bool added_to_drv; /* Managed by MO */ + struct lkpi_vif *lvif; /* Backpointer. */ struct ieee80211_chanctx_conf chanctx_conf __aligned(CACHE_LINE_SIZE); };