ath9k: add some calibration fixes from wireless-testing
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 300-pending_work.patch
index 6b8508f59914b608e9ee6bbe6aa3e16795a7c7c4..87493e488eec7b7a8b59d25dbce75a9f7e1d35c3 100644 (file)
  static DECLARE_WORK(reg_regdb_work, reg_regdb_search);
 --- a/drivers/net/wireless/ath/ath9k/recv.c
 +++ b/drivers/net/wireless/ath/ath9k/recv.c
-@@ -424,8 +424,8 @@ u32 ath_calcrxfilter(struct ath_softc *s
+@@ -286,7 +286,6 @@ int ath_rx_init(struct ath_softc *sc, in
+       spin_lock_init(&sc->sc_pcu_lock);
+       spin_lock_init(&sc->rx.rxbuflock);
+-      clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
+       common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 +
+                            sc->sc_ah->caps.rx_status_len;
+@@ -424,8 +423,8 @@ u32 ath_calcrxfilter(struct ath_softc *s
                rfilt |= ATH9K_RX_FILTER_COMP_BAR;
  
        if (sc->nvifs > 1 || (sc->rx.rxfilter & FIF_OTHER_BSS)) {
                        rfilt |= ATH9K_RX_FILTER_PROM;
                rfilt |= ATH9K_RX_FILTER_MCAST_BCAST_ALL;
        }
+@@ -473,6 +472,13 @@ start_recv:
+       return 0;
+ }
++static void ath_flushrecv(struct ath_softc *sc)
++{
++      if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
++              ath_rx_tasklet(sc, 1, true);
++      ath_rx_tasklet(sc, 1, false);
++}
++
+ bool ath_stoprecv(struct ath_softc *sc)
+ {
+       struct ath_hw *ah = sc->sc_ah;
+@@ -483,6 +489,8 @@ bool ath_stoprecv(struct ath_softc *sc)
+       ath9k_hw_setrxfilter(ah, 0);
+       stopped = ath9k_hw_stopdmarecv(ah, &reset);
++      ath_flushrecv(sc);
++
+       if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
+               ath_edma_stop_recv(sc);
+       else
+@@ -499,15 +507,6 @@ bool ath_stoprecv(struct ath_softc *sc)
+       return stopped && !reset;
+ }
+-void ath_flushrecv(struct ath_softc *sc)
+-{
+-      set_bit(SC_OP_RXFLUSH, &sc->sc_flags);
+-      if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
+-              ath_rx_tasklet(sc, 1, true);
+-      ath_rx_tasklet(sc, 1, false);
+-      clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
+-}
+-
+ static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb)
+ {
+       /* Check whether the Beacon frame has DTIM indicating buffered bc/mc */
+@@ -744,6 +743,7 @@ static struct ath_buf *ath_get_next_rx_b
+                       return NULL;
+       }
++      list_del(&bf->list);
+       if (!bf->bf_mpdu)
+               return bf;
+@@ -1066,9 +1066,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
+       do {
+               bool decrypt_error = false;
+-              /* If handling rx interrupt and flush is in progress => exit */
+-              if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags) && (flush == 0))
+-                      break;
+               memset(&rs, 0, sizeof(rs));
+               if (edma)
+@@ -1108,15 +1105,6 @@ int ath_rx_tasklet(struct ath_softc *sc,
+               sc->rx.num_pkts++;
+               ath_debug_stat_rx(sc, &rs);
+-              /*
+-               * If we're asked to flush receive queue, directly
+-               * chain it back at the queue without processing it.
+-               */
+-              if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags)) {
+-                      RX_STAT_INC(rx_drop_rxflush);
+-                      goto requeue_drop_frag;
+-              }
+-
+               memset(rxs, 0, sizeof(struct ieee80211_rx_status));
+               rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
+@@ -1251,14 +1239,15 @@ requeue_drop_frag:
+                       sc->rx.frag = NULL;
+               }
+ requeue:
++              list_add_tail(&bf->list, &sc->rx.rxbuf);
++              if (flush)
++                      continue;
++
+               if (edma) {
+-                      list_add_tail(&bf->list, &sc->rx.rxbuf);
+                       ath_rx_edma_buf_link(sc, qtype);
+               } else {
+-                      list_move_tail(&bf->list, &sc->rx.rxbuf);
+                       ath_rx_buf_link(sc, bf);
+-                      if (!flush)
+-                              ath9k_hw_rxena(ah);
++                      ath9k_hw_rxena(ah);
+               }
+       } while (1);
 --- a/net/mac80211/mlme.c
 +++ b/net/mac80211/mlme.c
 @@ -818,23 +818,71 @@ void ieee80211_sta_process_chanswitch(st
                return;
        }
  
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -2568,7 +2568,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw
+       if (AR_SREV_9300_20_OR_LATER(ah)) {
+               ah->enabled_cals |= TX_IQ_CAL;
+-              if (AR_SREV_9485_OR_LATER(ah))
++              if (AR_SREV_9485_OR_LATER(ah) && !AR_SREV_9340(ah))
+                       ah->enabled_cals |= TX_IQ_ON_AGC_CAL;
+       }
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -324,7 +324,6 @@ struct ath_rx {
+ int ath_startrecv(struct ath_softc *sc);
+ bool ath_stoprecv(struct ath_softc *sc);
+-void ath_flushrecv(struct ath_softc *sc);
+ u32 ath_calcrxfilter(struct ath_softc *sc);
+ int ath_rx_init(struct ath_softc *sc, int nbufs);
+ void ath_rx_cleanup(struct ath_softc *sc);
+@@ -627,7 +626,6 @@ void ath_ant_comb_update(struct ath_soft
+ enum sc_op_flags {
+       SC_OP_INVALID,
+       SC_OP_BEACONS,
+-      SC_OP_RXFLUSH,
+       SC_OP_ANI_RUN,
+       SC_OP_PRIM_STA_VIF,
+       SC_OP_HW_RESET,
+--- a/drivers/net/wireless/ath/ath9k/beacon.c
++++ b/drivers/net/wireless/ath/ath9k/beacon.c
+@@ -147,6 +147,7 @@ static struct ath_buf *ath9k_beacon_gene
+                                skb->len, DMA_TO_DEVICE);
+               dev_kfree_skb_any(skb);
+               bf->bf_buf_addr = 0;
++              bf->bf_mpdu = NULL;
+       }
+       skb = ieee80211_beacon_get(hw, vif);
+@@ -359,7 +360,6 @@ void ath9k_beacon_tasklet(unsigned long 
+               return;
+       bf = ath9k_beacon_generate(sc->hw, vif);
+-      WARN_ON(!bf);
+       if (sc->beacon.bmisscnt != 0) {
+               ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n",
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -919,7 +919,6 @@ static ssize_t read_file_recv(struct fil
+       RXS_ERR("RX-LENGTH-ERR", rx_len_err);
+       RXS_ERR("RX-OOM-ERR", rx_oom_err);
+       RXS_ERR("RX-RATE-ERR", rx_rate_err);
+-      RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush);
+       RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err);
+       PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
+--- a/drivers/net/wireless/ath/ath9k/debug.h
++++ b/drivers/net/wireless/ath/ath9k/debug.h
+@@ -198,7 +198,6 @@ struct ath_tx_stats {
+  * @rx_oom_err:  No. of frames dropped due to OOM issues.
+  * @rx_rate_err:  No. of frames dropped due to rate errors.
+  * @rx_too_many_frags_err:  Frames dropped due to too-many-frags received.
+- * @rx_drop_rxflush: No. of frames dropped due to RX-FLUSH.
+  * @rx_beacons:  No. of beacons received.
+  * @rx_frags:  No. of rx-fragements received.
+  */
+@@ -217,7 +216,6 @@ struct ath_rx_stats {
+       u32 rx_oom_err;
+       u32 rx_rate_err;
+       u32 rx_too_many_frags_err;
+-      u32 rx_drop_rxflush;
+       u32 rx_beacons;
+       u32 rx_frags;
+ };
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -181,7 +181,7 @@ static void ath_restart_work(struct ath_
+       ath_start_ani(sc);
+ }
+-static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)
++static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx)
+ {
+       struct ath_hw *ah = sc->sc_ah;
+       bool ret = true;
+@@ -195,19 +195,15 @@ static bool ath_prepare_reset(struct ath
+       ath9k_debug_samp_bb_mac(sc);
+       ath9k_hw_disable_interrupts(ah);
++      tasklet_disable(&sc->intr_tq);
++
+       if (!ath_stoprecv(sc))
+               ret = false;
+       if (!ath_drain_all_txq(sc, retry_tx))
+               ret = false;
+-      if (!flush) {
+-              if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
+-                      ath_rx_tasklet(sc, 1, true);
+-              ath_rx_tasklet(sc, 1, false);
+-      } else {
+-              ath_flushrecv(sc);
+-      }
++      tasklet_enable(&sc->intr_tq);
+       return ret;
+ }
+@@ -261,7 +257,6 @@ static int ath_reset_internal(struct ath
+       struct ath_common *common = ath9k_hw_common(ah);
+       struct ath9k_hw_cal_data *caldata = NULL;
+       bool fastcc = true;
+-      bool flush = false;
+       int r;
+       __ath_cancel_work(sc);
+@@ -275,11 +270,10 @@ static int ath_reset_internal(struct ath
+       if (!hchan) {
+               fastcc = false;
+-              flush = true;
+               hchan = ah->curchan;
+       }
+-      if (!ath_prepare_reset(sc, retry_tx, flush))
++      if (!ath_prepare_reset(sc, retry_tx))
+               fastcc = false;
+       ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n",
+@@ -821,7 +815,7 @@ static void ath9k_stop(struct ieee80211_
+               ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
+       }
+-      ath_prepare_reset(sc, false, true);
++      ath_prepare_reset(sc, false);
+       if (sc->rx.frag) {
+               dev_kfree_skb_any(sc->rx.frag);
+--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+@@ -893,7 +893,7 @@ static bool ar9003_hw_init_cal(struct at
+       struct ath9k_hw_cal_data *caldata = ah->caldata;
+       bool txiqcal_done = false, txclcal_done = false;
+       bool is_reusable = true, status = true;
+-      bool run_rtt_cal = false, run_agc_cal;
++      bool run_rtt_cal = false, run_agc_cal, sep_iq_cal = false;
+       bool rtt = !!(ah->caps.hw_caps & ATH9K_HW_CAP_RTT);
+       u32 agc_ctrl = 0, agc_supp_cals = AR_PHY_AGC_CONTROL_OFFSET_CAL |
+                                         AR_PHY_AGC_CONTROL_FLTR_CAL   |
+@@ -939,7 +939,8 @@ static bool ar9003_hw_init_cal(struct at
+               }
+       }
+-      if (!(ah->enabled_cals & TX_IQ_CAL))
++      if ((IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan)) ||
++          !(ah->enabled_cals & TX_IQ_CAL))
+               goto skip_tx_iqcal;
+       /* Do Tx IQ Calibration */
+@@ -959,21 +960,22 @@ static bool ar9003_hw_init_cal(struct at
+                       REG_CLR_BIT(ah, AR_PHY_TX_IQCAL_CONTROL_0,
+                                   AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL);
+               txiqcal_done = run_agc_cal = true;
+-              goto skip_tx_iqcal;
+-      } else if (caldata && !caldata->done_txiqcal_once)
++      } else if (caldata && !caldata->done_txiqcal_once) {
+               run_agc_cal = true;
++              sep_iq_cal = true;
++      }
++skip_tx_iqcal:
+       if (ath9k_hw_mci_is_enabled(ah) && IS_CHAN_2GHZ(chan) && run_agc_cal)
+               ar9003_mci_init_cal_req(ah, &is_reusable);
+-      if (!(IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan))) {
++      if (sep_iq_cal) {
+               txiqcal_done = ar9003_hw_tx_iq_cal_run(ah);
+               REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
+               udelay(5);
+               REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
+       }
+-skip_tx_iqcal:
+       if (run_agc_cal || !(ah->ah_flags & AH_FASTCC)) {
+               /* Calibrate the AGC */
+               REG_WRITE(ah, AR_PHY_AGC_CONTROL,