-+ if (ah->led_pin >= 0) {
-+ ath9k_hw_cfg_output(ah, ah->led_pin,
-+ AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-+ ath9k_hw_set_gpio(ah, ah->led_pin, 0);
-+ }
-+
-+ /*
-+ * Reset key cache to sane defaults (all entries cleared) instead of
-+ * semi-random values after suspend/resume.
-+ */
-+ ath9k_cmn_init_crypto(sc->sc_ah);
-+
- spin_unlock_bh(&sc->sc_pcu_lock);
-
- if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) &&
-@@ -1183,6 +1126,13 @@ static void ath9k_tx(struct ieee80211_hw
- }
- }
-
-+ /*
-+ * Cannot tx while the hardware is in full sleep, it first needs a full
-+ * chip reset to recover from that
-+ */
-+ if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_FULL_SLEEP))
-+ goto exit;
-+
- if (unlikely(sc->sc_ah->power_mode != ATH9K_PM_AWAKE)) {
- /*
- * We are using PS-Poll and mac80211 can request TX while in
-@@ -1229,6 +1179,7 @@ static void ath9k_stop(struct ieee80211_
- struct ath_softc *sc = hw->priv;
- struct ath_hw *ah = sc->sc_ah;
- struct ath_common *common = ath9k_hw_common(ah);
-+ bool prev_idle;
-
- mutex_lock(&sc->mutex);
-
-@@ -1259,35 +1210,45 @@ static void ath9k_stop(struct ieee80211_
- * before setting the invalid flag. */
- ath9k_hw_disable_interrupts(ah);
-
-- if (!(sc->sc_flags & SC_OP_INVALID)) {
-- ath_drain_all_txq(sc, false);
-- ath_stoprecv(sc);
-- ath9k_hw_phy_disable(ah);
-- } else
-- sc->rx.rxlink = NULL;
-+ spin_unlock_bh(&sc->sc_pcu_lock);
-+
-+ /* we can now sync irq and kill any running tasklets, since we already
-+ * disabled interrupts and not holding a spin lock */
-+ synchronize_irq(sc->irq);
-+ tasklet_kill(&sc->intr_tq);
-+ tasklet_kill(&sc->bcon_tasklet);
-+
-+ prev_idle = sc->ps_idle;
-+ sc->ps_idle = true;
-+
-+ spin_lock_bh(&sc->sc_pcu_lock);
-+
-+ if (ah->led_pin >= 0) {
-+ ath9k_hw_set_gpio(ah, ah->led_pin, 1);
-+ ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
-+ }
-+
-+ ath_prepare_reset(sc, false, true);
-
- if (sc->rx.frag) {
- dev_kfree_skb_any(sc->rx.frag);
- sc->rx.frag = NULL;
- }
-
-- /* disable HAL and put h/w to sleep */
-- ath9k_hw_disable(ah);
-+ if (!ah->curchan)
-+ ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
-
-- spin_unlock_bh(&sc->sc_pcu_lock);
-+ ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
-+ ath9k_hw_phy_disable(ah);
-
-- /* we can now sync irq and kill any running tasklets, since we already
-- * disabled interrupts and not holding a spin lock */
-- synchronize_irq(sc->irq);
-- tasklet_kill(&sc->intr_tq);
-- tasklet_kill(&sc->bcon_tasklet);
-+ ath9k_hw_configpcipowersave(ah, true);
-
-- ath9k_ps_restore(sc);
-+ spin_unlock_bh(&sc->sc_pcu_lock);
-
-- sc->ps_idle = true;
-- ath_radio_disable(sc, hw);
-+ ath9k_ps_restore(sc);
-
- sc->sc_flags |= SC_OP_INVALID;
-+ sc->ps_idle = prev_idle;
-
- mutex_unlock(&sc->mutex);
-
-@@ -1627,8 +1588,8 @@ static int ath9k_config(struct ieee80211
- struct ath_hw *ah = sc->sc_ah;
- struct ath_common *common = ath9k_hw_common(ah);
- struct ieee80211_conf *conf = &hw->conf;
-- bool disable_radio = false;
-
-+ ath9k_ps_wakeup(sc);
- mutex_lock(&sc->mutex);
-
- /*
-@@ -1639,13 +1600,8 @@ static int ath9k_config(struct ieee80211
- */
- if (changed & IEEE80211_CONF_CHANGE_IDLE) {
- sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
-- if (!sc->ps_idle) {
-- ath_radio_enable(sc, hw);
-- ath_dbg(common, ATH_DBG_CONFIG,
-- "not-idle: enabling radio\n");
-- } else {
-- disable_radio = true;
-- }
-+ if (sc->ps_idle)
-+ ath_cancel_work(sc);
- }
-
- /*
-@@ -1752,18 +1708,12 @@ static int ath9k_config(struct ieee80211
- ath_dbg(common, ATH_DBG_CONFIG,
- "Set power: %d\n", conf->power_level);
- sc->config.txpowlimit = 2 * conf->power_level;
-- ath9k_ps_wakeup(sc);
- ath9k_cmn_update_txpow(ah, sc->curtxpow,
- sc->config.txpowlimit, &sc->curtxpow);
-- ath9k_ps_restore(sc);
-- }
--
-- if (disable_radio) {
-- ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
-- ath_radio_disable(sc, hw);
- }
-
- mutex_unlock(&sc->mutex);
-+ ath9k_ps_restore(sc);
-
- return 0;
- }
-@@ -2331,9 +2281,6 @@ static void ath9k_flush(struct ieee80211
- return;
- }
-
-- if (drop)
-- timeout = 1;
--
- for (j = 0; j < timeout; j++) {
- bool npend = false;
-
-@@ -2351,21 +2298,22 @@ static void ath9k_flush(struct ieee80211
- }
-
- if (!npend)
-- goto out;
-+ break;
- }
-
-- ath9k_ps_wakeup(sc);
-- spin_lock_bh(&sc->sc_pcu_lock);
-- drain_txq = ath_drain_all_txq(sc, false);
-- spin_unlock_bh(&sc->sc_pcu_lock);
-+ if (drop) {
-+ ath9k_ps_wakeup(sc);
-+ spin_lock_bh(&sc->sc_pcu_lock);
-+ drain_txq = ath_drain_all_txq(sc, false);
-+ spin_unlock_bh(&sc->sc_pcu_lock);
-
-- if (!drain_txq)
-- ath_reset(sc, false);
-+ if (!drain_txq)
-+ ath_reset(sc, false);
-
-- ath9k_ps_restore(sc);
-- ieee80211_wake_queues(hw);
-+ ath9k_ps_restore(sc);
-+ ieee80211_wake_queues(hw);
-+ }
-
--out:
- ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0);
- mutex_unlock(&sc->mutex);
- }
---- a/drivers/net/wireless/ath/ath9k/pci.c
-+++ b/drivers/net/wireless/ath/ath9k/pci.c
-@@ -307,12 +307,11 @@ static int ath_pci_suspend(struct device
- struct ieee80211_hw *hw = pci_get_drvdata(pdev);
- struct ath_softc *sc = hw->priv;
-
-- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
--
- /* The device has to be moved to FULLSLEEP forcibly.
- * Otherwise the chip never moved to full sleep,
- * when no interface is up.
- */
-+ ath9k_hw_disable(sc->sc_ah);
- ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
-
- return 0;
-@@ -334,22 +333,6 @@ static int ath_pci_resume(struct device
- if ((val & 0x0000ff00) != 0)
- pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
-
-- ath9k_ps_wakeup(sc);
-- /* Enable LED */
-- ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
-- AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
--
-- /*
-- * Reset key cache to sane defaults (all entries cleared) instead of
-- * semi-random values after suspend/resume.
-- */
-- ath9k_cmn_init_crypto(sc->sc_ah);
-- ath9k_ps_restore(sc);
--
-- sc->ps_idle = true;
-- ath_radio_disable(sc, hw);
--
- return 0;
- }
-
---- a/drivers/net/wireless/ath/ath9k/xmit.c
-+++ b/drivers/net/wireless/ath/ath9k/xmit.c
-@@ -1954,7 +1954,7 @@ static void ath_tx_complete(struct ath_s
- skb_pull(skb, padsize);
- }
-
-- if (sc->ps_flags & PS_WAIT_FOR_TX_ACK) {
-+ if ((sc->ps_flags & PS_WAIT_FOR_TX_ACK) && !txq->axq_depth) {
- sc->ps_flags &= ~PS_WAIT_FOR_TX_ACK;
- ath_dbg(common, ATH_DBG_PS,
- "Going back to sleep after having received TX status (0x%lx)\n",
---- a/include/linux/nl80211.h
-+++ b/include/linux/nl80211.h
-@@ -2785,9 +2785,11 @@ enum nl80211_ap_sme_features {
- * @NL80211_FEATURE_SK_TX_STATUS: This driver supports reflecting back
- * TX status to the socket error queue when requested with the
- * socket option.
-+ * @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates.
- */
- enum nl80211_feature_flags {
- NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
-+ NL80211_FEATURE_HT_IBSS = 1 << 1,
- };
-
- /**
---- a/include/net/cfg80211.h
-+++ b/include/net/cfg80211.h
-@@ -1149,6 +1149,7 @@ struct cfg80211_ibss_params {
- u8 *ssid;
- u8 *bssid;
- struct ieee80211_channel *channel;
-+ enum nl80211_channel_type channel_type;
- u8 *ie;
- u8 ssid_len, ie_len;
- u16 beacon_interval;
-@@ -3270,6 +3271,16 @@ void cfg80211_report_obss_beacon(struct
- const u8 *frame, size_t len,
- int freq, gfp_t gfp);
-
-+/*
-+ * cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used
-+ * @wiphy: the wiphy
-+ * @chan: main channel
-+ * @channel_type: HT mode
-+ */
-+int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
-+ struct ieee80211_channel *chan,
-+ enum nl80211_channel_type channel_type);
-+
- /* Logging, debugging and troubleshooting/diagnostic helpers. */
-
- /* wiphy_printk helpers, similar to dev_printk */