From nobody Fri Apr 11 21:26:20 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 4ZZ8rF1VQjz5shW9; Fri, 11 Apr 2025 21:26:21 +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 4ZZ8rD6BJfz3tTf; Fri, 11 Apr 2025 21:26:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744406780; 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=blADl0t/7ajKRsCU5un+91prhoBYayz6l4CN+QiyBto=; b=GOX28nstGMptp9u21Op3/LouR29D6YU2IQIyhBUdTCZ34mdFV4u8tz6Mk3VnTaJD2w/WTn dLTdKU489mtNacBn4hKBfYktlvLDIdxEDXfwNFrqX+jpbEq3zDg0oTs2A642Jt2kMH/ZzZ YVPGpx6TfaHh96tIezbO+cXbZ2xgI1tnw1qVkxmcLwLSEA3I93CVJnn8xKwvvwN7fXSyz2 2L4CfMAQp//Fr+BElHTsnI8hrnpwWsxDy6I/9y3y1eBWHZNvXq3Jz9SfLJQcrsdNJ0dBeB RDkeTya0qArNw2eTCknRVUItP2veBXnhvz92Jqk2Dje07wgZ1hGkTEr9rgVuYQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744406780; a=rsa-sha256; cv=none; b=BFC/Cs+M5cZCl/EXn+ppwu79/XHbB64TulnykJgOwtz7kY+f37RX0+OvrPYiT3vB2AvY3v 3d2nk9EybDFjds69vIZOYeAFI7r1HnyL1xXhClkFL3FCdTAM2r4dmPycK2VLhU8B0MDiBU hcWwjcUOaRF4NiQrg6kSdluT2W0/06R94++QszUqfdUYcPyFozrdL0alWylQP2COjiNLpJ CZLXyJ5jIgM9cNZ/ZegYh9B+V9veKaDaESemDvYEqpWMvc6fnjIBW9kwwXsbacU25fjtpY fUyAhSanqRjnt3o6jp5iGTFBdolZ+PScvqBD9PkUAN3qwi0KIJCC0s+fGludWw== 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=1744406780; 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=blADl0t/7ajKRsCU5un+91prhoBYayz6l4CN+QiyBto=; b=TJer71B6ySgamKpOjFeJJUC1+aOzd8+ZknPySFlychlI+OwmbnNqrELt1KGolxMd5reuM8 VzipIuiDVnpdCedR+bL29BFDn3SRATYBrdBVhZABd2BYkvrw2lfmyXPbtM9pf1V+eyJvai 7yiWnYORoA205wSd98hAxtIDu+nBOcjb/L/UCl21Kk/DqUkRpNphE7nxNX77XhU6J9Agpz zpGEt3Kay56XQUKWM2Q+RjugjuhsDfTiDLaz+JZw4jfVmfH57rS/d6NYZmJ7NiVfimcvIF C1iBNYLBgc4rj8cI1j+X/Lmuwpq7IFSV7B1bNOZ7h7qSaffFOofEcQbuHjR4Kw== 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 4ZZ8rD5lX5zpRX; Fri, 11 Apr 2025 21:26:20 +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 53BLQK5q078230; Fri, 11 Apr 2025 21:26:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53BLQKgp078227; Fri, 11 Apr 2025 21:26:20 GMT (envelope-from git) Date: Fri, 11 Apr 2025 21:26:20 GMT Message-Id: <202504112126.53BLQKgp078227@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: 231168c7e777 - main - LinuxKPI: 802.11: adjust locking around lkpi_remove_chanctx() 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: 231168c7e77777f69a323bcd80a7956527d34548 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=231168c7e77777f69a323bcd80a7956527d34548 commit 231168c7e77777f69a323bcd80a7956527d34548 Author: Bjoern A. Zeeb AuthorDate: 2025-04-08 16:35:20 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-04-11 21:25:56 +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 MFC after: 3 days Tested by: Oleksandr Kryvulia (shuriku shurik.kiev.ua) Tested by: Oleg Nauman (oleg.nauman gmail.com) [rtw88] Differential Revision: https://reviews.freebsd.org/D49734 --- 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 28bd2c062427..7dc18eccd4c8 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 9a7207424b2f..336b8a1e9ce2 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211_macops.c +++ b/sys/compat/linuxkpi/common/src/linux_80211_macops.c @@ -466,21 +466,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); }