5ff40aac7a12d071f917efaed7327dd2039c6bf6
[librecmc/librecmc.git] /
1 From 88ca89202f8e8afb5225eb5244d79cd67c15d744 Mon Sep 17 00:00:00 2001
2 From: Wen Gong <quic_wgong@quicinc.com>
3 Date: Fri, 26 May 2023 12:41:06 +0300
4 Subject: [PATCH] wifi: ath11k: add support default regdb while searching
5  board-2.bin for WCN6855
6
7 Sometimes board-2.bin does not have the regdb data which matched the
8 parameters such as vendor, device, subsystem-vendor, subsystem-device
9 and etc. Add default regdb data with 'bus=%s' into board-2.bin for
10 WCN6855, then ath11k use 'bus=pci' to search regdb data in board-2.bin
11 for WCN6855.
12
13 kernel: [  122.515808] ath11k_pci 0000:03:00.0: boot using board name 'bus=pci,vendor=17cb,device=1103,subsystem-vendor=17cb,subsystem-device=3374,qmi-chip-id=2,qmi-board-id=262'
14 kernel: [  122.517240] ath11k_pci 0000:03:00.0: boot firmware request ath11k/WCN6855/hw2.0/board-2.bin size 6179564
15 kernel: [  122.517280] ath11k_pci 0000:03:00.0: failed to fetch regdb data for bus=pci,vendor=17cb,device=1103,subsystem-vendor=17cb,subsystem-device=3374,qmi-chip-id=2,qmi-board-id=262 from ath11k/WCN6855/hw2.0/board-2.bin
16 kernel: [  122.517464] ath11k_pci 0000:03:00.0: boot using board name 'bus=pci'
17 kernel: [  122.518901] ath11k_pci 0000:03:00.0: boot firmware request ath11k/WCN6855/hw2.0/board-2.bin size 6179564
18 kernel: [  122.518915] ath11k_pci 0000:03:00.0: board name
19 kernel: [  122.518917] ath11k_pci 0000:03:00.0: 00000000: 62 75 73 3d 70 63 69                             bus=pci
20 kernel: [  122.518918] ath11k_pci 0000:03:00.0: boot found match regdb data for name 'bus=pci'
21 kernel: [  122.518920] ath11k_pci 0000:03:00.0: boot found regdb data for 'bus=pci'
22 kernel: [  122.518921] ath11k_pci 0000:03:00.0: fetched regdb
23
24 Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3
25
26 Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
27 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
28 Link: https://lore.kernel.org/r/20230517133959.8224-1-quic_wgong@quicinc.com
29 ---
30  drivers/net/wireless/ath/ath11k/core.c | 53 +++++++++++++++++++-------
31  1 file changed, 40 insertions(+), 13 deletions(-)
32
33 --- a/drivers/net/wireless/ath/ath11k/core.c
34 +++ b/drivers/net/wireless/ath/ath11k/core.c
35 @@ -961,7 +961,8 @@ int ath11k_core_check_dt(struct ath11k_b
36  }
37  
38  static int __ath11k_core_create_board_name(struct ath11k_base *ab, char *name,
39 -                                          size_t name_len, bool with_variant)
40 +                                          size_t name_len, bool with_variant,
41 +                                          bool bus_type_mode)
42  {
43         /* strlen(',variant=') + strlen(ab->qmi.target.bdf_ext) */
44         char variant[9 + ATH11K_QMI_BDF_EXT_STR_LENGTH] = { 0 };
45 @@ -972,15 +973,20 @@ static int __ath11k_core_create_board_na
46  
47         switch (ab->id.bdf_search) {
48         case ATH11K_BDF_SEARCH_BUS_AND_BOARD:
49 -               scnprintf(name, name_len,
50 -                         "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x,qmi-chip-id=%d,qmi-board-id=%d%s",
51 -                         ath11k_bus_str(ab->hif.bus),
52 -                         ab->id.vendor, ab->id.device,
53 -                         ab->id.subsystem_vendor,
54 -                         ab->id.subsystem_device,
55 -                         ab->qmi.target.chip_id,
56 -                         ab->qmi.target.board_id,
57 -                         variant);
58 +               if (bus_type_mode)
59 +                       scnprintf(name, name_len,
60 +                                 "bus=%s",
61 +                                 ath11k_bus_str(ab->hif.bus));
62 +               else
63 +                       scnprintf(name, name_len,
64 +                                 "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x,qmi-chip-id=%d,qmi-board-id=%d%s",
65 +                                 ath11k_bus_str(ab->hif.bus),
66 +                                 ab->id.vendor, ab->id.device,
67 +                                 ab->id.subsystem_vendor,
68 +                                 ab->id.subsystem_device,
69 +                                 ab->qmi.target.chip_id,
70 +                                 ab->qmi.target.board_id,
71 +                                 variant);
72                 break;
73         default:
74                 scnprintf(name, name_len,
75 @@ -999,13 +1005,19 @@ static int __ath11k_core_create_board_na
76  static int ath11k_core_create_board_name(struct ath11k_base *ab, char *name,
77                                          size_t name_len)
78  {
79 -       return __ath11k_core_create_board_name(ab, name, name_len, true);
80 +       return __ath11k_core_create_board_name(ab, name, name_len, true, false);
81  }
82  
83  static int ath11k_core_create_fallback_board_name(struct ath11k_base *ab, char *name,
84                                                   size_t name_len)
85  {
86 -       return __ath11k_core_create_board_name(ab, name, name_len, false);
87 +       return __ath11k_core_create_board_name(ab, name, name_len, false, false);
88 +}
89 +
90 +static int ath11k_core_create_bus_type_board_name(struct ath11k_base *ab, char *name,
91 +                                                 size_t name_len)
92 +{
93 +       return __ath11k_core_create_board_name(ab, name, name_len, false, true);
94  }
95  
96  const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab,
97 @@ -1309,7 +1321,7 @@ success:
98  
99  int ath11k_core_fetch_regdb(struct ath11k_base *ab, struct ath11k_board_data *bd)
100  {
101 -       char boardname[BOARD_NAME_SIZE];
102 +       char boardname[BOARD_NAME_SIZE], default_boardname[BOARD_NAME_SIZE];
103         int ret;
104  
105         ret = ath11k_core_create_board_name(ab, boardname, BOARD_NAME_SIZE);
106 @@ -1323,6 +1335,21 @@ int ath11k_core_fetch_regdb(struct ath11
107                                                  ATH11K_BD_IE_REGDB,
108                                                  ATH11K_BD_IE_REGDB_NAME,
109                                                  ATH11K_BD_IE_REGDB_DATA);
110 +       if (!ret)
111 +               goto exit;
112 +
113 +       ret = ath11k_core_create_bus_type_board_name(ab, default_boardname,
114 +                                                    BOARD_NAME_SIZE);
115 +       if (ret) {
116 +               ath11k_dbg(ab, ATH11K_DBG_BOOT,
117 +                          "failed to create default board name for regdb: %d", ret);
118 +               goto exit;
119 +       }
120 +
121 +       ret = ath11k_core_fetch_board_data_api_n(ab, bd, default_boardname,
122 +                                                ATH11K_BD_IE_REGDB,
123 +                                                ATH11K_BD_IE_REGDB_NAME,
124 +                                                ATH11K_BD_IE_REGDB_DATA);
125         if (!ret)
126                 goto exit;
127