diff options
author | Luis R. Rodriguez <lrodriguez@atheros.com> | 2010-09-16 15:12:26 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-09-16 15:46:09 -0400 |
commit | 8ab2cd09fecc8819bbaee2d0fd8f3a092d866ce3 (patch) | |
tree | 95c55319794f0c9f09a6aa3abb3d676f281d75c6 /drivers | |
parent | 0f529e98498ff1a8bb264958b5fe7c0aa308d5dc (diff) |
ath9k: fix power save race conditions
ath9k has a race on putting the chip into network sleep and
having registers read from hardware. The race occurs because
although ath9k_ps_restore() locks its own callers it makes use
of some variables which get altered in the driver at different
code paths. The variables are the ps_enabled and ps_flags.
This is easily reprodicible in large network environments when
roaming with the wpa_supplicant simple bgscan. You'd get some
0xdeadbeef read out on certain registers such as:
ath: timeout (100000 us) on reg 0x806c: 0xdeadbeef & 0x01f00000 != 0x00000000
ath: RX failed to go idle in 10 ms RXSM=0xdeadbeef
ath: timeout (100000 us) on reg 0x7000: 0xdeadbeef & 0x00000003 != 0x00000000
ath: Chip reset failed
The fix is to protect the ath9k_config(hw, IEEE80211_CONF_CHANGE_PS)
calls with a spin_lock_irqsave() which will disable contendors for
these variables from interrupt context, timers, re-entry from mac80211
on the same callback, and most importantly from ath9k_ps_restore()
which is the only call which will put the device into network sleep.
There are quite a few threads and bug reports on these a few of them are:
https://bugs.launchpad.net/ubuntu/karmic/+source/linux/+bug/407040
http://code.google.com/p/chromium-os/issues/detail?id=5709
http://code.google.com/p/chromium-os/issues/detail?id=5943
Stable fixes apply to [2.6.32+]
Cc: stable@kernel.org
Cc: Paul Stewart <pstew@google.com>
Cc: Amod Bodas <amod.bodas@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/main.c | 5 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/recv.c | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index fa875d1c7e91..1dd8768c63dc 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c | |||
@@ -1554,6 +1554,8 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) | |||
1554 | * IEEE80211_CONF_CHANGE_PS is only passed by mac80211 for STA mode. | 1554 | * IEEE80211_CONF_CHANGE_PS is only passed by mac80211 for STA mode. |
1555 | */ | 1555 | */ |
1556 | if (changed & IEEE80211_CONF_CHANGE_PS) { | 1556 | if (changed & IEEE80211_CONF_CHANGE_PS) { |
1557 | unsigned long flags; | ||
1558 | spin_lock_irqsave(&sc->sc_pm_lock, flags); | ||
1557 | if (conf->flags & IEEE80211_CONF_PS) { | 1559 | if (conf->flags & IEEE80211_CONF_PS) { |
1558 | sc->ps_flags |= PS_ENABLED; | 1560 | sc->ps_flags |= PS_ENABLED; |
1559 | /* | 1561 | /* |
@@ -1568,7 +1570,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) | |||
1568 | sc->ps_enabled = false; | 1570 | sc->ps_enabled = false; |
1569 | sc->ps_flags &= ~(PS_ENABLED | | 1571 | sc->ps_flags &= ~(PS_ENABLED | |
1570 | PS_NULLFUNC_COMPLETED); | 1572 | PS_NULLFUNC_COMPLETED); |
1571 | ath9k_setpower(sc, ATH9K_PM_AWAKE); | 1573 | ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE); |
1572 | if (!(ah->caps.hw_caps & | 1574 | if (!(ah->caps.hw_caps & |
1573 | ATH9K_HW_CAP_AUTOSLEEP)) { | 1575 | ATH9K_HW_CAP_AUTOSLEEP)) { |
1574 | ath9k_hw_setrxabort(sc->sc_ah, 0); | 1576 | ath9k_hw_setrxabort(sc->sc_ah, 0); |
@@ -1583,6 +1585,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) | |||
1583 | } | 1585 | } |
1584 | } | 1586 | } |
1585 | } | 1587 | } |
1588 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); | ||
1586 | } | 1589 | } |
1587 | 1590 | ||
1588 | if (changed & IEEE80211_CONF_CHANGE_MONITOR) { | 1591 | if (changed & IEEE80211_CONF_CHANGE_MONITOR) { |
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index f921aa20b301..3e7b8fe36044 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c | |||
@@ -1640,6 +1640,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1640 | u8 rx_status_len = ah->caps.rx_status_len; | 1640 | u8 rx_status_len = ah->caps.rx_status_len; |
1641 | u64 tsf = 0; | 1641 | u64 tsf = 0; |
1642 | u32 tsf_lower = 0; | 1642 | u32 tsf_lower = 0; |
1643 | unsigned long flags; | ||
1643 | 1644 | ||
1644 | if (edma) | 1645 | if (edma) |
1645 | dma_type = DMA_BIDIRECTIONAL; | 1646 | dma_type = DMA_BIDIRECTIONAL; |
@@ -1748,11 +1749,13 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) | |||
1748 | sc->rx.rxotherant = 0; | 1749 | sc->rx.rxotherant = 0; |
1749 | } | 1750 | } |
1750 | 1751 | ||
1752 | spin_lock_irqsave(&sc->sc_pm_lock, flags); | ||
1751 | if (unlikely(ath9k_check_auto_sleep(sc) || | 1753 | if (unlikely(ath9k_check_auto_sleep(sc) || |
1752 | (sc->ps_flags & (PS_WAIT_FOR_BEACON | | 1754 | (sc->ps_flags & (PS_WAIT_FOR_BEACON | |
1753 | PS_WAIT_FOR_CAB | | 1755 | PS_WAIT_FOR_CAB | |
1754 | PS_WAIT_FOR_PSPOLL_DATA)))) | 1756 | PS_WAIT_FOR_PSPOLL_DATA)))) |
1755 | ath_rx_ps(sc, skb); | 1757 | ath_rx_ps(sc, skb); |
1758 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); | ||
1756 | 1759 | ||
1757 | if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) | 1760 | if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) |
1758 | ath_ant_comb_scan(sc, &rs); | 1761 | ath_ant_comb_scan(sc, &rs); |