mac80211: add more ath9k patches
[openwrt/openwrt.git] / package / mac80211 / patches / 406-ath9k-serialize-ath9k_hw_setpower-calls.patch
1 From 841c7e339c4775f4cc614c92aaea82f70fcafbdb Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Sun, 21 Jun 2009 16:59:53 +0200
4 Subject: [PATCH 1/3] ath9k: serialize ath9k_hw_setpower calls
5
6 Because ath9k_setpower is called from various contexts, we have to
7 protect it against concurrent calls.
8
9 Changes-licensed-under: ISC
10 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
11 ---
12 drivers/net/wireless/ath/ath9k/ath9k.h | 1 +
13 drivers/net/wireless/ath/ath9k/hw.c | 15 ++++++++++++++-
14 drivers/net/wireless/ath/ath9k/main.c | 1 +
15 3 files changed, 16 insertions(+), 1 deletions(-)
16
17 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
18 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
19 @@ -544,6 +544,7 @@ struct ath_softc {
20 int irq;
21 spinlock_t sc_resetlock;
22 spinlock_t sc_serial_rw;
23 + spinlock_t sc_pm_lock;
24 struct mutex mutex;
25
26 u8 curbssid[ETH_ALEN];
27 --- a/drivers/net/wireless/ath/ath9k/hw.c
28 +++ b/drivers/net/wireless/ath/ath9k/hw.c
29 @@ -2738,7 +2738,8 @@ static bool ath9k_hw_set_power_awake(str
30 return true;
31 }
32
33 -bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode)
34 +static bool ath9k_hw_setpower_nolock(struct ath_hw *ah,
35 + enum ath9k_power_mode mode)
36 {
37 int status = true, setChip = true;
38 static const char *modes[] = {
39 @@ -2772,6 +2773,18 @@ bool ath9k_hw_setpower(struct ath_hw *ah
40 return status;
41 }
42
43 +bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode)
44 +{
45 + unsigned long flags;
46 + bool ret;
47 +
48 + spin_lock_irqsave(&ah->ah_sc->sc_pm_lock, flags);
49 + ret = ath9k_hw_setpower_nolock(ah, mode);
50 + spin_unlock_irqrestore(&ah->ah_sc->sc_pm_lock, flags);
51 +
52 + return ret;
53 +}
54 +
55 /*
56 * Helper for ASPM support.
57 *
58 --- a/drivers/net/wireless/ath/ath9k/main.c
59 +++ b/drivers/net/wireless/ath/ath9k/main.c
60 @@ -1317,6 +1317,7 @@ static int ath_init(u16 devid, struct at
61 spin_lock_init(&sc->wiphy_lock);
62 spin_lock_init(&sc->sc_resetlock);
63 spin_lock_init(&sc->sc_serial_rw);
64 + spin_lock_init(&sc->sc_pm_lock);
65 mutex_init(&sc->mutex);
66 tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc);
67 tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet,