diff mbox series

[v5] Bluetooth: btusb: Add support using different nvm for variant WCN6855 controller

Message ID 1629793683-28770-1-git-send-email-zijuhu@codeaurora.org
State Superseded
Headers show
Series [v5] Bluetooth: btusb: Add support using different nvm for variant WCN6855 controller | expand

Commit Message

Zijun Hu Aug. 24, 2021, 8:28 a.m. UTC
From: Tim Jiang <tjiang@codeaurora.org>

we have variant wcn6855 soc chip from different foundries, so we should
use different nvm file with suffix to distinguish them.

Signed-off-by: Tim Jiang <tjiang@codeaurora.org>
---
 drivers/bluetooth/btusb.c | 57 +++++++++++++++++++++++++++++++++++++----------
 1 file changed, 45 insertions(+), 12 deletions(-)

Comments

kernel test robot Aug. 24, 2021, 1:26 p.m. UTC | #1
Hi Zijun,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bluetooth-next/master]
[also build test ERROR on linus/master v5.14-rc7 next-20210824]
[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/20210824-162956
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
config: arc-randconfig-r016-20210824 (attached as .config)
compiler: arc-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/a84ff3a51be3309837a325cd826083a72bbf48f0
        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/20210824-162956
        git checkout a84ff3a51be3309837a325cd826083a72bbf48f0
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/bluetooth/btusb.c: In function 'btusb_generate_qca_nvm_name':
>> drivers/bluetooth/btusb.c:3349:34: error: passing argument 1 of 'snprintf' from incompatible pointer type [-Werror=incompatible-pointer-types]
    3349 |                         snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x%s%s.bin",
         |                                  ^~~~~~
         |                                  |
         |                                  char **
   In file included from include/linux/list.h:9,
                    from include/linux/dmi.h:5,
                    from drivers/bluetooth/btusb.c:9:
   include/linux/kernel.h:204:20: note: expected 'char *' but argument is of type 'char **'
     204 | int snprintf(char *buf, size_t size, const char *fmt, ...);
         |              ~~~~~~^~~
   drivers/bluetooth/btusb.c:3354:34: error: passing argument 1 of 'snprintf' from incompatible pointer type [-Werror=incompatible-pointer-types]
    3354 |                         snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x%s%s%04x.bin",
         |                                  ^~~~~~
         |                                  |
         |                                  char **
   In file included from include/linux/list.h:9,
                    from include/linux/dmi.h:5,
                    from drivers/bluetooth/btusb.c:9:
   include/linux/kernel.h:204:20: note: expected 'char *' but argument is of type 'char **'
     204 | int snprintf(char *buf, size_t size, const char *fmt, ...);
         |              ~~~~~~^~~
   drivers/bluetooth/btusb.c:3361:26: error: passing argument 1 of 'snprintf' from incompatible pointer type [-Werror=incompatible-pointer-types]
    3361 |                 snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x.bin",
         |                          ^~~~~~
         |                          |
         |                          char **
   In file included from include/linux/list.h:9,
                    from include/linux/dmi.h:5,
                    from drivers/bluetooth/btusb.c:9:
   include/linux/kernel.h:204:20: note: expected 'char *' but argument is of type 'char **'
     204 | int snprintf(char *buf, size_t size, const char *fmt, ...);
         |              ~~~~~~^~~
   drivers/bluetooth/btusb.c: In function 'btusb_setup_qca_load_nvm':
>> drivers/bluetooth/btusb.c:3378:53: error: passing argument 1 of 'btusb_generate_qca_nvm_name' from incompatible pointer type [-Werror=incompatible-pointer-types]
    3378 |                         btusb_generate_qca_nvm_name(&fwname, sizeof(fwname), ver, "gf");
         |                                                     ^~~~~~~
         |                                                     |
         |                                                     char (*)[64]
   drivers/bluetooth/btusb.c:3333:48: note: expected 'char **' but argument is of type 'char (*)[64]'
    3333 | static void btusb_generate_qca_nvm_name(char **fwname,
         |                                         ~~~~~~~^~~~~~
   drivers/bluetooth/btusb.c:3381:53: error: passing argument 1 of 'btusb_generate_qca_nvm_name' from incompatible pointer type [-Werror=incompatible-pointer-types]
    3381 |                         btusb_generate_qca_nvm_name(&fwname, sizeof(fwname), ver, NULL);
         |                                                     ^~~~~~~
         |                                                     |
         |                                                     char (*)[64]
   drivers/bluetooth/btusb.c:3333:48: note: expected 'char **' but argument is of type 'char (*)[64]'
    3333 | static void btusb_generate_qca_nvm_name(char **fwname,
         |                                         ~~~~~~~^~~~~~
   cc1: some warnings being treated as errors


vim +/snprintf +3349 drivers/bluetooth/btusb.c

  3332	
  3333	static void btusb_generate_qca_nvm_name(char **fwname,
  3334						int max_size,
  3335						struct qca_version *ver,
  3336						char *foundry)
  3337	{
  3338		char *separator;
  3339		u16 board_id;
  3340		u32 rom_version;
  3341	
  3342		separator = (foundry == NULL) ? "" : "_";
  3343		board_id = le16_to_cpu(ver->board_id);
  3344		rom_version = le32_to_cpu(ver->rom_version);
  3345	
  3346		if (((ver->flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) {
  3347			/* if boardid equal 0, use default nvm without surfix */
  3348			if (le16_to_cpu(ver->board_id) == 0x0) {
> 3349				snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x%s%s.bin",
  3350					 rom_version,
  3351					 separator,
  3352					 foundry);
  3353			} else {
  3354				snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x%s%s%04x.bin",
  3355					rom_version,
  3356					separator,
  3357					foundry,
  3358					board_id);
  3359			}
  3360		} else {
  3361			snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x.bin",
  3362				 rom_version);
  3363		}
  3364	
  3365	}
  3366	
  3367	static int btusb_setup_qca_load_nvm(struct hci_dev *hdev,
  3368					    struct qca_version *ver,
  3369					    const struct qca_device_info *info)
  3370	{
  3371		const struct firmware *fw;
  3372		char fwname[64];
  3373		int err;
  3374	
  3375		switch (ver->ram_version) {
  3376		case WCN6855_2_0_RAM_VERSION_GF:
  3377		case WCN6855_2_1_RAM_VERSION_GF:
> 3378				btusb_generate_qca_nvm_name(&fwname, sizeof(fwname), ver, "gf");
  3379			break;
  3380		default:
  3381				btusb_generate_qca_nvm_name(&fwname, sizeof(fwname), ver, NULL);
  3382			break;
  3383		}
  3384	
  3385		err = request_firmware(&fw, fwname, &hdev->dev);
  3386		if (err) {
  3387			bt_dev_err(hdev, "failed to request NVM file: %s (%d)",
  3388				   fwname, err);
  3389			return err;
  3390		}
  3391	
  3392		bt_dev_info(hdev, "using NVM file: %s", fwname);
  3393	
  3394		err = btusb_setup_qca_download_fw(hdev, fw, info->nvm_hdr);
  3395	
  3396		release_firmware(fw);
  3397	
  3398		return err;
  3399	}
  3400	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Matthias Kaehlcke Aug. 26, 2021, 5:55 p.m. UTC | #2
On Tue, Aug 24, 2021 at 02:12:00AM -0700, Matthias Kaehlcke wrote:
> On Tue, Aug 24, 2021 at 04:28:03PM +0800, Zijun Hu wrote:
> > From: Tim Jiang <tjiang@codeaurora.org>
> > 
> > we have variant wcn6855 soc chip from different foundries, so we should
> > use different nvm file with suffix to distinguish them.
> 
> Similar question as on v4: why is it necessary to know where a chip was
> manufactured? Is the hardware different? Should the FW behave differently
> for some reason (e.g. regulatory differences)?

Tim briefly responded in private, I'm not sure if I'm allowed to share it
publicly.

I still doubt whether the 'foundry' is the right way to split things, I'm
more inclined towards the concept of a 'variant', which is more flexible.

Anyway, I'll leave it to the maintainers, if they are happy with the foundry
thing I'm fine with it.
diff mbox series

Patch

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 60d2fce59a71..ad7734f8917c 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3141,6 +3141,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;
@@ -3172,6 +3175,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,
@@ -3326,27 +3330,56 @@  static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev,
 	return err;
 }
 
-static int btusb_setup_qca_load_nvm(struct hci_dev *hdev,
-				    struct qca_version *ver,
-				    const struct qca_device_info *info)
+static void btusb_generate_qca_nvm_name(char **fwname,
+					int max_size,
+					struct qca_version *ver,
+					char *foundry)
 {
-	const struct firmware *fw;
-	char fwname[64];
-	int err;
+	char *separator;
+	u16 board_id;
+	u32 rom_version;
+
+	separator = (foundry == NULL) ? "" : "_";
+	board_id = le16_to_cpu(ver->board_id);
+	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 surfix */
 		if (le16_to_cpu(ver->board_id) == 0x0) {
-			snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x.bin",
-				 le32_to_cpu(ver->rom_version));
+			snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x%s%s.bin",
+				 rom_version,
+				 separator,
+				 foundry);
 		} else {
-			snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x_%04x.bin",
-				le32_to_cpu(ver->rom_version),
-				le16_to_cpu(ver->board_id));
+			snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x%s%s%04x.bin",
+				rom_version,
+				separator,
+				foundry,
+				board_id);
 		}
 	} else {
 		snprintf(fwname, sizeof(fwname), "qca/nvm_usb_%08x.bin",
-			 le32_to_cpu(ver->rom_version));
+			 rom_version);
+	}
+
+}
+
+static int btusb_setup_qca_load_nvm(struct hci_dev *hdev,
+				    struct qca_version *ver,
+				    const struct qca_device_info *info)
+{
+	const struct firmware *fw;
+	char fwname[64];
+	int err;
+
+	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, NULL);
+		break;
 	}
 
 	err = request_firmware(&fw, fwname, &hdev->dev);