2021-10-11 13:36:46

by tjiang

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

the RF performance 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 | 54
+++++++++++++++++++++++++++++++++++------------
1 file changed, 40 insertions(+), 14 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 75c83768c257..ed1ccf061a54 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3190,6 +3190,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;
@@ -3221,6 +3224,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,
@@ -3375,6 +3379,41 @@ 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)
+{
+ u32 rom_version = le32_to_cpu(ver->rom_version);
+
+ if (((ver->flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) {
+ u16 board_id = le16_to_cpu(ver->board_id);
+ const char *variant;
+
+ switch (ver->ram_version) {
+ case WCN6855_2_0_RAM_VERSION_GF:
+ case WCN6855_2_1_RAM_VERSION_GF:
+ variant = "_gf";
+ break;
+ default:
+ variant = "";
+ break;
+ }
+
+ /* if boardid equal 0, use default nvm without suffix */
+ if (board_id == 0x0) {
+ snprintf(fwname, max_size, "qca/nvm_usb_%08x%s.bin",
+ rom_version, variant);
+ } else {
+ snprintf(fwname, max_size, "qca/nvm_usb_%08x%s_%04x.bin",
+ rom_version, 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)
@@ -3383,20 +3422,7 @@ 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));
- }
+ btusb_generate_qca_nvm_name(fwname, sizeof(fwname), ver);

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


2021-10-12 06:32:51

by kernel test robot

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

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on bluetooth-next/master]
[also build test WARNING on linux/master linus/master v5.15-rc5 next-20211011]
[cannot apply to 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/tjiang-codeaurora-org/Bluetooth-btusb-Add-support-for-variant-WCN6855-by-using-different-nvm/20211011-184940
base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
config: openrisc-randconfig-s032-20211011 (attached as .config)
compiler: or1k-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/0day-ci/linux/commit/ac46dc5565c49861c2439a5534e2e64ff819eb60
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review tjiang-codeaurora-org/Bluetooth-btusb-Add-support-for-variant-WCN6855-by-using-different-nvm/20211011-184940
git checkout ac46dc5565c49861c2439a5534e2e64ff819eb60
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=openrisc 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:1900:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1900:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1900:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1900:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1904:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1904:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1904:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1904:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1908:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1908:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1908:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1908:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1912:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1912:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1912:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1912:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1916:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1916:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1916:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1916:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1922:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1922:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1922:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:1922:18: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btusb.c:3359:28: sparse: sparse: cast to restricted __le32
drivers/bluetooth/btusb.c:3359:28: sparse: sparse: cast to restricted __le32
drivers/bluetooth/btusb.c:3359:28: sparse: sparse: cast to restricted __le32
drivers/bluetooth/btusb.c:3359:28: sparse: sparse: cast to restricted __le32
drivers/bluetooth/btusb.c:3359:28: sparse: sparse: cast to restricted __le32
drivers/bluetooth/btusb.c:3359:28: sparse: sparse: cast to restricted __le32
drivers/bluetooth/btusb.c:3388:18: sparse: sparse: restricted __le16 degrades to integer
>> drivers/bluetooth/btusb.c:3392:28: sparse: sparse: restricted __le32 degrades to integer
>> drivers/bluetooth/btusb.c:3392:28: sparse: sparse: restricted __le32 degrades to integer

vim +3392 drivers/bluetooth/btusb.c

3381
3382 static void btusb_generate_qca_nvm_name(char *fwname,
3383 size_t max_size,
3384 struct qca_version *ver)
3385 {
3386 u32 rom_version = le32_to_cpu(ver->rom_version);
3387
3388 if (((ver->flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) {
3389 u16 board_id = le16_to_cpu(ver->board_id);
3390 const char *variant;
3391
> 3392 switch (ver->ram_version) {
3393 case WCN6855_2_0_RAM_VERSION_GF:
3394 case WCN6855_2_1_RAM_VERSION_GF:
3395 variant = "_gf";
3396 break;
3397 default:
3398 variant = "";
3399 break;
3400 }
3401
3402 /* if boardid equal 0, use default nvm without suffix */
3403 if (board_id == 0x0) {
3404 snprintf(fwname, max_size, "qca/nvm_usb_%08x%s.bin",
3405 rom_version, variant);
3406 } else {
3407 snprintf(fwname, max_size, "qca/nvm_usb_%08x%s_%04x.bin",
3408 rom_version, variant, board_id);
3409 }
3410 } else {
3411 snprintf(fwname, max_size, "qca/nvm_usb_%08x.bin",
3412 rom_version);
3413 }
3414

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


Attachments:
(No filename) (5.61 kB)
.config.gz (36.94 kB)
Download all attachments