Commit 404bbb3c authored by Lior David's avatar Lior David Committed by Kalle Valo

wil6210: rename p2p_wdev_mutex to vif_mutex

As more support is added for multiple VIFs, there is a need
to protect the wil6210_vif structure from access while it is
deleted (mainly from del_virtual_intf operation).
Instead of adding another mutex, use p2p_wdev_mutex and rename
it to vif_mutex to reflect the added role. Its existing roles
are similar so it extends nicely (for example it protects the
scan_request member which is also a member of wil6210_vif).
Signed-off-by: default avatarLior David <liord@codeaurora.org>
Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 3ada9314
...@@ -412,10 +412,10 @@ static void wil_cfg80211_stop_p2p_device(struct wiphy *wiphy, ...@@ -412,10 +412,10 @@ static void wil_cfg80211_stop_p2p_device(struct wiphy *wiphy,
wil_dbg_misc(wil, "stop_p2p_device: entered\n"); wil_dbg_misc(wil, "stop_p2p_device: entered\n");
mutex_lock(&wil->mutex); mutex_lock(&wil->mutex);
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
wil_p2p_stop_radio_operations(wil); wil_p2p_stop_radio_operations(wil);
wil->p2p_dev_started = 0; wil->p2p_dev_started = 0;
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
mutex_unlock(&wil->mutex); mutex_unlock(&wil->mutex);
} }
...@@ -706,14 +706,14 @@ static int wil_cfg80211_scan(struct wiphy *wiphy, ...@@ -706,14 +706,14 @@ static int wil_cfg80211_scan(struct wiphy *wiphy,
mutex_lock(&wil->mutex); mutex_lock(&wil->mutex);
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
if (vif->scan_request || vif->p2p.discovery_started) { if (vif->scan_request || vif->p2p.discovery_started) {
wil_err(wil, "Already scanning\n"); wil_err(wil, "Already scanning\n");
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
rc = -EAGAIN; rc = -EAGAIN;
goto out; goto out;
} }
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
if (wdev->iftype == NL80211_IFTYPE_P2P_DEVICE) { if (wdev->iftype == NL80211_IFTYPE_P2P_DEVICE) {
if (!wil->p2p_dev_started) { if (!wil->p2p_dev_started) {
...@@ -825,7 +825,7 @@ static void wil_cfg80211_abort_scan(struct wiphy *wiphy, ...@@ -825,7 +825,7 @@ static void wil_cfg80211_abort_scan(struct wiphy *wiphy,
wil_dbg_misc(wil, "wdev=0x%p iftype=%d\n", wdev, wdev->iftype); wil_dbg_misc(wil, "wdev=0x%p iftype=%d\n", wdev, wdev->iftype);
mutex_lock(&wil->mutex); mutex_lock(&wil->mutex);
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
if (!vif->scan_request) if (!vif->scan_request)
goto out; goto out;
...@@ -841,7 +841,7 @@ static void wil_cfg80211_abort_scan(struct wiphy *wiphy, ...@@ -841,7 +841,7 @@ static void wil_cfg80211_abort_scan(struct wiphy *wiphy,
wil_abort_scan(vif, true); wil_abort_scan(vif, true);
out: out:
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
mutex_unlock(&wil->mutex); mutex_unlock(&wil->mutex);
} }
...@@ -1944,10 +1944,10 @@ static int wil_cfg80211_suspend(struct wiphy *wiphy, ...@@ -1944,10 +1944,10 @@ static int wil_cfg80211_suspend(struct wiphy *wiphy,
wil_dbg_pm(wil, "suspending\n"); wil_dbg_pm(wil, "suspending\n");
mutex_lock(&wil->mutex); mutex_lock(&wil->mutex);
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
wil_p2p_stop_radio_operations(wil); wil_p2p_stop_radio_operations(wil);
wil_abort_scan(ndev_to_vif(wil->main_ndev), true); wil_abort_scan(ndev_to_vif(wil->main_ndev), true);
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
mutex_unlock(&wil->mutex); mutex_unlock(&wil->mutex);
out: out:
...@@ -2236,11 +2236,11 @@ void wil_p2p_wdev_free(struct wil6210_priv *wil) ...@@ -2236,11 +2236,11 @@ void wil_p2p_wdev_free(struct wil6210_priv *wil)
struct wireless_dev *p2p_wdev; struct wireless_dev *p2p_wdev;
struct wil6210_vif *vif; struct wil6210_vif *vif;
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
p2p_wdev = wil->p2p_wdev; p2p_wdev = wil->p2p_wdev;
wil->p2p_wdev = NULL; wil->p2p_wdev = NULL;
wil->radio_wdev = wil->main_ndev->ieee80211_ptr; wil->radio_wdev = wil->main_ndev->ieee80211_ptr;
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
if (p2p_wdev) { if (p2p_wdev) {
cfg80211_unregister_wdev(p2p_wdev); cfg80211_unregister_wdev(p2p_wdev);
vif = wdev_to_vif(wil, p2p_wdev); vif = wdev_to_vif(wil, p2p_wdev);
......
...@@ -536,8 +536,8 @@ int wil_priv_init(struct wil6210_priv *wil) ...@@ -536,8 +536,8 @@ int wil_priv_init(struct wil6210_priv *wil)
spin_lock_init(&wil->vring_tx_data[i].lock); spin_lock_init(&wil->vring_tx_data[i].lock);
mutex_init(&wil->mutex); mutex_init(&wil->mutex);
mutex_init(&wil->vif_mutex);
mutex_init(&wil->wmi_mutex); mutex_init(&wil->wmi_mutex);
mutex_init(&wil->p2p_wdev_mutex);
mutex_init(&wil->halp.lock); mutex_init(&wil->halp.lock);
init_completion(&wil->wmi_ready); init_completion(&wil->wmi_ready);
...@@ -1066,21 +1066,21 @@ void wil_abort_scan(struct wil6210_vif *vif, bool sync) ...@@ -1066,21 +1066,21 @@ void wil_abort_scan(struct wil6210_vif *vif, bool sync)
.aborted = true, .aborted = true,
}; };
lockdep_assert_held(&wil->p2p_wdev_mutex); lockdep_assert_held(&wil->vif_mutex);
if (!vif->scan_request) if (!vif->scan_request)
return; return;
wil_dbg_misc(wil, "Abort scan_request 0x%p\n", vif->scan_request); wil_dbg_misc(wil, "Abort scan_request 0x%p\n", vif->scan_request);
del_timer_sync(&vif->scan_timer); del_timer_sync(&vif->scan_timer);
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
rc = wmi_abort_scan(vif); rc = wmi_abort_scan(vif);
if (!rc && sync) if (!rc && sync)
wait_event_interruptible_timeout(wil->wq, !vif->scan_request, wait_event_interruptible_timeout(wil->wq, !vif->scan_request,
msecs_to_jiffies( msecs_to_jiffies(
WAIT_FOR_SCAN_ABORT_MS)); WAIT_FOR_SCAN_ABORT_MS));
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
if (vif->scan_request) { if (vif->scan_request) {
cfg80211_scan_done(vif->scan_request, &info); cfg80211_scan_done(vif->scan_request, &info);
vif->scan_request = NULL; vif->scan_request = NULL;
...@@ -1221,9 +1221,9 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw) ...@@ -1221,9 +1221,9 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
/* Disable device led before reset*/ /* Disable device led before reset*/
wmi_led_cfg(wil, false); wmi_led_cfg(wil, false);
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
wil_abort_scan(vif, false); wil_abort_scan(vif, false);
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
/* prevent NAPI from being scheduled and prevent wmi commands */ /* prevent NAPI from being scheduled and prevent wmi commands */
mutex_lock(&wil->wmi_mutex); mutex_lock(&wil->wmi_mutex);
...@@ -1444,10 +1444,10 @@ int __wil_down(struct wil6210_priv *wil) ...@@ -1444,10 +1444,10 @@ int __wil_down(struct wil6210_priv *wil)
} }
wil_enable_irq(wil); wil_enable_irq(wil);
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
wil_p2p_stop_radio_operations(wil); wil_p2p_stop_radio_operations(wil);
wil_abort_scan(ndev_to_vif(wil->main_ndev), false); wil_abort_scan(ndev_to_vif(wil->main_ndev), false);
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
return wil_reset(wil, false); return wil_reset(wil, false);
} }
......
...@@ -158,16 +158,16 @@ int wil_p2p_listen(struct wil6210_priv *wil, struct wireless_dev *wdev, ...@@ -158,16 +158,16 @@ int wil_p2p_listen(struct wil6210_priv *wil, struct wireless_dev *wdev,
*cookie = ++p2p->cookie; *cookie = ++p2p->cookie;
p2p->listen_duration = duration; p2p->listen_duration = duration;
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
if (vif->scan_request) { if (vif->scan_request) {
wil_dbg_misc(wil, "Delaying p2p listen until scan done\n"); wil_dbg_misc(wil, "Delaying p2p listen until scan done\n");
p2p->pending_listen_wdev = wdev; p2p->pending_listen_wdev = wdev;
p2p->discovery_started = 1; p2p->discovery_started = 1;
rc = 0; rc = 0;
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
goto out; goto out;
} }
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
rc = wil_p2p_start_listen(vif); rc = wil_p2p_start_listen(vif);
if (rc) if (rc)
...@@ -228,14 +228,14 @@ int wil_p2p_cancel_listen(struct wil6210_vif *vif, u64 cookie) ...@@ -228,14 +228,14 @@ int wil_p2p_cancel_listen(struct wil6210_vif *vif, u64 cookie)
return -ENOENT; return -ENOENT;
} }
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
cfg80211_remain_on_channel_expired(vif_to_radio_wdev(wil, vif), cfg80211_remain_on_channel_expired(vif_to_radio_wdev(wil, vif),
p2p->cookie, p2p->cookie,
&p2p->listen_chan, &p2p->listen_chan,
GFP_KERNEL); GFP_KERNEL);
if (vif->mid == 0) if (vif->mid == 0)
wil->radio_wdev = wil->main_ndev->ieee80211_ptr; wil->radio_wdev = wil->main_ndev->ieee80211_ptr;
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
return 0; return 0;
} }
...@@ -257,14 +257,14 @@ void wil_p2p_listen_expired(struct work_struct *work) ...@@ -257,14 +257,14 @@ void wil_p2p_listen_expired(struct work_struct *work)
if (!started) if (!started)
return; return;
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
cfg80211_remain_on_channel_expired(vif_to_radio_wdev(wil, vif), cfg80211_remain_on_channel_expired(vif_to_radio_wdev(wil, vif),
p2p->cookie, p2p->cookie,
&p2p->listen_chan, &p2p->listen_chan,
GFP_KERNEL); GFP_KERNEL);
if (vif->mid == 0) if (vif->mid == 0)
wil->radio_wdev = wil->main_ndev->ieee80211_ptr; wil->radio_wdev = wil->main_ndev->ieee80211_ptr;
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
} }
void wil_p2p_search_expired(struct work_struct *work) void wil_p2p_search_expired(struct work_struct *work)
...@@ -287,7 +287,7 @@ void wil_p2p_search_expired(struct work_struct *work) ...@@ -287,7 +287,7 @@ void wil_p2p_search_expired(struct work_struct *work)
.aborted = false, .aborted = false,
}; };
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
if (vif->scan_request) { if (vif->scan_request) {
cfg80211_scan_done(vif->scan_request, &info); cfg80211_scan_done(vif->scan_request, &info);
vif->scan_request = NULL; vif->scan_request = NULL;
...@@ -295,7 +295,7 @@ void wil_p2p_search_expired(struct work_struct *work) ...@@ -295,7 +295,7 @@ void wil_p2p_search_expired(struct work_struct *work)
wil->radio_wdev = wil->radio_wdev =
wil->main_ndev->ieee80211_ptr; wil->main_ndev->ieee80211_ptr;
} }
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
} }
} }
...@@ -314,17 +314,17 @@ void wil_p2p_delayed_listen_work(struct work_struct *work) ...@@ -314,17 +314,17 @@ void wil_p2p_delayed_listen_work(struct work_struct *work)
if (!p2p->discovery_started || !p2p->pending_listen_wdev) if (!p2p->discovery_started || !p2p->pending_listen_wdev)
goto out; goto out;
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
if (vif->scan_request) { if (vif->scan_request) {
/* another scan started, wait again... */ /* another scan started, wait again... */
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
goto out; goto out;
} }
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
rc = wil_p2p_start_listen(vif); rc = wil_p2p_start_listen(vif);
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
if (rc) { if (rc) {
cfg80211_remain_on_channel_expired(p2p->pending_listen_wdev, cfg80211_remain_on_channel_expired(p2p->pending_listen_wdev,
p2p->cookie, p2p->cookie,
...@@ -340,7 +340,7 @@ void wil_p2p_delayed_listen_work(struct work_struct *work) ...@@ -340,7 +340,7 @@ void wil_p2p_delayed_listen_work(struct work_struct *work)
wil->radio_wdev = p2p->pending_listen_wdev; wil->radio_wdev = p2p->pending_listen_wdev;
} }
p2p->pending_listen_wdev = NULL; p2p->pending_listen_wdev = NULL;
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
out: out:
mutex_unlock(&wil->mutex); mutex_unlock(&wil->mutex);
...@@ -355,7 +355,7 @@ void wil_p2p_stop_radio_operations(struct wil6210_priv *wil) ...@@ -355,7 +355,7 @@ void wil_p2p_stop_radio_operations(struct wil6210_priv *wil)
}; };
lockdep_assert_held(&wil->mutex); lockdep_assert_held(&wil->mutex);
lockdep_assert_held(&wil->p2p_wdev_mutex); lockdep_assert_held(&wil->vif_mutex);
if (wil->radio_wdev != wil->p2p_wdev) if (wil->radio_wdev != wil->p2p_wdev)
goto out; goto out;
...@@ -369,9 +369,9 @@ void wil_p2p_stop_radio_operations(struct wil6210_priv *wil) ...@@ -369,9 +369,9 @@ void wil_p2p_stop_radio_operations(struct wil6210_priv *wil)
} }
/* Search or listen on p2p device */ /* Search or listen on p2p device */
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
wil_p2p_stop_discovery(vif); wil_p2p_stop_discovery(vif);
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
if (vif->scan_request) { if (vif->scan_request) {
/* search */ /* search */
......
...@@ -725,6 +725,7 @@ struct wil6210_priv { ...@@ -725,6 +725,7 @@ struct wil6210_priv {
wait_queue_head_t wq; /* for all wait_event() use */ wait_queue_head_t wq; /* for all wait_event() use */
u8 max_vifs; /* maximum number of interfaces, including main */ u8 max_vifs; /* maximum number of interfaces, including main */
struct wil6210_vif *vifs[WIL_MAX_VIFS]; struct wil6210_vif *vifs[WIL_MAX_VIFS];
struct mutex vif_mutex; /* protects access to VIF entries */
/* profile */ /* profile */
struct cfg80211_chan_def monitor_chandef; struct cfg80211_chan_def monitor_chandef;
u32 monitor_flags; u32 monitor_flags;
...@@ -793,7 +794,6 @@ struct wil6210_priv { ...@@ -793,7 +794,6 @@ struct wil6210_priv {
/* P2P_DEVICE vif */ /* P2P_DEVICE vif */
struct wireless_dev *p2p_wdev; struct wireless_dev *p2p_wdev;
struct mutex p2p_wdev_mutex; /* protect @p2p_wdev and @scan_request */
struct wireless_dev *radio_wdev; struct wireless_dev *radio_wdev;
/* High Access Latency Policy voting */ /* High Access Latency Policy voting */
......
...@@ -766,10 +766,10 @@ static void wmi_evt_rx_mgmt(struct wil6210_vif *vif, int id, void *d, int len) ...@@ -766,10 +766,10 @@ static void wmi_evt_rx_mgmt(struct wil6210_vif *vif, int id, void *d, int len)
wil_err(wil, "cfg80211_inform_bss_frame() failed\n"); wil_err(wil, "cfg80211_inform_bss_frame() failed\n");
} }
} else { } else {
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
cfg80211_rx_mgmt(vif_to_radio_wdev(wil, vif), freq, signal, cfg80211_rx_mgmt(vif_to_radio_wdev(wil, vif), freq, signal,
(void *)rx_mgmt_frame, d_len, 0); (void *)rx_mgmt_frame, d_len, 0);
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
} }
} }
...@@ -789,7 +789,7 @@ static void wmi_evt_scan_complete(struct wil6210_vif *vif, int id, ...@@ -789,7 +789,7 @@ static void wmi_evt_scan_complete(struct wil6210_vif *vif, int id,
{ {
struct wil6210_priv *wil = vif_to_wil(vif); struct wil6210_priv *wil = vif_to_wil(vif);
mutex_lock(&wil->p2p_wdev_mutex); mutex_lock(&wil->vif_mutex);
if (vif->scan_request) { if (vif->scan_request) {
struct wmi_scan_complete_event *data = d; struct wmi_scan_complete_event *data = d;
int status = le32_to_cpu(data->status); int status = le32_to_cpu(data->status);
...@@ -814,7 +814,7 @@ static void wmi_evt_scan_complete(struct wil6210_vif *vif, int id, ...@@ -814,7 +814,7 @@ static void wmi_evt_scan_complete(struct wil6210_vif *vif, int id,
} else { } else {
wil_err(wil, "SCAN_COMPLETE while not scanning\n"); wil_err(wil, "SCAN_COMPLETE while not scanning\n");
} }
mutex_unlock(&wil->p2p_wdev_mutex); mutex_unlock(&wil->vif_mutex);
} }
static void wmi_evt_connect(struct wil6210_vif *vif, int id, void *d, int len) static void wmi_evt_connect(struct wil6210_vif *vif, int id, void *d, int len)
......
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