aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-02-15 13:31:20 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-02-21 14:45:25 -0500
commit9bbb8168ed3d8b946f9c1901a63a675012de88f2 (patch)
tree2719d974ce305af5633ed350b1c04c0808319b8e /drivers/net
parent2504a6423b9ab4c36df78227055995644de19edb (diff)
ath9k_hw: prevent writes to const data on AR9160
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 Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/ath/ath9k/ar5008_phy.c25
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_hw.c19
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h1
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 f901a17f76ba..86a891f93fc9 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)
489 ATH_ALLOC_BANK(ah->analogBank6Data, ah->iniBank6.ia_rows); 489 ATH_ALLOC_BANK(ah->analogBank6Data, ah->iniBank6.ia_rows);
490 ATH_ALLOC_BANK(ah->analogBank6TPCData, ah->iniBank6TPC.ia_rows); 490 ATH_ALLOC_BANK(ah->analogBank6TPCData, ah->iniBank6TPC.ia_rows);
491 ATH_ALLOC_BANK(ah->analogBank7Data, ah->iniBank7.ia_rows); 491 ATH_ALLOC_BANK(ah->analogBank7Data, ah->iniBank7.ia_rows);
492 ATH_ALLOC_BANK(ah->addac5416_21,
493 ah->iniAddac.ia_rows * ah->iniAddac.ia_columns);
494 ATH_ALLOC_BANK(ah->bank6Temp, ah->iniBank6.ia_rows); 492 ATH_ALLOC_BANK(ah->bank6Temp, ah->iniBank6.ia_rows);
495 493
496 return 0; 494 return 0;
@@ -519,7 +517,6 @@ static void ar5008_hw_rf_free_ext_banks(struct ath_hw *ah)
519 ATH_FREE_BANK(ah->analogBank6Data); 517 ATH_FREE_BANK(ah->analogBank6Data);
520 ATH_FREE_BANK(ah->analogBank6TPCData); 518 ATH_FREE_BANK(ah->analogBank6TPCData);
521 ATH_FREE_BANK(ah->analogBank7Data); 519 ATH_FREE_BANK(ah->analogBank7Data);
522 ATH_FREE_BANK(ah->addac5416_21);
523 ATH_FREE_BANK(ah->bank6Temp); 520 ATH_FREE_BANK(ah->bank6Temp);
524 521
525#undef ATH_FREE_BANK 522#undef ATH_FREE_BANK
@@ -805,27 +802,7 @@ static int ar5008_hw_process_ini(struct ath_hw *ah,
805 if (ah->eep_ops->set_addac) 802 if (ah->eep_ops->set_addac)
806 ah->eep_ops->set_addac(ah, chan); 803 ah->eep_ops->set_addac(ah, chan);
807 804
808 if (AR_SREV_5416_22_OR_LATER(ah)) { 805 REG_WRITE_ARRAY(&ah->iniAddac, 1, regWrites);
809 REG_WRITE_ARRAY(&ah->iniAddac, 1, regWrites);
810 } else {
811 struct ar5416IniArray temp;
812 u32 addacSize =
813 sizeof(u32) * ah->iniAddac.ia_rows *
814 ah->iniAddac.ia_columns;
815
816 /* For AR5416 2.0/2.1 */
817 memcpy(ah->addac5416_21,
818 ah->iniAddac.ia_array, addacSize);
819
820 /* override CLKDRV value at [row, column] = [31, 1] */
821 (ah->addac5416_21)[31 * ah->iniAddac.ia_columns + 1] = 0;
822
823 temp.ia_array = ah->addac5416_21;
824 temp.ia_columns = ah->iniAddac.ia_columns;
825 temp.ia_rows = ah->iniAddac.ia_rows;
826 REG_WRITE_ARRAY(&temp, 1, regWrites);
827 }
828
829 REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_INTERNAL_ADDAC); 806 REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_INTERNAL_ADDAC);
830 807
831 ENABLE_REGWRITE_BUFFER(ah); 808 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 11f192a1ceb7..d190411ac8f5 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)
180 INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac, 180 INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac,
181 ARRAY_SIZE(ar5416Addac), 2); 181 ARRAY_SIZE(ar5416Addac), 2);
182 } 182 }
183
184 /* iniAddac needs to be modified for these chips */
185 if (AR_SREV_9160(ah) || !AR_SREV_5416_22_OR_LATER(ah)) {
186 struct ar5416IniArray *addac = &ah->iniAddac;
187 u32 size = sizeof(u32) * addac->ia_rows * addac->ia_columns;
188 u32 *data;
189
190 data = kmalloc(size, GFP_KERNEL);
191 if (!data)
192 return;
193
194 memcpy(data, addac->ia_array, size);
195 addac->ia_array = data;
196
197 if (!AR_SREV_5416_22_OR_LATER(ah)) {
198 /* override CLKDRV value */
199 INI_RA(addac, 31,1) = 0;
200 }
201 }
183} 202}
184 203
185/* Support for Japan ch.14 (2484) spread */ 204/* 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 6a29004a71b0..c8261d4fc780 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -940,7 +940,6 @@ struct ath_hw {
940 u32 *analogBank6Data; 940 u32 *analogBank6Data;
941 u32 *analogBank6TPCData; 941 u32 *analogBank6TPCData;
942 u32 *analogBank7Data; 942 u32 *analogBank7Data;
943 u32 *addac5416_21;
944 u32 *bank6Temp; 943 u32 *bank6Temp;
945 944
946 u8 txpower_limit; 945 u8 txpower_limit;