From nobody Fri Apr 18 14:37:14 2025 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 4ZfHQz3LrTz5stfG; Fri, 18 Apr 2025 14:37:15 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZfHQy6FBvz3KpP; Fri, 18 Apr 2025 14:37:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744987034; 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=MpnGOqfR3/Sv4fkdqFfZFbg87dSf3uCNY96Q8ZCHXpA=; b=SlOkJTD6BfbhhxxJVpOA1YdUPbbs5+yTQ7iZzIbJNRBZoCioj1wmIbU1jb1xSOT998TkfD KemmjQVtl16iAxIgsFECXolO+m8OjPC+iNIxZNbEsMm18as+fl1eZh3YG4/0GfHZDqhkHJ 4vkfytraRqPMtIH191FPs6cSxMdMbZVqF1YhJY9gKKaDnhhdGPG9ntqmEmbD8cTXK92Pou FT1WBlNhUILLUHyNCtI18THqYFx5PVfM9Lg+211TDXTfhHE34+lyMw/SPhfWe4PT/Pcosx 5ThafaqliJs+DkLzVjwhyeIY4RJ8LDj7pC2l84C1XmlhGCsEma1iQE4CbQ8JQA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744987034; a=rsa-sha256; cv=none; b=ax7P0hpRzAI2ovGbnOpsEicZlqiO+zJJap3YJaIpQgZi2Jidy3FfnAnZHsnmXyBfyUqxLc pAUnWsqRkaX8f22qmiW8UmY7xTjr7LdlsQJDh3G3WZml8tMhJSDFDL+pRlHpcnd2EgYhLD onrxjPQGidPObk0e/uth/hBi4omkbZm3qjTgBUGj7cx/zLGTbGGb3OJw0aIDtoQQeeIj3s EnWWnUb9nUR3FxbRxxv4jouCFD94rKPoA8XEgi9toxfk+YydvGAScIwXCw6aMAVm6YHs17 C+orAFIV7/R/dYU4LyNs9R5bKigPk3Sc6wS+jn6Xtt5ZoO87SKp03aXap0nyjA== 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=1744987034; 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=MpnGOqfR3/Sv4fkdqFfZFbg87dSf3uCNY96Q8ZCHXpA=; b=Y6CMHt1MBsGMCBG53yjFWG/HVpdMf6096vN4l4E/del6VBVqbrcX7uCQQs5ibDHOeqSXjU pUd4kkUZBEDqNUkpQ+k4piwqZ+XTOohPJb/roR77eKCF08fd321USDWR3uhtc1rjFzK9Tq d12Vk5NmFx0nYyV6vjyMGAxUqryXW5ppFkh0Zulv8LcmGzjXbqdCY1NOwE1W/NFRwL+Wp9 a92CCR+b3FUpOH5Ar/urepaWd/qoI4hqyBpZCWTbBxc9vbPwEX2oHDhPDUl3Fxz1t9pKEm XE1/MXtTn5E9TNz5QALgGG2divJQWWFBWejMqws22ASD2wHevsWSH1umRHlpOQ== 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 4ZfHQy5qb4zdxx; Fri, 18 Apr 2025 14:37:14 +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 53IEbEXj091874; Fri, 18 Apr 2025 14:37:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53IEbE4d091871; Fri, 18 Apr 2025 14:37:14 GMT (envelope-from git) Date: Fri, 18 Apr 2025 14:37:14 GMT Message-Id: <202504181437.53IEbE4d091871@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 7614861463e6 - stable/14 - LinuxKPI: 802.11: adjust locking around lkpi_remove_chanctx() 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: 7614861463e6c26fdaaa79206b2bb0c79bb23683 Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=7614861463e6c26fdaaa79206b2bb0c79bb23683 commit 7614861463e6c26fdaaa79206b2bb0c79bb23683 Author: Bjoern A. Zeeb AuthorDate: 2025-04-08 16:35:20 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-04-18 14:36:01 +0000 LinuxKPI: 802.11: adjust locking around lkpi_remove_chanctx() With the adjusted locking as a first step and the single code path into lkpi_80211_mo_unassign_vif_chanctx() we also move the "setting chnactx to NULL" into the caller to simplify the code. Before we can adjust the other places touching vif->bss_conf.chanctx we need to adjust the overall locking in LinuxKPI 802.11. Sponsored by: The FreeBSD Foundation PR: 280546 Tested by: Oleksandr Kryvulia (shuriku shurik.kiev.ua) Tested by: Oleg Nauman (oleg.nauman gmail.com) [rtw88] Differential Revision: https://reviews.freebsd.org/D49734 (cherry picked from commit 231168c7e77777f69a323bcd80a7956527d34548) --- sys/compat/linuxkpi/common/src/linux_80211.c | 39 +++++++++++++--------- sys/compat/linuxkpi/common/src/linux_80211.h | 2 +- .../linuxkpi/common/src/linux_80211_macops.c | 12 ++++--- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 43d5c5dc9deb..edd3b91dcecf 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -1735,24 +1735,27 @@ lkpi_80211_flush_tx(struct lkpi_hw *lhw, struct lkpi_sta *lsta) static void lkpi_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - /* Take the chan ctx down. */ - if (vif->bss_conf.chanctx_conf != NULL) { - struct lkpi_chanctx *lchanctx; - struct ieee80211_chanctx_conf *chanctx_conf; + struct ieee80211_chanctx_conf *chanctx_conf; + struct lkpi_chanctx *lchanctx; - chanctx_conf = vif->bss_conf.chanctx_conf; - /* Remove vif context. */ - lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, &vif->bss_conf.chanctx_conf); - /* NB: vif->bss_conf.chanctx_conf is NULL now. */ + chanctx_conf = rcu_dereference_protected(vif->bss_conf.chanctx_conf, + lockdep_is_held(&hw->wiphy->mtx)); - lkpi_hw_conf_idle(hw, true); + if (chanctx_conf == NULL) + return; - /* Remove chan ctx. */ - lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); - vif->bss_conf.chanctx_conf = NULL; - lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); - free(lchanctx, M_LKPI80211); - } + /* Remove vif context. */ + lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, chanctx_conf); + + lkpi_hw_conf_idle(hw, true); + + /* Remove chan ctx. */ + lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); + + /* Cleanup. */ + rcu_assign_pointer(vif->bss_conf.chanctx_conf, NULL); + lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); + free(lchanctx, M_LKPI80211); } @@ -2183,7 +2186,9 @@ lkpi_sta_auth_to_scan(struct ieee80211vap *vap, enum ieee80211_state nstate, int /* conf_tx */ + wiphy_lock(hw->wiphy); lkpi_remove_chanctx(hw, vif); + wiphy_unlock(hw->wiphy); out: LKPI_80211_LHW_UNLOCK(lhw); @@ -2511,7 +2516,9 @@ _lkpi_sta_assoc_to_down(struct ieee80211vap *vap, enum ieee80211_state nstate, i /* conf_tx */ + wiphy_lock(hw->wiphy); lkpi_remove_chanctx(hw, vif); + wiphy_unlock(hw->wiphy); error = EALREADY; out: @@ -3111,7 +3118,9 @@ lkpi_sta_run_to_init(struct ieee80211vap *vap, enum ieee80211_state nstate, int /* conf_tx */ + wiphy_lock(hw->wiphy); lkpi_remove_chanctx(hw, vif); + wiphy_unlock(hw->wiphy); error = EALREADY; out: diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index c2d29b2dcc4b..c01a6cb0cd7c 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -425,7 +425,7 @@ int lkpi_80211_mo_config(struct ieee80211_hw *, uint32_t); int lkpi_80211_mo_assign_vif_chanctx(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf *); void lkpi_80211_mo_unassign_vif_chanctx(struct ieee80211_hw *, struct ieee80211_vif *, - struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf **); + struct ieee80211_bss_conf *, struct ieee80211_chanctx_conf *); int lkpi_80211_mo_add_chanctx(struct ieee80211_hw *, struct ieee80211_chanctx_conf *); void lkpi_80211_mo_change_chanctx(struct ieee80211_hw *, struct ieee80211_chanctx_conf *, uint32_t); diff --git a/sys/compat/linuxkpi/common/src/linux_80211_macops.c b/sys/compat/linuxkpi/common/src/linux_80211_macops.c index e9f97914a4b1..ff3959340af7 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211_macops.c +++ b/sys/compat/linuxkpi/common/src/linux_80211_macops.c @@ -467,21 +467,23 @@ out: void lkpi_80211_mo_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_bss_conf *conf, struct ieee80211_chanctx_conf **chanctx_conf) + struct ieee80211_bss_conf *conf, struct ieee80211_chanctx_conf *chanctx_conf) { struct lkpi_hw *lhw; + might_sleep(); + lockdep_assert_wiphy(hw->wiphy); + lhw = HW_TO_LHW(hw); if (lhw->ops->unassign_vif_chanctx == NULL) return; - if (*chanctx_conf == NULL) + if (chanctx_conf == NULL) return; LKPI_80211_TRACE_MO("hw %p vif %p bss_conf %p chanctx_conf %p", - hw, vif, conf, *chanctx_conf); - lhw->ops->unassign_vif_chanctx(hw, vif, conf, *chanctx_conf); - *chanctx_conf = NULL; + hw, vif, conf, chanctx_conf); + lhw->ops->unassign_vif_chanctx(hw, vif, conf, chanctx_conf); }