From patchwork Tue Aug 6 00:40:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rory Little X-Patchwork-Id: 13754283 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AD28184D for ; Tue, 6 Aug 2024 00:41:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.129.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722904885; cv=none; b=H5J5ic4Vp3dYfX5DFdMzTIeCZcX1AYYoBRzAY4fgdvcq5CYfFdjqMtFXxgCfLttXrNQqzhY+zb4YUyTFzkhcwRNZ5XAcGWvCNZmlUt/kU7kla1qXOOLD0/ImDbUR9ldQy4hS4ot8lBzCRYbM64xH2zDDGIt9zj1oK7i226KHa54= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722904885; c=relaxed/simple; bh=6rpFksuZv0QPk4Gmly0DRa7c/BanhtLnZg7XdGCPb+o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HjdCQgjs9bjCFZU8RFD3/AmKPoXaQVzgWrZkrRqn6AkURLHBxgzGCXA4MnQBmX0OlNuJm7MeVcY2to6/q8pzCn6FbdKAgADaDETYPIvlg3YUwaOh6bcYzvQanKpvEUvKZNO65sefJPysLOdmMkY5vDnKhJiiqU38TZC3vkvb9yM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=candelatech.com; spf=pass smtp.mailfrom=candelatech.com; dkim=pass (1024-bit key) header.d=candelatech.com header.i=@candelatech.com header.b=qA/wBazy; arc=none smtp.client-ip=148.163.129.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=candelatech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=candelatech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=candelatech.com header.i=@candelatech.com header.b="qA/wBazy" X-Virus-Scanned: Proofpoint Essentials engine Received: from mail3.candelatech.com (mail.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 23C0818007C; Tue, 6 Aug 2024 00:41:15 +0000 (UTC) Received: from carkeek.candelatech.com (unknown [50.251.239.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail3.candelatech.com (Postfix) with ESMTPSA id B59AE13C2B1; Mon, 5 Aug 2024 17:41:14 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com B59AE13C2B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1722904874; bh=6rpFksuZv0QPk4Gmly0DRa7c/BanhtLnZg7XdGCPb+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qA/wBazy8DtqrN3OjA8GZT25B0diOI4CIjZH5hycVhe4gw54ynpT6B1M9karvSOQQ Dr9sxtSySF+E170rYggc3OTOfgWFyQTNfnQJkRSkMGB+KkYgXZXQMggXCGJPhLCgHT ph69htOm2DgBFYeFSyDog171xsKdN2rxKiVfB6z4= From: Rory Little To: kvalo@kernel.org, johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Rory Little Subject: [PATCH 1/2] wifi: mac80211: Add non-atomic station iterator. Date: Mon, 5 Aug 2024 17:40:23 -0700 Message-Id: <20240806004024.2014080-2-rory@candelatech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240806004024.2014080-1-rory@candelatech.com> References: <20240806004024.2014080-1-rory@candelatech.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MDID: 1722904876-MP_zBZic_eJW X-MDID-O: us5;ut7;1722904876;MP_zBZic_eJW;;9989741adba0574bb335b9e9d00002fb Drivers may at times want to iterate their stations with a function which requires some non-atomic operations. ieee80211_iterate_stations_mtx() introduces an API to iterate stations while holding that wiphy's mutex. This allows the iterating function to do non-atomic operations safely. Signed-off-by: Rory Little --- include/net/mac80211.h | 18 ++++++++++++++++++ net/mac80211/util.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index e1580360e099..6c8a2dd53243 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -6313,6 +6313,24 @@ void ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, void (*iterator)(void *data, struct ieee80211_sta *sta), void *data); + +/** + * ieee80211_iterate_stations_mtx - iterate stations + * + * This function iterates over all stations associated with a given + * hardware that are currently uploaded to the driver and calls the callback + * function for them. This version can only be used while holding the wiphy + * mutex. + * + * @hw: the hardware struct of which the interfaces should be iterated over + * @iterator: the iterator function to call + * @data: first argument of the iterator function + */ +void ieee80211_iterate_stations_mtx(struct ieee80211_hw *hw, + void (*iterator)(void *data, + struct ieee80211_sta *sta), + void *data); + /** * ieee80211_queue_work - add work onto the mac80211 workqueue * diff --git a/net/mac80211/util.c b/net/mac80211/util.c index ef7133ac13f0..e12c871f0477 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -940,6 +940,23 @@ static void __iterate_stations(struct ieee80211_local *local, } } +static void __iterate_stations_safe(struct ieee80211_local *local, + void (*iterator)(void *data, + struct ieee80211_sta *sta), + void *data) +{ + struct sta_info *sta, *sta_temp; + + lockdep_assert_wiphy(local->hw.wiphy); + + list_for_each_entry_safe(sta, sta_temp, &local->sta_list, list) { + if (!sta->uploaded) + continue; + + iterator(data, &sta->sta); + } +} + void ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, void (*iterator)(void *data, struct ieee80211_sta *sta), @@ -953,6 +970,19 @@ void ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, } EXPORT_SYMBOL_GPL(ieee80211_iterate_stations_atomic); +void ieee80211_iterate_stations_mtx(struct ieee80211_hw *hw, + void (*iterator)(void *data, + struct ieee80211_sta *sta), + void *data) +{ + struct ieee80211_local *local = hw_to_local(hw); + + lockdep_assert_wiphy(local->hw.wiphy); + + __iterate_stations_safe(local, iterator, data); +} +EXPORT_SYMBOL_GPL(ieee80211_iterate_stations_mtx); + struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev) { struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); From patchwork Tue Aug 6 00:40:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rory Little X-Patchwork-Id: 13754285 X-Patchwork-Delegate: kvalo@adurom.com Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7228C8F62 for ; Tue, 6 Aug 2024 00:41:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.129.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722904892; cv=none; b=ZZunXIvjW5nSFt8j/qr3dSGHu50s1Yse8hUYNDIQItgHa1EKuH3wTEkL44WwFK2sBU0vjRxNrG6C2C1+5d5Jq0cebKIeomC3v5AbDw79s0khmpIBjLv+SpM9dtWKb57jrmH86m+Tb0WS8wnvW7jkyKFru0vXjtv1PC5/MF8igNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722904892; c=relaxed/simple; bh=iqlEX4A0QrpNFkzwsk4HphEl3DI0MhY7Zg8ZeXn4HiQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b/dM3lxPhEIg+0vL0vyNuElcAnLdnh2isC+n3745yXGMaSGuhP2tF/9alQb1131zZFce0kNQ+hgWsjukw69hdLxjBOBk0xcrV2x7EhTq+a4DUimJQyT18q5f7ewkAtxOaJuxFnzQrDc9YOWm4ze2nPEwFKm0Yp8SCHp+Obzb0U4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=candelatech.com; spf=pass smtp.mailfrom=candelatech.com; dkim=pass (1024-bit key) header.d=candelatech.com header.i=@candelatech.com header.b=owaiRq5m; arc=none smtp.client-ip=148.163.129.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=candelatech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=candelatech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=candelatech.com header.i=@candelatech.com header.b="owaiRq5m" Received: from dispatch1-us1.ppe-hosted.com (ip6-localhost [127.0.0.1]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 00C862A3949 for ; Tue, 6 Aug 2024 00:41:23 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mail3.candelatech.com (mail.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 7BA401000D9; Tue, 6 Aug 2024 00:41:15 +0000 (UTC) Received: from carkeek.candelatech.com (unknown [50.251.239.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail3.candelatech.com (Postfix) with ESMTPSA id E7A9813C2B3; Mon, 5 Aug 2024 17:41:14 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com E7A9813C2B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1722904875; bh=iqlEX4A0QrpNFkzwsk4HphEl3DI0MhY7Zg8ZeXn4HiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=owaiRq5mGhtU5WsC/SK7w/jJtv/SRoQ3NrdtFdR9wAqnvjn8A7f96dR3cv0qaTfud k5/TZQxgiyxij3GXuSsaXGzd3lFxyd0Gigy3fJ2F+PLDHH7daPUPfcLZYKS8nSpchT YhpOTTLsHweToht39TfdRe/CvK4KOqPu2uweZhVA= From: Rory Little To: kvalo@kernel.org, johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Rory Little Subject: [PATCH 2/2] wifi: ath10k: Removed atomic iteration in bitrate mask clear. Date: Mon, 5 Aug 2024 17:40:24 -0700 Message-Id: <20240806004024.2014080-3-rory@candelatech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240806004024.2014080-1-rory@candelatech.com> References: <20240806004024.2014080-1-rory@candelatech.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MDID: 1722904876-yqWhOzTSY8xC X-MDID-O: us5;ut7;1722904876;yqWhOzTSY8xC;;9989741adba0574bb335b9e9d00002fb This operation requires some blocking calls, which causes issues when attempting to guard this iteration's critical section with an RCU lock. Instead, we will take advantage of the held wiphy mutex to protect this operation. Signed-off-by: Rory Little --- drivers/net/wireless/ath/ath10k/mac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 7579a1cd7d15..a1a13b9ad465 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -9502,9 +9502,9 @@ static int ath10k_mac_op_set_bitrate_mask(struct ieee80211_hw *hw, ar->normal_mode_fw.fw_file.fw_features); if (allow_pfr) { mutex_lock(&ar->conf_mutex); - ieee80211_iterate_stations_atomic(ar->hw, - ath10k_mac_clr_bitrate_mask_iter, - arvif); + ieee80211_iterate_stations_mtx(ar->hw, + ath10k_mac_clr_bitrate_mask_iter, + arvif); mutex_unlock(&ar->conf_mutex); }