2021-11-18 10:01:49

by Wen Gong

[permalink] [raw]
Subject: [PATCH v2] ath11k: add read variant from SMBIOS for download board data

This is to read variant from SMBIOS such as read from DT, the variant
string will be used to one part of string which used to search board
data from board-2.bin.

Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1

Signed-off-by: Wen Gong <[email protected]>
---
v2: rebased to latest ath.git master ath-202111170737

drivers/net/wireless/ath/ath11k/core.c | 74 ++++++++++++++++++++++++++
drivers/net/wireless/ath/ath11k/core.h | 11 ++++
drivers/net/wireless/ath/ath11k/qmi.c | 4 ++
3 files changed, 89 insertions(+)

diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c
index a40bbca3e9af..eac5675e0df4 100644
--- a/drivers/net/wireless/ath/ath11k/core.c
+++ b/drivers/net/wireless/ath/ath11k/core.c
@@ -8,6 +8,9 @@
#include <linux/remoteproc.h>
#include <linux/firmware.h>
#include <linux/of.h>
+#include <linux/dmi.h>
+#include <linux/ctype.h>
+
#include "core.h"
#include "dp_tx.h"
#include "dp_rx.h"
@@ -379,6 +382,77 @@ int ath11k_core_resume(struct ath11k_base *ab)
}
EXPORT_SYMBOL(ath11k_core_resume);

+static void ath11k_core_check_bdfext(const struct dmi_header *hdr, void *data)
+{
+ struct ath11k_base *ab = data;
+ const char *bdf_ext;
+ const char *magic = ATH11K_SMBIOS_BDF_EXT_MAGIC;
+ u8 bdf_enabled;
+ int i;
+ size_t len;
+
+ if (ab->qmi.target.bdf_ext[0] != '\0')
+ return;
+
+ if (hdr->type != ATH11K_SMBIOS_BDF_EXT_TYPE)
+ return;
+
+ if (hdr->length != ATH11K_SMBIOS_BDF_EXT_LENGTH) {
+ ath11k_dbg(ab, ATH11K_DBG_BOOT,
+ "wrong smbios bdf ext type length (%d).\n",
+ hdr->length);
+ return;
+ }
+
+ bdf_enabled = *((u8 *)hdr + ATH11K_SMBIOS_BDF_EXT_OFFSET);
+ if (!bdf_enabled) {
+ ath11k_dbg(ab, ATH11K_DBG_BOOT, "bdf variant name not found.\n");
+ return;
+ }
+
+ /* Only one string exists (per spec) */
+ bdf_ext = (char *)hdr + hdr->length;
+
+ if (memcmp(bdf_ext, magic, strlen(magic)) != 0) {
+ ath11k_dbg(ab, ATH11K_DBG_BOOT,
+ "bdf variant magic does not match.\n");
+ return;
+ }
+
+ len = strlen(bdf_ext);
+ for (i = 0; i < len; i++) {
+ if (!isascii(bdf_ext[i]) || !isprint(bdf_ext[i])) {
+ ath11k_dbg(ab, ATH11K_DBG_BOOT,
+ "bdf variant name contains non ascii chars.\n");
+ return;
+ }
+ }
+
+ /* Copy extension name without magic prefix */
+ if (strscpy(ab->qmi.target.bdf_ext, bdf_ext + strlen(magic),
+ sizeof(ab->qmi.target.bdf_ext)) < 0) {
+ ath11k_dbg(ab, ATH11K_DBG_BOOT,
+ "bdf variant string is longer than the buffer can accommodate (variant: %s)\n",
+ bdf_ext);
+ return;
+ }
+
+ ath11k_dbg(ab, ATH11K_DBG_BOOT,
+ "found and validated bdf variant smbios_type 0x%x bdf %s\n",
+ ATH11K_SMBIOS_BDF_EXT_TYPE, bdf_ext);
+}
+
+int ath11k_core_check_smbios(struct ath11k_base *ab)
+{
+ ab->qmi.target.bdf_ext[0] = '\0';
+ dmi_walk(ath11k_core_check_bdfext, ab);
+
+ if (ab->qmi.target.bdf_ext[0] == '\0')
+ return -ENODATA;
+
+ return 0;
+}
+
int ath11k_core_check_dt(struct ath11k_base *ab)
{
size_t max_len = sizeof(ab->qmi.target.bdf_ext);
diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index bbfc10fd5c6d..b234514e7138 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -952,7 +952,18 @@ int ath11k_core_fetch_bdf(struct ath11k_base *ath11k,
struct ath11k_board_data *bd);
void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd);
int ath11k_core_check_dt(struct ath11k_base *ath11k);
+/* SMBIOS type containing Board Data File Name Extension */
+#define ATH11K_SMBIOS_BDF_EXT_TYPE 0xF8

+/* SMBIOS type structure length (excluding strings-set) */
+#define ATH11K_SMBIOS_BDF_EXT_LENGTH 0x9
+
+/* Offset pointing to Board Data File Name Extension */
+#define ATH11K_SMBIOS_BDF_EXT_OFFSET 0x8
+
+/* The magic used by QCA spec */
+#define ATH11K_SMBIOS_BDF_EXT_MAGIC "BDF_"
+int ath11k_core_check_smbios(struct ath11k_base *ab);
void ath11k_core_halt(struct ath11k *ar);
int ath11k_core_resume(struct ath11k_base *ab);
int ath11k_core_suspend(struct ath11k_base *ab);
diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c
index 25eb22cbeaeb..700a9c137018 100644
--- a/drivers/net/wireless/ath/ath11k/qmi.c
+++ b/drivers/net/wireless/ath/ath11k/qmi.c
@@ -1991,6 +1991,10 @@ static int ath11k_qmi_request_target_cap(struct ath11k_base *ab)
ab->qmi.target.fw_build_timestamp,
ab->qmi.target.fw_build_id);

+ r = ath11k_core_check_smbios(ab);
+ if (r)
+ ath11k_dbg(ab, ATH11K_DBG_QMI, "SMBIOS bdf variant name not set.\n");
+
r = ath11k_core_check_dt(ab);
if (r)
ath11k_dbg(ab, ATH11K_DBG_QMI, "DT bdf variant name not set.\n");

base-commit: 63ec871bc50a306aac550e2d85f697ca2d5f5deb
--
2.31.1



2021-11-22 14:25:47

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v2] ath11k: add read variant from SMBIOS for download board data

Wen Gong <[email protected]> writes:

> This is to read variant from SMBIOS such as read from DT, the variant
> string will be used to one part of string which used to search board
> data from board-2.bin.
>
> Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
>
> Signed-off-by: Wen Gong <[email protected]>

[...]

> +int ath11k_core_check_smbios(struct ath11k_base *ab)
> +{
> + ab->qmi.target.bdf_ext[0] = '\0';
> + dmi_walk(ath11k_core_check_bdfext, ab);

For consistency I added error handling for dmi_walk().

> diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
> index bbfc10fd5c6d..b234514e7138 100644
> --- a/drivers/net/wireless/ath/ath11k/core.h
> +++ b/drivers/net/wireless/ath/ath11k/core.h
> @@ -952,7 +952,18 @@ int ath11k_core_fetch_bdf(struct ath11k_base *ath11k,
> struct ath11k_board_data *bd);
> void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd);
> int ath11k_core_check_dt(struct ath11k_base *ath11k);
> +/* SMBIOS type containing Board Data File Name Extension */
> +#define ATH11K_SMBIOS_BDF_EXT_TYPE 0xF8
>
> +/* SMBIOS type structure length (excluding strings-set) */
> +#define ATH11K_SMBIOS_BDF_EXT_LENGTH 0x9
> +
> +/* Offset pointing to Board Data File Name Extension */
> +#define ATH11K_SMBIOS_BDF_EXT_OFFSET 0x8
> +
> +/* The magic used by QCA spec */
> +#define ATH11K_SMBIOS_BDF_EXT_MAGIC "BDF_"
> +int ath11k_core_check_smbios(struct ath11k_base *ab);
> void ath11k_core_halt(struct ath11k *ar);
> int ath11k_core_resume(struct ath11k_base *ab);
> int ath11k_core_suspend(struct ath11k_base *ab);

This was an awkward place for the defines, so I moved up in the file.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2021-11-22 14:35:32

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v2] ath11k: add read variant from SMBIOS for download board data

Wen Gong <[email protected]> wrote:

> This is to read variant from SMBIOS such as read from DT, the variant
> string will be used to one part of string which used to search board
> data from board-2.bin.
>
> Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
>
> Signed-off-by: Wen Gong <[email protected]>
> Signed-off-by: Kalle Valo <[email protected]>

Patch applied to ath-next branch of ath.git, thanks.

46e46db313a2 ath11k: add read variant from SMBIOS for download board data

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


2021-11-22 17:59:06

by Mark Herbert

[permalink] [raw]
Subject: Re: [PATCH v2] ath11k: add read variant from SMBIOS for download board data

Tried this on Dell XPS 13 9310

Maybe this patch is good for 6855, but 6390 in Dell seems to be killed
completely with it. Reverting it makes things work again.

[    5.537034] ath11k_pci 0000:72:00.0: chip_id 0x0 chip_family 0xb
board_id 0xff soc_id 0xffffffff
[    5.537038] ath11k_pci 0000:72:00.0: fw_version 0x101c06cc
fw_build_timestamp 2020-06-24 19:50 fw_build_id
[    5.537236] ath11k_pci 0000:72:00.0: failed to fetch board data for
bus=pci,qmi-chip-id=0,qmi-board-id=255,variant=DE_1901 from
ath11k/QCA6390/hw2.0/board-2.bin
[    5.537255] ath11k_pci 0000:72:00.0: failed to fetch board-2.bin or
board.bin from QCA6390/hw2.0
[    5.537257] ath11k_pci 0000:72:00.0: qmi failed to fetch board file: -2
[    5.537258] ath11k_pci 0000:72:00.0: failed to load board data file: -2

On 22.11.2021 17:35, Kalle Valo wrote:
> Wen Gong <[email protected]> wrote:
>
>> This is to read variant from SMBIOS such as read from DT, the variant
>> string will be used to one part of string which used to search board
>> data from board-2.bin.
>>
>> Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1
>>
>> Signed-off-by: Wen Gong <[email protected]>
>> Signed-off-by: Kalle Valo <[email protected]>
> Patch applied to ath-next branch of ath.git, thanks.
>
> 46e46db313a2 ath11k: add read variant from SMBIOS for download board data
>

2021-11-22 18:06:31

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v2] ath11k: add read variant from SMBIOS for download board data

Mark Herbert <[email protected]> writes:

> Tried this on Dell XPS 13 9310
>
> Maybe this patch is good for 6855, but 6390 in Dell seems to be killed
> completely with it. Reverting it makes things work again.
>
> [    5.537034] ath11k_pci 0000:72:00.0: chip_id 0x0 chip_family 0xb
> board_id 0xff soc_id 0xffffffff
> [    5.537038] ath11k_pci 0000:72:00.0: fw_version 0x101c06cc
> fw_build_timestamp 2020-06-24 19:50 fw_build_id
> [    5.537236] ath11k_pci 0000:72:00.0: failed to fetch board data for
> bus=pci,qmi-chip-id=0,qmi-board-id=255,variant=DE_1901 from
> ath11k/QCA6390/hw2.0/board-2.bin
> [    5.537255] ath11k_pci 0000:72:00.0: failed to fetch board-2.bin or
> board.bin from QCA6390/hw2.0
> [    5.537257] ath11k_pci 0000:72:00.0: qmi failed to fetch board file: -2
> [    5.537258] ath11k_pci 0000:72:00.0: failed to load board data file: -2

Doh, I didn't realise that. I only tested this on my NUC testbox, I
should have tested this on my XPS 13 9310 as well. Thanks for the
report!

I think I need to revert this and rethink how to handle the backwards
compatibility.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2021-11-24 09:44:18

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v2] ath11k: add read variant from SMBIOS for download board data

Kalle Valo <[email protected]> writes:

> Mark Herbert <[email protected]> writes:
>
>> Tried this on Dell XPS 13 9310
>>
>> Maybe this patch is good for 6855, but 6390 in Dell seems to be killed
>> completely with it. Reverting it makes things work again.
>>
>> [    5.537034] ath11k_pci 0000:72:00.0: chip_id 0x0 chip_family 0xb
>> board_id 0xff soc_id 0xffffffff
>> [    5.537038] ath11k_pci 0000:72:00.0: fw_version 0x101c06cc
>> fw_build_timestamp 2020-06-24 19:50 fw_build_id
>> [    5.537236] ath11k_pci 0000:72:00.0: failed to fetch board data for
>> bus=pci,qmi-chip-id=0,qmi-board-id=255,variant=DE_1901 from
>> ath11k/QCA6390/hw2.0/board-2.bin
>> [    5.537255] ath11k_pci 0000:72:00.0: failed to fetch board-2.bin or
>> board.bin from QCA6390/hw2.0
>> [    5.537257] ath11k_pci 0000:72:00.0: qmi failed to fetch board file: -2
>> [    5.537258] ath11k_pci 0000:72:00.0: failed to load board data file: -2
>
> Doh, I didn't realise that. I only tested this on my NUC testbox, I
> should have tested this on my XPS 13 9310 as well. Thanks for the
> report!
>
> I think I need to revert this and rethink how to handle the backwards
> compatibility.

Revert sent:

https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2021-11-24 10:07:54

by Wen Gong

[permalink] [raw]
Subject: Re: [PATCH v2] ath11k: add read variant from SMBIOS for download board data

On 11/23/2021 2:06 AM, Kalle Valo wrote:
> Mark Herbert <[email protected]> writes:
>
>> Tried this on Dell XPS 13 9310
>>
>> Maybe this patch is good for 6855, but 6390 in Dell seems to be killed
>> completely with it. Reverting it makes things work again.
>>
>> [    5.537034] ath11k_pci 0000:72:00.0: chip_id 0x0 chip_family 0xb
>> board_id 0xff soc_id 0xffffffff
>> [    5.537038] ath11k_pci 0000:72:00.0: fw_version 0x101c06cc
>> fw_build_timestamp 2020-06-24 19:50 fw_build_id
>> [    5.537236] ath11k_pci 0000:72:00.0: failed to fetch board data for
>> bus=pci,qmi-chip-id=0,qmi-board-id=255,variant=DE_1901 from
>> ath11k/QCA6390/hw2.0/board-2.bin
>> [    5.537255] ath11k_pci 0000:72:00.0: failed to fetch board-2.bin or
>> board.bin from QCA6390/hw2.0
>> [    5.537257] ath11k_pci 0000:72:00.0: qmi failed to fetch board file: -2
>> [    5.537258] ath11k_pci 0000:72:00.0: failed to load board data file: -2
> Doh, I didn't realise that. I only tested this on my NUC testbox, I
> should have tested this on my XPS 13 9310 as well. Thanks for the
> report!
>
> I think I need to revert this and rethink how to handle the backwards
> compatibility.
ath10k has patches to handle backwards compatibility for this issue, I
think ath11k can also follow it.

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/drivers/net/wireless/ath?id=c8489668065a283d3027e86e877b103a87f99d22
ath10k: search all IEs for variant before falling back

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/drivers/net/wireless/ath?id=2bc2b87bb35a4d7b022016819fc28ce9e2b13adc
ath10k: add option for chip-id based BDF selection

2021-11-25 08:57:30

by Wen Gong

[permalink] [raw]
Subject: Re: [PATCH v2] ath11k: add read variant from SMBIOS for download board data

Hi Kalle,

I have sent v3 of "ath11k: add read variant from SMBIOS for download
board data", it fixed the backwards compatibility issue.

https://patchwork.kernel.org/project/linux-wireless/list/?series=585697

Wen Gong (2):
  ath11k: add fallback board name without variant while searching
board-2.bin
  ath11k: add read variant from SMBIOS for download board data

On 11/24/2021 5:44 PM, Kalle Valo wrote:
> Kalle Valo <[email protected]> writes:
>
>> Mark Herbert <[email protected]> writes:
>>
>>> Tried this on Dell XPS 13 9310
>>>
>>> Maybe this patch is good for 6855, but 6390 in Dell seems to be killed
>>> completely with it. Reverting it makes things work again.
>>>
>>> [    5.537034] ath11k_pci 0000:72:00.0: chip_id 0x0 chip_family 0xb
>>> board_id 0xff soc_id 0xffffffff
>>> [    5.537038] ath11k_pci 0000:72:00.0: fw_version 0x101c06cc
>>> fw_build_timestamp 2020-06-24 19:50 fw_build_id
>>> [    5.537236] ath11k_pci 0000:72:00.0: failed to fetch board data for
>>> bus=pci,qmi-chip-id=0,qmi-board-id=255,variant=DE_1901 from
>>> ath11k/QCA6390/hw2.0/board-2.bin
>>> [    5.537255] ath11k_pci 0000:72:00.0: failed to fetch board-2.bin or
>>> board.bin from QCA6390/hw2.0
>>> [    5.537257] ath11k_pci 0000:72:00.0: qmi failed to fetch board file: -2
>>> [    5.537258] ath11k_pci 0000:72:00.0: failed to load board data file: -2
>> Doh, I didn't realise that. I only tested this on my NUC testbox, I
>> should have tested this on my XPS 13 9310 as well. Thanks for the
>> report!
>>
>> I think I need to revert this and rethink how to handle the backwards
>> compatibility.
> Revert sent:
>
> https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/
>