2021-09-02 10:01:34

by Zijun Hu

[permalink] [raw]
Subject: [PATCH v7] Bluetooth: btusb: Add support using different nvm for variant WCN6855 controller

From: Tim Jiang <[email protected]>

the RF perfermence of wcn6855 soc chip from different foundries will be
difference, so we should use different nvm to configure them.

Signed-off-by: Tim Jiang <[email protected]>
---
drivers/bluetooth/btusb.c | 50 +++++++++++++++++++++++++++++++++++------------
1 file changed, 37 insertions(+), 13 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 928cbfa4c42d..218547f6097e 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3161,6 +3161,9 @@ static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev,
#define QCA_DFU_TIMEOUT 3000
#define QCA_FLAG_MULTI_NVM 0x80

+#define WCN6855_2_0_RAM_VERSION_GF 0x400c1200
+#define WCN6855_2_1_RAM_VERSION_GF 0x400c1211
+
struct qca_version {
__le32 rom_version;
__le32 patch_version;
@@ -3192,6 +3195,7 @@ static const struct qca_device_info qca_devices_table[] = {
{ 0x00000302, 28, 4, 16 }, /* Rome 3.2 */
{ 0x00130100, 40, 4, 16 }, /* WCN6855 1.0 */
{ 0x00130200, 40, 4, 16 }, /* WCN6855 2.0 */
+ { 0x00130201, 40, 4, 16 }, /* WCN6855 2.1 */
};

static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 request,
@@ -3346,6 +3350,31 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev,
return err;
}

+static void btusb_generate_qca_nvm_name(char *fwname,
+ size_t max_size,
+ struct qca_version *ver,
+ char *variant)
+{
+ char *separator = (strlen(variant) == 0) ? "" : "_";
+ u16 board_id = le16_to_cpu(ver->board_id);
+ u32 rom_version = le32_to_cpu(ver->rom_version);
+
+ if (((ver->flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) {
+ /* if boardid equal 0, use default nvm without suffix */
+ if (board_id == 0x0) {
+ snprintf(fwname, max_size, "qca/nvm_usb_%08x%s%s.bin",
+ rom_version, separator, variant);
+ } else {
+ snprintf(fwname, max_size, "qca/nvm_usb_%08x%s%s_%04x.bin",
+ rom_version, separator, variant, board_id);
+ }
+ } else {
+ snprintf(fwname, max_size, "qca/nvm_usb_%08x.bin",
+ rom_version);
+ }
+
+}
+
static int btusb_setup_qca_load_nvm(struct hci_dev *hdev,
struct qca_version *ver,
const struct qca_device_info *info)
@@ -3354,19 +3383,14 @@ static int btusb_setup_qca_load_nvm(struct hci_dev *hdev,
char fwname[64];
int err;

- if (((ver->flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) {
- /* if boardid equal 0, use default nvm without surfix */
- if (le16_to_cpu(ver->board_id) == 0x0) {
- snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x.bin",
- le32_to_cpu(ver->rom_version));
- } else {
- snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x_%04x.bin",
- le32_to_cpu(ver->rom_version),
- le16_to_cpu(ver->board_id));
- }
- } else {
- snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x.bin",
- le32_to_cpu(ver->rom_version));
+ switch (ver->ram_version) {
+ case WCN6855_2_0_RAM_VERSION_GF:
+ case WCN6855_2_1_RAM_VERSION_GF:
+ btusb_generate_qca_nvm_name(fwname, sizeof(fwname), ver, "gf");
+ break;
+ default:
+ btusb_generate_qca_nvm_name(fwname, sizeof(fwname), ver, "");
+ break;
}

err = request_firmware(&fw, fwname, &hdev->dev);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project


2021-09-02 10:53:20

by bluez.test.bot

[permalink] [raw]
Subject: RE: [v7] Bluetooth: btusb: Add support using different nvm for variant WCN6855 controller

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=541095

---Test result---

Test Summary:
CheckPatch PASS 0.47 seconds
GitLint FAIL 0.09 seconds
BuildKernel PASS 498.39 seconds
TestRunner: Setup PASS 336.63 seconds
TestRunner: l2cap-tester PASS 2.60 seconds
TestRunner: bnep-tester PASS 1.89 seconds
TestRunner: mgmt-tester PASS 31.04 seconds
TestRunner: rfcomm-tester PASS 2.06 seconds
TestRunner: sco-tester PASS 2.00 seconds
TestRunner: smp-tester PASS 2.07 seconds
TestRunner: userchan-tester PASS 1.89 seconds

Details
##############################
Test: CheckPatch - PASS - 0.47 seconds
Run checkpatch.pl script with rule in .checkpatch.conf


##############################
Test: GitLint - FAIL - 0.09 seconds
Run gitlint with rule in .gitlint
Bluetooth: btusb: Add support using different nvm for variant WCN6855 controller
1: T1 Title exceeds max length (80>72): "Bluetooth: btusb: Add support using different nvm for variant WCN6855 controller"


##############################
Test: BuildKernel - PASS - 498.39 seconds
Build Kernel with minimal configuration supports Bluetooth


##############################
Test: TestRunner: Setup - PASS - 336.63 seconds
Setup environment for running Test Runner


##############################
Test: TestRunner: l2cap-tester - PASS - 2.60 seconds
Run test-runner with l2cap-tester
Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0

##############################
Test: TestRunner: bnep-tester - PASS - 1.89 seconds
Run test-runner with bnep-tester
Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0

##############################
Test: TestRunner: mgmt-tester - PASS - 31.04 seconds
Run test-runner with mgmt-tester
Total: 452, Passed: 452 (100.0%), Failed: 0, Not Run: 0

##############################
Test: TestRunner: rfcomm-tester - PASS - 2.06 seconds
Run test-runner with rfcomm-tester
Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0

##############################
Test: TestRunner: sco-tester - PASS - 2.00 seconds
Run test-runner with sco-tester
Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0

##############################
Test: TestRunner: smp-tester - PASS - 2.07 seconds
Run test-runner with smp-tester
Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0

##############################
Test: TestRunner: userchan-tester - PASS - 1.89 seconds
Run test-runner with userchan-tester
Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0



---
Regards,
Linux Bluetooth


Attachments:
l2cap-tester.log (43.34 kB)
bnep-tester.log (3.51 kB)
mgmt-tester.log (607.97 kB)
rfcomm-tester.log (11.44 kB)
sco-tester.log (9.71 kB)
smp-tester.log (11.58 kB)
userchan-tester.log (5.36 kB)
Download all attachments

2021-09-02 23:25:53

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v7] Bluetooth: btusb: Add support using different nvm for variant WCN6855 controller

Hi Zijun,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on bluetooth-next/master]
[also build test WARNING on linus/master v5.14 next-20210902]
[cannot apply to linux/master bluetooth/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Zijun-Hu/Bluetooth-btusb-Add-support-using-different-nvm-for-variant-WCN6855-controller/20210902-165857
base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
config: i386-randconfig-s002-20210831 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-348-gf0e6938b-dirty
# https://github.com/0day-ci/linux/commit/971383be35e3681a6e8b1e85ad3c01f21f4e0076
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Zijun-Hu/Bluetooth-btusb-Add-support-using-different-nvm-for-variant-WCN6855-controller/20210902-165857
git checkout 971383be35e3681a6e8b1e85ad3c01f21f4e0076
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/bluetooth/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


sparse warnings: (new ones prefixed by >>)
drivers/bluetooth/btusb.c:1871:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1875:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1879:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1883:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1887:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1893:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:3330:28: sparse: sparse: cast to restricted __le32
drivers/bluetooth/btusb.c:3362:18: sparse: sparse: restricted __le16 degrades to integer
>> drivers/bluetooth/btusb.c:3386:20: sparse: sparse: restricted __le32 degrades to integer
>> drivers/bluetooth/btusb.c:3386:20: sparse: sparse: restricted __le32 degrades to integer

vim +3386 drivers/bluetooth/btusb.c

3377
3378 static int btusb_setup_qca_load_nvm(struct hci_dev *hdev,
3379 struct qca_version *ver,
3380 const struct qca_device_info *info)
3381 {
3382 const struct firmware *fw;
3383 char fwname[64];
3384 int err;
3385
> 3386 switch (ver->ram_version) {
3387 case WCN6855_2_0_RAM_VERSION_GF:
3388 case WCN6855_2_1_RAM_VERSION_GF:
3389 btusb_generate_qca_nvm_name(fwname, sizeof(fwname), ver, "gf");
3390 break;
3391 default:
3392 btusb_generate_qca_nvm_name(fwname, sizeof(fwname), ver, "");
3393 break;
3394 }
3395
3396 err = request_firmware(&fw, fwname, &hdev->dev);
3397 if (err) {
3398 bt_dev_err(hdev, "failed to request NVM file: %s (%d)",
3399 fwname, err);
3400 return err;
3401 }
3402
3403 bt_dev_info(hdev, "using NVM file: %s", fwname);
3404
3405 err = btusb_setup_qca_download_fw(hdev, fw, info->nvm_hdr);
3406
3407 release_firmware(fw);
3408
3409 return err;
3410 }
3411

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (3.55 kB)
.config.gz (35.38 kB)
Download all attachments