Commit 5435af6e authored by Johannes Berg's avatar Johannes Berg

wifi: mac80211: remove chanctx_mtx

We now hold the wiphy mutex everywhere that we use or
needed the chanctx_mtx, so we don't need this mutex any
more. Remove it.

Most of this change was done automatically with spatch.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 2a8b665e
...@@ -261,9 +261,9 @@ static int ieee80211_start_p2p_device(struct wiphy *wiphy, ...@@ -261,9 +261,9 @@ static int ieee80211_start_p2p_device(struct wiphy *wiphy,
struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
int ret; int ret;
mutex_lock(&sdata->local->chanctx_mtx); lockdep_assert_wiphy(sdata->local->hw.wiphy);
ret = ieee80211_check_combinations(sdata, NULL, 0, 0); ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
mutex_unlock(&sdata->local->chanctx_mtx);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -283,9 +283,9 @@ static int ieee80211_start_nan(struct wiphy *wiphy, ...@@ -283,9 +283,9 @@ static int ieee80211_start_nan(struct wiphy *wiphy,
struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
int ret; int ret;
mutex_lock(&sdata->local->chanctx_mtx); lockdep_assert_wiphy(sdata->local->hw.wiphy);
ret = ieee80211_check_combinations(sdata, NULL, 0, 0); ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
mutex_unlock(&sdata->local->chanctx_mtx);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -3619,7 +3619,7 @@ static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata) ...@@ -3619,7 +3619,7 @@ static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
sdata_assert_lock(sdata); sdata_assert_lock(sdata);
lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->mtx);
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
/* /*
* using reservation isn't immediate as it may be deferred until later * using reservation isn't immediate as it may be deferred until later
...@@ -3692,7 +3692,7 @@ void ieee80211_csa_finalize_work(struct wiphy *wiphy, struct wiphy_work *work) ...@@ -3692,7 +3692,7 @@ void ieee80211_csa_finalize_work(struct wiphy *wiphy, struct wiphy_work *work)
sdata_lock(sdata); sdata_lock(sdata);
mutex_lock(&local->mtx); mutex_lock(&local->mtx);
mutex_lock(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
/* AP might have been stopped while waiting for the lock. */ /* AP might have been stopped while waiting for the lock. */
if (!sdata->vif.bss_conf.csa_active) if (!sdata->vif.bss_conf.csa_active)
...@@ -3704,7 +3704,6 @@ void ieee80211_csa_finalize_work(struct wiphy *wiphy, struct wiphy_work *work) ...@@ -3704,7 +3704,6 @@ void ieee80211_csa_finalize_work(struct wiphy *wiphy, struct wiphy_work *work)
ieee80211_csa_finalize(sdata); ieee80211_csa_finalize(sdata);
unlock: unlock:
mutex_unlock(&local->chanctx_mtx);
mutex_unlock(&local->mtx); mutex_unlock(&local->mtx);
sdata_unlock(sdata); sdata_unlock(sdata);
} }
...@@ -3864,6 +3863,7 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, ...@@ -3864,6 +3863,7 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
sdata_assert_lock(sdata); sdata_assert_lock(sdata);
lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->mtx);
lockdep_assert_wiphy(local->hw.wiphy);
if (!list_empty(&local->roc_list) || local->scanning) if (!list_empty(&local->roc_list) || local->scanning)
return -EBUSY; return -EBUSY;
...@@ -3879,9 +3879,8 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, ...@@ -3879,9 +3879,8 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
if (sdata->vif.bss_conf.csa_active) if (sdata->vif.bss_conf.csa_active)
return -EBUSY; return -EBUSY;
mutex_lock(&local->chanctx_mtx);
conf = rcu_dereference_protected(sdata->vif.bss_conf.chanctx_conf, conf = rcu_dereference_protected(sdata->vif.bss_conf.chanctx_conf,
lockdep_is_held(&local->chanctx_mtx)); lockdep_is_held(&local->hw.wiphy->mtx));
if (!conf) { if (!conf) {
err = -EBUSY; err = -EBUSY;
goto out; goto out;
...@@ -3955,7 +3954,6 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, ...@@ -3955,7 +3954,6 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
} }
out: out:
mutex_unlock(&local->chanctx_mtx);
return err; return err;
} }
......
...@@ -18,7 +18,7 @@ static int ieee80211_chanctx_num_assigned(struct ieee80211_local *local, ...@@ -18,7 +18,7 @@ static int ieee80211_chanctx_num_assigned(struct ieee80211_local *local,
struct ieee80211_link_data *link; struct ieee80211_link_data *link;
int num = 0; int num = 0;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
list_for_each_entry(link, &ctx->assigned_links, assigned_chanctx_list) list_for_each_entry(link, &ctx->assigned_links, assigned_chanctx_list)
num++; num++;
...@@ -32,7 +32,7 @@ static int ieee80211_chanctx_num_reserved(struct ieee80211_local *local, ...@@ -32,7 +32,7 @@ static int ieee80211_chanctx_num_reserved(struct ieee80211_local *local,
struct ieee80211_link_data *link; struct ieee80211_link_data *link;
int num = 0; int num = 0;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
list_for_each_entry(link, &ctx->reserved_links, reserved_chanctx_list) list_for_each_entry(link, &ctx->reserved_links, reserved_chanctx_list)
num++; num++;
...@@ -52,7 +52,7 @@ static int ieee80211_num_chanctx(struct ieee80211_local *local) ...@@ -52,7 +52,7 @@ static int ieee80211_num_chanctx(struct ieee80211_local *local)
struct ieee80211_chanctx *ctx; struct ieee80211_chanctx *ctx;
int num = 0; int num = 0;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
list_for_each_entry(ctx, &local->chanctx_list, list) list_for_each_entry(ctx, &local->chanctx_list, list)
num++; num++;
...@@ -62,7 +62,8 @@ static int ieee80211_num_chanctx(struct ieee80211_local *local) ...@@ -62,7 +62,8 @@ static int ieee80211_num_chanctx(struct ieee80211_local *local)
static bool ieee80211_can_create_new_chanctx(struct ieee80211_local *local) static bool ieee80211_can_create_new_chanctx(struct ieee80211_local *local)
{ {
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
return ieee80211_num_chanctx(local) < ieee80211_max_num_channels(local); return ieee80211_num_chanctx(local) < ieee80211_max_num_channels(local);
} }
...@@ -73,7 +74,7 @@ ieee80211_link_get_chanctx(struct ieee80211_link_data *link) ...@@ -73,7 +74,7 @@ ieee80211_link_get_chanctx(struct ieee80211_link_data *link)
struct ieee80211_chanctx_conf *conf; struct ieee80211_chanctx_conf *conf;
conf = rcu_dereference_protected(link->conf->chanctx_conf, conf = rcu_dereference_protected(link->conf->chanctx_conf,
lockdep_is_held(&local->chanctx_mtx)); lockdep_is_held(&local->hw.wiphy->mtx));
if (!conf) if (!conf)
return NULL; return NULL;
...@@ -87,7 +88,7 @@ ieee80211_chanctx_reserved_chandef(struct ieee80211_local *local, ...@@ -87,7 +88,7 @@ ieee80211_chanctx_reserved_chandef(struct ieee80211_local *local,
{ {
struct ieee80211_link_data *link; struct ieee80211_link_data *link;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
list_for_each_entry(link, &ctx->reserved_links, list_for_each_entry(link, &ctx->reserved_links,
reserved_chanctx_list) { reserved_chanctx_list) {
...@@ -110,7 +111,7 @@ ieee80211_chanctx_non_reserved_chandef(struct ieee80211_local *local, ...@@ -110,7 +111,7 @@ ieee80211_chanctx_non_reserved_chandef(struct ieee80211_local *local,
{ {
struct ieee80211_link_data *link; struct ieee80211_link_data *link;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
list_for_each_entry(link, &ctx->assigned_links, list_for_each_entry(link, &ctx->assigned_links,
assigned_chanctx_list) { assigned_chanctx_list) {
...@@ -136,7 +137,7 @@ ieee80211_chanctx_combined_chandef(struct ieee80211_local *local, ...@@ -136,7 +137,7 @@ ieee80211_chanctx_combined_chandef(struct ieee80211_local *local,
struct ieee80211_chanctx *ctx, struct ieee80211_chanctx *ctx,
const struct cfg80211_chan_def *compat) const struct cfg80211_chan_def *compat)
{ {
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
compat = ieee80211_chanctx_reserved_chandef(local, ctx, compat); compat = ieee80211_chanctx_reserved_chandef(local, ctx, compat);
if (!compat) if (!compat)
...@@ -154,7 +155,7 @@ ieee80211_chanctx_can_reserve_chandef(struct ieee80211_local *local, ...@@ -154,7 +155,7 @@ ieee80211_chanctx_can_reserve_chandef(struct ieee80211_local *local,
struct ieee80211_chanctx *ctx, struct ieee80211_chanctx *ctx,
const struct cfg80211_chan_def *def) const struct cfg80211_chan_def *def)
{ {
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
if (ieee80211_chanctx_combined_chandef(local, ctx, def)) if (ieee80211_chanctx_combined_chandef(local, ctx, def))
return true; return true;
...@@ -173,7 +174,7 @@ ieee80211_find_reservation_chanctx(struct ieee80211_local *local, ...@@ -173,7 +174,7 @@ ieee80211_find_reservation_chanctx(struct ieee80211_local *local,
{ {
struct ieee80211_chanctx *ctx; struct ieee80211_chanctx *ctx;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
if (mode == IEEE80211_CHANCTX_EXCLUSIVE) if (mode == IEEE80211_CHANCTX_EXCLUSIVE)
return NULL; return NULL;
...@@ -361,7 +362,7 @@ _ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local, ...@@ -361,7 +362,7 @@ _ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local,
enum nl80211_chan_width max_bw; enum nl80211_chan_width max_bw;
struct cfg80211_chan_def min_def; struct cfg80211_chan_def min_def;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
/* don't optimize non-20MHz based and radar_enabled confs */ /* don't optimize non-20MHz based and radar_enabled confs */
if (ctx->conf.def.width == NL80211_CHAN_WIDTH_5 || if (ctx->conf.def.width == NL80211_CHAN_WIDTH_5 ||
...@@ -537,7 +538,7 @@ ieee80211_find_chanctx(struct ieee80211_local *local, ...@@ -537,7 +538,7 @@ ieee80211_find_chanctx(struct ieee80211_local *local,
{ {
struct ieee80211_chanctx *ctx; struct ieee80211_chanctx *ctx;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
if (mode == IEEE80211_CHANCTX_EXCLUSIVE) if (mode == IEEE80211_CHANCTX_EXCLUSIVE)
return NULL; return NULL;
...@@ -602,7 +603,7 @@ ieee80211_chanctx_radar_required(struct ieee80211_local *local, ...@@ -602,7 +603,7 @@ ieee80211_chanctx_radar_required(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
bool required = false; bool required = false;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->mtx);
rcu_read_lock(); rcu_read_lock();
...@@ -641,7 +642,7 @@ ieee80211_alloc_chanctx(struct ieee80211_local *local, ...@@ -641,7 +642,7 @@ ieee80211_alloc_chanctx(struct ieee80211_local *local,
{ {
struct ieee80211_chanctx *ctx; struct ieee80211_chanctx *ctx;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
ctx = kzalloc(sizeof(*ctx) + local->hw.chanctx_data_size, GFP_KERNEL); ctx = kzalloc(sizeof(*ctx) + local->hw.chanctx_data_size, GFP_KERNEL);
if (!ctx) if (!ctx)
...@@ -666,7 +667,7 @@ static int ieee80211_add_chanctx(struct ieee80211_local *local, ...@@ -666,7 +667,7 @@ static int ieee80211_add_chanctx(struct ieee80211_local *local,
int err; int err;
lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->mtx);
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
if (!local->use_chanctx) if (!local->use_chanctx)
local->hw.conf.radar_enabled = ctx->conf.radar_enabled; local->hw.conf.radar_enabled = ctx->conf.radar_enabled;
...@@ -699,7 +700,7 @@ ieee80211_new_chanctx(struct ieee80211_local *local, ...@@ -699,7 +700,7 @@ ieee80211_new_chanctx(struct ieee80211_local *local,
int err; int err;
lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->mtx);
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
ctx = ieee80211_alloc_chanctx(local, chandef, mode); ctx = ieee80211_alloc_chanctx(local, chandef, mode);
if (!ctx) if (!ctx)
...@@ -718,7 +719,7 @@ ieee80211_new_chanctx(struct ieee80211_local *local, ...@@ -718,7 +719,7 @@ ieee80211_new_chanctx(struct ieee80211_local *local,
static void ieee80211_del_chanctx(struct ieee80211_local *local, static void ieee80211_del_chanctx(struct ieee80211_local *local,
struct ieee80211_chanctx *ctx) struct ieee80211_chanctx *ctx)
{ {
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
if (!local->use_chanctx) { if (!local->use_chanctx) {
struct cfg80211_chan_def *chandef = &local->_oper_chandef; struct cfg80211_chan_def *chandef = &local->_oper_chandef;
...@@ -753,7 +754,7 @@ static void ieee80211_del_chanctx(struct ieee80211_local *local, ...@@ -753,7 +754,7 @@ static void ieee80211_del_chanctx(struct ieee80211_local *local,
static void ieee80211_free_chanctx(struct ieee80211_local *local, static void ieee80211_free_chanctx(struct ieee80211_local *local,
struct ieee80211_chanctx *ctx) struct ieee80211_chanctx *ctx)
{ {
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
WARN_ON_ONCE(ieee80211_chanctx_refcount(local, ctx) != 0); WARN_ON_ONCE(ieee80211_chanctx_refcount(local, ctx) != 0);
...@@ -770,7 +771,7 @@ void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local, ...@@ -770,7 +771,7 @@ void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
const struct cfg80211_chan_def *compat = NULL; const struct cfg80211_chan_def *compat = NULL;
struct sta_info *sta; struct sta_info *sta;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(sdata, &local->interfaces, list) { list_for_each_entry_rcu(sdata, &local->interfaces, list) {
...@@ -833,7 +834,7 @@ static void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local, ...@@ -833,7 +834,7 @@ static void ieee80211_recalc_radar_chanctx(struct ieee80211_local *local,
{ {
bool radar_enabled; bool radar_enabled;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
/* for ieee80211_is_radar_required */ /* for ieee80211_is_radar_required */
lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->mtx);
...@@ -865,7 +866,7 @@ static int ieee80211_assign_link_chanctx(struct ieee80211_link_data *link, ...@@ -865,7 +866,7 @@ static int ieee80211_assign_link_chanctx(struct ieee80211_link_data *link,
return -ENOTSUPP; return -ENOTSUPP;
conf = rcu_dereference_protected(link->conf->chanctx_conf, conf = rcu_dereference_protected(link->conf->chanctx_conf,
lockdep_is_held(&local->chanctx_mtx)); lockdep_is_held(&local->hw.wiphy->mtx));
if (conf) { if (conf) {
curr_ctx = container_of(conf, struct ieee80211_chanctx, conf); curr_ctx = container_of(conf, struct ieee80211_chanctx, conf);
...@@ -920,7 +921,7 @@ void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local, ...@@ -920,7 +921,7 @@ void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
u8 rx_chains_static, rx_chains_dynamic; u8 rx_chains_static, rx_chains_dynamic;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
rx_chains_static = 1; rx_chains_static = 1;
rx_chains_dynamic = 1; rx_chains_dynamic = 1;
...@@ -1032,7 +1033,7 @@ __ieee80211_link_copy_chanctx_to_vlans(struct ieee80211_link_data *link, ...@@ -1032,7 +1033,7 @@ __ieee80211_link_copy_chanctx_to_vlans(struct ieee80211_link_data *link,
* to a channel context that has already been freed. * to a channel context that has already been freed.
*/ */
conf = rcu_dereference_protected(link_conf->chanctx_conf, conf = rcu_dereference_protected(link_conf->chanctx_conf,
lockdep_is_held(&local->chanctx_mtx)); lockdep_is_held(&local->hw.wiphy->mtx));
WARN_ON(!conf); WARN_ON(!conf);
if (clear) if (clear)
...@@ -1056,11 +1057,9 @@ void ieee80211_link_copy_chanctx_to_vlans(struct ieee80211_link_data *link, ...@@ -1056,11 +1057,9 @@ void ieee80211_link_copy_chanctx_to_vlans(struct ieee80211_link_data *link,
{ {
struct ieee80211_local *local = link->sdata->local; struct ieee80211_local *local = link->sdata->local;
mutex_lock(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
__ieee80211_link_copy_chanctx_to_vlans(link, clear); __ieee80211_link_copy_chanctx_to_vlans(link, clear);
mutex_unlock(&local->chanctx_mtx);
} }
int ieee80211_link_unreserve_chanctx(struct ieee80211_link_data *link) int ieee80211_link_unreserve_chanctx(struct ieee80211_link_data *link)
...@@ -1068,7 +1067,7 @@ int ieee80211_link_unreserve_chanctx(struct ieee80211_link_data *link) ...@@ -1068,7 +1067,7 @@ int ieee80211_link_unreserve_chanctx(struct ieee80211_link_data *link)
struct ieee80211_sub_if_data *sdata = link->sdata; struct ieee80211_sub_if_data *sdata = link->sdata;
struct ieee80211_chanctx *ctx = link->reserved_chanctx; struct ieee80211_chanctx *ctx = link->reserved_chanctx;
lockdep_assert_held(&sdata->local->chanctx_mtx); lockdep_assert_wiphy(sdata->local->hw.wiphy);
if (WARN_ON(!ctx)) if (WARN_ON(!ctx))
return -EINVAL; return -EINVAL;
...@@ -1108,7 +1107,7 @@ int ieee80211_link_reserve_chanctx(struct ieee80211_link_data *link, ...@@ -1108,7 +1107,7 @@ int ieee80211_link_reserve_chanctx(struct ieee80211_link_data *link,
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
struct ieee80211_chanctx *new_ctx, *curr_ctx, *ctx; struct ieee80211_chanctx *new_ctx, *curr_ctx, *ctx;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
curr_ctx = ieee80211_link_get_chanctx(link); curr_ctx = ieee80211_link_get_chanctx(link);
if (curr_ctx && local->use_chanctx && !local->ops->switch_vif_chanctx) if (curr_ctx && local->use_chanctx && !local->ops->switch_vif_chanctx)
...@@ -1266,7 +1265,7 @@ ieee80211_link_use_reserved_reassign(struct ieee80211_link_data *link) ...@@ -1266,7 +1265,7 @@ ieee80211_link_use_reserved_reassign(struct ieee80211_link_data *link)
int err; int err;
lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->mtx);
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
new_ctx = link->reserved_chanctx; new_ctx = link->reserved_chanctx;
old_ctx = ieee80211_link_get_chanctx(link); old_ctx = ieee80211_link_get_chanctx(link);
...@@ -1390,7 +1389,7 @@ ieee80211_link_has_in_place_reservation(struct ieee80211_link_data *link) ...@@ -1390,7 +1389,7 @@ ieee80211_link_has_in_place_reservation(struct ieee80211_link_data *link)
struct ieee80211_sub_if_data *sdata = link->sdata; struct ieee80211_sub_if_data *sdata = link->sdata;
struct ieee80211_chanctx *old_ctx, *new_ctx; struct ieee80211_chanctx *old_ctx, *new_ctx;
lockdep_assert_held(&sdata->local->chanctx_mtx); lockdep_assert_wiphy(sdata->local->hw.wiphy);
new_ctx = link->reserved_chanctx; new_ctx = link->reserved_chanctx;
old_ctx = ieee80211_link_get_chanctx(link); old_ctx = ieee80211_link_get_chanctx(link);
...@@ -1416,7 +1415,7 @@ static int ieee80211_chsw_switch_hwconf(struct ieee80211_local *local, ...@@ -1416,7 +1415,7 @@ static int ieee80211_chsw_switch_hwconf(struct ieee80211_local *local,
const struct cfg80211_chan_def *chandef; const struct cfg80211_chan_def *chandef;
lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->mtx);
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
chandef = ieee80211_chanctx_reserved_chandef(local, new_ctx, NULL); chandef = ieee80211_chanctx_reserved_chandef(local, new_ctx, NULL);
if (WARN_ON(!chandef)) if (WARN_ON(!chandef))
...@@ -1438,7 +1437,7 @@ static int ieee80211_chsw_switch_vifs(struct ieee80211_local *local, ...@@ -1438,7 +1437,7 @@ static int ieee80211_chsw_switch_vifs(struct ieee80211_local *local,
int i, err; int i, err;
lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->mtx);
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
vif_chsw = kcalloc(n_vifs, sizeof(vif_chsw[0]), GFP_KERNEL); vif_chsw = kcalloc(n_vifs, sizeof(vif_chsw[0]), GFP_KERNEL);
if (!vif_chsw) if (!vif_chsw)
...@@ -1483,7 +1482,7 @@ static int ieee80211_chsw_switch_ctxs(struct ieee80211_local *local) ...@@ -1483,7 +1482,7 @@ static int ieee80211_chsw_switch_ctxs(struct ieee80211_local *local)
int err; int err;
lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->mtx);
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
list_for_each_entry(ctx, &local->chanctx_list, list) { list_for_each_entry(ctx, &local->chanctx_list, list) {
if (ctx->replace_state != IEEE80211_CHANCTX_REPLACES_OTHER) if (ctx->replace_state != IEEE80211_CHANCTX_REPLACES_OTHER)
...@@ -1524,7 +1523,7 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local) ...@@ -1524,7 +1523,7 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)
int n_ctx = 0, n_vifs_switch = 0, n_vifs_assign = 0, n_vifs_ctxless = 0; int n_ctx = 0, n_vifs_switch = 0, n_vifs_assign = 0, n_vifs_ctxless = 0;
lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->mtx);
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
/* /*
* If there are 2 independent pairs of channel contexts performing * If there are 2 independent pairs of channel contexts performing
...@@ -1783,10 +1782,10 @@ static void __ieee80211_link_release_channel(struct ieee80211_link_data *link) ...@@ -1783,10 +1782,10 @@ static void __ieee80211_link_release_channel(struct ieee80211_link_data *link)
struct ieee80211_chanctx *ctx; struct ieee80211_chanctx *ctx;
bool use_reserved_switch = false; bool use_reserved_switch = false;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
conf = rcu_dereference_protected(link_conf->chanctx_conf, conf = rcu_dereference_protected(link_conf->chanctx_conf,
lockdep_is_held(&local->chanctx_mtx)); lockdep_is_held(&local->hw.wiphy->mtx));
if (!conf) if (!conf)
return; return;
...@@ -1829,7 +1828,7 @@ int ieee80211_link_use_channel(struct ieee80211_link_data *link, ...@@ -1829,7 +1828,7 @@ int ieee80211_link_use_channel(struct ieee80211_link_data *link,
return 0; return 0;
} }
mutex_lock(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
ret = cfg80211_chandef_dfs_required(local->hw.wiphy, ret = cfg80211_chandef_dfs_required(local->hw.wiphy,
chandef, chandef,
...@@ -1872,7 +1871,6 @@ int ieee80211_link_use_channel(struct ieee80211_link_data *link, ...@@ -1872,7 +1871,6 @@ int ieee80211_link_use_channel(struct ieee80211_link_data *link,
if (ret) if (ret)
link->radar_required = false; link->radar_required = false;
mutex_unlock(&local->chanctx_mtx);
return ret; return ret;
} }
...@@ -1885,7 +1883,7 @@ int ieee80211_link_use_reserved_context(struct ieee80211_link_data *link) ...@@ -1885,7 +1883,7 @@ int ieee80211_link_use_reserved_context(struct ieee80211_link_data *link)
int err; int err;
lockdep_assert_held(&local->mtx); lockdep_assert_held(&local->mtx);
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
new_ctx = link->reserved_chanctx; new_ctx = link->reserved_chanctx;
old_ctx = ieee80211_link_get_chanctx(link); old_ctx = ieee80211_link_get_chanctx(link);
...@@ -1948,51 +1946,40 @@ int ieee80211_link_change_bandwidth(struct ieee80211_link_data *link, ...@@ -1948,51 +1946,40 @@ int ieee80211_link_change_bandwidth(struct ieee80211_link_data *link,
struct ieee80211_chanctx_conf *conf; struct ieee80211_chanctx_conf *conf;
struct ieee80211_chanctx *ctx; struct ieee80211_chanctx *ctx;
const struct cfg80211_chan_def *compat; const struct cfg80211_chan_def *compat;
int ret;
lockdep_assert_wiphy(local->hw.wiphy);
if (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef, if (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
IEEE80211_CHAN_DISABLED)) IEEE80211_CHAN_DISABLED))
return -EINVAL; return -EINVAL;
mutex_lock(&local->chanctx_mtx); if (cfg80211_chandef_identical(chandef, &link_conf->chandef))
if (cfg80211_chandef_identical(chandef, &link_conf->chandef)) { return 0;
ret = 0;
goto out;
}
if (chandef->width == NL80211_CHAN_WIDTH_20_NOHT || if (chandef->width == NL80211_CHAN_WIDTH_20_NOHT ||
link_conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT) { link_conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
ret = -EINVAL; return -EINVAL;
goto out;
}
conf = rcu_dereference_protected(link_conf->chanctx_conf, conf = rcu_dereference_protected(link_conf->chanctx_conf,
lockdep_is_held(&local->chanctx_mtx)); lockdep_is_held(&local->hw.wiphy->mtx));
if (!conf) { if (!conf)
ret = -EINVAL; return -EINVAL;
goto out;
}
ctx = container_of(conf, struct ieee80211_chanctx, conf); ctx = container_of(conf, struct ieee80211_chanctx, conf);
compat = cfg80211_chandef_compatible(&conf->def, chandef); compat = cfg80211_chandef_compatible(&conf->def, chandef);
if (!compat) { if (!compat)
ret = -EINVAL; return -EINVAL;
goto out;
}
switch (ctx->replace_state) { switch (ctx->replace_state) {
case IEEE80211_CHANCTX_REPLACE_NONE: case IEEE80211_CHANCTX_REPLACE_NONE:
if (!ieee80211_chanctx_reserved_chandef(local, ctx, compat)) { if (!ieee80211_chanctx_reserved_chandef(local, ctx, compat))
ret = -EBUSY; return -EBUSY;
goto out;
}
break; break;
case IEEE80211_CHANCTX_WILL_BE_REPLACED: case IEEE80211_CHANCTX_WILL_BE_REPLACED:
/* TODO: Perhaps the bandwidth change could be treated as a /* TODO: Perhaps the bandwidth change could be treated as a
* reservation itself? */ * reservation itself? */
ret = -EBUSY; return -EBUSY;
goto out;
case IEEE80211_CHANCTX_REPLACES_OTHER: case IEEE80211_CHANCTX_REPLACES_OTHER:
/* channel context that is going to replace another channel /* channel context that is going to replace another channel
* context doesn't really exist and shouldn't be assigned * context doesn't really exist and shouldn't be assigned
...@@ -2006,22 +1993,19 @@ int ieee80211_link_change_bandwidth(struct ieee80211_link_data *link, ...@@ -2006,22 +1993,19 @@ int ieee80211_link_change_bandwidth(struct ieee80211_link_data *link,
ieee80211_recalc_chanctx_chantype(local, ctx); ieee80211_recalc_chanctx_chantype(local, ctx);
*changed |= BSS_CHANGED_BANDWIDTH; *changed |= BSS_CHANGED_BANDWIDTH;
ret = 0; return 0;
out:
mutex_unlock(&local->chanctx_mtx);
return ret;
} }
void ieee80211_link_release_channel(struct ieee80211_link_data *link) void ieee80211_link_release_channel(struct ieee80211_link_data *link)
{ {
struct ieee80211_sub_if_data *sdata = link->sdata; struct ieee80211_sub_if_data *sdata = link->sdata;
mutex_lock(&sdata->local->chanctx_mtx); lockdep_assert_wiphy(sdata->local->hw.wiphy);
if (rcu_access_pointer(link->conf->chanctx_conf)) { if (rcu_access_pointer(link->conf->chanctx_conf)) {
lockdep_assert_held(&sdata->local->mtx); lockdep_assert_held(&sdata->local->mtx);
__ieee80211_link_release_channel(link); __ieee80211_link_release_channel(link);
} }
mutex_unlock(&sdata->local->chanctx_mtx);
} }
void ieee80211_link_vlan_copy_chanctx(struct ieee80211_link_data *link) void ieee80211_link_vlan_copy_chanctx(struct ieee80211_link_data *link)
...@@ -2034,20 +2018,19 @@ void ieee80211_link_vlan_copy_chanctx(struct ieee80211_link_data *link) ...@@ -2034,20 +2018,19 @@ void ieee80211_link_vlan_copy_chanctx(struct ieee80211_link_data *link)
struct ieee80211_sub_if_data *ap; struct ieee80211_sub_if_data *ap;
struct ieee80211_chanctx_conf *conf; struct ieee80211_chanctx_conf *conf;
lockdep_assert_wiphy(local->hw.wiphy);
if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->bss)) if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->bss))
return; return;
ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap);
mutex_lock(&local->chanctx_mtx);
rcu_read_lock(); rcu_read_lock();
ap_conf = rcu_dereference(ap->vif.link_conf[link_id]); ap_conf = rcu_dereference(ap->vif.link_conf[link_id]);
conf = rcu_dereference_protected(ap_conf->chanctx_conf, conf = rcu_dereference_protected(ap_conf->chanctx_conf,
lockdep_is_held(&local->chanctx_mtx)); lockdep_is_held(&local->hw.wiphy->mtx));
rcu_assign_pointer(link_conf->chanctx_conf, conf); rcu_assign_pointer(link_conf->chanctx_conf, conf);
rcu_read_unlock(); rcu_read_unlock();
mutex_unlock(&local->chanctx_mtx);
} }
void ieee80211_iter_chan_contexts_atomic( void ieee80211_iter_chan_contexts_atomic(
......
...@@ -1765,6 +1765,8 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, ...@@ -1765,6 +1765,8 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
int i; int i;
int ret; int ret;
lockdep_assert_wiphy(local->hw.wiphy);
if (params->chandef.chan->freq_offset) { if (params->chandef.chan->freq_offset) {
/* this may work, but is untested */ /* this may work, but is untested */
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -1785,10 +1787,8 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, ...@@ -1785,10 +1787,8 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
chanmode = (params->channel_fixed && !ret) ? chanmode = (params->channel_fixed && !ret) ?
IEEE80211_CHANCTX_SHARED : IEEE80211_CHANCTX_EXCLUSIVE; IEEE80211_CHANCTX_SHARED : IEEE80211_CHANCTX_EXCLUSIVE;
mutex_lock(&local->chanctx_mtx);
ret = ieee80211_check_combinations(sdata, &params->chandef, chanmode, ret = ieee80211_check_combinations(sdata, &params->chandef, chanmode,
radar_detect_width); radar_detect_width);
mutex_unlock(&local->chanctx_mtx);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -979,8 +979,8 @@ struct ieee80211_link_data { ...@@ -979,8 +979,8 @@ struct ieee80211_link_data {
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
unsigned int link_id; unsigned int link_id;
struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */ struct list_head assigned_chanctx_list; /* protected by wiphy mutex */
struct list_head reserved_chanctx_list; /* protected by chanctx_mtx */ struct list_head reserved_chanctx_list; /* protected by wiphy mutex */
/* multicast keys only */ /* multicast keys only */
struct ieee80211_key __rcu *gtk[NUM_DEFAULT_KEYS + struct ieee80211_key __rcu *gtk[NUM_DEFAULT_KEYS +
...@@ -1001,7 +1001,7 @@ struct ieee80211_link_data { ...@@ -1001,7 +1001,7 @@ struct ieee80211_link_data {
struct delayed_work color_collision_detect_work; struct delayed_work color_collision_detect_work;
u64 color_bitmap; u64 color_bitmap;
/* context reservation -- protected with chanctx_mtx */ /* context reservation -- protected with wiphy mutex */
struct ieee80211_chanctx *reserved_chanctx; struct ieee80211_chanctx *reserved_chanctx;
struct cfg80211_chan_def reserved_chandef; struct cfg80211_chan_def reserved_chandef;
bool reserved_radar_required; bool reserved_radar_required;
...@@ -1499,7 +1499,6 @@ struct ieee80211_local { ...@@ -1499,7 +1499,6 @@ struct ieee80211_local {
/* channel contexts */ /* channel contexts */
struct list_head chanctx_list; struct list_head chanctx_list;
struct mutex chanctx_mtx;
#ifdef CONFIG_MAC80211_LEDS #ifdef CONFIG_MAC80211_LEDS
struct led_trigger tx_led, rx_led, assoc_led, radio_led; struct led_trigger tx_led, rx_led, assoc_led, radio_led;
......
...@@ -324,9 +324,9 @@ static int ieee80211_check_concurrent_iface(struct ieee80211_sub_if_data *sdata, ...@@ -324,9 +324,9 @@ static int ieee80211_check_concurrent_iface(struct ieee80211_sub_if_data *sdata,
{ {
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
struct ieee80211_sub_if_data *nsdata; struct ieee80211_sub_if_data *nsdata;
int ret;
ASSERT_RTNL(); ASSERT_RTNL();
lockdep_assert_wiphy(local->hw.wiphy);
/* we hold the RTNL here so can safely walk the list */ /* we hold the RTNL here so can safely walk the list */
list_for_each_entry(nsdata, &local->interfaces, list) { list_for_each_entry(nsdata, &local->interfaces, list) {
...@@ -391,10 +391,7 @@ static int ieee80211_check_concurrent_iface(struct ieee80211_sub_if_data *sdata, ...@@ -391,10 +391,7 @@ static int ieee80211_check_concurrent_iface(struct ieee80211_sub_if_data *sdata,
} }
} }
mutex_lock(&local->chanctx_mtx); return ieee80211_check_combinations(sdata, NULL, 0, 0);
ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
mutex_unlock(&local->chanctx_mtx);
return ret;
} }
static int ieee80211_check_queues(struct ieee80211_sub_if_data *sdata, static int ieee80211_check_queues(struct ieee80211_sub_if_data *sdata,
......
...@@ -826,7 +826,6 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len, ...@@ -826,7 +826,6 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
spin_lock_init(&local->handle_wake_tx_queue_lock); spin_lock_init(&local->handle_wake_tx_queue_lock);
INIT_LIST_HEAD(&local->chanctx_list); INIT_LIST_HEAD(&local->chanctx_list);
mutex_init(&local->chanctx_mtx);
wiphy_delayed_work_init(&local->scan_work, ieee80211_scan_work); wiphy_delayed_work_init(&local->scan_work, ieee80211_scan_work);
......
...@@ -1691,7 +1691,7 @@ static void ieee80211_chswitch_work(struct wiphy *wiphy, ...@@ -1691,7 +1691,7 @@ static void ieee80211_chswitch_work(struct wiphy *wiphy,
sdata_lock(sdata); sdata_lock(sdata);
mutex_lock(&local->mtx); mutex_lock(&local->mtx);
mutex_lock(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
if (!ifmgd->associated) if (!ifmgd->associated)
goto out; goto out;
...@@ -1743,7 +1743,6 @@ static void ieee80211_chswitch_work(struct wiphy *wiphy, ...@@ -1743,7 +1743,6 @@ static void ieee80211_chswitch_work(struct wiphy *wiphy,
ieee80211_sta_reset_conn_monitor(sdata); ieee80211_sta_reset_conn_monitor(sdata);
out: out:
mutex_unlock(&local->chanctx_mtx);
mutex_unlock(&local->mtx); mutex_unlock(&local->mtx);
sdata_unlock(sdata); sdata_unlock(sdata);
} }
...@@ -1813,14 +1812,14 @@ ieee80211_sta_abort_chanswitch(struct ieee80211_link_data *link) ...@@ -1813,14 +1812,14 @@ ieee80211_sta_abort_chanswitch(struct ieee80211_link_data *link)
struct ieee80211_sub_if_data *sdata = link->sdata; struct ieee80211_sub_if_data *sdata = link->sdata;
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
lockdep_assert_wiphy(local->hw.wiphy);
if (!local->ops->abort_channel_switch) if (!local->ops->abort_channel_switch)
return; return;
mutex_lock(&local->mtx); mutex_lock(&local->mtx);
mutex_lock(&local->chanctx_mtx);
ieee80211_link_unreserve_chanctx(link); ieee80211_link_unreserve_chanctx(link);
mutex_unlock(&local->chanctx_mtx);
if (link->csa_block_tx) if (link->csa_block_tx)
ieee80211_wake_vif_queues(local, sdata, ieee80211_wake_vif_queues(local, sdata,
...@@ -1854,6 +1853,7 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link, ...@@ -1854,6 +1853,7 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
int res; int res;
sdata_assert_lock(sdata); sdata_assert_lock(sdata);
lockdep_assert_wiphy(local->hw.wiphy);
if (!cbss) if (!cbss)
return; return;
...@@ -1936,9 +1936,8 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link, ...@@ -1936,9 +1936,8 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
ieee80211_teardown_tdls_peers(sdata); ieee80211_teardown_tdls_peers(sdata);
mutex_lock(&local->mtx); mutex_lock(&local->mtx);
mutex_lock(&local->chanctx_mtx);
conf = rcu_dereference_protected(link->conf->chanctx_conf, conf = rcu_dereference_protected(link->conf->chanctx_conf,
lockdep_is_held(&local->chanctx_mtx)); lockdep_is_held(&local->hw.wiphy->mtx));
if (!conf) { if (!conf) {
sdata_info(sdata, sdata_info(sdata,
"no channel context assigned to vif?, disconnecting\n"); "no channel context assigned to vif?, disconnecting\n");
...@@ -1968,7 +1967,6 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link, ...@@ -1968,7 +1967,6 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
res); res);
goto drop_connection; goto drop_connection;
} }
mutex_unlock(&local->chanctx_mtx);
link->conf->csa_active = true; link->conf->csa_active = true;
link->csa_chandef = csa_ie.chandef; link->csa_chandef = csa_ie.chandef;
...@@ -2000,7 +1998,6 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link, ...@@ -2000,7 +1998,6 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
return; return;
lock_and_drop_connection: lock_and_drop_connection:
mutex_lock(&local->mtx); mutex_lock(&local->mtx);
mutex_lock(&local->chanctx_mtx);
drop_connection: drop_connection:
/* /*
* This is just so that the disconnect flow will know that * This is just so that the disconnect flow will know that
...@@ -2014,7 +2011,6 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link, ...@@ -2014,7 +2011,6 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
wiphy_work_queue(sdata->local->hw.wiphy, wiphy_work_queue(sdata->local->hw.wiphy,
&ifmgd->csa_connection_drop_work); &ifmgd->csa_connection_drop_work);
mutex_unlock(&local->chanctx_mtx);
mutex_unlock(&local->mtx); mutex_unlock(&local->mtx);
} }
...@@ -3186,6 +3182,8 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata) ...@@ -3186,6 +3182,8 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata)
u8 unicast_limit = max(1, max_probe_tries - 3); u8 unicast_limit = max(1, max_probe_tries - 3);
struct sta_info *sta; struct sta_info *sta;
lockdep_assert_wiphy(sdata->local->hw.wiphy);
if (WARN_ON(ieee80211_vif_is_mld(&sdata->vif))) if (WARN_ON(ieee80211_vif_is_mld(&sdata->vif)))
return; return;
...@@ -3207,7 +3205,6 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata) ...@@ -3207,7 +3205,6 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata)
ifmgd->probe_send_count++; ifmgd->probe_send_count++;
if (dst) { if (dst) {
lockdep_assert_wiphy(sdata->local->hw.wiphy);
sta = sta_info_get(sdata, dst); sta = sta_info_get(sdata, dst);
if (!WARN_ON(!sta)) if (!WARN_ON(!sta))
ieee80211_check_fast_rx(sta); ieee80211_check_fast_rx(sta);
...@@ -3629,6 +3626,8 @@ static bool ieee80211_mark_sta_auth(struct ieee80211_sub_if_data *sdata) ...@@ -3629,6 +3626,8 @@ static bool ieee80211_mark_sta_auth(struct ieee80211_sub_if_data *sdata)
const u8 *ap_addr = ifmgd->auth_data->ap_addr; const u8 *ap_addr = ifmgd->auth_data->ap_addr;
struct sta_info *sta; struct sta_info *sta;
lockdep_assert_wiphy(sdata->local->hw.wiphy);
sdata_info(sdata, "authenticated\n"); sdata_info(sdata, "authenticated\n");
ifmgd->auth_data->done = true; ifmgd->auth_data->done = true;
ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC; ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC;
...@@ -3636,7 +3635,6 @@ static bool ieee80211_mark_sta_auth(struct ieee80211_sub_if_data *sdata) ...@@ -3636,7 +3635,6 @@ static bool ieee80211_mark_sta_auth(struct ieee80211_sub_if_data *sdata)
run_again(sdata, ifmgd->auth_data->timeout); run_again(sdata, ifmgd->auth_data->timeout);
/* move station state to auth */ /* move station state to auth */
lockdep_assert_wiphy(sdata->local->hw.wiphy);
sta = sta_info_get(sdata, ap_addr); sta = sta_info_get(sdata, ap_addr);
if (!sta) { if (!sta) {
WARN_ONCE(1, "%s: STA %pM not found", sdata->name, ap_addr); WARN_ONCE(1, "%s: STA %pM not found", sdata->name, ap_addr);
...@@ -5899,6 +5897,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link, ...@@ -5899,6 +5897,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link,
}; };
sdata_assert_lock(sdata); sdata_assert_lock(sdata);
lockdep_assert_wiphy(local->hw.wiphy);
/* Process beacon from the current BSS */ /* Process beacon from the current BSS */
bssid = ieee80211_get_bssid(hdr, len, sdata->vif.type); bssid = ieee80211_get_bssid(hdr, len, sdata->vif.type);
...@@ -6133,7 +6132,6 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link, ...@@ -6133,7 +6132,6 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link,
le16_to_cpu(mgmt->u.beacon.capab_info), le16_to_cpu(mgmt->u.beacon.capab_info),
erp_valid, erp_value); erp_valid, erp_value);
lockdep_assert_wiphy(local->hw.wiphy);
sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr); sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr);
if (WARN_ON(!sta)) { if (WARN_ON(!sta)) {
goto free; goto free;
......
...@@ -1354,9 +1354,10 @@ static void iee80211_tdls_recalc_chanctx(struct ieee80211_sub_if_data *sdata, ...@@ -1354,9 +1354,10 @@ static void iee80211_tdls_recalc_chanctx(struct ieee80211_sub_if_data *sdata,
enum nl80211_chan_width width; enum nl80211_chan_width width;
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
mutex_lock(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
conf = rcu_dereference_protected(sdata->vif.bss_conf.chanctx_conf, conf = rcu_dereference_protected(sdata->vif.bss_conf.chanctx_conf,
lockdep_is_held(&local->chanctx_mtx)); lockdep_is_held(&local->hw.wiphy->mtx));
if (conf) { if (conf) {
width = conf->def.width; width = conf->def.width;
sband = local->hw.wiphy->bands[conf->def.chan->band]; sband = local->hw.wiphy->bands[conf->def.chan->band];
...@@ -1384,7 +1385,6 @@ static void iee80211_tdls_recalc_chanctx(struct ieee80211_sub_if_data *sdata, ...@@ -1384,7 +1385,6 @@ static void iee80211_tdls_recalc_chanctx(struct ieee80211_sub_if_data *sdata,
} }
} }
mutex_unlock(&local->chanctx_mtx);
} }
static int iee80211_tdls_have_ht_peers(struct ieee80211_sub_if_data *sdata) static int iee80211_tdls_have_ht_peers(struct ieee80211_sub_if_data *sdata)
...@@ -1447,6 +1447,8 @@ int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, ...@@ -1447,6 +1447,8 @@ int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
int ret; int ret;
lockdep_assert_wiphy(local->hw.wiphy);
if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
return -ENOTSUPP; return -ENOTSUPP;
...@@ -1479,7 +1481,6 @@ int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, ...@@ -1479,7 +1481,6 @@ int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
break; break;
} }
lockdep_assert_wiphy(local->hw.wiphy);
sta = sta_info_get(sdata, peer); sta = sta_info_get(sdata, peer);
if (!sta) { if (!sta) {
ret = -ENOLINK; ret = -ENOLINK;
...@@ -1512,7 +1513,6 @@ int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, ...@@ -1512,7 +1513,6 @@ int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
ret = sta_info_destroy_addr(sdata, peer); ret = sta_info_destroy_addr(sdata, peer);
lockdep_assert_wiphy(local->hw.wiphy);
iee80211_tdls_recalc_ht_protection(sdata, NULL); iee80211_tdls_recalc_ht_protection(sdata, NULL);
iee80211_tdls_recalc_chanctx(sdata, NULL); iee80211_tdls_recalc_chanctx(sdata, NULL);
...@@ -1667,11 +1667,12 @@ ieee80211_tdls_channel_switch(struct wiphy *wiphy, struct net_device *dev, ...@@ -1667,11 +1667,12 @@ ieee80211_tdls_channel_switch(struct wiphy *wiphy, struct net_device *dev,
u32 ch_sw_tm_ie; u32 ch_sw_tm_ie;
int ret; int ret;
lockdep_assert_wiphy(local->hw.wiphy);
if (chandef->chan->freq_offset) if (chandef->chan->freq_offset)
/* this may work, but is untested */ /* this may work, but is untested */
return -EOPNOTSUPP; return -EOPNOTSUPP;
lockdep_assert_wiphy(local->hw.wiphy);
sta = sta_info_get(sdata, addr); sta = sta_info_get(sdata, addr);
if (!sta) { if (!sta) {
tdls_dbg(sdata, tdls_dbg(sdata,
...@@ -1793,6 +1794,8 @@ ieee80211_process_tdls_channel_switch_resp(struct ieee80211_sub_if_data *sdata, ...@@ -1793,6 +1794,8 @@ ieee80211_process_tdls_channel_switch_resp(struct ieee80211_sub_if_data *sdata,
struct ieee80211_tdls_ch_sw_params params = {}; struct ieee80211_tdls_ch_sw_params params = {};
int ret; int ret;
lockdep_assert_wiphy(local->hw.wiphy);
params.action_code = WLAN_TDLS_CHANNEL_SWITCH_RESPONSE; params.action_code = WLAN_TDLS_CHANNEL_SWITCH_RESPONSE;
params.timestamp = rx_status->device_timestamp; params.timestamp = rx_status->device_timestamp;
...@@ -1802,7 +1805,6 @@ ieee80211_process_tdls_channel_switch_resp(struct ieee80211_sub_if_data *sdata, ...@@ -1802,7 +1805,6 @@ ieee80211_process_tdls_channel_switch_resp(struct ieee80211_sub_if_data *sdata,
return -EINVAL; return -EINVAL;
} }
lockdep_assert_wiphy(local->hw.wiphy);
sta = sta_info_get(sdata, tf->sa); sta = sta_info_get(sdata, tf->sa);
if (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH)) { if (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH)) {
tdls_dbg(sdata, "TDLS chan switch from non-peer sta %pM\n", tdls_dbg(sdata, "TDLS chan switch from non-peer sta %pM\n",
...@@ -1890,6 +1892,8 @@ ieee80211_process_tdls_channel_switch_req(struct ieee80211_sub_if_data *sdata, ...@@ -1890,6 +1892,8 @@ ieee80211_process_tdls_channel_switch_req(struct ieee80211_sub_if_data *sdata,
struct ieee80211_tdls_ch_sw_params params = {}; struct ieee80211_tdls_ch_sw_params params = {};
int ret = 0; int ret = 0;
lockdep_assert_wiphy(local->hw.wiphy);
params.action_code = WLAN_TDLS_CHANNEL_SWITCH_REQUEST; params.action_code = WLAN_TDLS_CHANNEL_SWITCH_REQUEST;
params.timestamp = rx_status->device_timestamp; params.timestamp = rx_status->device_timestamp;
...@@ -1978,7 +1982,6 @@ ieee80211_process_tdls_channel_switch_req(struct ieee80211_sub_if_data *sdata, ...@@ -1978,7 +1982,6 @@ ieee80211_process_tdls_channel_switch_req(struct ieee80211_sub_if_data *sdata,
goto free; goto free;
} }
lockdep_assert_wiphy(local->hw.wiphy);
sta = sta_info_get(sdata, tf->sa); sta = sta_info_get(sdata, tf->sa);
if (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH)) { if (!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH)) {
tdls_dbg(sdata, "TDLS chan switch from non-peer sta %pM\n", tdls_dbg(sdata, "TDLS chan switch from non-peer sta %pM\n",
......
...@@ -2351,6 +2351,8 @@ static void ieee80211_handle_reconfig_failure(struct ieee80211_local *local) ...@@ -2351,6 +2351,8 @@ static void ieee80211_handle_reconfig_failure(struct ieee80211_local *local)
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
struct ieee80211_chanctx *ctx; struct ieee80211_chanctx *ctx;
lockdep_assert_wiphy(local->hw.wiphy);
/* /*
* We get here if during resume the device can't be restarted properly. * We get here if during resume the device can't be restarted properly.
* We might also get here if this happens during HW reset, which is a * We might also get here if this happens during HW reset, which is a
...@@ -2379,10 +2381,8 @@ static void ieee80211_handle_reconfig_failure(struct ieee80211_local *local) ...@@ -2379,10 +2381,8 @@ static void ieee80211_handle_reconfig_failure(struct ieee80211_local *local)
/* Mark channel contexts as not being in the driver any more to avoid /* Mark channel contexts as not being in the driver any more to avoid
* removing them from the driver during the shutdown process... * removing them from the driver during the shutdown process...
*/ */
mutex_lock(&local->chanctx_mtx);
list_for_each_entry(ctx, &local->chanctx_list, list) list_for_each_entry(ctx, &local->chanctx_list, list)
ctx->driver_present = false; ctx->driver_present = false;
mutex_unlock(&local->chanctx_mtx);
} }
static void ieee80211_assign_chanctx(struct ieee80211_local *local, static void ieee80211_assign_chanctx(struct ieee80211_local *local,
...@@ -2392,17 +2392,17 @@ static void ieee80211_assign_chanctx(struct ieee80211_local *local, ...@@ -2392,17 +2392,17 @@ static void ieee80211_assign_chanctx(struct ieee80211_local *local,
struct ieee80211_chanctx_conf *conf; struct ieee80211_chanctx_conf *conf;
struct ieee80211_chanctx *ctx; struct ieee80211_chanctx *ctx;
lockdep_assert_wiphy(local->hw.wiphy);
if (!local->use_chanctx) if (!local->use_chanctx)
return; return;
mutex_lock(&local->chanctx_mtx);
conf = rcu_dereference_protected(link->conf->chanctx_conf, conf = rcu_dereference_protected(link->conf->chanctx_conf,
lockdep_is_held(&local->chanctx_mtx)); lockdep_is_held(&local->hw.wiphy->mtx));
if (conf) { if (conf) {
ctx = container_of(conf, struct ieee80211_chanctx, conf); ctx = container_of(conf, struct ieee80211_chanctx, conf);
drv_assign_vif_chanctx(local, sdata, link->conf, ctx); drv_assign_vif_chanctx(local, sdata, link->conf, ctx);
} }
mutex_unlock(&local->chanctx_mtx);
} }
static void ieee80211_reconfig_stations(struct ieee80211_sub_if_data *sdata) static void ieee80211_reconfig_stations(struct ieee80211_sub_if_data *sdata)
...@@ -2410,8 +2410,9 @@ static void ieee80211_reconfig_stations(struct ieee80211_sub_if_data *sdata) ...@@ -2410,8 +2410,9 @@ static void ieee80211_reconfig_stations(struct ieee80211_sub_if_data *sdata)
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
struct sta_info *sta; struct sta_info *sta;
/* add STAs back */
lockdep_assert_wiphy(local->hw.wiphy); lockdep_assert_wiphy(local->hw.wiphy);
/* add STAs back */
list_for_each_entry(sta, &local->sta_list, list) { list_for_each_entry(sta, &local->sta_list, list) {
enum ieee80211_sta_state state; enum ieee80211_sta_state state;
...@@ -2509,6 +2510,8 @@ int ieee80211_reconfig(struct ieee80211_local *local) ...@@ -2509,6 +2510,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
bool suspended = local->suspended; bool suspended = local->suspended;
bool in_reconfig = false; bool in_reconfig = false;
lockdep_assert_wiphy(local->hw.wiphy);
/* nothing to do if HW shouldn't run */ /* nothing to do if HW shouldn't run */
if (!local->open_count) if (!local->open_count)
goto wake_up; goto wake_up;
...@@ -2624,12 +2627,10 @@ int ieee80211_reconfig(struct ieee80211_local *local) ...@@ -2624,12 +2627,10 @@ int ieee80211_reconfig(struct ieee80211_local *local)
/* add channel contexts */ /* add channel contexts */
if (local->use_chanctx) { if (local->use_chanctx) {
mutex_lock(&local->chanctx_mtx);
list_for_each_entry(ctx, &local->chanctx_list, list) list_for_each_entry(ctx, &local->chanctx_list, list)
if (ctx->replace_state != if (ctx->replace_state !=
IEEE80211_CHANCTX_REPLACES_OTHER) IEEE80211_CHANCTX_REPLACES_OTHER)
WARN_ON(drv_add_chanctx(local, ctx)); WARN_ON(drv_add_chanctx(local, ctx));
mutex_unlock(&local->chanctx_mtx);
sdata = wiphy_dereference(local->hw.wiphy, sdata = wiphy_dereference(local->hw.wiphy,
local->monitor_sdata); local->monitor_sdata);
...@@ -2901,8 +2902,6 @@ int ieee80211_reconfig(struct ieee80211_local *local) ...@@ -2901,8 +2902,6 @@ int ieee80211_reconfig(struct ieee80211_local *local)
* are active. This is really a workaround though. * are active. This is really a workaround though.
*/ */
if (ieee80211_hw_check(hw, AMPDU_AGGREGATION)) { if (ieee80211_hw_check(hw, AMPDU_AGGREGATION)) {
lockdep_assert_wiphy(local->hw.wiphy);
list_for_each_entry(sta, &local->sta_list, list) { list_for_each_entry(sta, &local->sta_list, list) {
if (!local->resuming) if (!local->resuming)
ieee80211_sta_tear_down_BA_sessions( ieee80211_sta_tear_down_BA_sessions(
...@@ -3025,10 +3024,10 @@ void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata, ...@@ -3025,10 +3024,10 @@ void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata,
struct ieee80211_chanctx_conf *chanctx_conf; struct ieee80211_chanctx_conf *chanctx_conf;
struct ieee80211_chanctx *chanctx; struct ieee80211_chanctx *chanctx;
mutex_lock(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
chanctx_conf = rcu_dereference_protected(link->conf->chanctx_conf, chanctx_conf = rcu_dereference_protected(link->conf->chanctx_conf,
lockdep_is_held(&local->chanctx_mtx)); lockdep_is_held(&local->hw.wiphy->mtx));
/* /*
* This function can be called from a work, thus it may be possible * This function can be called from a work, thus it may be possible
...@@ -3037,12 +3036,10 @@ void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata, ...@@ -3037,12 +3036,10 @@ void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata,
* So nothing should be done in such case. * So nothing should be done in such case.
*/ */
if (!chanctx_conf) if (!chanctx_conf)
goto unlock; return;
chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, conf); chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, conf);
ieee80211_recalc_smps_chanctx(local, chanctx); ieee80211_recalc_smps_chanctx(local, chanctx);
unlock:
mutex_unlock(&local->chanctx_mtx);
} }
void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata, void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata,
...@@ -3053,7 +3050,7 @@ void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata, ...@@ -3053,7 +3050,7 @@ void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata,
struct ieee80211_chanctx *chanctx; struct ieee80211_chanctx *chanctx;
int i; int i;
mutex_lock(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
for (i = 0; i < ARRAY_SIZE(sdata->vif.link_conf); i++) { for (i = 0; i < ARRAY_SIZE(sdata->vif.link_conf); i++) {
struct ieee80211_bss_conf *bss_conf; struct ieee80211_bss_conf *bss_conf;
...@@ -3069,9 +3066,9 @@ void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata, ...@@ -3069,9 +3066,9 @@ void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata,
} }
chanctx_conf = rcu_dereference_protected(bss_conf->chanctx_conf, chanctx_conf = rcu_dereference_protected(bss_conf->chanctx_conf,
lockdep_is_held(&local->chanctx_mtx)); lockdep_is_held(&local->hw.wiphy->mtx));
/* /*
* Since we hold the chanctx_mtx (checked above) * Since we hold the wiphy mutex (checked above)
* we can take the chanctx_conf pointer out of the * we can take the chanctx_conf pointer out of the
* RCU critical section, it cannot go away without * RCU critical section, it cannot go away without
* the mutex. Just the way we reached it could - in * the mutex. Just the way we reached it could - in
...@@ -3081,14 +3078,12 @@ void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata, ...@@ -3081,14 +3078,12 @@ void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata,
rcu_read_unlock(); rcu_read_unlock();
if (!chanctx_conf) if (!chanctx_conf)
goto unlock; return;
chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, chanctx = container_of(chanctx_conf, struct ieee80211_chanctx,
conf); conf);
ieee80211_recalc_chanctx_min_def(local, chanctx, NULL); ieee80211_recalc_chanctx_min_def(local, chanctx, NULL);
} }
unlock:
mutex_unlock(&local->chanctx_mtx);
} }
size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset) size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset)
...@@ -4364,7 +4359,7 @@ void ieee80211_dfs_radar_detected_work(struct wiphy *wiphy, ...@@ -4364,7 +4359,7 @@ void ieee80211_dfs_radar_detected_work(struct wiphy *wiphy,
struct ieee80211_chanctx *ctx; struct ieee80211_chanctx *ctx;
int num_chanctx = 0; int num_chanctx = 0;
mutex_lock(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
list_for_each_entry(ctx, &local->chanctx_list, list) { list_for_each_entry(ctx, &local->chanctx_list, list) {
if (ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER) if (ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER)
continue; continue;
...@@ -4372,7 +4367,6 @@ void ieee80211_dfs_radar_detected_work(struct wiphy *wiphy, ...@@ -4372,7 +4367,6 @@ void ieee80211_dfs_radar_detected_work(struct wiphy *wiphy,
num_chanctx++; num_chanctx++;
chandef = ctx->conf.def; chandef = ctx->conf.def;
} }
mutex_unlock(&local->chanctx_mtx);
ieee80211_dfs_cac_cancel(local); ieee80211_dfs_cac_cancel(local);
...@@ -4773,7 +4767,7 @@ static u8 ieee80211_chanctx_radar_detect(struct ieee80211_local *local, ...@@ -4773,7 +4767,7 @@ static u8 ieee80211_chanctx_radar_detect(struct ieee80211_local *local,
struct ieee80211_link_data *link; struct ieee80211_link_data *link;
u8 radar_detect = 0; u8 radar_detect = 0;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
if (WARN_ON(ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED)) if (WARN_ON(ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED))
return 0; return 0;
...@@ -4814,7 +4808,7 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, ...@@ -4814,7 +4808,7 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
.radar_detect = radar_detect, .radar_detect = radar_detect,
}; };
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
if (WARN_ON(hweight32(radar_detect) > 1)) if (WARN_ON(hweight32(radar_detect) > 1))
return -EINVAL; return -EINVAL;
...@@ -4904,7 +4898,7 @@ int ieee80211_max_num_channels(struct ieee80211_local *local) ...@@ -4904,7 +4898,7 @@ int ieee80211_max_num_channels(struct ieee80211_local *local)
int err; int err;
struct iface_combination_params params = {0}; struct iface_combination_params params = {0};
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_wiphy(local->hw.wiphy);
list_for_each_entry(ctx, &local->chanctx_list, list) { list_for_each_entry(ctx, &local->chanctx_list, list) {
if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED) if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment