From nobody Fri Apr 15 15:56:54 2022 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 6EC797CD6CD; Fri, 15 Apr 2022 15:56:55 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Kg1D65zCNz3Fqq; Fri, 15 Apr 2022 15:56:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650038215; 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=cZNOyY1kUu3P7w9HNSGcjpdolU7d6/Ig+oGSwOI12F8=; b=hgZN2jlHVgCPWVq2UXENYEPlS/TXdCdSqSH1uaDxYf3spsI4y5i2QepZyB9+toMZQuTJ9L 3/UTFo/TPqQWyoWbkZfD1shNFz6gPYGxtev2qFssxBU/Jf6vTnuBwfjnVyUK9W12T96DZz k7rAOeNAm7A3/F4FduIkKhYr9tLkiwW4zf50owbAMssQqaO0o120xagLLLr9YTpVRUbt+x aYlV1SfUz8beiVLck+Rfw7T67UJz0uPUU+gVBIVstT8OKo4c6WasPU1j0P1fHE89tRne9Z ssjFzPZEYjoSe6RSJjJ1oH3PCHNw3YI4zVsy660vvyUs7zjdzGyhBqRbSwNiCQ== 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 4DB7C182BB; Fri, 15 Apr 2022 15:56:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23FFus9G084389; Fri, 15 Apr 2022 15:56:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23FFusZu084388; Fri, 15 Apr 2022 15:56:54 GMT (envelope-from git) Date: Fri, 15 Apr 2022 15:56:54 GMT Message-Id: <202204151556.23FFusZu084388@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: 8891c45563f8 - main - LinuxKPI: 802.11: use an sx lock to protect the list of vifs 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/main X-Git-Reftype: branch X-Git-Commit: 8891c45563f8d3b657a876197c66e00e75214909 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650038215; 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=cZNOyY1kUu3P7w9HNSGcjpdolU7d6/Ig+oGSwOI12F8=; b=a+w718gTq75qFcTtuY0TI6K0oPiczOp4UZEwzvISOPp27CzWZUZSsCi9TGQCPSir2Om01P ckkTw+ermvTQX6tHBIPiEUpK1ZUHVjE8yCcwU89tFx2/jwGMtKNwX8aSzgVn+1Rqv1moz/ Rsoa0Hn9FTGbzexuWQfk/dIshXPh0CSNeKAWjJpddlYtAgGlxOOK2R5SLFjD1V90Lzd+ns wF+d2Ka3tM1aHzwBtxl4t2Oa0RoQ5EMzFlke1FsybpklGIYdr/1La13SQA4qgk4F5cF+5X mBkfmdfkU53UPv/4DFdpvBQ4eT4rDUSyWH9UQ+fBPrUYsI4RFlc24M/xJVGVMg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650038215; a=rsa-sha256; cv=none; b=fHQITtjuOG1VT8qU/BXC4jbpbAAaQAIx96hJyW1b/ZPRKRNjZePxzyIjj+JVWSTGFfvGW+ 1+zf3W7tWW5TKW9JaTQcfd1pRQE2GUj8i2kyGjNVWWu8ZpsBBpDUjL1PrvJxozl47i6IeY 3JsoHRz2QvD7RNJNfOoEC3sKvUXLOWwO/GF5VrR8MsJdmodSeh1wWbmjiN+MTLYPNHt4qu 98+zwbBd679M6M/PEpyLNxZGdEHwYbiMVFghe7ey6hpwURdMjAqC4Q48iU2IbONxF/E5LV 92Vz6wMd/YkY1uhDaaKh7NlmeCSS2jxNyObZaDJMR34hDKsAhNWc1J1S1gbwNw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=8891c45563f8d3b657a876197c66e00e75214909 commit 8891c45563f8d3b657a876197c66e00e75214909 Author: Bjoern A. Zeeb AuthorDate: 2022-04-15 14:22:43 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-04-15 15:54:03 +0000 LinuxKPI: 802.11: use an sx lock to protect the list of vifs Use an sx lock to protect the list of vifs. We could use the linux mutex compat for this but our current implementation may re-acquire the lock recursively so allow this. The change is mainly motivated by the fact that some callers may sleep in the interator function called. Recursiveness is needed because we see find_sta_by_ifaddr() being called from an iterator function from iterate_interfaces(). Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/compat/linuxkpi/common/src/linux_80211.c | 22 ++++++++++++---------- sys/compat/linuxkpi/common/src/linux_80211.h | 4 ++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index e5a4aee842eb..286c40d7de4f 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -2261,9 +2261,9 @@ lkpi_ic_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], return (NULL); } - LKPI_80211_LHW_LOCK(lhw); + LKPI_80211_LHW_LVIF_LOCK(lhw); TAILQ_INSERT_TAIL(&lhw->lvif_head, lvif, lvif_entry); - LKPI_80211_LHW_UNLOCK(lhw); + LKPI_80211_LHW_LVIF_UNLOCK(lhw); /* Set bss_info. */ changed = 0; @@ -2329,9 +2329,9 @@ lkpi_ic_vap_delete(struct ieee80211vap *vap) lhw = ic->ic_softc; hw = LHW_TO_HW(lhw); - LKPI_80211_LHW_LOCK(lhw); + LKPI_80211_LHW_LVIF_LOCK(lhw); TAILQ_REMOVE(&lhw->lvif_head, lvif, lvif_entry); - LKPI_80211_LHW_UNLOCK(lhw); + LKPI_80211_LHW_LVIF_UNLOCK(lhw); lkpi_80211_mo_remove_interface(hw, vif); ieee80211_ratectl_deinit(vap); @@ -3240,6 +3240,7 @@ linuxkpi_ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops) lhw->ops = ops; mtx_init(&lhw->mtx, "lhw", NULL, MTX_DEF | MTX_RECURSE); + sx_init_flags(&lhw->lvif_sx, "lhw-lvif", SX_RECURSE | SX_DUPOK); TAILQ_INIT(&lhw->lvif_head); /* @@ -3273,6 +3274,7 @@ linuxkpi_ieee80211_iffree(struct ieee80211_hw *hw) lhw->ic = NULL; /* Cleanup more of lhw here or in wiphy_free()? */ + sx_destroy(&lhw->lvif_sx); mtx_destroy(&lhw->mtx); IMPROVE(); } @@ -3497,7 +3499,7 @@ linuxkpi_ieee80211_iterate_interfaces(struct ieee80211_hw *hw, nin_drv = (flags & IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER) != 0; if (atomic) - LKPI_80211_LHW_LOCK(lhw); + LKPI_80211_LHW_LVIF_LOCK(lhw); TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { struct ieee80211vap *vap; @@ -3530,7 +3532,7 @@ linuxkpi_ieee80211_iterate_interfaces(struct ieee80211_hw *hw, iterfunc(arg, vif->addr, vif); } if (atomic) - LKPI_80211_LHW_UNLOCK(lhw); + LKPI_80211_LHW_LVIF_UNLOCK(lhw); } void @@ -3568,7 +3570,7 @@ linuxkpi_ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, lhw = HW_TO_LHW(hw); - LKPI_80211_LHW_LOCK(lhw); + LKPI_80211_LHW_LVIF_LOCK(lhw); TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { LKPI_80211_LVIF_LOCK(lvif); @@ -3580,7 +3582,7 @@ linuxkpi_ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, } LKPI_80211_LVIF_UNLOCK(lvif); } - LKPI_80211_LHW_UNLOCK(lhw); + LKPI_80211_LHW_LVIF_UNLOCK(lhw); } int @@ -3974,7 +3976,7 @@ linuxkpi_ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, lhw = wiphy_priv(hw->wiphy); sta = NULL; - LKPI_80211_LHW_LOCK(lhw); + LKPI_80211_LHW_LVIF_LOCK(lhw); TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { /* XXX-BZ check our address from the vif. */ @@ -3987,7 +3989,7 @@ linuxkpi_ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, if (sta != NULL) break; } - LKPI_80211_LHW_UNLOCK(lhw); + LKPI_80211_LHW_LVIF_UNLOCK(lhw); if (sta != NULL) { lsta = STA_TO_LSTA(sta); diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index fabc90e07a87..bdcdb3fbf455 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -140,6 +140,7 @@ struct lkpi_hw { /* name it mac80211_sc? */ struct lkpi_radiotap_rx_hdr rtap_rx; TAILQ_HEAD(, lkpi_vif) lvif_head; + struct sx lvif_sx; struct mtx mtx; @@ -179,6 +180,9 @@ struct lkpi_wiphy { #define LKPI_80211_LHW_UNLOCK_ASSERT(_lhw) \ mtx_assert(&(_lhw)->mtx, MA_NOTOWNED) +#define LKPI_80211_LHW_LVIF_LOCK(_lhw) sx_xlock(&(_lhw)->lvif_sx) +#define LKPI_80211_LHW_LVIF_UNLOCK(_lhw) sx_xunlock(&(_lhw)->lvif_sx) + #define LKPI_80211_LVIF_LOCK(_lvif) mtx_lock(&(_lvif)->mtx) #define LKPI_80211_LVIF_UNLOCK(_lvif) mtx_unlock(&(_lvif)->mtx)