1 --- a/drivers/net/wireless/ath/ath9k/main.c
2 +++ b/drivers/net/wireless/ath/ath9k/main.c
3 @@ -883,82 +883,6 @@ chip_reset:
7 -static void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
9 - struct ath_hw *ah = sc->sc_ah;
10 - struct ath_common *common = ath9k_hw_common(ah);
11 - struct ieee80211_channel *channel = hw->conf.channel;
14 - ath9k_ps_wakeup(sc);
15 - spin_lock_bh(&sc->sc_pcu_lock);
16 - atomic_set(&ah->intr_ref_cnt, -1);
18 - ath9k_hw_configpcipowersave(ah, false);
21 - ah->curchan = ath9k_cmn_get_curchannel(sc->hw, ah);
23 - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
26 - "Unable to reset channel (%u MHz), reset status %d\n",
27 - channel->center_freq, r);
30 - ath_complete_reset(sc, true);
33 - ath9k_hw_cfg_output(ah, ah->led_pin,
34 - AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
35 - ath9k_hw_set_gpio(ah, ah->led_pin, 0);
37 - spin_unlock_bh(&sc->sc_pcu_lock);
39 - ath9k_ps_restore(sc);
42 -void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
44 - struct ath_hw *ah = sc->sc_ah;
45 - struct ieee80211_channel *channel = hw->conf.channel;
48 - ath9k_ps_wakeup(sc);
50 - ath_cancel_work(sc);
52 - spin_lock_bh(&sc->sc_pcu_lock);
55 - * Keep the LED on when the radio is disabled
56 - * during idle unassociated state.
59 - ath9k_hw_set_gpio(ah, ah->led_pin, 1);
60 - ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
63 - ath_prepare_reset(sc, false, true);
66 - ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
68 - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
70 - ath_err(ath9k_hw_common(sc->sc_ah),
71 - "Unable to reset channel (%u MHz), reset status %d\n",
72 - channel->center_freq, r);
75 - ath9k_hw_phy_disable(ah);
77 - ath9k_hw_configpcipowersave(ah, true);
79 - spin_unlock_bh(&sc->sc_pcu_lock);
80 - ath9k_ps_restore(sc);
83 static int ath_reset(struct ath_softc *sc, bool retry_tx)
86 @@ -1094,6 +1018,9 @@ static int ath9k_start(struct ieee80211_
87 * and then setup of the interrupt mask.
89 spin_lock_bh(&sc->sc_pcu_lock);
91 + atomic_set(&ah->intr_ref_cnt, -1);
93 r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
96 @@ -1132,6 +1059,18 @@ static int ath9k_start(struct ieee80211_
100 + if (ah->led_pin >= 0) {
101 + ath9k_hw_cfg_output(ah, ah->led_pin,
102 + AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
103 + ath9k_hw_set_gpio(ah, ah->led_pin, 0);
107 + * Reset key cache to sane defaults (all entries cleared) instead of
108 + * semi-random values after suspend/resume.
110 + ath9k_cmn_init_crypto(sc->sc_ah);
112 spin_unlock_bh(&sc->sc_pcu_lock);
114 if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) &&
115 @@ -1229,6 +1168,7 @@ static void ath9k_stop(struct ieee80211_
116 struct ath_softc *sc = hw->priv;
117 struct ath_hw *ah = sc->sc_ah;
118 struct ath_common *common = ath9k_hw_common(ah);
121 mutex_lock(&sc->mutex);
123 @@ -1258,35 +1198,45 @@ static void ath9k_stop(struct ieee80211_
124 * before setting the invalid flag. */
125 ath9k_hw_disable_interrupts(ah);
127 - if (!(sc->sc_flags & SC_OP_INVALID)) {
128 - ath_drain_all_txq(sc, false);
130 - ath9k_hw_phy_disable(ah);
132 - sc->rx.rxlink = NULL;
133 + spin_unlock_bh(&sc->sc_pcu_lock);
135 + /* we can now sync irq and kill any running tasklets, since we already
136 + * disabled interrupts and not holding a spin lock */
137 + synchronize_irq(sc->irq);
138 + tasklet_kill(&sc->intr_tq);
139 + tasklet_kill(&sc->bcon_tasklet);
141 + prev_idle = sc->ps_idle;
142 + sc->ps_idle = true;
144 + spin_lock_bh(&sc->sc_pcu_lock);
146 + if (ah->led_pin >= 0) {
147 + ath9k_hw_set_gpio(ah, ah->led_pin, 1);
148 + ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
151 + ath_prepare_reset(sc, false, true);
154 dev_kfree_skb_any(sc->rx.frag);
158 - /* disable HAL and put h/w to sleep */
159 - ath9k_hw_disable(ah);
161 + ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
163 - spin_unlock_bh(&sc->sc_pcu_lock);
164 + ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
165 + ath9k_hw_phy_disable(ah);
167 - /* we can now sync irq and kill any running tasklets, since we already
168 - * disabled interrupts and not holding a spin lock */
169 - synchronize_irq(sc->irq);
170 - tasklet_kill(&sc->intr_tq);
171 - tasklet_kill(&sc->bcon_tasklet);
172 + ath9k_hw_configpcipowersave(ah, true);
174 - ath9k_ps_restore(sc);
175 + spin_unlock_bh(&sc->sc_pcu_lock);
177 - sc->ps_idle = true;
178 - ath_radio_disable(sc, hw);
179 + ath9k_ps_restore(sc);
181 sc->sc_flags |= SC_OP_INVALID;
182 + sc->ps_idle = prev_idle;
184 mutex_unlock(&sc->mutex);
186 @@ -1608,8 +1558,8 @@ static int ath9k_config(struct ieee80211
187 struct ath_hw *ah = sc->sc_ah;
188 struct ath_common *common = ath9k_hw_common(ah);
189 struct ieee80211_conf *conf = &hw->conf;
190 - bool disable_radio = false;
192 + ath9k_ps_wakeup(sc);
193 mutex_lock(&sc->mutex);
196 @@ -1618,16 +1568,8 @@ static int ath9k_config(struct ieee80211
197 * of the changes. Likewise we must only disable the radio towards
200 - if (changed & IEEE80211_CONF_CHANGE_IDLE) {
201 + if (changed & IEEE80211_CONF_CHANGE_IDLE)
202 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
203 - if (!sc->ps_idle) {
204 - ath_radio_enable(sc, hw);
205 - ath_dbg(common, ATH_DBG_CONFIG,
206 - "not-idle: enabling radio\n");
208 - disable_radio = true;
213 * We just prepare to enable PS. We have to wait until our AP has
214 @@ -1752,19 +1694,13 @@ static int ath9k_config(struct ieee80211
215 ath_dbg(common, ATH_DBG_CONFIG,
216 "Set power: %d\n", conf->power_level);
217 sc->config.txpowlimit = 2 * conf->power_level;
218 - ath9k_ps_wakeup(sc);
219 ath9k_cmn_update_txpow(ah, sc->curtxpow,
220 sc->config.txpowlimit, &sc->curtxpow);
221 - ath9k_ps_restore(sc);
222 conf->cur_power_level = sc->curtxpow / 2;
225 - if (disable_radio) {
226 - ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
227 - ath_radio_disable(sc, hw);
230 mutex_unlock(&sc->mutex);
231 + ath9k_ps_restore(sc);
235 --- a/drivers/net/wireless/ath/ath9k/pci.c
236 +++ b/drivers/net/wireless/ath/ath9k/pci.c
237 @@ -306,12 +306,11 @@ static int ath_pci_suspend(struct device
238 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
239 struct ath_softc *sc = hw->priv;
241 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
243 /* The device has to be moved to FULLSLEEP forcibly.
244 * Otherwise the chip never moved to full sleep,
245 * when no interface is up.
247 + ath9k_hw_disable(sc->sc_ah);
248 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
251 @@ -333,22 +332,6 @@ static int ath_pci_resume(struct device
252 if ((val & 0x0000ff00) != 0)
253 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
255 - ath9k_ps_wakeup(sc);
257 - ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
258 - AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
259 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
262 - * Reset key cache to sane defaults (all entries cleared) instead of
263 - * semi-random values after suspend/resume.
265 - ath9k_cmn_init_crypto(sc->sc_ah);
266 - ath9k_ps_restore(sc);
268 - sc->ps_idle = true;
269 - ath_radio_disable(sc, hw);