package/devel/binutils: Update to 2.27
[openwrt/staging/chunkeey.git] / package / kernel / mac80211 / patches / 314-ath9k-Use-tsf-offset-helper-in-ath9k_hw_reset.patch
1 From: Benjamin Berg <benjamin.berg@open-mesh.com>
2 Date: Mon, 4 Jul 2016 14:37:22 +0200
3 Subject: [PATCH] ath9k: Use tsf offset helper in ath9k_hw_reset
4
5 These changes make ath9k_hw_reset more consistent with other places that
6 handle the TSF value by using the same helper routine.
7
8 A slight improvement is to not assume that a fixed time of 1.5ms has
9 passed for the initval writes when compared to the first write attempt.
10 Instead the TSF value is re-calculated which will yield a higher accuracy
11 of the restored TSF timer.
12
13 Signed-off-by: Benjamin Berg <benjamin.berg@open-mesh.com>
14 ---
15
16 --- a/drivers/net/wireless/ath/ath9k/hw.c
17 +++ b/drivers/net/wireless/ath/ath9k/hw.c
18 @@ -1832,8 +1832,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st
19 u32 saveLedState;
20 u32 saveDefAntenna;
21 u32 macStaId1;
22 + struct timespec tsf_ts;
23 + u32 tsf_offset;
24 u64 tsf = 0;
25 - s64 usec = 0;
26 int r;
27 bool start_mci_reset = false;
28 bool save_fullsleep = ah->chip_fullsleep;
29 @@ -1877,8 +1878,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
30 macStaId1 = REG_READ(ah, AR_STA_ID1) & AR_STA_ID1_BASE_RATE_11B;
31
32 /* Save TSF before chip reset, a cold reset clears it */
33 + getrawmonotonic(&tsf_ts);
34 tsf = ath9k_hw_gettsf64(ah);
35 - usec = ktime_to_us(ktime_get_raw());
36
37 saveLedState = REG_READ(ah, AR_CFG_LED) &
38 (AR_CFG_LED_ASSOC_CTL | AR_CFG_LED_MODE_SEL |
39 @@ -1911,8 +1912,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
40 }
41
42 /* Restore TSF */
43 - usec = ktime_to_us(ktime_get_raw()) - usec;
44 - ath9k_hw_settsf64(ah, tsf + usec);
45 + tsf_offset = ath9k_hw_get_tsf_offset(&tsf_ts, NULL);
46 + ath9k_hw_settsf64(ah, tsf + tsf_offset);
47
48 if (AR_SREV_9280_20_OR_LATER(ah))
49 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE);
50 @@ -1932,12 +1933,11 @@ int ath9k_hw_reset(struct ath_hw *ah, st
51 /*
52 * Some AR91xx SoC devices frequently fail to accept TSF writes
53 * right after the chip reset. When that happens, write a new
54 - * value after the initvals have been applied, with an offset
55 - * based on measured time difference
56 + * value after the initvals have been applied.
57 */
58 if (AR_SREV_9100(ah) && (ath9k_hw_gettsf64(ah) < tsf)) {
59 - tsf += 1500;
60 - ath9k_hw_settsf64(ah, tsf);
61 + tsf_offset = ath9k_hw_get_tsf_offset(&tsf_ts, NULL);
62 + ath9k_hw_settsf64(ah, tsf + tsf_offset);
63 }
64
65 ath9k_hw_init_mfp(ah);