mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-12-21 19:31:55 +00:00
104 lines
3.5 KiB
Diff
104 lines
3.5 KiB
Diff
From 9dfbdc8c77493cd5791002b464054bfc503eff02 Mon Sep 17 00:00:00 2001
|
|
From: Johannes Berg <johannes.berg@intel.com>
|
|
Date: Fri, 18 Nov 2022 18:48:12 +0530
|
|
Subject: [PATCH] wifi: mac80211: add vif/sta link RCU dereference macros
|
|
|
|
Add macros (and an exported function) to allow checking some
|
|
link RCU protected accesses that are happening in callbacks
|
|
from mac80211 and are thus under the correct lock.
|
|
|
|
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
|
|
---
|
|
drivers/net/wireless/mac80211_hwsim.c | 16 ++++++++++++++--
|
|
include/net/mac80211.h | 17 ++++++++++++++---
|
|
net/mac80211/sta_info.c | 10 ++++++++++
|
|
3 files changed, 38 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
|
|
index be0a05a..1a7d74e 100644
|
|
--- a/drivers/net/wireless/mac80211_hwsim.c
|
|
+++ b/drivers/net/wireless/mac80211_hwsim.c
|
|
@@ -2991,6 +2991,19 @@ static int mac80211_hwsim_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
+/**
|
|
+ * lockdep_vif_mutex_held - for lockdep checks on link poiners
|
|
+ * @vif: the interface to check
|
|
+ */
|
|
+static inline bool lockdep_vif_mutex_held(struct ieee80211_vif *vif)
|
|
+{
|
|
+ return lockdep_is_held(&ieee80211_vif_to_wdev(vif)->mtx);
|
|
+}
|
|
+
|
|
+#define link_conf_dereference_protected(vif, link_id) \
|
|
+ rcu_dereference_protected((vif)->link_conf[link_id], \
|
|
+ lockdep_vif_mutex_held(vif))
|
|
+
|
|
static int mac80211_hwsim_change_vif_links(struct ieee80211_hw *hw,
|
|
struct ieee80211_vif *vif,
|
|
u16 old_links, u16 new_links,
|
|
@@ -3006,8 +3019,7 @@ static int mac80211_hwsim_change_vif_links(struct ieee80211_hw *hw,
|
|
for_each_set_bit(i, &add, IEEE80211_MLD_MAX_NUM_LINKS) {
|
|
struct ieee80211_bss_conf *link_conf;
|
|
|
|
- /* FIXME: figure out how to get the locking here */
|
|
- link_conf = rcu_dereference_protected(vif->link_conf[i], 1);
|
|
+ link_conf = link_conf_dereference_protected(vif, i);
|
|
if (WARN_ON(!link_conf))
|
|
continue;
|
|
|
|
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
|
|
index 685d5e8..550c294 100644
|
|
--- a/include/net/mac80211.h
|
|
+++ b/include/net/mac80211.h
|
|
@@ -2384,13 +2384,24 @@ struct ieee80211_sta {
|
|
u8 drv_priv[] __aligned(sizeof(void *));
|
|
};
|
|
|
|
-/* FIXME: check the locking correctly */
|
|
+#ifdef CONFIG_LOCKDEP
|
|
+bool lockdep_sta_mutex_held(struct ieee80211_sta *pubsta);
|
|
+#else
|
|
+static inline bool lockdep_sta_mutex_held(struct ieee80211_sta *pubsta)
|
|
+{
|
|
+ return true;
|
|
+}
|
|
+#endif
|
|
+
|
|
+#define link_sta_dereference_protected(sta, link_id) \
|
|
+ rcu_dereference_protected((sta)->link[link_id], \
|
|
+ lockdep_sta_mutex_held(sta))
|
|
+
|
|
#define for_each_sta_active_link(vif, sta, link_sta, link_id) \
|
|
for (link_id = 0; link_id < ARRAY_SIZE((sta)->link); link_id++) \
|
|
if ((!(vif)->active_links || \
|
|
(vif)->active_links & BIT(link_id)) && \
|
|
- ((link_sta) = rcu_dereference_protected((sta)->link[link_id],\
|
|
- 1)))
|
|
+ ((link_sta) = link_sta_dereference_protected(sta, link_id)))
|
|
|
|
/**
|
|
* enum sta_notify_cmd - sta notify command
|
|
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
|
|
index e485b55..492ea9b 100644
|
|
--- a/net/mac80211/sta_info.c
|
|
+++ b/net/mac80211/sta_info.c
|
|
@@ -2860,3 +2860,13 @@ void ieee80211_sta_set_max_amsdu_subframes(struct sta_info *sta,
|
|
if (val)
|
|
sta->sta.max_amsdu_subframes = 4 << val;
|
|
}
|
|
+
|
|
+#ifdef CONFIG_LOCKDEP
|
|
+bool lockdep_sta_mutex_held(struct ieee80211_sta *pubsta)
|
|
+{
|
|
+ struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
|
|
+
|
|
+ return lockdep_is_held(&sta->local->sta_mtx);
|
|
+}
|
|
+EXPORT_SYMBOL(lockdep_sta_mutex_held);
|
|
+#endif
|
|
--
|
|
2.17.1
|
|
|