mac80211: merge a few pending upstream fixes
[openwrt.git] / package / kernel / mac80211 / patches / 331-ath9k_hw-do-not-run-NF-and-periodic-calibration-at-t.patch
1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Sat, 18 Oct 2014 13:39:11 +0200
3 Subject: [PATCH] ath9k_hw: do not run NF and periodic calibration at the
4  same time
5
6 It can cause inconsistent calibration results or in some cases turn the
7 radio deaf.
8
9 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 ---
11
12 --- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
13 +++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
14 @@ -660,27 +660,26 @@ static void ar9002_hw_olc_temp_compensat
15  static int ar9002_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
16                                u8 rxchainmask, bool longcal)
17  {
18 -       bool iscaldone = true;
19         struct ath9k_cal_list *currCal = ah->cal_list_curr;
20 -       bool nfcal, nfcal_pending = false;
21 +       bool nfcal, nfcal_pending = false, percal_pending;
22         int ret;
23  
24         nfcal = !!(REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF);
25         if (ah->caldata)
26                 nfcal_pending = test_bit(NFCAL_PENDING, &ah->caldata->cal_flags);
27  
28 -       if (currCal && !nfcal &&
29 -           (currCal->calState == CAL_RUNNING ||
30 -            currCal->calState == CAL_WAITING)) {
31 -               iscaldone = ar9002_hw_per_calibration(ah, chan,
32 -                                                     rxchainmask, currCal);
33 -               if (iscaldone) {
34 -                       ah->cal_list_curr = currCal = currCal->calNext;
35 -
36 -                       if (currCal->calState == CAL_WAITING) {
37 -                               iscaldone = false;
38 -                               ath9k_hw_reset_calibration(ah, currCal);
39 -                       }
40 +       percal_pending = (currCal &&
41 +                         (currCal->calState == CAL_RUNNING ||
42 +                          currCal->calState == CAL_WAITING));
43 +
44 +       if (percal_pending && !nfcal) {
45 +               if (!ar9002_hw_per_calibration(ah, chan, rxchainmask, currCal))
46 +                       return 0;
47 +
48 +               ah->cal_list_curr = currCal = currCal->calNext;
49 +               if (currCal->calState == CAL_WAITING) {
50 +                       ath9k_hw_reset_calibration(ah, currCal);
51 +                       return 0;
52                 }
53         }
54  
55 @@ -710,7 +709,7 @@ static int ar9002_hw_calibrate(struct at
56                 }
57         }
58  
59 -       return iscaldone;
60 +       return !percal_pending;
61  }
62  
63  /* Carrier leakage Calibration fix */