ath9k: fix crashes when using shared IRQs
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Thu, 13 Nov 2014 18:26:27 +0000 (18:26 +0000)
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Thu, 13 Nov 2014 18:26:27 +0000 (18:26 +0000)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Backport of r43239

git-svn-id: svn://svn.openwrt.org/openwrt/branches/barrier_breaker@43240 3c298f89-4303-0410-b956-a3cf2f4a3e73

package/kernel/mac80211/patches/300-pending_work.patch
package/kernel/mac80211/patches/410-ath9k_allow_adhoc_and_ap.patch
package/kernel/mac80211/patches/501-ath9k-eeprom_endianess.patch
package/kernel/mac80211/patches/502-ath9k_ahb_init.patch
package/kernel/mac80211/patches/521-ath9k_cur_txpower.patch
package/kernel/mac80211/patches/523-ath9k_use_configured_antenna_gain.patch
package/kernel/mac80211/patches/530-ath9k_extra_leds.patch
package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch
package/kernel/mac80211/patches/543-ath9k-allow-to-disable-bands-via-platform-data.patch
package/kernel/mac80211/patches/550-ath9k_entropy_from_adc.patch
package/kernel/mac80211/patches/563-ath9k_rxorn_intr_fix.patch

index 796b34c..95d37af 100644 (file)
@@ -1,3 +1,38 @@
+commit 24028dc203af73088ab969c2b4236bf9bee99d85
+Author: Felix Fietkau <nbd@openwrt.org>
+Date:   Thu Nov 13 18:29:26 2014 +0100
+
+    ath9k: do not access hardware on IRQs during reset
+    
+    Instead of killing interrupts during reset when the first one happens,
+    kill them before issuing the reset.
+    This fixes an easy to reproduce crash with multiple cards sharing the
+    same IRQ.
+    
+    Cc: stable@vger.kernel.org
+    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+
+commit 8115a0d774754a1a01feb25fb436832d4f3be41b
+Author: Felix Fietkau <nbd@openwrt.org>
+Date:   Thu Nov 13 18:29:00 2014 +0100
+
+    ath9k: set ATH_OP_INVALID before disabling hardware
+    
+    Closes another small IRQ handler race
+    
+    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+
+commit d10478d3983574c2bae11146ef6b01d0103a777d
+Author: Felix Fietkau <nbd@openwrt.org>
+Date:   Thu Nov 13 18:27:47 2014 +0100
+
+    ath9k: prevent early IRQs from accessing hardware
+    
+    IRQs are suppressed if ah == NULL and ATH_OP_INVALID being set in
+    common->op_flags. Close a short time window between those two.
+    
+    Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+
 commit 77980bee5f1f743b46f8749185aca28b8ec69741
 Author: Johannes Berg <johannes.berg@intel.com>
 Date:   Mon Nov 3 14:29:09 2014 +0100
@@ -1688,7 +1723,66 @@ Date:   Mon May 19 21:20:49 2014 +0200
        ENTRY_DATA_IO_FAILED,
 --- a/drivers/net/wireless/ath/ath9k/main.c
 +++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1757,7 +1757,6 @@ out:
+@@ -582,16 +582,13 @@ irqreturn_t ath_isr(int irq, void *dev)
+       if (test_bit(ATH_OP_INVALID, &common->op_flags))
+               return IRQ_NONE;
+-      /* shared irq, not for us */
++      if (test_bit(ATH_OP_HW_RESET, &common->op_flags))
++              return IRQ_NONE;
++      /* shared irq, not for us */
+       if (!ath9k_hw_intrpend(ah))
+               return IRQ_NONE;
+-      if (test_bit(ATH_OP_HW_RESET, &common->op_flags)) {
+-              ath9k_hw_kill_interrupts(ah);
+-              return IRQ_HANDLED;
+-      }
+-
+       /*
+        * Figure out the reason(s) for the interrupt.  Note
+        * that the hal returns a pseudo-ISR that may include
+@@ -677,8 +674,12 @@ chip_reset:
+ int ath_reset(struct ath_softc *sc)
+ {
++      struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+       int r;
++      ath9k_hw_kill_interrupts(sc->sc_ah);
++      set_bit(ATH_OP_HW_RESET, &common->op_flags);
++
+       ath9k_ps_wakeup(sc);
+       r = ath_reset_internal(sc, NULL);
+       ath9k_ps_restore(sc);
+@@ -692,6 +693,7 @@ void ath9k_queue_reset(struct ath_softc 
+ #ifdef CPTCFG_ATH9K_DEBUGFS
+       RESET_STAT_INC(sc, type);
+ #endif
++      ath9k_hw_kill_interrupts(sc->sc_ah);
+       set_bit(ATH_OP_HW_RESET, &common->op_flags);
+       ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
+ }
+@@ -937,6 +939,9 @@ static void ath9k_stop(struct ieee80211_
+               ah->curchan = ath9k_cmn_get_channel(hw, ah, &hw->conf.chandef);
+       ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
++
++      set_bit(ATH_OP_INVALID, &common->op_flags);
++
+       ath9k_hw_phy_disable(ah);
+       ath9k_hw_configpcipowersave(ah, true);
+@@ -945,7 +950,6 @@ static void ath9k_stop(struct ieee80211_
+       ath9k_ps_restore(sc);
+-      set_bit(ATH_OP_INVALID, &common->op_flags);
+       sc->ps_idle = prev_idle;
+       mutex_unlock(&sc->mutex);
+@@ -1757,7 +1761,6 @@ out:
  void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif *vif)
  {
        struct ath_vif *avp = (void *)vif->drv_priv;
@@ -1696,7 +1790,7 @@ Date:   Mon May 19 21:20:49 2014 +0200
        u32 tsf;
  
        if (!sc->p2p_ps_timer)
-@@ -1767,14 +1766,9 @@ void ath9k_update_p2p_ps(struct ath_soft
+@@ -1767,14 +1770,9 @@ void ath9k_update_p2p_ps(struct ath_soft
                return;
  
        sc->p2p_ps_vif = avp;
@@ -1714,7 +1808,7 @@ Date:   Mon May 19 21:20:49 2014 +0200
  }
  
  static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
-@@ -1791,6 +1785,7 @@ static void ath9k_bss_info_changed(struc
+@@ -1791,6 +1789,7 @@ static void ath9k_bss_info_changed(struc
        struct ath_hw *ah = sc->sc_ah;
        struct ath_common *common = ath9k_hw_common(ah);
        struct ath_vif *avp = (void *)vif->drv_priv;
@@ -1722,7 +1816,7 @@ Date:   Mon May 19 21:20:49 2014 +0200
        int slottime;
  
        ath9k_ps_wakeup(sc);
-@@ -1853,7 +1848,10 @@ static void ath9k_bss_info_changed(struc
+@@ -1853,7 +1852,10 @@ static void ath9k_bss_info_changed(struc
  
        if (changed & BSS_CHANGED_P2P_PS) {
                spin_lock_bh(&sc->sc_pcu_lock);
@@ -1734,7 +1828,7 @@ Date:   Mon May 19 21:20:49 2014 +0200
                spin_unlock_bh(&sc->sc_pcu_lock);
        }
  
-@@ -2232,14 +2230,6 @@ static void ath9k_sw_scan_complete(struc
+@@ -2232,14 +2234,6 @@ static void ath9k_sw_scan_complete(struc
        clear_bit(ATH_OP_SCANNING, &common->op_flags);
  }
  
@@ -1749,7 +1843,7 @@ Date:   Mon May 19 21:20:49 2014 +0200
  struct ieee80211_ops ath9k_ops = {
        .tx                 = ath9k_tx,
        .start              = ath9k_start,
-@@ -2287,5 +2277,4 @@ struct ieee80211_ops ath9k_ops = {
+@@ -2287,5 +2281,4 @@ struct ieee80211_ops ath9k_ops = {
  #endif
        .sw_scan_start      = ath9k_sw_scan_start,
        .sw_scan_complete   = ath9k_sw_scan_complete,
@@ -3495,3 +3589,31 @@ Date:   Mon May 19 21:20:49 2014 +0200
  }
  
  void b43_phy_mask(struct b43_wldev *dev, u16 offset, u16 mask)
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -500,10 +500,14 @@ static int ath9k_init_softc(u16 devid, s
+       ah->reg_ops.read = ath9k_ioread32;
+       ah->reg_ops.write = ath9k_iowrite32;
+       ah->reg_ops.rmw = ath9k_reg_rmw;
+-      sc->sc_ah = ah;
+       pCap = &ah->caps;
+       common = ath9k_hw_common(ah);
++
++      /* Will be cleared in ath9k_start() */
++      set_bit(ATH_OP_INVALID, &common->op_flags);
++
++      sc->sc_ah = ah;
+       sc->dfs_detector = dfs_pattern_detector_init(common, NL80211_DFS_UNSET);
+       sc->tx99_power = MAX_RATE_POWER + 1;
+       init_waitqueue_head(&sc->tx_wait);
+@@ -787,9 +791,6 @@ int ath9k_init_device(u16 devid, struct 
+       common = ath9k_hw_common(ah);
+       ath9k_set_hw_capab(sc, hw);
+-      /* Will be cleared in ath9k_start() */
+-      set_bit(ATH_OP_INVALID, &common->op_flags);
+-
+       /* Initialize regulatory */
+       error = ath_regd_init(&common->regulatory, sc->hw->wiphy,
+                             ath9k_reg_notifier);
index ce752f1..7821f6b 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/init.c
 +++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -655,6 +655,7 @@ static const struct ieee80211_iface_limi
+@@ -659,6 +659,7 @@ static const struct ieee80211_iface_limi
                                 BIT(NL80211_IFTYPE_AP) },
        { .max = 1,     .types = BIT(NL80211_IFTYPE_P2P_CLIENT) |
                                 BIT(NL80211_IFTYPE_P2P_GO) },
index 169eb9a..b2cfe5f 100644 (file)
@@ -81,7 +81,7 @@
        struct ath_ops reg_ops;
 --- a/drivers/net/wireless/ath/ath9k/init.c
 +++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -518,6 +518,8 @@ static int ath9k_init_softc(u16 devid, s
+@@ -522,6 +522,8 @@ static int ath9k_init_softc(u16 devid, s
                ah->is_clk_25mhz = pdata->is_clk_25mhz;
                ah->get_mac_revision = pdata->get_mac_revision;
                ah->external_reset = pdata->external_reset;
index 0c8e813..7346745 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/init.c
 +++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -904,23 +904,23 @@ static int __init ath9k_init(void)
+@@ -905,23 +905,23 @@ static int __init ath9k_init(void)
  {
        int error;
  
index 83ff465..85ad64c 100644 (file)
@@ -14,7 +14,7 @@
  
  out:
        spin_unlock_bh(&sc->sc_pcu_lock);
-@@ -1405,6 +1409,7 @@ static int ath9k_config(struct ieee80211
+@@ -1409,6 +1413,7 @@ static int ath9k_config(struct ieee80211
                sc->config.txpowlimit = 2 * conf->power_level;
                ath9k_cmn_update_txpow(ah, sc->curtxpow,
                                       sc->config.txpowlimit, &sc->curtxpow);
index 9b51c4c..3a711f7 100644 (file)
@@ -21,7 +21,7 @@
        if (ant_gain > max_gain)
 --- a/drivers/net/wireless/ath/ath9k/main.c
 +++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1405,7 +1405,10 @@ static int ath9k_config(struct ieee80211
+@@ -1409,7 +1409,10 @@ static int ath9k_config(struct ieee80211
        }
  
        if (changed & IEEE80211_CONF_CHANGE_POWER) {
index 29efdf5..ed606a9 100644 (file)
  void ath_fill_led_pin(struct ath_softc *sc)
 --- a/drivers/net/wireless/ath/ath9k/init.c
 +++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -815,7 +815,7 @@ int ath9k_init_device(u16 devid, struct 
+@@ -816,7 +816,7 @@ int ath9k_init_device(u16 devid, struct 
  
  #ifdef CPTCFG_MAC80211_LEDS
        /* must be initialized before ieee80211_register_hw */
index f36a0e6..309c1c6 100644 (file)
                REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, AR_BTCOEX_WL_LNADIV_FORCE_ON);
 --- a/drivers/net/wireless/ath/ath9k/main.c
 +++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -606,6 +606,11 @@ irqreturn_t ath_isr(int irq, void *dev)
+@@ -603,6 +603,11 @@ irqreturn_t ath_isr(int irq, void *dev)
        ath9k_debug_sync_cause(sc, sync_cause);
        status &= ah->imask;    /* discard unasked-for bits */
  
index 2483744..e4c01be 100644 (file)
@@ -58,7 +58,7 @@
  };
 --- a/drivers/net/wireless/ath/ath9k/init.c
 +++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -518,6 +518,8 @@ static int ath9k_init_softc(u16 devid, s
+@@ -522,6 +522,8 @@ static int ath9k_init_softc(u16 devid, s
                ah->is_clk_25mhz = pdata->is_clk_25mhz;
                ah->get_mac_revision = pdata->get_mac_revision;
                ah->external_reset = pdata->external_reset;
index f16f6b0..22b9e2e 100644 (file)
@@ -55,7 +55,7 @@
        ops->spectral_scan_config = ar9003_hw_spectral_scan_config;
 --- a/drivers/net/wireless/ath/ath9k/init.c
 +++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -646,7 +646,8 @@ static void ath9k_init_txpower_limits(st
+@@ -650,7 +650,8 @@ static void ath9k_init_txpower_limits(st
        if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
                ath9k_init_band_txpower(sc, IEEE80211_BAND_5GHZ);
  
@@ -65,7 +65,7 @@
  }
  
  static const struct ieee80211_iface_limit if_limits[] = {
-@@ -774,6 +775,18 @@ static void ath9k_set_hw_capab(struct at
+@@ -778,6 +779,18 @@ static void ath9k_set_hw_capab(struct at
        SET_IEEE80211_PERM_ADDR(hw, common->macaddr);
  }
  
@@ -84,7 +84,7 @@
  int ath9k_init_device(u16 devid, struct ath_softc *sc,
                    const struct ath_bus_ops *bus_ops)
  {
-@@ -822,6 +835,8 @@ int ath9k_init_device(u16 devid, struct 
+@@ -823,6 +836,8 @@ int ath9k_init_device(u16 devid, struct 
                ARRAY_SIZE(ath9k_tpt_blink));
  #endif
  
index 47a7d82..6d901c2 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/main.c
 +++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -628,8 +628,7 @@ irqreturn_t ath_isr(int irq, void *dev)
+@@ -625,8 +625,7 @@ irqreturn_t ath_isr(int irq, void *dev)
         * If a FATAL or RXORN interrupt is received, we have to reset the
         * chip immediately.
         */