* [RFC] iwlwifi: fix scan abort
@ 2010-07-28 13:45 Stanislaw Gruszka
2010-07-28 14:34 ` Guy, Wey-Yi
0 siblings, 1 reply; 2+ messages in thread
From: Stanislaw Gruszka @ 2010-07-28 13:45 UTC (permalink / raw)
To: Wey-Yi Guy, Reinette Chatre, John W. Linville; +Cc: linux-wireless
We can not call cancel_delayed_work_sync(&priv->scan_check) with
priv->mutex locked because workqueue function iwl_bg_scan_check()
take that lock internally.
We do not need to synchronize when canceling priv->scan_check work.
We can avoid races (sending double abort command or send no
command at all) using STATUS_SCAN_ABORT bit. Moreover
current iwl_bg_scan_check() code seems to be broken, as
we should not send abort commands when currently aborting.
I did not test patch yet, just want to know if it is theoretically
correct. Except obvious circular priv->mutex locking fix, maybe it
can help with warning in ieee80211_scan_completed, which is still
reported by the users from time to time.
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 2a7c399..b0c6b04 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -429,11 +429,10 @@ void iwl_bg_scan_check(struct work_struct *data)
return;
mutex_lock(&priv->mutex);
- if (test_bit(STATUS_SCANNING, &priv->status) ||
- test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
- IWL_DEBUG_SCAN(priv, "Scan completion watchdog resetting "
- "adapter (%dms)\n",
- jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG));
+ if (test_bit(STATUS_SCANNING, &priv->status) &&
+ !test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
+ IWL_DEBUG_SCAN(priv, "Scan completion watchdog (%dms)\n",
+ jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG));
if (!test_bit(STATUS_EXIT_PENDING, &priv->status))
iwl_send_scan_abort(priv);
@@ -498,12 +497,11 @@ void iwl_bg_abort_scan(struct work_struct *work)
!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
return;
- mutex_lock(&priv->mutex);
-
- cancel_delayed_work_sync(&priv->scan_check);
- set_bit(STATUS_SCAN_ABORTING, &priv->status);
- iwl_send_scan_abort(priv);
+ cancel_delayed_work(&priv->scan_check);
+ mutex_lock(&priv->mutex);
+ if (test_bit(STATUS_SCAN_ABORTING, &priv->status))
+ iwl_send_scan_abort(priv);
mutex_unlock(&priv->mutex);
}
EXPORT_SYMBOL(iwl_bg_abort_scan);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [RFC] iwlwifi: fix scan abort
2010-07-28 13:45 [RFC] iwlwifi: fix scan abort Stanislaw Gruszka
@ 2010-07-28 14:34 ` Guy, Wey-Yi
0 siblings, 0 replies; 2+ messages in thread
From: Guy, Wey-Yi @ 2010-07-28 14:34 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Chatre, Reinette, John W. Linville, linux-wireless
Hi Gruszka,
On Wed, 2010-07-28 at 06:45 -0700, Stanislaw Gruszka wrote:
> We can not call cancel_delayed_work_sync(&priv->scan_check) with
> priv->mutex locked because workqueue function iwl_bg_scan_check()
> take that lock internally.
>
> We do not need to synchronize when canceling priv->scan_check work.
> We can avoid races (sending double abort command or send no
> command at all) using STATUS_SCAN_ABORT bit. Moreover
> current iwl_bg_scan_check() code seems to be broken, as
> we should not send abort commands when currently aborting.
>
> I did not test patch yet, just want to know if it is theoretically
> correct. Except obvious circular priv->mutex locking fix, maybe it
> can help with warning in ieee80211_scan_completed, which is still
> reported by the users from time to time.
>
> diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
> index 2a7c399..b0c6b04 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-scan.c
> +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
> @@ -429,11 +429,10 @@ void iwl_bg_scan_check(struct work_struct *data)
> return;
>
> mutex_lock(&priv->mutex);
> - if (test_bit(STATUS_SCANNING, &priv->status) ||
> - test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
> - IWL_DEBUG_SCAN(priv, "Scan completion watchdog resetting "
> - "adapter (%dms)\n",
> - jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG));
> + if (test_bit(STATUS_SCANNING, &priv->status) &&
> + !test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
> + IWL_DEBUG_SCAN(priv, "Scan completion watchdog (%dms)\n",
> + jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG));
make sense here, the code is broken, we should not abort scan if already
doing it.
>
> if (!test_bit(STATUS_EXIT_PENDING, &priv->status))
> iwl_send_scan_abort(priv);
> @@ -498,12 +497,11 @@ void iwl_bg_abort_scan(struct work_struct *work)
> !test_bit(STATUS_GEO_CONFIGURED, &priv->status))
> return;
>
> - mutex_lock(&priv->mutex);
> -
> - cancel_delayed_work_sync(&priv->scan_check);
> - set_bit(STATUS_SCAN_ABORTING, &priv->status);
> - iwl_send_scan_abort(priv);
> + cancel_delayed_work(&priv->scan_check);
>
> + mutex_lock(&priv->mutex);
> + if (test_bit(STATUS_SCAN_ABORTING, &priv->status))
> + iwl_send_scan_abort(priv);
> mutex_unlock(&priv->mutex);
> }
Looks right to me, thanks a lot to catch this one.
Wey
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-28 14:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-28 13:45 [RFC] iwlwifi: fix scan abort Stanislaw Gruszka
2010-07-28 14:34 ` Guy, Wey-Yi
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).