linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 3.3] ath9k_hw: prevent writes to const data on AR9160
  2012-02-15 18:31 [PATCH 3.3] ath9k_hw: prevent writes to const data on AR9160 Felix Fietkau
@ 2012-02-15 18:30 ` John W. Linville
  2012-02-15 18:53   ` Felix Fietkau
  0 siblings, 1 reply; 4+ messages in thread
From: John W. Linville @ 2012-02-15 18:30 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, mcgrof, magnus.maatta

Do you have a link to the reported crash?

On Wed, Feb 15, 2012 at 07:31:20PM +0100, Felix Fietkau wrote:
> Duplicate the data for iniAddac early on, to avoid having to do redundant
> memcpy calls later. While we're at it, make AR5416 < v2.2 use the same
> codepath. Fixes a reported crash on x86.
> 
> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
> Reported-by: Magnus Määttä <magnus.maatta@logica.com>
> Cc: stable@vger.kernel.org
> ---
>  drivers/net/wireless/ath/ath9k/ar5008_phy.c |   25 +------------------------
>  drivers/net/wireless/ath/ath9k/ar9002_hw.c  |   19 +++++++++++++++++++
>  drivers/net/wireless/ath/ath9k/hw.h         |    1 -
>  3 files changed, 20 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
> index f901a17..86a891f 100644
> --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
> +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
> @@ -489,8 +489,6 @@ static int ar5008_hw_rf_alloc_ext_banks(struct ath_hw *ah)
>  	ATH_ALLOC_BANK(ah->analogBank6Data, ah->iniBank6.ia_rows);
>  	ATH_ALLOC_BANK(ah->analogBank6TPCData, ah->iniBank6TPC.ia_rows);
>  	ATH_ALLOC_BANK(ah->analogBank7Data, ah->iniBank7.ia_rows);
> -	ATH_ALLOC_BANK(ah->addac5416_21,
> -		       ah->iniAddac.ia_rows * ah->iniAddac.ia_columns);
>  	ATH_ALLOC_BANK(ah->bank6Temp, ah->iniBank6.ia_rows);
>  
>  	return 0;
> @@ -519,7 +517,6 @@ static void ar5008_hw_rf_free_ext_banks(struct ath_hw *ah)
>  	ATH_FREE_BANK(ah->analogBank6Data);
>  	ATH_FREE_BANK(ah->analogBank6TPCData);
>  	ATH_FREE_BANK(ah->analogBank7Data);
> -	ATH_FREE_BANK(ah->addac5416_21);
>  	ATH_FREE_BANK(ah->bank6Temp);
>  
>  #undef ATH_FREE_BANK
> @@ -805,27 +802,7 @@ static int ar5008_hw_process_ini(struct ath_hw *ah,
>  	if (ah->eep_ops->set_addac)
>  		ah->eep_ops->set_addac(ah, chan);
>  
> -	if (AR_SREV_5416_22_OR_LATER(ah)) {
> -		REG_WRITE_ARRAY(&ah->iniAddac, 1, regWrites);
> -	} else {
> -		struct ar5416IniArray temp;
> -		u32 addacSize =
> -			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;
> -		temp.ia_columns = ah->iniAddac.ia_columns;
> -		temp.ia_rows = ah->iniAddac.ia_rows;
> -		REG_WRITE_ARRAY(&temp, 1, regWrites);
> -	}
> -
> +	REG_WRITE_ARRAY(&ah->iniAddac, 1, regWrites);
>  	REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_INTERNAL_ADDAC);
>  
>  	ENABLE_REGWRITE_BUFFER(ah);
> diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
> index 11f192a..d190411 100644
> --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
> +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
> @@ -180,6 +180,25 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah)
>  		INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac,
>  			       ARRAY_SIZE(ar5416Addac), 2);
>  	}
> +
> +	/* iniAddac needs to be modified for these chips */
> +	if (AR_SREV_9160(ah) || !AR_SREV_5416_22_OR_LATER(ah)) {
> +		struct ar5416IniArray *addac = &ah->iniAddac;
> +		u32 size = sizeof(u32) * addac->ia_rows * addac->ia_columns;
> +		u32 *data;
> +
> +		data = kmalloc(size, GFP_KERNEL);
> +		if (!data)
> +			return;
> +
> +		memcpy(data, addac->ia_array, size);
> +		addac->ia_array = data;
> +
> +		if (!AR_SREV_5416_22_OR_LATER(ah)) {
> +			/* override CLKDRV value */
> +			INI_RA(addac, 31,1) = 0;
> +		}
> +	}
>  }
>  
>  /* Support for Japan ch.14 (2484) spread */
> diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
> index 6a29004..c8261d4 100644
> --- a/drivers/net/wireless/ath/ath9k/hw.h
> +++ b/drivers/net/wireless/ath/ath9k/hw.h
> @@ -940,7 +940,6 @@ struct ath_hw {
>  	u32 *analogBank6Data;
>  	u32 *analogBank6TPCData;
>  	u32 *analogBank7Data;
> -	u32 *addac5416_21;
>  	u32 *bank6Temp;
>  
>  	u8 txpower_limit;
> -- 
> 1.7.3.2
> 
> 

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3.3] ath9k_hw: prevent writes to const data on AR9160
@ 2012-02-15 18:31 Felix Fietkau
  2012-02-15 18:30 ` John W. Linville
  0 siblings, 1 reply; 4+ messages in thread
From: Felix Fietkau @ 2012-02-15 18:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: linville, mcgrof, magnus.maatta

Duplicate the data for iniAddac early on, to avoid having to do redundant
memcpy calls later. While we're at it, make AR5416 < v2.2 use the same
codepath. Fixes a reported crash on x86.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Reported-by: Magnus Määttä <magnus.maatta@logica.com>
Cc: stable@vger.kernel.org
---
 drivers/net/wireless/ath/ath9k/ar5008_phy.c |   25 +------------------------
 drivers/net/wireless/ath/ath9k/ar9002_hw.c  |   19 +++++++++++++++++++
 drivers/net/wireless/ath/ath9k/hw.h         |    1 -
 3 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
index f901a17..86a891f 100644
--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
@@ -489,8 +489,6 @@ static int ar5008_hw_rf_alloc_ext_banks(struct ath_hw *ah)
 	ATH_ALLOC_BANK(ah->analogBank6Data, ah->iniBank6.ia_rows);
 	ATH_ALLOC_BANK(ah->analogBank6TPCData, ah->iniBank6TPC.ia_rows);
 	ATH_ALLOC_BANK(ah->analogBank7Data, ah->iniBank7.ia_rows);
-	ATH_ALLOC_BANK(ah->addac5416_21,
-		       ah->iniAddac.ia_rows * ah->iniAddac.ia_columns);
 	ATH_ALLOC_BANK(ah->bank6Temp, ah->iniBank6.ia_rows);
 
 	return 0;
@@ -519,7 +517,6 @@ static void ar5008_hw_rf_free_ext_banks(struct ath_hw *ah)
 	ATH_FREE_BANK(ah->analogBank6Data);
 	ATH_FREE_BANK(ah->analogBank6TPCData);
 	ATH_FREE_BANK(ah->analogBank7Data);
-	ATH_FREE_BANK(ah->addac5416_21);
 	ATH_FREE_BANK(ah->bank6Temp);
 
 #undef ATH_FREE_BANK
@@ -805,27 +802,7 @@ static int ar5008_hw_process_ini(struct ath_hw *ah,
 	if (ah->eep_ops->set_addac)
 		ah->eep_ops->set_addac(ah, chan);
 
-	if (AR_SREV_5416_22_OR_LATER(ah)) {
-		REG_WRITE_ARRAY(&ah->iniAddac, 1, regWrites);
-	} else {
-		struct ar5416IniArray temp;
-		u32 addacSize =
-			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;
-		temp.ia_columns = ah->iniAddac.ia_columns;
-		temp.ia_rows = ah->iniAddac.ia_rows;
-		REG_WRITE_ARRAY(&temp, 1, regWrites);
-	}
-
+	REG_WRITE_ARRAY(&ah->iniAddac, 1, regWrites);
 	REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_INTERNAL_ADDAC);
 
 	ENABLE_REGWRITE_BUFFER(ah);
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
index 11f192a..d190411 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
@@ -180,6 +180,25 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah)
 		INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac,
 			       ARRAY_SIZE(ar5416Addac), 2);
 	}
+
+	/* iniAddac needs to be modified for these chips */
+	if (AR_SREV_9160(ah) || !AR_SREV_5416_22_OR_LATER(ah)) {
+		struct ar5416IniArray *addac = &ah->iniAddac;
+		u32 size = sizeof(u32) * addac->ia_rows * addac->ia_columns;
+		u32 *data;
+
+		data = kmalloc(size, GFP_KERNEL);
+		if (!data)
+			return;
+
+		memcpy(data, addac->ia_array, size);
+		addac->ia_array = data;
+
+		if (!AR_SREV_5416_22_OR_LATER(ah)) {
+			/* override CLKDRV value */
+			INI_RA(addac, 31,1) = 0;
+		}
+	}
 }
 
 /* Support for Japan ch.14 (2484) spread */
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 6a29004..c8261d4 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -940,7 +940,6 @@ struct ath_hw {
 	u32 *analogBank6Data;
 	u32 *analogBank6TPCData;
 	u32 *analogBank7Data;
-	u32 *addac5416_21;
 	u32 *bank6Temp;
 
 	u8 txpower_limit;
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 3.3] ath9k_hw: prevent writes to const data on AR9160
  2012-02-15 18:30 ` John W. Linville
@ 2012-02-15 18:53   ` Felix Fietkau
  2012-02-15 19:01     ` John W. Linville
  0 siblings, 1 reply; 4+ messages in thread
From: Felix Fietkau @ 2012-02-15 18:53 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, mcgrof, magnus.maatta

On 2012-02-15 7:30 PM, John W. Linville wrote:
> Do you have a link to the reported crash?
It was reported on IRC, the trace is here: http://pastebin.com/wvxXwLs4

- Felix

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 3.3] ath9k_hw: prevent writes to const data on AR9160
  2012-02-15 18:53   ` Felix Fietkau
@ 2012-02-15 19:01     ` John W. Linville
  0 siblings, 0 replies; 4+ messages in thread
From: John W. Linville @ 2012-02-15 19:01 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, mcgrof, magnus.maatta

On Wed, Feb 15, 2012 at 07:53:31PM +0100, Felix Fietkau wrote:
> On 2012-02-15 7:30 PM, John W. Linville wrote:
> > Do you have a link to the reported crash?
> It was reported on IRC, the trace is here: http://pastebin.com/wvxXwLs4

Cool, thanks.

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-15 19:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-15 18:31 [PATCH 3.3] ath9k_hw: prevent writes to const data on AR9160 Felix Fietkau
2012-02-15 18:30 ` John W. Linville
2012-02-15 18:53   ` Felix Fietkau
2012-02-15 19:01     ` John W. Linville

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).