[kernel] use 2.4.37.5
[openwrt.git] / package / mac80211 / patches / 409-ath9k-fix-race-with-IEEE80211_CONF_PS-checks.patch
1 From c96f9c17f71213a562ce20d85a7418d5549235cc Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Fri, 24 Jul 2009 16:34:37 +0200
4 Subject: [PATCH 1/2] ath9k: fix race with IEEE80211_CONF_PS checks
5
6 There is a small window where the mac80211 changes the IEEE80211_CONF_PS
7 flag, and then informs the driver about the change. We have a race
8 condition if we are checking the flag in the same time. Avoid it by
9 introducing a local variable, and using that instead of checking the
10 IEEE80211_CONF_PS flag directly.
11
12 This fix the problem reported by Luis:
13 http://article.gmane.org/gmane.linux.kernel.wireless.general/34363
14
15 Changes-licensed-under: ISC
16 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
17 ---
18 drivers/net/wireless/ath/ath9k/ath9k.h | 1 +
19 drivers/net/wireless/ath/ath9k/hw.c | 17 +++++++----------
20 drivers/net/wireless/ath/ath9k/hw.h | 1 -
21 drivers/net/wireless/ath/ath9k/main.c | 8 ++++----
22 4 files changed, 12 insertions(+), 15 deletions(-)
23
24 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
25 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
26 @@ -561,6 +561,7 @@ struct ath_softc {
27 u32 keymax;
28 DECLARE_BITMAP(keymap, ATH_KEYMAX);
29 u8 splitmic;
30 + bool ps_enabled;
31 unsigned long ps_usecount;
32 enum ath9k_int imask;
33 enum ath9k_ht_extprotspacing ht_extprotspacing;
34 --- a/drivers/net/wireless/ath/ath9k/hw.c
35 +++ b/drivers/net/wireless/ath/ath9k/hw.c
36 @@ -2793,10 +2793,8 @@ void ath9k_ps_wakeup(struct ath_softc *s
37 if (++sc->ps_usecount != 1)
38 goto unlock;
39
40 - if (sc->sc_ah->power_mode != ATH9K_PM_AWAKE) {
41 - sc->sc_ah->restore_mode = sc->sc_ah->power_mode;
42 + if (sc->sc_ah->power_mode != ATH9K_PM_AWAKE)
43 ath9k_hw_setpower_nolock(sc->sc_ah, ATH9K_PM_AWAKE);
44 - }
45
46 unlock:
47 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
48 @@ -2810,13 +2808,12 @@ void ath9k_ps_restore(struct ath_softc *
49 if (--sc->ps_usecount != 0)
50 goto unlock;
51
52 - if ((sc->hw->conf.flags & IEEE80211_CONF_PS) &&
53 - !(sc->sc_flags & (SC_OP_WAIT_FOR_BEACON |
54 - SC_OP_WAIT_FOR_CAB |
55 - SC_OP_WAIT_FOR_PSPOLL_DATA |
56 - SC_OP_WAIT_FOR_TX_ACK)))
57 - ath9k_hw_setpower_nolock(sc->sc_ah,
58 - sc->sc_ah->restore_mode);
59 + if (sc->ps_enabled &&
60 + !(sc->sc_flags & (SC_OP_WAIT_FOR_BEACON |
61 + SC_OP_WAIT_FOR_CAB |
62 + SC_OP_WAIT_FOR_PSPOLL_DATA |
63 + SC_OP_WAIT_FOR_TX_ACK)))
64 + ath9k_hw_setpower_nolock(sc->sc_ah, ATH9K_PM_NETWORK_SLEEP);
65
66 unlock:
67 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
68 --- a/drivers/net/wireless/ath/ath9k/hw.h
69 +++ b/drivers/net/wireless/ath/ath9k/hw.h
70 @@ -418,7 +418,6 @@ struct ath_hw {
71
72 enum nl80211_iftype opmode;
73 enum ath9k_power_mode power_mode;
74 - enum ath9k_power_mode restore_mode;
75
76 struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS];
77 struct ar5416Stats stats;
78 --- a/drivers/net/wireless/ath/ath9k/main.c
79 +++ b/drivers/net/wireless/ath/ath9k/main.c
80 @@ -496,8 +496,7 @@ static void ath9k_tasklet(unsigned long
81 if (status & ATH9K_INT_TX)
82 ath_tx_tasklet(sc);
83
84 - if ((status & ATH9K_INT_TSFOOR) &&
85 - (sc->hw->conf.flags & IEEE80211_CONF_PS)) {
86 + if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) {
87 /*
88 * TSF sync does not look correct; remain awake to sync with
89 * the next Beacon.
90 @@ -2001,7 +2000,7 @@ static int ath9k_tx(struct ieee80211_hw
91 goto exit;
92 }
93
94 - if (sc->hw->conf.flags & IEEE80211_CONF_PS) {
95 + if (sc->ps_enabled) {
96 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
97 /*
98 * mac80211 does not set PM field for normal data frames, so we
99 @@ -2270,8 +2269,9 @@ static int ath9k_config(struct ieee80211
100 }
101 ath9k_hw_setrxabort(sc->sc_ah, 1);
102 }
103 - ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_NETWORK_SLEEP);
104 + sc->ps_enabled = true;
105 } else {
106 + sc->ps_enabled = false;
107 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
108 if (!(ah->caps.hw_caps &
109 ATH9K_HW_CAP_AUTOSLEEP)) {
This page took 0.05286 seconds and 5 git commands to generate.