mac80211: ath11k: sync with ath-next
[openwrt/staging/hauke.git] / package / kernel / mac80211 / patches / ath11k / 0031-wifi-ath11k-fix-ce-memory-mapping-for-ahb-devices.patch
1 From 53a998c4d7284debd77734d01e1466e59a1d03b2 Mon Sep 17 00:00:00 2001
2 From: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
3 Date: Fri, 13 Jan 2023 12:02:09 +0530
4 Subject: [PATCH] wifi: ath11k: fix ce memory mapping for ahb devices
5
6 Currently ath11k_ahb module is not loaded successfully and the wifi
7 interface is not created. Kernel trace is seen while loading the
8 ath11k_ahb module. The issue is seen in all ath11k AHB devices except
9 in IPQ5018.
10
11 This happens because in ath11k_ahb_probe(), ab->mem_ce is initialized
12 with the value of ab->mem. However, at this instant ab->mem is not
13 yet set.
14
15 Later, during write to a particular memory via ath11k_ahb_write32()
16 this ab->mem_ce is used with particular offset. Since ab->mem_ce is
17 not set properly this possibly leads to memory conflict to handle
18 kernel paging request and the below trace is seen.
19
20 [ 93.035047] Unable to handle kernel paging request at virtual address ffff800100a00000
21 [ 93.035083] Mem abort info:
22 [ 93.041869] ESR = 0x0000000096000045
23 [ 93.044561] EC = 0x25: DABT (current EL), IL = 32 bits
24 [ 93.048377] SET = 0, FnV = 0
25 [ 93.053840] EA = 0, S1PTW = 0
26 [ 93.056704] FSC = 0x05: level 1 translation fault
27 [ 93.059745] Data abort info:
28 [ 93.064603] ISV = 0, ISS = 0x00000045
29 [ 93.067729] CM = 0, WnR = 1
30 [ 93.071287] swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000042219000
31 [ 93.074409] [ffff800100a00000] pgd=100000007ffff003, p4d=100000007ffff003, pud=0000000000000000
32 [ 93.081195] Internal error: Oops: 0000000096000045 [#1] PREEMPT SMP
33 [ 93.089598] Modules linked in: ath11k_ahb ath11k_pci ath11k qmi_helpers
34 [ 93.095851] CPU: 2 PID: 66 Comm: kworker/u8:3 Not tainted 6.1.0-rc8-wt-ath-658126-g58e4b9df840c-dirty #2
35 [ 93.102454] Hardware name: Qualcomm Technologies, Inc. IPQ8074/AP-HK14 (DT)
36 [ 93.112171] Workqueue: ath11k_qmi_driver_event ath11k_qmi_driver_event_work [ath11k]
37 [ 93.118856] pstate: 40000005 (nZcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
38 [ 93.126838] pc : ath11k_ahb_write32+0xc/0x18 [ath11k_ahb]
39 [ 93.133520] lr : ath11k_hal_srng_setup+0x860/0x8f0 [ath11k]
40 [ 93.139075] sp : ffff80000aaebb70
41 [ 93.144452] x29: ffff80000aaebb70 x28: 0000000000000020 x27: ffff80000aaebc50
42 [ 93.147934] x26: ffff000004923750 x25: ffff000004921200 x24: ffff000004928000
43 [ 93.155051] x23: 0000000000000020 x22: ffff000004930000 x21: ffff000004923200
44 [ 93.162170] x20: ffff000004920000 x19: 00000000eea00000 x18: ffff0000049200f0
45 [ 93.169288] x17: 0000000000000000 x16: 0000000000000000 x15: 000000000000025e
46 [ 93.176405] x14: ffff000003c414f0 x13: 0000000000000000 x12: 0000000000000008
47 [ 93.183524] x11: ffff000003c41488 x10: 0000000000000040 x9 : 0000000000000000
48 [ 93.190641] x8 : ffff80000a9dd100 x7 : 0000000000000000 x6 : 000000000000003f
49 [ 93.197759] x5 : ffff800100a00400 x4 : ffff8000031f4018 x3 : 0000000000000004
50 [ 93.204877] x2 : 0000000047b62000 x1 : ffff800100a00000 x0 : ffff800012000000
51 [ 93.211996] Call trace:
52 [ 93.219104] ath11k_ahb_write32+0xc/0x18 [ath11k_ahb]
53 [ 93.221366] ath11k_ce_init_ring+0x184/0x278 [ath11k]
54 [ 93.226576] ath11k_ce_init_pipes+0x4c/0x1a0 [ath11k]
55 [ 93.231610] ath11k_core_qmi_firmware_ready+0x3c/0x568 [ath11k]
56 [ 93.236646] ath11k_qmi_driver_event_work+0x168/0x4f8 [ath11k]
57 [ 93.242376] process_one_work+0x144/0x350
58 [ 93.248275] worker_thread+0x120/0x430
59 [ 93.252352] kthread+0xf4/0x110
60 [ 93.255997] ret_from_fork+0x10/0x20
61 [ 93.259043] Code: d503201f f94e1c00 8b214001 d50332bf (b9000022)
62 [ 93.262863] ---[ end trace 0000000000000000 ]---
63
64 However, for the device IPQ5018 ath11k_hw_params .ce_remap is
65 defined. This parameter is used to recalculate ab->mem_ce and hence,
66 this issue is not seen in IPQ5018.
67
68 Hence, fix this by initializing ab->mem_ce after ab->mem is set.
69 ab->mem is set inside the ath11k_ahb_setup_resources() therefore
70 initialize ab->mem_ce after ath11k_ahb_setup_resources().
71
72 Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
73
74 Fixes: b42b3678c91f ("wifi: ath11k: remap ce register space for IPQ5018")
75
76 Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
77 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
78 Link: https://lore.kernel.org/r/20230113063209.7256-1-quic_rajkbhag@quicinc.com
79 ---
80 drivers/net/wireless/ath/ath11k/ahb.c | 12 ++++++------
81 1 file changed, 6 insertions(+), 6 deletions(-)
82
83 --- a/drivers/net/wireless/ath/ath11k/ahb.c
84 +++ b/drivers/net/wireless/ath/ath11k/ahb.c
85 @@ -1157,12 +1157,16 @@ static int ath11k_ahb_probe(struct platf
86 goto err_core_free;
87 }
88
89 - ab->mem_ce = ab->mem;
90 -
91 ret = ath11k_core_pre_init(ab);
92 if (ret)
93 goto err_core_free;
94
95 + ret = ath11k_ahb_setup_resources(ab);
96 + if (ret)
97 + goto err_core_free;
98 +
99 + ab->mem_ce = ab->mem;
100 +
101 if (ab->hw_params.ce_remap) {
102 const struct ce_remap *ce_remap = ab->hw_params.ce_remap;
103 /* ce register space is moved out of wcss unlike ipq8074 or ipq6018
104 @@ -1177,10 +1181,6 @@ static int ath11k_ahb_probe(struct platf
105 }
106 }
107
108 - ret = ath11k_ahb_setup_resources(ab);
109 - if (ret)
110 - goto err_core_free;
111 -
112 ret = ath11k_ahb_fw_resources_init(ab);
113 if (ret)
114 goto err_core_free;