7a7d08be487f5c10c171999078da1215257ab315
[openwrt/openwrt.git] /
1 From 6f8c8bf4c7c9be1c42088689fd4370e06b46608a Mon Sep 17 00:00:00 2001
2 From: Abinaya Kalaiselvan <akalaise@codeaurora.org>
3 Date: Wed, 20 Oct 2021 11:59:07 +0300
4 Subject: ath10k: fix module load regression with iram-recovery feature
5
6 Commit 9af7c32ceca8 ("ath10k: add target IRAM recovery feature support")
7 introduced a new firmware feature flag ATH10K_FW_FEATURE_IRAM_RECOVERY. But
8 this caused ath10k_pci module load to fail if ATH10K_FW_CRASH_DUMP_RAM_DATA bit
9 was not enabled in the ath10k coredump_mask module parameter:
10
11 [ 2209.328190] ath10k_pci 0000:02:00.0: qca9984/qca9994 hw1.0 target 0x01000000 chip_id 0x00000000 sub 168c:cafe
12 [ 2209.434414] ath10k_pci 0000:02:00.0: kconfig debug 1 debugfs 1 tracing 1 dfs 1 testmode 1
13 [ 2209.547191] ath10k_pci 0000:02:00.0: firmware ver 10.4-3.9.0.2-00099 api 5 features no-p2p,mfp,peer-flow-ctrl,btcoex-param,allows-mesh-bcast,no-ps,peer-fixed-rate,iram-recovery crc32 cbade90a
14 [ 2210.896485] ath10k_pci 0000:02:00.0: board_file api 1 bmi_id 0:1 crc32 a040efc2
15 [ 2213.603339] ath10k_pci 0000:02:00.0: failed to copy target iram contents: -12
16 [ 2213.839027] ath10k_pci 0000:02:00.0: could not init core (-12)
17 [ 2213.933910] ath10k_pci 0000:02:00.0: could not probe fw (-12)
18
19 And by default coredump_mask does not have ATH10K_FW_CRASH_DUMP_RAM_DATA
20 enabled so anyone using a firmware with iram-recovery feature would fail. To my
21 knowledge only QCA9984 firmwares starting from release 10.4-3.9.0.2-00099
22 enabled the feature.
23
24 The reason for regression was that ath10k_core_copy_target_iram() used
25 ath10k_coredump_get_mem_layout() to get the memory layout, but when
26 ATH10K_FW_CRASH_DUMP_RAM_DATA was disabled it would get just NULL and bail out
27 with an error.
28
29 While looking at all this I noticed another bug: if CONFIG_DEV_COREDUMP is
30 disabled but the firmware has iram-recovery enabled the module load fails with
31 similar error messages. I fixed that by returning 0 from
32 ath10k_core_copy_target_iram() when _ath10k_coredump_get_mem_layout() returns
33 NULL.
34
35 Tested-on: QCA9984 hw2.0 PCI 10.4-3.9.0.2-00139
36
37 Fixes: 9af7c32ceca8 ("ath10k: add target IRAM recovery feature support")
38 Signed-off-by: Abinaya Kalaiselvan <akalaise@codeaurora.org>
39 Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
40 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
41 Link: https://lore.kernel.org/r/20211020075054.23061-1-kvalo@codeaurora.org
42 ---
43 drivers/net/wireless/ath/ath10k/core.c | 11 +++++++++--
44 drivers/net/wireless/ath/ath10k/coredump.c | 11 ++++++++---
45 drivers/net/wireless/ath/ath10k/coredump.h | 7 +++++++
46 3 files changed, 24 insertions(+), 5 deletions(-)
47
48 --- a/drivers/net/wireless/ath/ath10k/core.c
49 +++ b/drivers/net/wireless/ath/ath10k/core.c
50 @@ -2690,9 +2690,16 @@ static int ath10k_core_copy_target_iram(
51 int i, ret;
52 u32 len, remaining_len;
53
54 - hw_mem = ath10k_coredump_get_mem_layout(ar);
55 + /* copy target iram feature must work also when
56 + * ATH10K_FW_CRASH_DUMP_RAM_DATA is disabled, so
57 + * _ath10k_coredump_get_mem_layout() to accomplist that
58 + */
59 + hw_mem = _ath10k_coredump_get_mem_layout(ar);
60 if (!hw_mem)
61 - return -ENOMEM;
62 + /* if CONFIG_DEV_COREDUMP is disabled we get NULL, then
63 + * just silently disable the feature by doing nothing
64 + */
65 + return 0;
66
67 for (i = 0; i < hw_mem->region_table.size; i++) {
68 tmp = &hw_mem->region_table.regions[i];
69 --- a/drivers/net/wireless/ath/ath10k/coredump.c
70 +++ b/drivers/net/wireless/ath/ath10k/coredump.c
71 @@ -1447,11 +1447,17 @@ static u32 ath10k_coredump_get_ramdump_s
72
73 const struct ath10k_hw_mem_layout *ath10k_coredump_get_mem_layout(struct ath10k *ar)
74 {
75 - int i;
76 -
77 if (!test_bit(ATH10K_FW_CRASH_DUMP_RAM_DATA, &ath10k_coredump_mask))
78 return NULL;
79
80 + return _ath10k_coredump_get_mem_layout(ar);
81 +}
82 +EXPORT_SYMBOL(ath10k_coredump_get_mem_layout);
83 +
84 +const struct ath10k_hw_mem_layout *_ath10k_coredump_get_mem_layout(struct ath10k *ar)
85 +{
86 + int i;
87 +
88 if (WARN_ON(ar->target_version == 0))
89 return NULL;
90
91 @@ -1464,7 +1470,6 @@ const struct ath10k_hw_mem_layout *ath10
92
93 return NULL;
94 }
95 -EXPORT_SYMBOL(ath10k_coredump_get_mem_layout);
96
97 struct ath10k_fw_crash_data *ath10k_coredump_new(struct ath10k *ar)
98 {
99 --- a/drivers/net/wireless/ath/ath10k/coredump.h
100 +++ b/drivers/net/wireless/ath/ath10k/coredump.h
101 @@ -176,6 +176,7 @@ int ath10k_coredump_register(struct ath1
102 void ath10k_coredump_unregister(struct ath10k *ar);
103 void ath10k_coredump_destroy(struct ath10k *ar);
104
105 +const struct ath10k_hw_mem_layout *_ath10k_coredump_get_mem_layout(struct ath10k *ar);
106 const struct ath10k_hw_mem_layout *ath10k_coredump_get_mem_layout(struct ath10k *ar);
107
108 #else /* CONFIG_DEV_COREDUMP */
109 @@ -213,6 +214,12 @@ ath10k_coredump_get_mem_layout(struct at
110 {
111 return NULL;
112 }
113 +
114 +static inline const struct ath10k_hw_mem_layout *
115 +_ath10k_coredump_get_mem_layout(struct ath10k *ar)
116 +{
117 + return NULL;
118 +}
119
120 #endif /* CONFIG_DEV_COREDUMP */
121