aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/main.c
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 /drivers/net/wireless/wl12xx/main.c
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>
Diffstat (limited to 'drivers/net/wireless/wl12xx/main.c')
-rw-r--r--drivers/net/wireless/wl12xx/main.c46
1 files changed, 46 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