mac80211: ath10k: Allow to enable the thermal code of ath10k
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 364-ath9k_hw-fix-channel-maximum-power-level-test.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Wed, 22 Mar 2017 20:37:04 +0100
3 Subject: [PATCH] ath9k_hw: fix channel maximum power level test
4
5 The tx power applied by set_txpower is limited by the CTL (conformance
6 test limit) entries in the EEPROM. These can change based on the user
7 configured regulatory domain.
8 Depending on the EEPROM data this can cause the tx power to become too
9 limited, if the original regdomain CTLs impose lowr limits than the CTLs
10 of the user configured regdomain.
11
12 To fix this issue, set the initial channel limits without any CTL
13 restrictions and only apply the CTL at run time when setting the channel
14 and the real tx power.
15
16 Cc: stable@vger.kernel.org
17 Signed-off-by: Felix Fietkau <nbd@nbd.name>
18 ---
19
20 --- a/drivers/net/wireless/ath/ath9k/hw.c
21 +++ b/drivers/net/wireless/ath/ath9k/hw.c
22 @@ -2937,10 +2937,14 @@ void ath9k_hw_apply_txpower(struct ath_h
23 struct ieee80211_channel *channel;
24 int chan_pwr, new_pwr, max_gain;
25 int ant_gain, ant_reduction = 0;
26 + u16 ctl = NO_CTL;
27
28 if (!chan)
29 return;
30
31 + if (!test)
32 + ctl = ath9k_regd_get_ctl(reg, chan);
33 +
34 channel = chan->chan;
35 chan_pwr = min_t(int, channel->max_power * 2, MAX_RATE_POWER);
36 new_pwr = min_t(int, chan_pwr, reg->power_limit);
37 @@ -2950,9 +2954,7 @@ void ath9k_hw_apply_txpower(struct ath_h
38 if (ant_gain > max_gain)
39 ant_reduction = ant_gain - max_gain;
40
41 - ah->eep_ops->set_txpower(ah, chan,
42 - ath9k_regd_get_ctl(reg, chan),
43 - ant_reduction, new_pwr, test);
44 + ah->eep_ops->set_txpower(ah, chan, ctl, ant_reduction, new_pwr, test);
45 }
46
47 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)