mac80211: CVE-2024-46760: rtw88: schedule rx work after everything is set up
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / ath11k / 0016-wifi-ath11k-add-chip-id-board-name-while-searching-b.patch
1 From 1133af5aea588a58043244a4ecb5ce511b310356 Mon Sep 17 00:00:00 2001
2 From: Wen Gong <quic_wgong@quicinc.com>
3 Date: Wed, 30 Aug 2023 02:02:26 -0400
4 Subject: [PATCH] wifi: ath11k: add chip id board name while searching
5 board-2.bin for WCN6855
6
7 Sometimes board-2.bin does not have the board data which matched the
8 parameters such as bus type, vendor, device, subsystem-vendor,
9 subsystem-device, qmi-chip-id and qmi-board-id, then wlan will load fail.
10
11 Hence add another type which only matches the bus type and qmi-chip-id,
12 then the ratio of missing board data reduced.
13
14 Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23
15
16 Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
17 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
18 Link: https://lore.kernel.org/r/20230830060226.18664-1-quic_wgong@quicinc.com
19 ---
20 drivers/net/wireless/ath/ath11k/core.c | 108 ++++++++++++++++++++-----
21 1 file changed, 87 insertions(+), 21 deletions(-)
22
23 --- a/drivers/net/wireless/ath/ath11k/core.c
24 +++ b/drivers/net/wireless/ath/ath11k/core.c
25 @@ -985,9 +985,15 @@ int ath11k_core_check_dt(struct ath11k_b
26 return 0;
27 }
28
29 +enum ath11k_bdf_name_type {
30 + ATH11K_BDF_NAME_FULL,
31 + ATH11K_BDF_NAME_BUS_NAME,
32 + ATH11K_BDF_NAME_CHIP_ID,
33 +};
34 +
35 static int __ath11k_core_create_board_name(struct ath11k_base *ab, char *name,
36 size_t name_len, bool with_variant,
37 - bool bus_type_mode)
38 + enum ath11k_bdf_name_type name_type)
39 {
40 /* strlen(',variant=') + strlen(ab->qmi.target.bdf_ext) */
41 char variant[9 + ATH11K_QMI_BDF_EXT_STR_LENGTH] = { 0 };
42 @@ -998,11 +1004,8 @@ static int __ath11k_core_create_board_na
43
44 switch (ab->id.bdf_search) {
45 case ATH11K_BDF_SEARCH_BUS_AND_BOARD:
46 - if (bus_type_mode)
47 - scnprintf(name, name_len,
48 - "bus=%s",
49 - ath11k_bus_str(ab->hif.bus));
50 - else
51 + switch (name_type) {
52 + case ATH11K_BDF_NAME_FULL:
53 scnprintf(name, name_len,
54 "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x,qmi-chip-id=%d,qmi-board-id=%d%s",
55 ath11k_bus_str(ab->hif.bus),
56 @@ -1012,6 +1015,19 @@ static int __ath11k_core_create_board_na
57 ab->qmi.target.chip_id,
58 ab->qmi.target.board_id,
59 variant);
60 + break;
61 + case ATH11K_BDF_NAME_BUS_NAME:
62 + scnprintf(name, name_len,
63 + "bus=%s",
64 + ath11k_bus_str(ab->hif.bus));
65 + break;
66 + case ATH11K_BDF_NAME_CHIP_ID:
67 + scnprintf(name, name_len,
68 + "bus=%s,qmi-chip-id=%d",
69 + ath11k_bus_str(ab->hif.bus),
70 + ab->qmi.target.chip_id);
71 + break;
72 + }
73 break;
74 default:
75 scnprintf(name, name_len,
76 @@ -1030,19 +1046,29 @@ static int __ath11k_core_create_board_na
77 static int ath11k_core_create_board_name(struct ath11k_base *ab, char *name,
78 size_t name_len)
79 {
80 - return __ath11k_core_create_board_name(ab, name, name_len, true, false);
81 + return __ath11k_core_create_board_name(ab, name, name_len, true,
82 + ATH11K_BDF_NAME_FULL);
83 }
84
85 static int ath11k_core_create_fallback_board_name(struct ath11k_base *ab, char *name,
86 size_t name_len)
87 {
88 - return __ath11k_core_create_board_name(ab, name, name_len, false, false);
89 + return __ath11k_core_create_board_name(ab, name, name_len, false,
90 + ATH11K_BDF_NAME_FULL);
91 }
92
93 static int ath11k_core_create_bus_type_board_name(struct ath11k_base *ab, char *name,
94 size_t name_len)
95 {
96 - return __ath11k_core_create_board_name(ab, name, name_len, false, true);
97 + return __ath11k_core_create_board_name(ab, name, name_len, false,
98 + ATH11K_BDF_NAME_BUS_NAME);
99 +}
100 +
101 +static int ath11k_core_create_chip_id_board_name(struct ath11k_base *ab, char *name,
102 + size_t name_len)
103 +{
104 + return __ath11k_core_create_board_name(ab, name, name_len, false,
105 + ATH11K_BDF_NAME_CHIP_ID);
106 }
107
108 const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab,
109 @@ -1289,16 +1315,21 @@ int ath11k_core_fetch_board_data_api_1(s
110 #define BOARD_NAME_SIZE 200
111 int ath11k_core_fetch_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd)
112 {
113 - char boardname[BOARD_NAME_SIZE], fallback_boardname[BOARD_NAME_SIZE];
114 + char *boardname = NULL, *fallback_boardname = NULL, *chip_id_boardname = NULL;
115 char *filename, filepath[100];
116 - int ret;
117 + int ret = 0;
118
119 filename = ATH11K_BOARD_API2_FILE;
120 + boardname = kzalloc(BOARD_NAME_SIZE, GFP_KERNEL);
121 + if (!boardname) {
122 + ret = -ENOMEM;
123 + goto exit;
124 + }
125
126 - ret = ath11k_core_create_board_name(ab, boardname, sizeof(boardname));
127 + ret = ath11k_core_create_board_name(ab, boardname, BOARD_NAME_SIZE);
128 if (ret) {
129 ath11k_err(ab, "failed to create board name: %d", ret);
130 - return ret;
131 + goto exit;
132 }
133
134 ab->bd_api = 2;
135 @@ -1307,13 +1338,19 @@ int ath11k_core_fetch_bdf(struct ath11k_
136 ATH11K_BD_IE_BOARD_NAME,
137 ATH11K_BD_IE_BOARD_DATA);
138 if (!ret)
139 - goto success;
140 + goto exit;
141 +
142 + fallback_boardname = kzalloc(BOARD_NAME_SIZE, GFP_KERNEL);
143 + if (!fallback_boardname) {
144 + ret = -ENOMEM;
145 + goto exit;
146 + }
147
148 ret = ath11k_core_create_fallback_board_name(ab, fallback_boardname,
149 - sizeof(fallback_boardname));
150 + BOARD_NAME_SIZE);
151 if (ret) {
152 ath11k_err(ab, "failed to create fallback board name: %d", ret);
153 - return ret;
154 + goto exit;
155 }
156
157 ret = ath11k_core_fetch_board_data_api_n(ab, bd, fallback_boardname,
158 @@ -1321,7 +1358,28 @@ int ath11k_core_fetch_bdf(struct ath11k_
159 ATH11K_BD_IE_BOARD_NAME,
160 ATH11K_BD_IE_BOARD_DATA);
161 if (!ret)
162 - goto success;
163 + goto exit;
164 +
165 + chip_id_boardname = kzalloc(BOARD_NAME_SIZE, GFP_KERNEL);
166 + if (!chip_id_boardname) {
167 + ret = -ENOMEM;
168 + goto exit;
169 + }
170 +
171 + ret = ath11k_core_create_chip_id_board_name(ab, chip_id_boardname,
172 + BOARD_NAME_SIZE);
173 + if (ret) {
174 + ath11k_err(ab, "failed to create chip id board name: %d", ret);
175 + goto exit;
176 + }
177 +
178 + ret = ath11k_core_fetch_board_data_api_n(ab, bd, chip_id_boardname,
179 + ATH11K_BD_IE_BOARD,
180 + ATH11K_BD_IE_BOARD_NAME,
181 + ATH11K_BD_IE_BOARD_DATA);
182 +
183 + if (!ret)
184 + goto exit;
185
186 ab->bd_api = 1;
187 ret = ath11k_core_fetch_board_data_api_1(ab, bd, ATH11K_DEFAULT_BOARD_FILE);
188 @@ -1334,14 +1392,22 @@ int ath11k_core_fetch_bdf(struct ath11k_
189 ath11k_err(ab, "failed to fetch board data for %s from %s\n",
190 fallback_boardname, filepath);
191
192 + ath11k_err(ab, "failed to fetch board data for %s from %s\n",
193 + chip_id_boardname, filepath);
194 +
195 ath11k_err(ab, "failed to fetch board.bin from %s\n",
196 ab->hw_params.fw.dir);
197 - return ret;
198 }
199
200 -success:
201 - ath11k_dbg(ab, ATH11K_DBG_BOOT, "using board api %d\n", ab->bd_api);
202 - return 0;
203 +exit:
204 + kfree(boardname);
205 + kfree(fallback_boardname);
206 + kfree(chip_id_boardname);
207 +
208 + if (!ret)
209 + ath11k_dbg(ab, ATH11K_DBG_BOOT, "using board api %d\n", ab->bd_api);
210 +
211 + return ret;
212 }
213
214 int ath11k_core_fetch_regdb(struct ath11k_base *ab, struct ath11k_board_data *bd)