aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEliad Peller <eliad@wizery.com>2011-05-13 04:57:11 -0400
committerLuciano Coelho <coelho@ti.com>2011-05-13 07:55:49 -0400
commitf44e58681aec420b132a54823d8911293a644d4e (patch)
tree4c7c26b6fa3e7401036b4c897761b4ca0816f1e9
parent039bdb1494d1d514987ce596a4898494021c7af2 (diff)
wl12xx: prevent scheduling while suspending (WoW enabled)
When WoW is enabled, the interface will stay up and the chip will be powered on, so we have to flush/cancel any remaining work, and prevent the irq handler from scheduling a new work until the system is resumed. Add 2 new flags: * WL1271_FLAG_SUSPENDED - the system is (about to be) suspended. * WL1271_FLAG_PENDING_WORK - there is a pending irq work which should be scheduled when the system is being resumed. In order to wake-up the system while getting an irq, we initialize the device as wakeup device, and calling pm_wakeup_event() upon getting the interrupt (while the system is about to be suspended) Signed-off-by: Eliad Peller <eliad@wizery.com> Signed-off-by: Luciano Coelho <coelho@ti.com>
-rw-r--r--drivers/net/wireless/wl12xx/main.c46
-rw-r--r--drivers/net/wireless/wl12xx/sdio.c24
-rw-r--r--drivers/net/wireless/wl12xx/wl12xx.h2
3 files changed, 72 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index 4b421d801873..8f9e6152f3b7 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -1356,6 +1356,28 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw,
1356 struct wl1271 *wl = hw->priv; 1356 struct wl1271 *wl = hw->priv;
1357 wl1271_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow); 1357 wl1271_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow);
1358 wl->wow_enabled = !!wow; 1358 wl->wow_enabled = !!wow;
1359 if (wl->wow_enabled) {
1360 /* flush any remaining work */
1361 wl1271_debug(DEBUG_MAC80211, "flushing remaining works");
1362 flush_delayed_work(&wl->scan_complete_work);
1363
1364 /*
1365 * disable and re-enable interrupts in order to flush
1366 * the threaded_irq
1367 */
1368 wl1271_disable_interrupts(wl);
1369
1370 /*
1371 * set suspended flag to avoid triggering a new threaded_irq
1372 * work. no need for spinlock as interrupts are disabled.
1373 */
1374 set_bit(WL1271_FLAG_SUSPENDED, &wl->flags);
1375
1376 wl1271_enable_interrupts(wl);
1377 flush_work(&wl->tx_work);
1378 flush_delayed_work(&wl->pspoll_work);
1379 flush_delayed_work(&wl->elp_work);
1380 }
1359 return 0; 1381 return 0;
1360} 1382}
1361 1383
@@ -1364,6 +1386,30 @@ static int wl1271_op_resume(struct ieee80211_hw *hw)
1364 struct wl1271 *wl = hw->priv; 1386 struct wl1271 *wl = hw->priv;
1365 wl1271_debug(DEBUG_MAC80211, "mac80211 resume wow=%d", 1387 wl1271_debug(DEBUG_MAC80211, "mac80211 resume wow=%d",
1366 wl->wow_enabled); 1388 wl->wow_enabled);
1389
1390 /*
1391 * re-enable irq_work enqueuing, and call irq_work directly if
1392 * there is a pending work.
1393 */
1394 if (wl->wow_enabled) {
1395 struct wl1271 *wl = hw->priv;
1396 unsigned long flags;
1397 bool run_irq_work = false;
1398
1399 spin_lock_irqsave(&wl->wl_lock, flags);
1400 clear_bit(WL1271_FLAG_SUSPENDED, &wl->flags);
1401 if (test_and_clear_bit(WL1271_FLAG_PENDING_WORK, &wl->flags))
1402 run_irq_work = true;
1403 spin_unlock_irqrestore(&wl->wl_lock, flags);
1404
1405 if (run_irq_work) {
1406 wl1271_debug(DEBUG_MAC80211,
1407 "run postponed irq_work directly");
1408 wl1271_irq(0, wl);
1409 wl1271_enable_interrupts(wl);
1410 }
1411 }
1412
1367 return 0; 1413 return 0;
1368} 1414}
1369 1415
diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c
index 5b03fd5ee33f..41183db34836 100644
--- a/drivers/net/wireless/wl12xx/sdio.c
+++ b/drivers/net/wireless/wl12xx/sdio.c
@@ -82,6 +82,16 @@ static irqreturn_t wl1271_hardirq(int irq, void *cookie)
82 complete(wl->elp_compl); 82 complete(wl->elp_compl);
83 wl->elp_compl = NULL; 83 wl->elp_compl = NULL;
84 } 84 }
85
86 if (test_bit(WL1271_FLAG_SUSPENDED, &wl->flags)) {
87 /* don't enqueue a work right now. mark it as pending */
88 set_bit(WL1271_FLAG_PENDING_WORK, &wl->flags);
89 wl1271_debug(DEBUG_IRQ, "should not enqueue work");
90 disable_irq_nosync(wl->irq);
91 pm_wakeup_event(wl1271_sdio_wl_to_dev(wl), 0);
92 spin_unlock_irqrestore(&wl->wl_lock, flags);
93 return IRQ_HANDLED;
94 }
85 spin_unlock_irqrestore(&wl->wl_lock, flags); 95 spin_unlock_irqrestore(&wl->wl_lock, flags);
86 96
87 return IRQ_WAKE_THREAD; 97 return IRQ_WAKE_THREAD;
@@ -268,6 +278,7 @@ static int __devinit wl1271_probe(struct sdio_func *func,
268 } 278 }
269 279
270 enable_irq_wake(wl->irq); 280 enable_irq_wake(wl->irq);
281 device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 1);
271 282
272 disable_irq(wl->irq); 283 disable_irq(wl->irq);
273 284
@@ -305,6 +316,7 @@ static void __devexit wl1271_remove(struct sdio_func *func)
305 pm_runtime_get_noresume(&func->dev); 316 pm_runtime_get_noresume(&func->dev);
306 317
307 wl1271_unregister_hw(wl); 318 wl1271_unregister_hw(wl);
319 device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 0);
308 disable_irq_wake(wl->irq); 320 disable_irq_wake(wl->irq);
309 free_irq(wl->irq, wl); 321 free_irq(wl->irq, wl);
310 wl1271_free_hw(wl); 322 wl1271_free_hw(wl);
@@ -339,6 +351,9 @@ static int wl1271_suspend(struct device *dev)
339 wl1271_error("error while trying to keep power"); 351 wl1271_error("error while trying to keep power");
340 goto out; 352 goto out;
341 } 353 }
354
355 /* release host */
356 sdio_release_host(func);
342 } 357 }
343out: 358out:
344 return ret; 359 return ret;
@@ -346,6 +361,15 @@ out:
346 361
347static int wl1271_resume(struct device *dev) 362static int wl1271_resume(struct device *dev)
348{ 363{
364 struct sdio_func *func = dev_to_sdio_func(dev);
365 struct wl1271 *wl = sdio_get_drvdata(func);
366
367 wl1271_debug(DEBUG_MAC80211, "wl1271 resume");
368 if (wl->wow_enabled) {
369 /* claim back host */
370 sdio_claim_host(func);
371 }
372
349 return 0; 373 return 0;
350} 374}
351 375
diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h
index 9629e90d9b55..2218b9c63844 100644
--- a/drivers/net/wireless/wl12xx/wl12xx.h
+++ b/drivers/net/wireless/wl12xx/wl12xx.h
@@ -357,6 +357,8 @@ enum wl12xx_flags {
357 WL1271_FLAG_AP_STARTED, 357 WL1271_FLAG_AP_STARTED,
358 WL1271_FLAG_IF_INITIALIZED, 358 WL1271_FLAG_IF_INITIALIZED,
359 WL1271_FLAG_DUMMY_PACKET_PENDING, 359 WL1271_FLAG_DUMMY_PACKET_PENDING,
360 WL1271_FLAG_SUSPENDED,
361 WL1271_FLAG_PENDING_WORK,
360}; 362};
361 363
362struct wl1271_link { 364struct wl1271_link {