From: Luca Coelho <luca@coelho.fi>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH 8/9] mac80211: disentangle iflist_mtx and chanctx_mtx
Date: Wed, 26 Apr 2017 10:58:53 +0300 [thread overview]
Message-ID: <20170426075854.13546-9-luca@coelho.fi> (raw)
In-Reply-To: <20170426075854.13546-1-luca@coelho.fi>
From: Johannes Berg <johannes.berg@intel.com>
At least on iwlwifi, sometimes lockdep complains that we can
lock
chanctx_mtx -> mvm.mutex -> iflist_mtx
(due to iterate_interfaces)
and
iflist_mtx -> chanctx_mtx
Remove the latter dependency in mac80211 by using the RTNL
that we already hold in one case, and can relatively easily
achieve in the other case.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/cfg.c | 6 +-----
net/mac80211/main.c | 2 ++
net/mac80211/util.c | 9 ++++++---
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index d041f78ecee6..bdcb82c2ab74 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -739,11 +739,8 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
return 0;
mutex_lock(&local->mtx);
- mutex_lock(&local->iflist_mtx);
if (local->use_chanctx) {
- sdata = rcu_dereference_protected(
- local->monitor_sdata,
- lockdep_is_held(&local->iflist_mtx));
+ sdata = rtnl_dereference(local->monitor_sdata);
if (sdata) {
ieee80211_vif_release_channel(sdata);
ret = ieee80211_vif_use_channel(sdata, chandef,
@@ -756,7 +753,6 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
if (ret == 0)
local->monitor_chandef = *chandef;
- mutex_unlock(&local->iflist_mtx);
mutex_unlock(&local->mtx);
return ret;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index ae408a96c407..8aa1f5b6a051 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -253,6 +253,7 @@ static void ieee80211_restart_work(struct work_struct *work)
WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
"%s called with hardware scan in progress\n", __func__);
+ flush_work(&local->radar_detected_work);
rtnl_lock();
list_for_each_entry(sdata, &local->interfaces, list)
flush_delayed_work(&sdata->dec_tailroom_needed_wk);
@@ -1187,6 +1188,7 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
cancel_work_sync(&local->reconfig_filter);
cancel_work_sync(&local->tdls_chsw_work);
flush_work(&local->sched_scan_stopped_work);
+ flush_work(&local->radar_detected_work);
ieee80211_clear_tx_pending(local);
rate_control_deinitialize(local);
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 1b8e54444c36..27a27070a751 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2800,8 +2800,10 @@ void ieee80211_dfs_cac_cancel(struct ieee80211_local *local)
struct ieee80211_sub_if_data *sdata;
struct cfg80211_chan_def chandef;
+ /* for interface list, to avoid linking iflist_mtx and chanctx_mtx */
+ ASSERT_RTNL();
+
mutex_lock(&local->mtx);
- mutex_lock(&local->iflist_mtx);
list_for_each_entry(sdata, &local->interfaces, list) {
/* it might be waiting for the local->mtx, but then
* by the time it gets it, sdata->wdev.cac_started
@@ -2818,7 +2820,6 @@ void ieee80211_dfs_cac_cancel(struct ieee80211_local *local)
GFP_KERNEL);
}
}
- mutex_unlock(&local->iflist_mtx);
mutex_unlock(&local->mtx);
}
@@ -2840,7 +2841,9 @@ void ieee80211_dfs_radar_detected_work(struct work_struct *work)
}
mutex_unlock(&local->chanctx_mtx);
+ rtnl_lock();
ieee80211_dfs_cac_cancel(local);
+ rtnl_unlock();
if (num_chanctx > 1)
/* XXX: multi-channel is not supported yet */
@@ -2855,7 +2858,7 @@ void ieee80211_radar_detected(struct ieee80211_hw *hw)
trace_api_radar_detected(local);
- ieee80211_queue_work(hw, &local->radar_detected_work);
+ schedule_work(&local->radar_detected_work);
}
EXPORT_SYMBOL(ieee80211_radar_detected);
--
2.11.0
next prev parent reply other threads:[~2017-04-26 7:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-26 7:58 [PATCH 0/9] cfg80211/mac80211 patches from our internal tree 2017-04-26 Luca Coelho
2017-04-26 7:58 ` [PATCH 1/9] ieee80211: add SUITE_B AKM selectors Luca Coelho
2017-04-26 7:58 ` [PATCH 2/9] mac80211: Add support for BSS max idle period element Luca Coelho
2017-04-28 9:26 ` Johannes Berg
2017-04-26 7:58 ` [PATCH 3/9] ieee80211: add FT-802.1X AKM suite selector Luca Coelho
2017-04-26 7:58 ` [PATCH 4/9] cfg80211: unify cfg80211_roamed() and cfg80211_roamed_bss() Luca Coelho
2017-04-26 8:54 ` Arend van Spriel
2017-04-28 9:25 ` Johannes Berg
2017-04-26 7:58 ` [PATCH 5/9] cfg80211/nl80211: add authorized flag to roaming event Luca Coelho
2017-04-26 10:05 ` Arend van Spriel
2017-04-26 18:44 ` Arend Van Spriel
2017-04-28 21:02 ` Johannes Berg
2017-05-01 9:40 ` Arend van Spriel
2017-05-02 6:59 ` Johannes Berg
2017-04-26 7:58 ` [PATCH 6/9] mac80211: don't parse encrypted management frames in ieee80211_frame_acked Luca Coelho
2017-04-26 7:58 ` [PATCH 7/9] ieee80211: fix kernel-doc parsing errors Luca Coelho
2017-04-26 7:58 ` Luca Coelho [this message]
2017-04-26 7:58 ` [PATCH 9/9] mac80211: make multicast variable a bool in ieee80211_accept_frame() Luca Coelho
2017-04-26 8:08 ` [PATCH 0/9] cfg80211/mac80211 patches from our internal tree 2017-04-26 Johannes Berg
2017-04-26 8:11 ` Luca Coelho
2017-04-26 8:28 ` Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170426075854.13546-9-luca@coelho.fi \
--to=luca@coelho.fi \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).