Skip to contentSkip to conversation

ath9k: Fix calibration for AR9462

PATCH In review Sujith Manoharan 2 participants 6 messages Sep 11, 2013 – Sep 12, 2013 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ath9k: Fix calibration for AR9462

From: Sujith Manoharan <[email protected]>

TX IQ calibration is disabled by default for AR9462, this is done using the initvals (reg 0xa644).

But, to compensate for this, the AR_PHY_RX_DELAY register should be set to the max allowed value when performing calibration.

---
 drivers/net/wireless/ath/ath9k/ar9003_calib.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/net/wireless/ath/ath9k/ar9003_calib.c +15 -0
index 6988e1d..6001bc0 100644
@@ -1019,6 +1019,7 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah,
 	bool is_reusable = true, status = true;
 	bool run_rtt_cal = false, run_agc_cal, sep_iq_cal = false;
 	bool rtt = !!(ah->caps.hw_caps & ATH9K_HW_CAP_RTT);
+	u32 rx_delay = 0;
 	u32 agc_ctrl = 0, agc_supp_cals = AR_PHY_AGC_CONTROL_OFFSET_CAL |
 					  AR_PHY_AGC_CONTROL_FLTR_CAL   |
 					  AR_PHY_AGC_CONTROL_PKDET_CAL;
@@ -1099,6 +1100,15 @@ skip_tx_iqcal:
 		REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
 	}
 
+	if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE) {
+		rx_delay = REG_READ(ah, AR_PHY_RX_DELAY);
+		/* Disable BB_active */
+		REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
+		udelay(5);
+		REG_WRITE(ah, AR_PHY_RX_DELAY, AR_PHY_RX_DELAY_DELAY);
+		REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
+	}
+
 	if (run_agc_cal || !(ah->ah_flags & AH_FASTCC)) {
 		/* Calibrate the AGC */
 		REG_WRITE(ah, AR_PHY_AGC_CONTROL,
@@ -1113,6 +1123,11 @@ skip_tx_iqcal:
 		ar9003_hw_do_manual_peak_cal(ah, chan);
 	}
 
+	if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE) {
+		REG_WRITE(ah, AR_PHY_RX_DELAY, rx_delay);
+		udelay(5);
+	}
+
 	if (ath9k_hw_mci_is_enabled(ah) && IS_CHAN_2GHZ(chan) && run_agc_cal)
 		ar9003_mci_init_cal_done(ah);
 
Signature · 1 line
1.8.4
#1 lore raw

PATCH 2/3 ath9k: Fix issue with parsing malformed CFP IE

From: Sujith Manoharan <[email protected]>

All QCA chips have the ability to parse the CF Parameter Set IE in beacons. If the IE is malformed in the beacons from some APs [1], the HW locks up. In AP mode, a beacon stuck would happen and in client mode, a disconnection usually is the result.

To fix this issue, set the AR_PCU_MISC_MODE2_CFP_IGNORE to ignore the CFP IE in beacons - this is applicable for all chips. For AP mode, if this issue happens, the NAV is also corrupted and has to be reset - this will be done in a subsequent patch.

[1] : http://msujith.org/ath9k/cfp/Malformed-CF-Param.png

---
 drivers/net/wireless/ath/ath9k/ar5008_phy.c | 2 ++
 drivers/net/wireless/ath/ath9k/ar9003_phy.c | 6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/ar5008_phy.c +2 -0
index 0865647..9e4e2a6 100644
@@ -626,6 +626,8 @@ static void ar5008_hw_override_ini(struct ath_hw *ah,
 		if (AR_SREV_9287_11_OR_LATER(ah))
 			val = val & (~AR_PCU_MISC_MODE2_HWWAR2);
 
+		val |= AR_PCU_MISC_MODE2_CFP_IGNORE;
+
 		REG_WRITE(ah, AR_PCU_MISC_MODE2, val);
 	}
 
drivers/net/wireless/ath/ath9k/ar9003_phy.c +4 -2
index b8a279e..ec37213 100644
@@ -627,8 +627,10 @@ static void ar9003_hw_override_ini(struct ath_hw *ah)
 	 * MAC addr only will fail.
 	 */
 	val = REG_READ(ah, AR_PCU_MISC_MODE2) & (~AR_ADHOC_MCAST_KEYID_ENABLE);
-	REG_WRITE(ah, AR_PCU_MISC_MODE2,
-		  val | AR_AGG_WEP_ENABLE_FIX | AR_AGG_WEP_ENABLE);
+	val |= AR_AGG_WEP_ENABLE_FIX |
+	       AR_AGG_WEP_ENABLE |
+	       AR_PCU_MISC_MODE2_CFP_IGNORE;
+	REG_WRITE(ah, AR_PCU_MISC_MODE2, val);
 
 	REG_SET_BIT(ah, AR_PHY_CCK_DETECT,
 		    AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV);
Signature · 1 line
1.8.4
#3 lore raw

Re: [PATCH 2/3] ath9k: Fix issue with parsing malformed CFP IE

Quoted 6 lines · Kalle Valo
Quoted 1 line · Sujith Manoharan

[1] : http://msujith.org/ath9k/cfp/Malformed-CF-Param.png

Not that it matters anything, but tshark most likely would have given you ASCII output of that :)

Unfortunately, I don't have the actual trace, just the pic. I got this from a Field Engineer.

Sujith

#4 lore raw

PATCH 3/3 ath9k: Handle abnormal NAV in AP mode

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

Beacon transmission would get stuck if the NAV is an invalid value for some reason. Check and correct the NAV value in the HW when this happens.

---
 drivers/net/wireless/ath/ath9k/beacon.c |  2 ++
 drivers/net/wireless/ath/ath9k/hw.c     | 13 +++++++++++++
 drivers/net/wireless/ath/ath9k/hw.h     |  1 +
 3 files changed, 16 insertions(+)
drivers/net/wireless/ath/ath9k/beacon.c +2 -0
index b5c16b3a..17be353 100644
@@ -334,6 +334,8 @@ void ath9k_beacon_tasklet(unsigned long data)
 	if (ath9k_hw_numtxpending(ah, sc->beacon.beaconq) != 0) {
 		sc->beacon.bmisscnt++;
 
+		ath9k_hw_check_nav(ah);
+
 		if (!ath9k_hw_check_alive(ah))
 			ieee80211_queue_work(sc->hw, &sc->hw_check_work);
 
drivers/net/wireless/ath/ath9k/hw.c +13 -0
index 260e0c6..7d6e35d 100644
@@ -1656,6 +1656,19 @@ hang_check_iter:
 	return true;
 }
 
+void ath9k_hw_check_nav(struct ath_hw *ah)
+{
+	struct ath_common *common = ath9k_hw_common(ah);
+	u32 val;
+
+	val = REG_READ(ah, 0x8084);
+	if (val != 0xdeadbeef && val > 0x7fff) {
+		ath_dbg(common, BSTUCK, "Abnormal NAV: 0x%x\n", val);
+		REG_WRITE(ah, 0x8084, 0);
+	}
+}
+EXPORT_SYMBOL(ath9k_hw_check_nav);
+
 bool ath9k_hw_check_alive(struct ath_hw *ah)
 {
 	int count = 50;
drivers/net/wireless/ath/ath9k/hw.h +1 -0
index 88f67c3..8e1c675 100644
@@ -1031,6 +1031,7 @@ void ath9k_hw_set11nmac2040(struct ath_hw *ah);
 void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period);
 void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
 				    const struct ath9k_beacon_state *bs);
+void ath9k_hw_check_nav(struct ath_hw *ah);
 bool ath9k_hw_check_alive(struct ath_hw *ah);
 
 bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode);
Signature · 1 line
1.8.4
#5 lore raw

PATCH v2 3/3 ath9k: Handle abnormal NAV in AP mode

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

Beacon transmission would get stuck if the NAV is an invalid value for some reason. Check and correct the NAV value in the HW when this happens.

---
v2 - Use AR_NAV macro instead of the register address.

 drivers/net/wireless/ath/ath9k/beacon.c |  2 ++
 drivers/net/wireless/ath/ath9k/hw.c     | 13 +++++++++++++
 drivers/net/wireless/ath/ath9k/hw.h     |  1 +
 3 files changed, 16 insertions(+)
drivers/net/wireless/ath/ath9k/beacon.c +2 -0
index b5c16b3a..17be353 100644
@@ -334,6 +334,8 @@ void ath9k_beacon_tasklet(unsigned long data)
 	if (ath9k_hw_numtxpending(ah, sc->beacon.beaconq) != 0) {
 		sc->beacon.bmisscnt++;
 
+		ath9k_hw_check_nav(ah);
+
 		if (!ath9k_hw_check_alive(ah))
 			ieee80211_queue_work(sc->hw, &sc->hw_check_work);
 
drivers/net/wireless/ath/ath9k/hw.c +13 -0
index 260e0c6..11ed897 100644
@@ -1656,6 +1656,19 @@ hang_check_iter:
 	return true;
 }
 
+void ath9k_hw_check_nav(struct ath_hw *ah)
+{
+	struct ath_common *common = ath9k_hw_common(ah);
+	u32 val;
+
+	val = REG_READ(ah, AR_NAV);
+	if (val != 0xdeadbeef && val > 0x7fff) {
+		ath_dbg(common, BSTUCK, "Abnormal NAV: 0x%x\n", val);
+		REG_WRITE(ah, AR_NAV, 0);
+	}
+}
+EXPORT_SYMBOL(ath9k_hw_check_nav);
+
 bool ath9k_hw_check_alive(struct ath_hw *ah)
 {
 	int count = 50;
drivers/net/wireless/ath/ath9k/hw.h +1 -0
index 88f67c3..8e1c675 100644
@@ -1031,6 +1031,7 @@ void ath9k_hw_set11nmac2040(struct ath_hw *ah);
 void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period);
 void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
 				    const struct ath9k_beacon_state *bs);
+void ath9k_hw_check_nav(struct ath_hw *ah);
 bool ath9k_hw_check_alive(struct ath_hw *ah);
 
 bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode);
Signature · 1 line
1.8.4