]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.21/rtlwifi-rtl8821ae-fix-connection-lost-problem-correctly.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.14.21 / rtlwifi-rtl8821ae-fix-connection-lost-problem-correctly.patch
1 From c713fb071edc0efc01a955f65a006b0e1795d2eb Mon Sep 17 00:00:00 2001
2 From: Larry Finger <Larry.Finger@lwfinger.net>
3 Date: Mon, 5 Feb 2018 12:38:11 -0600
4 Subject: rtlwifi: rtl8821ae: Fix connection lost problem correctly
5
6 From: Larry Finger <Larry.Finger@lwfinger.net>
7
8 commit c713fb071edc0efc01a955f65a006b0e1795d2eb upstream.
9
10 There has been a coding error in rtl8821ae since it was first introduced,
11 namely that an 8-bit register was read using a 16-bit read in
12 _rtl8821ae_dbi_read(). This error was fixed with commit 40b368af4b75
13 ("rtlwifi: Fix alignment issues"); however, this change led to
14 instability in the connection. To restore stability, this change
15 was reverted in commit b8b8b16352cd ("rtlwifi: rtl8821ae: Fix connection
16 lost problem").
17
18 Unfortunately, the unaligned access causes machine checks in ARM
19 architecture, and we were finally forced to find the actual cause of the
20 problem on x86 platforms. Following a suggestion from Pkshih
21 <pkshih@realtek.com>, it was found that increasing the ASPM L1
22 latency from 0 to 7 fixed the instability. This parameter was varied to
23 see if a smaller value would work; however, it appears that 7 is the
24 safest value. A new symbol is defined for this quantity, thus it can be
25 easily changed if necessary.
26
27 Fixes: b8b8b16352cd ("rtlwifi: rtl8821ae: Fix connection lost problem")
28 Cc: Stable <stable@vger.kernel.org> # 4.14+
29 Fix-suggested-by: Pkshih <pkshih@realtek.com>
30 Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
31 Tested-by: James Cameron <quozl@laptop.org> # x86_64 OLPC NL3
32 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
33 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34
35 ---
36 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c | 5 +++--
37 drivers/net/wireless/realtek/rtlwifi/wifi.h | 1 +
38 2 files changed, 4 insertions(+), 2 deletions(-)
39
40 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
41 +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
42 @@ -1122,7 +1122,7 @@ static u8 _rtl8821ae_dbi_read(struct rtl
43 }
44 if (0 == tmp) {
45 read_addr = REG_DBI_RDATA + addr % 4;
46 - ret = rtl_read_word(rtlpriv, read_addr);
47 + ret = rtl_read_byte(rtlpriv, read_addr);
48 }
49 return ret;
50 }
51 @@ -1164,7 +1164,8 @@ static void _rtl8821ae_enable_aspm_back_
52 }
53
54 tmp = _rtl8821ae_dbi_read(rtlpriv, 0x70f);
55 - _rtl8821ae_dbi_write(rtlpriv, 0x70f, tmp | BIT(7));
56 + _rtl8821ae_dbi_write(rtlpriv, 0x70f, tmp | BIT(7) |
57 + ASPM_L1_LATENCY << 3);
58
59 tmp = _rtl8821ae_dbi_read(rtlpriv, 0x719);
60 _rtl8821ae_dbi_write(rtlpriv, 0x719, tmp | BIT(3) | BIT(4));
61 --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
62 +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
63 @@ -99,6 +99,7 @@
64 #define RTL_USB_MAX_RX_COUNT 100
65 #define QBSS_LOAD_SIZE 5
66 #define MAX_WMMELE_LENGTH 64
67 +#define ASPM_L1_LATENCY 7
68
69 #define TOTAL_CAM_ENTRY 32
70