aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-scan.c
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2010-09-13 08:46:41 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-09-14 16:14:25 -0400
commite7e16b90b477a07d17af37dceb2e8af1ddbd9712 (patch)
treec7f58d181d8a0a06718d2e28c9e88c4653204a24 /drivers/net/wireless/iwlwifi/iwl-scan.c
parent6bd1758d978f917dc0804f44e3528ef1a80d9d43 (diff)
iwlwifi: do not force complete scan too early
Currently we force scan complete at the end of iwl_scan_cancel_timeout function. This cause race condition when we can get a new scan request from mac80211 and complete it by iwl_bg_complete from older scan. Change code to force scan complete only when really needed: device goes down, interface is removed or scan timeout occurs. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Acked-by: Wey-Yi W Guy <wey-yi.w.guy@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-scan.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index da037b2f08b4..af9a83669f5e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -106,14 +106,22 @@ static void iwl_complete_scan(struct iwl_priv *priv, bool aborted)
106 priv->scan_request = NULL; 106 priv->scan_request = NULL;
107} 107}
108 108
109static void iwl_force_scan_end(struct iwl_priv *priv) 109void iwl_force_scan_end(struct iwl_priv *priv)
110{ 110{
111 lockdep_assert_held(&priv->mutex);
112
113 if (!test_bit(STATUS_SCANNING, &priv->status)) {
114 IWL_DEBUG_SCAN(priv, "Forcing scan end while not scanning\n");
115 return;
116 }
117
111 IWL_DEBUG_SCAN(priv, "Forcing scan end\n"); 118 IWL_DEBUG_SCAN(priv, "Forcing scan end\n");
112 clear_bit(STATUS_SCANNING, &priv->status); 119 clear_bit(STATUS_SCANNING, &priv->status);
113 clear_bit(STATUS_SCAN_HW, &priv->status); 120 clear_bit(STATUS_SCAN_HW, &priv->status);
114 clear_bit(STATUS_SCAN_ABORTING, &priv->status); 121 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
115 iwl_complete_scan(priv, true); 122 iwl_complete_scan(priv, true);
116} 123}
124EXPORT_SYMBOL(iwl_force_scan_end);
117 125
118static void iwl_do_scan_abort(struct iwl_priv *priv) 126static void iwl_do_scan_abort(struct iwl_priv *priv)
119{ 127{
@@ -157,7 +165,6 @@ EXPORT_SYMBOL(iwl_scan_cancel);
157 */ 165 */
158int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) 166int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms)
159{ 167{
160 int ret;
161 unsigned long timeout = jiffies + msecs_to_jiffies(ms); 168 unsigned long timeout = jiffies + msecs_to_jiffies(ms);
162 169
163 lockdep_assert_held(&priv->mutex); 170 lockdep_assert_held(&priv->mutex);
@@ -172,10 +179,7 @@ int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms)
172 msleep(20); 179 msleep(20);
173 } 180 }
174 181
175 ret = test_bit(STATUS_SCAN_HW, &priv->status); 182 return test_bit(STATUS_SCAN_HW, &priv->status);
176 if (ret)
177 iwl_force_scan_end(priv);
178 return ret;
179} 183}
180EXPORT_SYMBOL(iwl_scan_cancel_timeout); 184EXPORT_SYMBOL(iwl_scan_cancel_timeout);
181 185
@@ -490,8 +494,11 @@ static void iwl_bg_scan_check(struct work_struct *data)
490 struct iwl_priv *priv = 494 struct iwl_priv *priv =
491 container_of(data, struct iwl_priv, scan_check.work); 495 container_of(data, struct iwl_priv, scan_check.work);
492 496
497 /* Since we are here firmware does not finish scan and
498 * most likely is in bad shape, so we don't bother to
499 * send abort command, just force scan complete to mac80211 */
493 mutex_lock(&priv->mutex); 500 mutex_lock(&priv->mutex);
494 iwl_scan_cancel_timeout(priv, 200); 501 iwl_force_scan_end(priv);
495 mutex_unlock(&priv->mutex); 502 mutex_unlock(&priv->mutex);
496} 503}
497 504
@@ -547,8 +554,8 @@ static void iwl_bg_abort_scan(struct work_struct *work)
547{ 554{
548 struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); 555 struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan);
549 556
550 cancel_delayed_work(&priv->scan_check); 557 /* We keep scan_check work queued in case when firmware will not
551 558 * report back scan completed notification */
552 mutex_lock(&priv->mutex); 559 mutex_lock(&priv->mutex);
553 iwl_scan_cancel_timeout(priv, 200); 560 iwl_scan_cancel_timeout(priv, 200);
554 mutex_unlock(&priv->mutex); 561 mutex_unlock(&priv->mutex);
@@ -631,3 +638,16 @@ void iwl_setup_scan_deferred_work(struct iwl_priv *priv)
631} 638}
632EXPORT_SYMBOL(iwl_setup_scan_deferred_work); 639EXPORT_SYMBOL(iwl_setup_scan_deferred_work);
633 640
641void iwl_cancel_scan_deferred_work(struct iwl_priv *priv)
642{
643 cancel_work_sync(&priv->start_internal_scan);
644 cancel_work_sync(&priv->abort_scan);
645 cancel_work_sync(&priv->scan_completed);
646
647 if (cancel_delayed_work_sync(&priv->scan_check)) {
648 mutex_lock(&priv->mutex);
649 iwl_force_scan_end(priv);
650 mutex_unlock(&priv->mutex);
651 }
652}
653EXPORT_SYMBOL(iwl_cancel_scan_deferred_work);