OSDN Git Service

mac80211: ath10k: backport bus and device specific API 1 BDF selection
[immortalwrt/immortalwrt.git] / package / kernel / mac80211 / patches / ath10k / 100-ath10k-support-bus-and-device-specific-API-1-BDF-sel.patch
1 From f2a7064a78b22f2b68b9fcbc8a6f4c5e61c5ba64 Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robimarko@gmail.com>
3 Date: Sun, 10 Oct 2021 00:17:11 +0200
4 Subject: [PATCH] ath10k: support bus and device specific API 1 BDF selection
5
6 Some ath10k IPQ40xx devices like the MikroTik hAP ac2 and ac3 require the
7 BDF-s to be extracted from the device storage instead of shipping packaged
8 API 2 BDF-s.
9
10 This is required as MikroTik has started shipping boards that require BDF-s
11 to be updated, as otherwise their WLAN performance really suffers.
12 This is however impossible as the devices that require this are release
13 under the same revision and its not possible to differentiate them from
14 devices using the older BDF-s.
15
16 In OpenWrt we are extracting the calibration data during runtime and we are
17 able to extract the BDF-s in the same manner, however we cannot package the
18 BDF-s to API 2 format on the fly and can only use API 1 to provide BDF-s on
19 the fly.
20 This is an issue as the ath10k driver explicitly looks only for the
21 board.bin file and not for something like board-bus-device.bin like it does
22 for pre-cal data.
23 Due to this we have no way of providing correct BDF-s on the fly, so lets
24 extend the ath10k driver to first look for BDF-s in the
25 board-bus-device.bin format, for example: board-ahb-a800000.wifi.bin
26 If that fails, look for the default board file name as defined previously.
27
28 Signed-off-by: Robert Marko <robimarko@gmail.com>
29 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
30 Link: https://lore.kernel.org/r/20211009221711.2315352-1-robimarko@gmail.com
31 ---
32  drivers/net/wireless/ath/ath10k/core.c | 13 ++++++++++++-
33  1 file changed, 12 insertions(+), 1 deletion(-)
34
35 --- a/drivers/net/wireless/ath/ath10k/core.c
36 +++ b/drivers/net/wireless/ath/ath10k/core.c
37 @@ -1199,6 +1199,7 @@ success:
38  static int ath10k_core_fetch_board_data_api_1(struct ath10k *ar, int bd_ie_type)
39  {
40         const struct firmware *fw;
41 +       char boardname[100];
42  
43         if (bd_ie_type == ATH10K_BD_IE_BOARD) {
44                 if (!ar->hw_params.fw.board) {
45 @@ -1206,9 +1207,19 @@ static int ath10k_core_fetch_board_data_
46                         return -EINVAL;
47                 }
48  
49 +               scnprintf(boardname, sizeof(boardname), "board-%s-%s.bin",
50 +                         ath10k_bus_str(ar->hif.bus), dev_name(ar->dev));
51 +
52                 ar->normal_mode_fw.board = ath10k_fetch_fw_file(ar,
53                                                                 ar->hw_params.fw.dir,
54 -                                                               ar->hw_params.fw.board);
55 +                                                               boardname);
56 +               if (IS_ERR(ar->normal_mode_fw.board)) {
57 +                       fw = ath10k_fetch_fw_file(ar,
58 +                                                 ar->hw_params.fw.dir,
59 +                                                 ar->hw_params.fw.board);
60 +                       ar->normal_mode_fw.board = fw;
61 +               }
62 +
63                 if (IS_ERR(ar->normal_mode_fw.board))
64                         return PTR_ERR(ar->normal_mode_fw.board);
65