Skip to contentSkip to conversation

ath9k_htc: Add ath9k_htc driver

PATCH In review Sujith 5 participants 9 messages Feb 26, 2010 – Mar 6, 2010

Subsystems (2)
lore
Share & tools
lore

Sujith

author
#0 lore raw

PATCH 1/1 ath9k_htc: Add ath9k_htc driver

Support for AR9271 chipset.

Features:

* Station mode
* IBSS mode
* Legacy support
* HT support
* TX/RX 11n Aggregation
* HW encryption
* LED

For more information: http://wireless.kernel.org/en/users/Drivers/ath9k_htc

---
 drivers/net/wireless/ath/Kconfig                |    2 +-
 drivers/net/wireless/ath/ath9k/Kconfig          |   20 +
 drivers/net/wireless/ath/ath9k/Makefile         |   11 +
 drivers/net/wireless/ath/ath9k/calib.c          |   27 +-
 drivers/net/wireless/ath/ath9k/calib.h          |    1 +
 drivers/net/wireless/ath/ath9k/hif_usb.c        |  929 +++++++++++++
 drivers/net/wireless/ath/ath9k/hif_usb.h        |  105 ++
 drivers/net/wireless/ath/ath9k/htc.h            |  416 ++++++
 drivers/net/wireless/ath/ath9k/htc_drv_beacon.c |  260 ++++
 drivers/net/wireless/ath/ath9k/htc_drv_init.c   |  691 ++++++++++
 drivers/net/wireless/ath/ath9k/htc_drv_main.c   | 1580 +++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c   |  568 ++++++++
 drivers/net/wireless/ath/ath9k/htc_hst.c        |  460 +++++++
 drivers/net/wireless/ath/ath9k/htc_hst.h        |  246 ++++
 drivers/net/wireless/ath/ath9k/hw.c             |  145 ++-
 drivers/net/wireless/ath/ath9k/hw.h             |    8 +
 drivers/net/wireless/ath/ath9k/init.c           |    3 +
 drivers/net/wireless/ath/ath9k/initvals.h       |  141 ++-
 drivers/net/wireless/ath/ath9k/lib.c            |  487 +++++++
 drivers/net/wireless/ath/ath9k/lib.h            |   85 ++
 drivers/net/wireless/ath/ath9k/mac.c            |    2 +-
 drivers/net/wireless/ath/ath9k/mac.h            |   26 +
 drivers/net/wireless/ath/ath9k/phy.c            |    6 +-
 drivers/net/wireless/ath/ath9k/reg.h            |    3 +
 drivers/net/wireless/ath/ath9k/wmi.c            |  319 +++++
 drivers/net/wireless/ath/ath9k/wmi.h            |  125 ++
 drivers/net/wireless/ath/debug.h                |    1 +
 27 files changed, 6544 insertions(+), 123 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/hif_usb.c
 create mode 100644 drivers/net/wireless/ath/ath9k/hif_usb.h
 create mode 100644 drivers/net/wireless/ath/ath9k/htc.h
 create mode 100644 drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
 create mode 100644 drivers/net/wireless/ath/ath9k/htc_drv_init.c
 create mode 100644 drivers/net/wireless/ath/ath9k/htc_drv_main.c
 create mode 100644 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
 create mode 100644 drivers/net/wireless/ath/ath9k/htc_hst.c
 create mode 100644 drivers/net/wireless/ath/ath9k/htc_hst.h
 create mode 100644 drivers/net/wireless/ath/ath9k/lib.c
 create mode 100644 drivers/net/wireless/ath/ath9k/lib.h
 create mode 100644 drivers/net/wireless/ath/ath9k/wmi.c
 create mode 100644 drivers/net/wireless/ath/ath9k/wmi.h
drivers/net/wireless/ath/Kconfig +1 -1
index 4e7a7fd..0a75be0 100644
@@ -3,7 +3,7 @@ menuconfig ATH_COMMON
 	depends on CFG80211
 	---help---
 	  This will enable the support for the Atheros wireless drivers.
-	  ath5k, ath9k and ar9170 drivers share some common code, this option
+	  ath5k, ath9k, ath9k_htc and ar9170 drivers share some common code, this option
 	  enables the common ath.ko module which shares common helpers.
 
 	  For more information and documentation on this module you can visit:
drivers/net/wireless/ath/ath9k/Kconfig +20 -0
index 5774cea..fd28803 100644
@@ -32,3 +32,23 @@ config ATH9K_DEBUGFS
 
 	  Also required for changing debug message flags at run time.
 
+config ATH9K_HTC
+       tristate "Atheros HTC based wireless cards support"
+       depends on USB && MAC80211
+       select ATH9K_HW
+       select MAC80211_LEDS
+       select LEDS_CLASS
+       select NEW_LEDS
+       ---help---
+	 Support for Atheros HTC based cards.
+	 Chipsets supported: AR9271
+
+	 For more information: http://wireless.kernel.org/en/users/Drivers/ath9k_htc
+
+	 The built module will be ath9k_htc.
+
+config ATH9K_HTC_DEBUGFS
+	bool "Atheros ath9k_htc debugging"
+	depends on ATH9K_HTC && DEBUG_FS
+	---help---
+	  Say Y, if you need access to ath9k_htc's statistics.
drivers/net/wireless/ath/ath9k/Makefile +11 -0
index 6b50d5e..b1af5d5 100644
@@ -28,3 +28,14 @@ obj-$(CONFIG_ATH9K_HW) += ath9k_hw.o
 
 obj-$(CONFIG_ATH9K_COMMON) += ath9k_common.o
 ath9k_common-y:=	common.o
+
+ath9k_htc-y +=	htc_hst.o \
+		hif_usb.o \
+		wmi.o \
+		htc_drv_txrx.o \
+		htc_drv_main.o \
+		htc_drv_beacon.o \
+		htc_drv_init.o \
+		lib.o
+
+obj-$(CONFIG_ATH9K_HTC) += ath9k_htc.o
drivers/net/wireless/ath/ath9k/calib.c +21 -6
index 238a574..f8d4da6 100644
@@ -101,9 +101,13 @@ static void ath9k_hw_do_getnf(struct ath_hw *ah,
 		nf = 0 - ((nf ^ 0x1ff) + 1);
 	ath_print(common, ATH_DBG_CALIBRATE,
 		  "NF calibrated [ctl] [chain 0] is %d\n", nf);
+
+	if (AR_SREV_9271(ah))
+		if (nf >= -114)
+			nf = -116;
 	nfarray[0] = nf;
 
-	if (!AR_SREV_9285(ah)) {
+	if (!AR_SREV_9285(ah) && !AR_SREV_9271(ah)) {
 		if (AR_SREV_9280_10_OR_LATER(ah))
 			nf = MS(REG_READ(ah, AR_PHY_CH1_CCA),
 					AR9280_PHY_CH1_MINCCA_PWR);
@@ -139,6 +143,11 @@ static void ath9k_hw_do_getnf(struct ath_hw *ah,
 		nf = 0 - ((nf ^ 0x1ff) + 1);
 	ath_print(common, ATH_DBG_CALIBRATE,
 		  "NF calibrated [ext] [chain 0] is %d\n", nf);
+
+	if (AR_SREV_9271(ah))
+		if (nf >= -114)
+			nf = -116;
+
 	nfarray[3] = nf;
 
 	if (!AR_SREV_9285(ah)) {
@@ -621,7 +630,7 @@ void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
 	u8 chainmask, rx_chain_status;
 
 	rx_chain_status = REG_READ(ah, AR_PHY_RX_CHAINMASK);
-	if (AR_SREV_9285(ah))
+	if (AR_SREV_9285(ah) || AR_SREV_9271(ah))
 		chainmask = 0x9;
 	else if (AR_SREV_9280(ah) || AR_SREV_9287(ah)) {
 		if ((rx_chain_status & 0x2) || (rx_chain_status & 0x4))
@@ -715,7 +724,7 @@ void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah)
 
 	if (AR_SREV_9280(ah))
 		noise_floor = AR_PHY_CCA_MAX_AR9280_GOOD_VALUE;
-	else if (AR_SREV_9285(ah))
+	else if (AR_SREV_9285(ah) || AR_SREV_9271(ah))
 		noise_floor = AR_PHY_CCA_MAX_AR9285_GOOD_VALUE;
 	else if (AR_SREV_9287(ah))
 		noise_floor = AR_PHY_CCA_MAX_AR9287_GOOD_VALUE;
@@ -815,6 +824,7 @@ static void ath9k_olc_temp_compensation(struct ath_hw *ah)
 
 static void ath9k_hw_9271_pa_cal(struct ath_hw *ah, bool is_reset)
 {
+	struct ath_common *common = ath9k_hw_common(ah);
 	u32 regVal;
 	unsigned int i;
 	u32 regList [][2] = {
@@ -828,6 +838,8 @@ static void ath9k_hw_9271_pa_cal(struct ath_hw *ah, bool is_reset)
 		{ 0x7828, 0 } ,
 	};
 
+	ath_print(common, ATH_DBG_CALIBRATE, "Running PA Calibration\n");
+
 	for (i = 0; i < ARRAY_SIZE(regList); i++)
 		regList[i][1] = REG_READ(ah, regList[i][0]);
 
@@ -1051,9 +1063,12 @@ bool ath9k_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
 	/* Do NF cal only at longer intervals */
 	if (longcal) {
 		/* Do periodic PAOffset Cal */
-		if (AR_SREV_9271(ah))
-			ath9k_hw_9271_pa_cal(ah, false);
-		else if (AR_SREV_9285_11_OR_LATER(ah)) {
+		if (AR_SREV_9271(ah)) {
+			if (!ah->pacal_info.skipcount)
+				ath9k_hw_9271_pa_cal(ah, false);
+			else
+				ah->pacal_info.skipcount--;
+		} else if (AR_SREV_9285_11_OR_LATER(ah)) {
 			if (!ah->pacal_info.skipcount)
 				ath9k_hw_9285_pa_cal(ah, false);
 			else
drivers/net/wireless/ath/ath9k/calib.h +1 -0
index b2c873e..3b634d4 100644
@@ -114,6 +114,7 @@ struct ath9k_nfcal_hist {
 };
 
 #define MAX_PACAL_SKIPCOUNT 8
+
 struct ath9k_pacal_info{
 	int32_t prev_offset;	/* Previous value of PA offset value */
 	int8_t max_skipcount;	/* Max No. of times PACAL can be skipped */
drivers/net/wireless/ath/ath9k/hif_usb.c new file +929 -0

929 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/hif_usb.h new file +105 -0

105 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/htc.h new file +416 -0

416 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/htc_drv_beacon.c new file +260 -0

260 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/htc_drv_init.c new file +691 -0

691 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/htc_drv_main.c new file +1580 -0

476 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/htc_drv_txrx.c new file +568 -0

568 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/htc_hst.c new file +460 -0

460 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/htc_hst.h new file +246 -0

246 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/hw.c +74 -71

145 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/hw.h +8 -0
index dbbf7ca..608ec77 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/ath/ath9k/init.c +3 -0
index 623c2f8..6063f54 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/ath/ath9k/initvals.h +102 -39

141 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/lib.c new file +487 -0

487 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/lib.h new file +85 -0

85 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/mac.c +1 -1
index efc420c..e19c823 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/ath/ath9k/mac.h +26 -0
index 29851e6..a5e543b 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/ath/ath9k/phy.c +1 -5
index c3b5939..10e68cb 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/ath/ath9k/reg.h +3 -0
index 72cfa8e..198e41d 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/ath/ath9k/wmi.c new file +319 -0

319 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/wmi.h new file +125 -0

125 lines not on this page · raw message

drivers/net/wireless/ath/debug.h +1 -0
index 8263633..873bf52 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.0

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 1 line · Sujith

Support for AR9271 chipset.

Great news!!!

drivers/net/wireless/ath/ath9k/calib.h struct ath9k_nfcal_hist { · line 118

Quoted 8 lines
drivers/net/wireless/ath/ath9k/calib.h +1 -0
@@ -114,6 +114,7 @@ struct ath9k_nfcal_hist {
 };
 
 #define MAX_PACAL_SKIPCOUNT 8
+
 struct ath9k_pacal_info{

You may want to omit this part ;-)

drivers/net/wireless/ath/ath9k/calib.h void ath9k_hw_deinit(struct ath_hw *ah) · line 1234

Quoted 9 lines
drivers/net/wireless/ath/ath9k/calib.h +1 -1
@@ -1240,7 +1228,7 @@ void ath9k_hw_deinit(struct ath_hw *ah)
 {
 	struct ath_common *common = ath9k_hw_common(ah);
 
-	if (common->state <= ATH_HW_INITIALIZED)
+	if (common->state < ATH_HW_INITIALIZED)
 		goto free_hw;
 
 	if (!AR_SREV_9100(ah))

There are some non-trivial parts like this one that could be submitted separately.

drivers/net/wireless/ath/ath9k/calib.h void ath9k_hw_deinit(struct ath_hw *ah) · line 1255

Quoted 9 lines
drivers/net/wireless/ath/ath9k/calib.h +1 -3
@@ -1249,10 +1237,8 @@ void ath9k_hw_deinit(struct ath_hw *ah)
 	ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP);
 
 free_hw:
-	if (!AR_SREV_9280_10_OR_LATER(ah))
+	if (!AR_SREV_9280_10_OR_LATER(ah) && !AR_SREV_9271(ah))
 		ath9k_hw_rf_free_ext_banks(ah);
-	kfree(ah);
-	ah = NULL;

Another one. Actually, it is trivial, but not ath9k_htc related.

It would be really nice to fast track the ath9k_htc driver to 2.6.34, but the changes affecting other devices should be separate, I believe.

Signature · 2 lines
Regards,
Pavel Roskin
#2 lore raw
Quoted 42 lines · Pavel Roskin
Quoted 1 line · Sujith

Support for AR9271 chipset.

Great news!!!

drivers/net/wireless/ath/ath9k/calib.h struct ath9k_nfcal_hist { · line 118

Quoted 8 lines
drivers/net/wireless/ath/ath9k/calib.h +1 -0
@@ -114,6 +114,7 @@ struct ath9k_nfcal_hist {
  };
 
  #define MAX_PACAL_SKIPCOUNT 8
+
  struct ath9k_pacal_info{

You may want to omit this part ;-)

drivers/net/wireless/ath/ath9k/calib.h void ath9k_hw_deinit(struct ath_hw *ah) · line 1234

Quoted 9 lines
drivers/net/wireless/ath/ath9k/calib.h +1 -1
@@ -1240,7 +1228,7 @@ void ath9k_hw_deinit(struct ath_hw *ah)
  {
       struct ath_common *common = ath9k_hw_common(ah);
 
-     if (common->state <= ATH_HW_INITIALIZED)
+     if (common->state < ATH_HW_INITIALIZED)
               goto free_hw;
 
       if (!AR_SREV_9100(ah))

There are some non-trivial parts like this one that could be submitted separately.

Quoted 9 lines
drivers/net/wireless/ath/ath9k/calib.h +0 -0
@@ -1249,10 +1237,8 @@ void ath9k_hw_deinit(struct ath_hw *ah)
       ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP);
 

 free_hw:
-     if (!AR_SREV_9280_10_OR_LATER(ah))
+     if (!AR_SREV_9280_10_OR_LATER(ah) && !AR_SREV_9271(ah)) ath9k_hw_rf_free_ext_banks(ah);
-     kfree(ah);
-     ah = NULL;

Another one.  Actually, it is trivial, but not ath9k_htc related.

Quoted 2 lines

It would be really nice to fast track the ath9k_htc driver to 2.6.34, but the changes affecting other devices should be separate, I believe.

While at it, if you can separate the ath9k_hw changes that would be great.

Luis

#3 lore raw
Quoted 1 line · Luis R. Rodriguez

While at it, if you can separate the ath9k_hw changes that would be great.

OK, I left the changes that could affect other hardware and comment changes. I removed the code that doesn't affect AR9271 and formatting changes.

This piece of code is almost certainly wrong (it addition to being longer than 80 characters:

if (AR_SREV_9271(ah) && (ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE) == 1)) {
        REG_WRITE_ARRAY(&ah->iniModes_high_power_tx_gain_9271,
                        modesIndex, regWrites);
} else {
        REG_WRITE_ARRAY(&ah->iniModes_normal_power_tx_gain_9271,
                        modesIndex, regWrites);
}

I think the right code would be

if (AR_SREV_9271(ah)) {
        if (ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE) == 1))
                REG_WRITE_ARRAY(&ah->iniModes_high_power_tx_gain_9271,
                                modesIndex, regWrites);
        else
                REG_WRITE_ARRAY(&ah->iniModes_normal_power_tx_gain_9271,
                                modesIndex, regWrites);
}

Better yet, I would use a variable and refactor REG_WRITE_ARRAY.

This code also looks wrong:

                val = REG_READ(ah, AR_PCU_MISC_MODE2) &
                               (~AR_PCU_MISC_MODE2_HWWAR1);

                if (!AR_SREV_9271(ah))
                        val &= ~AR_PCU_MISC_MODE2_HWWAR1;

I think it should be:

                val = REG_READ(ah, AR_PCU_MISC_MODE2);

                if (!AR_SREV_9271(ah))
                        val &= ~AR_PCU_MISC_MODE2_HWWAR1;

The change involving ATH_HW_INITIALIZED appears to be a serious bugfix, perhaps even suitable for stable kernels.

The message "Running PA Calibration" would be more suitable in ath9k_hw_init_cal().

The original patch should be run through checkpatch.pl. In addition to overly long lines, there are some other formatting issues.

Here's the patch (changes potentially affecting other hardware and comments)

drivers/net/wireless/ath/ath9k/calib.c +3 -0
index 238a574..be82f05 100644
@@ -815,6 +815,7 @@ static void ath9k_olc_temp_compensation(struct ath_hw *ah)
 
 static void ath9k_hw_9271_pa_cal(struct ath_hw *ah, bool is_reset)
 {
+	struct ath_common *common = ath9k_hw_common(ah);
 	u32 regVal;
 	unsigned int i;
 	u32 regList [][2] = {
@@ -828,6 +829,8 @@ static void ath9k_hw_9271_pa_cal(struct ath_hw *ah, bool is_reset)
 		{ 0x7828, 0 } ,
 	};
 
+	ath_print(common, ATH_DBG_CALIBRATE, "Running PA Calibration\n");
+
 	for (i = 0; i < ARRAY_SIZE(regList); i++)
 		regList[i][1] = REG_READ(ah, regList[i][0]);
 
drivers/net/wireless/ath/ath9k/hw.c +20 -7
index f00f5c7..959f964 100644
@@ -1240,7 +1240,7 @@ void ath9k_hw_deinit(struct ath_hw *ah)
 {
 	struct ath_common *common = ath9k_hw_common(ah);
 
-	if (common->state <= ATH_HW_INITIALIZED)
+	if (common->state < ATH_HW_INITIALIZED)
 		goto free_hw;
 
 	if (!AR_SREV_9100(ah))
@@ -1251,8 +1251,6 @@ void ath9k_hw_deinit(struct ath_hw *ah)
 free_hw:
 	if (!AR_SREV_9280_10_OR_LATER(ah))
 		ath9k_hw_rf_free_ext_banks(ah);
-	kfree(ah);
-	ah = NULL;
 }
 EXPORT_SYMBOL(ath9k_hw_deinit);
 
@@ -1296,6 +1294,9 @@ static void ath9k_hw_override_ini(struct ath_hw *ah,
 		val = REG_READ(ah, AR_PCU_MISC_MODE2) &
 			       (~AR_PCU_MISC_MODE2_HWWAR1);
 
+		if (!AR_SREV_9271(ah))
+			val &= ~AR_PCU_MISC_MODE2_HWWAR1;
+
 		if (AR_SREV_9287_10_OR_LATER(ah))
 			val = val & (~AR_PCU_MISC_MODE2_HWWAR2);
 
@@ -1428,7 +1429,10 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
 		return -EINVAL;
 	}
 
+	/* Set correct baseband to analog shift setting to access analog chips */
 	REG_WRITE(ah, AR_PHY(0), 0x00000007);
+
+	/* Write ADDAC shifts */
 	REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_EXTERNAL_RADIO);
 	ah->eep_ops->set_addac(ah, chan);
 
@@ -1440,9 +1444,11 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
 			sizeof(u32) * ah->iniAddac.ia_rows *
 			ah->iniAddac.ia_columns;
 
+		/* For AR5416 2.0/2.1 */
 		memcpy(ah->addac5416_21,
 		       ah->iniAddac.ia_array, addacSize);
 
+		/* override CLKDRV value at [row, column] = [31, 1] */
 		(ah->addac5416_21)[31 * ah->iniAddac.ia_columns + 1] = 0;
 
 		temp.ia_array = ah->addac5416_21;
@@ -1474,6 +1480,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
 	    AR_SREV_9287_10_OR_LATER(ah))
 		REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites);
 
+	/* Write common array parameters */
 	for (i = 0; i < ah->iniCommon.ia_rows; i++) {
 		u32 reg = INI_RA(&ah->iniCommon, i, 0);
 		u32 val = INI_RA(&ah->iniCommon, i, 1);
@@ -1488,11 +1495,15 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
 		DO_DELAY(regWrites);
 	}
 
-	ath9k_hw_write_regs(ah, freqIndex, regWrites);
-
-	if (AR_SREV_9271_10(ah))
-		REG_WRITE_ARRAY(&ah->iniModes_9271_1_0_only,
+	if (AR_SREV_9271(ah) && (ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE) == 1)) {
+		REG_WRITE_ARRAY(&ah->iniModes_high_power_tx_gain_9271,
 				modesIndex, regWrites);
+	} else {
+		REG_WRITE_ARRAY(&ah->iniModes_normal_power_tx_gain_9271,
+				modesIndex, regWrites);
+	}
+
+	ath9k_hw_write_regs(ah, freqIndex, regWrites);
 
 	if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan)) {
 		REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex,
@@ -1506,6 +1517,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
 	if (OLC_FOR_AR9280_20_LATER)
 		ath9k_olc_init(ah);
 
+	/* Set TX power */
 	ah->eep_ops->set_txpower(ah, chan,
 				 ath9k_regd_get_ctl(regulatory, chan),
 				 channel->max_antenna_gain * 2,
@@ -1513,6 +1525,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
 				 min((u32) MAX_RATE_POWER,
 				 (u32) regulatory->power_limit));
 
+	/* Write analog registers */
 	if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
 		ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
 			  "ar5416SetRfRegs failed\n");
drivers/net/wireless/ath/ath9k/init.c +3 -0
index 623c2f8..6063f54 100644
@@ -758,6 +758,9 @@ static void ath9k_deinit_softc(struct ath_softc *sc)
 
 	tasklet_kill(&sc->intr_tq);
 	tasklet_kill(&sc->bcon_tasklet);
+
+	kfree(sc->sc_ah);
+	sc->sc_ah = NULL;
 }
 
 void ath9k_deinit_device(struct ath_softc *sc)
drivers/net/wireless/ath/ath9k/phy.c +0 -4
index c3b5939..ec3f58c 100644
@@ -839,8 +839,6 @@ int ath9k_hw_rf_alloc_ext_banks(struct ath_hw *ah)
 
 	struct ath_common *common = ath9k_hw_common(ah);
 
-	BUG_ON(AR_SREV_9280_10_OR_LATER(ah));
-
 	ATH_ALLOC_BANK(ah->analogBank0Data, ah->iniBank0.ia_rows);
 	ATH_ALLOC_BANK(ah->analogBank1Data, ah->iniBank1.ia_rows);
 	ATH_ALLOC_BANK(ah->analogBank2Data, ah->iniBank2.ia_rows);
@@ -870,8 +868,6 @@ ath9k_hw_rf_free_ext_banks(struct ath_hw *ah)
 		bank = NULL; \
 	} while (0);
 
-	BUG_ON(AR_SREV_9280_10_OR_LATER(ah));
-
 	ATH_FREE_BANK(ah->analogBank0Data);
 	ATH_FREE_BANK(ah->analogBank1Data);
 	ATH_FREE_BANK(ah->analogBank2Data);
Signature · 2 lines
Regards,
Pavel Roskin
author
#4 lore raw
Quoted 22 lines · Pavel Roskin

This piece of code is almost certainly wrong (it addition to being longer than 80 characters:

if (AR_SREV_9271(ah) && (ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE) == 1)) {
        REG_WRITE_ARRAY(&ah->iniModes_high_power_tx_gain_9271,
                        modesIndex, regWrites);
} else {
        REG_WRITE_ARRAY(&ah->iniModes_normal_power_tx_gain_9271,
                        modesIndex, regWrites);
}

I think the right code would be

if (AR_SREV_9271(ah)) {
        if (ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE) == 1))
                REG_WRITE_ARRAY(&ah->iniModes_high_power_tx_gain_9271,
                                modesIndex, regWrites);
        else
                REG_WRITE_ARRAY(&ah->iniModes_normal_power_tx_gain_9271,
                                modesIndex, regWrites);
}
Quoted 1 line

Better yet, I would use a variable and refactor REG_WRITE_ARRAY.

Indeed. Good catch !

Quoted 8 lines

This code also looks wrong:

                val = REG_READ(ah, AR_PCU_MISC_MODE2) &
                               (~AR_PCU_MISC_MODE2_HWWAR1);

                if (!AR_SREV_9271(ah))
                        val &= ~AR_PCU_MISC_MODE2_HWWAR1;
Quoted 6 lines

I think it should be:

                val = REG_READ(ah, AR_PCU_MISC_MODE2);

                if (!AR_SREV_9271(ah))
                        val &= ~AR_PCU_MISC_MODE2_HWWAR1;

Again, great catch. ;)

Quoted 2 lines

The change involving ATH_HW_INITIALIZED appears to be a serious bugfix, perhaps even suitable for stable kernels.

Right, I'll do that.

Quoted 5 lines

The message "Running PA Calibration" would be more suitable in ath9k_hw_init_cal().

The original patch should be run through checkpatch.pl. In addition to overly long lines, there are some other formatting issues.

I thought that the default was 106 (or 132 ?) these days ..

Sujith

#5 lore raw
Quoted 6 lines · Sujith
Quoted 2 lines

The original patch should be run through checkpatch.pl. In addition to overly long lines, there are some other formatting issues.

I thought that the default was 106 (or 132 ?) these days ..

From CodingStyle:

"The limit on the length of lines is 80 columns and this is a strongly preferred limit."

And I fully agree with that. It's easier to read code that way.

Signature · 1 line
Kalle Valo
#6 lore raw
Quoted 5 lines · Kalle Valo
Quoted 3 lines · Sujith
Quoted 2 lines

The original patch should be run through checkpatch.pl. In addition to overly long lines, there are some other formatting issues.

Quoted 8 lines
Quoted 1 line

I thought that the default was 106 (or 132 ?) these days ..

From CodingStyle:

"The limit on the length of lines is 80 columns and this is a strongly preferred limit."

And I fully agree with that. It's easier to read code that way.

ACK

Signature · 2 lines
John W. Linville                Someday the world will need a hero, and you
[email protected]                  might be all we have.  Be ready.
author
#7 lore raw
In reply to Luis R. Rodriguez
Quoted 1 line · Luis R. Rodriguez

While at it, if you can separate the ath9k_hw changes that would be great.

I have separated the HW portion into a separate patch. A review would be great. :)

Sujith

author
#8 lore raw
In reply to Pavel Roskin
Quoted 25 lines · Pavel Roskin

drivers/net/wireless/ath/ath9k/hw.c void ath9k_hw_deinit(struct ath_hw *ah) · line 1234

Quoted 9 lines
drivers/net/wireless/ath/ath9k/hw.c +1 -1
@@ -1240,7 +1228,7 @@ void ath9k_hw_deinit(struct ath_hw *ah)
 {
      struct ath_common *common = ath9k_hw_common(ah);
 
-     if (common->state <= ATH_HW_INITIALIZED)
+     if (common->state < ATH_HW_INITIALIZED)
              goto free_hw;
 
      if (!AR_SREV_9100(ah))

There are some non-trivial parts like this one that could be submitted separately.

drivers/net/wireless/ath/ath9k/hw.c void ath9k_hw_deinit(struct ath_hw *ah) · line 1255

Quoted 9 lines
drivers/net/wireless/ath/ath9k/hw.c +1 -3
@@ -1249,10 +1237,8 @@ void ath9k_hw_deinit(struct ath_hw *ah)
      ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP);
 
 free_hw:
-     if (!AR_SREV_9280_10_OR_LATER(ah))
+     if (!AR_SREV_9280_10_OR_LATER(ah) && !AR_SREV_9271(ah))
              ath9k_hw_rf_free_ext_banks(ah);
-     kfree(ah);
-     ah = NULL;

Another one. Actually, it is trivial, but not ath9k_htc related.

Quoted 2 lines

It would be really nice to fast track the ath9k_htc driver to 2.6.34, but the changes affecting other devices should be separate, I believe.

I'll submit this fix as a separate patch.

Sujith