LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name
@ 2024-05-07 19:21 sean.wang
  2024-05-07 19:21 ` [PATCH v4 2/5] Bluetooth: btmtk: apply the common btmtk_fw_get_filename sean.wang
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: sean.wang @ 2024-05-07 19:21 UTC (permalink / raw
  To: marcel, johan.hedberg, luiz.dentz
  Cc: linux-bluetooth, linux-mediatek, linux-kernel, Sean Wang

From: Sean Wang <sean.wang@mediatek.com>

Include a shared function to get the firmware name, to prevent repeating
code for similar chipsets.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
v3: first added to the series
v4: rebase onto the latest code and add an additional parameter
    fw_flavor into the function btmtk_fw_get_filename.
---
 drivers/bluetooth/btmtk.c | 18 ++++++++++++++++++
 drivers/bluetooth/btmtk.h |  8 ++++++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
index 812fd2a8f853..a0a858a0706d 100644
--- a/drivers/bluetooth/btmtk.c
+++ b/drivers/bluetooth/btmtk.c
@@ -103,6 +103,24 @@ static void btmtk_coredump_notify(struct hci_dev *hdev, int state)
 	}
 }
 
+void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
+			   u32 fw_flavor)
+{
+	if (dev_id == 0x7925)
+		snprintf(buf, size,
+			 "mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
+			 dev_id & 0xffff, dev_id & 0xffff, (fw_ver & 0xff) + 1);
+	else if (dev_id == 0x7961 && fw_flavor)
+		snprintf(buf, sizeof(size),
+			 "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
+			 dev_id & 0xffff, (fw_ver & 0xff) + 1);
+	else
+		snprintf(buf, size,
+			 "mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
+			 dev_id & 0xffff, (fw_ver & 0xff) + 1);
+}
+EXPORT_SYMBOL_GPL(btmtk_fw_get_filename);
+
 int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,
 			      wmt_cmd_sync_func_t wmt_cmd_sync)
 {
diff --git a/drivers/bluetooth/btmtk.h b/drivers/bluetooth/btmtk.h
index cbcdb99a22e6..e76b8a358be8 100644
--- a/drivers/bluetooth/btmtk.h
+++ b/drivers/bluetooth/btmtk.h
@@ -160,6 +160,9 @@ int btmtk_register_coredump(struct hci_dev *hdev, const char *name,
 			    u32 fw_version);
 
 int btmtk_process_coredump(struct hci_dev *hdev, struct sk_buff *skb);
+
+void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
+			   u32 fw_flavor);
 #else
 
 static inline int btmtk_set_bdaddr(struct hci_dev *hdev,
@@ -194,4 +197,9 @@ static int btmtk_process_coredump(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	return -EOPNOTSUPP;
 }
+
+static void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id,
+				  u32 fw_ver, u32 fw_flavor)
+{
+}
 #endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 2/5] Bluetooth: btmtk: apply the common btmtk_fw_get_filename
  2024-05-07 19:21 [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name sean.wang
@ 2024-05-07 19:21 ` sean.wang
  2024-05-07 19:21 ` [PATCH v4 3/5] Bluetooth: btusb: mediatek: refactor the function btusb_mtk_reset sean.wang
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: sean.wang @ 2024-05-07 19:21 UTC (permalink / raw
  To: marcel, johan.hedberg, luiz.dentz
  Cc: linux-bluetooth, linux-mediatek, linux-kernel, Sean Wang

From: Sean Wang <sean.wang@mediatek.com>

Apply the common btmtk_fw_get_filename to avoid the similar coding in each
driver.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
v3: first added to the series
v4: rebase onto the latest code
---
 drivers/bluetooth/btmtksdio.c |  3 +++
 drivers/bluetooth/btusb.c     | 14 ++------------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
index ff4868c83cd8..04be06f73e05 100644
--- a/drivers/bluetooth/btmtksdio.c
+++ b/drivers/bluetooth/btmtksdio.c
@@ -1117,6 +1117,9 @@ static int btmtksdio_setup(struct hci_dev *hdev)
 			return err;
 		}
 
+		btmtk_fw_get_filename(fwname, sizeof(fwname), dev_id,
+				      fw_version, 0);
+
 		snprintf(fwname, sizeof(fwname),
 			 "mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
 			 dev_id & 0xffff, (fw_version & 0xff) + 1);
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 90d1f1697357..1603e97f0d7c 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3166,18 +3166,8 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
 	case 0x7922:
 	case 0x7961:
 	case 0x7925:
-		if (dev_id == 0x7925)
-			snprintf(fw_bin_name, sizeof(fw_bin_name),
-				 "mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
-				 dev_id & 0xffff, dev_id & 0xffff, (fw_version & 0xff) + 1);
-		else if (dev_id == 0x7961 && fw_flavor)
-			snprintf(fw_bin_name, sizeof(fw_bin_name),
-				 "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
-				 dev_id & 0xffff, (fw_version & 0xff) + 1);
-		else
-			snprintf(fw_bin_name, sizeof(fw_bin_name),
-				 "mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
-				 dev_id & 0xffff, (fw_version & 0xff) + 1);
+		btmtk_fw_get_filename(fw_bin_name, sizeof(fw_bin_name), dev_id,
+				      fw_version, fw_flavor);
 
 		err = btmtk_setup_firmware_79xx(hdev, fw_bin_name,
 						btusb_mtk_hci_wmt_sync);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 3/5] Bluetooth: btusb: mediatek: refactor the function btusb_mtk_reset
  2024-05-07 19:21 [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name sean.wang
  2024-05-07 19:21 ` [PATCH v4 2/5] Bluetooth: btmtk: apply the common btmtk_fw_get_filename sean.wang
@ 2024-05-07 19:21 ` sean.wang
  2024-05-07 19:22 ` [PATCH v4 4/5] Bluetooth: btusb: mediatek: reset the controller before downloading the fw sean.wang
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: sean.wang @ 2024-05-07 19:21 UTC (permalink / raw
  To: marcel, johan.hedberg, luiz.dentz
  Cc: linux-bluetooth, linux-mediatek, linux-kernel, Hao Qin, Sean Wang

From: Hao Qin <hao.qin@mediatek.com>

Extract the function btusb_mtk_subsys_reset from the btusb_mtk_reset
for the future handling of resetting bluetooth controller without
the USB reset.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Hao Qin <hao.qin@mediatek.com>
---
v3: refine the git message
v4: rebase onto the latest code
---
 drivers/bluetooth/btusb.c | 45 +++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 1603e97f0d7c..76c52f2fe917 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3033,28 +3033,13 @@ static u32 btusb_mtk_reset_done(struct hci_dev *hdev)
 	return val & MTK_BT_RST_DONE;
 }
 
-static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data)
+static int btusb_mtk_subsys_reset(struct hci_dev *hdev, u32 dev_id)
 {
 	struct btusb_data *data = hci_get_drvdata(hdev);
-	struct btmediatek_data *mediatek;
 	u32 val;
 	int err;
 
-	/* It's MediaTek specific bluetooth reset mechanism via USB */
-	if (test_and_set_bit(BTUSB_HW_RESET_ACTIVE, &data->flags)) {
-		bt_dev_err(hdev, "last reset failed? Not resetting again");
-		return -EBUSY;
-	}
-
-	err = usb_autopm_get_interface(data->intf);
-	if (err < 0)
-		return err;
-
-	btusb_stop_traffic(data);
-	usb_kill_anchored_urbs(&data->tx_anchor);
-	mediatek = hci_get_priv(hdev);
-
-	if (mediatek->dev_id == 0x7925) {
+	if (dev_id == 0x7925) {
 		btusb_mtk_uhw_reg_read(data, MTK_BT_RESET_REG_CONNV3, &val);
 		val |= (1 << 5);
 		btusb_mtk_uhw_reg_write(data, MTK_BT_RESET_REG_CONNV3, val);
@@ -3098,8 +3083,32 @@ static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data)
 	if (!val)
 		bt_dev_err(hdev, "Can't get device id, subsys reset fail.");
 
-	usb_queue_reset_device(data->intf);
+	return err;
+}
 
+static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data)
+{
+	struct btusb_data *data = hci_get_drvdata(hdev);
+	struct btmediatek_data *mtk_data;
+	int err;
+
+	/* It's MediaTek specific bluetooth reset mechanism via USB */
+	if (test_and_set_bit(BTUSB_HW_RESET_ACTIVE, &data->flags)) {
+		bt_dev_err(hdev, "last reset failed? Not resetting again");
+		return -EBUSY;
+	}
+
+	err = usb_autopm_get_interface(data->intf);
+	if (err < 0)
+		return err;
+
+	btusb_stop_traffic(data);
+	usb_kill_anchored_urbs(&data->tx_anchor);
+	mtk_data = hci_get_priv(hdev);
+
+	err = btusb_mtk_subsys_reset(hdev, mtk_data->dev_id);
+
+	usb_queue_reset_device(data->intf);
 	clear_bit(BTUSB_HW_RESET_ACTIVE, &data->flags);
 
 	return err;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 4/5] Bluetooth: btusb: mediatek: reset the controller before downloading the fw
  2024-05-07 19:21 [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name sean.wang
  2024-05-07 19:21 ` [PATCH v4 2/5] Bluetooth: btmtk: apply the common btmtk_fw_get_filename sean.wang
  2024-05-07 19:21 ` [PATCH v4 3/5] Bluetooth: btusb: mediatek: refactor the function btusb_mtk_reset sean.wang
@ 2024-05-07 19:22 ` sean.wang
  2024-05-07 19:22 ` [PATCH v4 5/5] Bluetooth: btusb: mediatek: add MT7922 subsystem reset sean.wang
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: sean.wang @ 2024-05-07 19:22 UTC (permalink / raw
  To: marcel, johan.hedberg, luiz.dentz
  Cc: linux-bluetooth, linux-mediatek, linux-kernel, Hao Qin, Sean Wang,
	Chris Lu

From: Hao Qin <hao.qin@mediatek.com>

Reset the controller before downloading the firmware to improve its
reliability. This includes situations like cold or warm reboots, ensuring
the controller is in its initial state before starting the firmware
download.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Chris Lu <chris.lu@mediatek.com>
Signed-off-by: Chris Lu <chris.lu@mediatek.com>
Signed-off-by: Hao Qin <hao.qin@mediatek.com>
---
v3: split from the v2 to make the patch do one thing in a patch and ensure
    the reset the controller only when we actually need it to avoid the
    regression on the time spent in opening the controller.
v4: rebase onto the latest code
---
 drivers/bluetooth/btusb.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 76c52f2fe917..054e8c06bcf3 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3175,6 +3175,13 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
 	case 0x7922:
 	case 0x7961:
 	case 0x7925:
+		/* Reset the device to ensure it's in the initial state before
+		 * downloading the firmware to ensure.
+		 */
+
+		if (!test_bit(BTUSB_FIRMWARE_LOADED, &data->flags))
+			btusb_mtk_subsys_reset(hdev, dev_id);
+
 		btmtk_fw_get_filename(fw_bin_name, sizeof(fw_bin_name), dev_id,
 				      fw_version, fw_flavor);
 
@@ -3182,9 +3189,12 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
 						btusb_mtk_hci_wmt_sync);
 		if (err < 0) {
 			bt_dev_err(hdev, "Failed to set up firmware (%d)", err);
+			clear_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
 			return err;
 		}
 
+		set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
+
 		/* It's Device EndPoint Reset Option Register */
 		btusb_mtk_uhw_reg_write(data, MTK_EP_RST_OPT, MTK_EP_RST_IN_OUT_OPT);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 5/5] Bluetooth: btusb: mediatek: add MT7922 subsystem reset
  2024-05-07 19:21 [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name sean.wang
                   ` (2 preceding siblings ...)
  2024-05-07 19:22 ` [PATCH v4 4/5] Bluetooth: btusb: mediatek: reset the controller before downloading the fw sean.wang
@ 2024-05-07 19:22 ` sean.wang
  2024-05-08  7:12 ` [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name kernel test robot
  2024-05-08 11:22 ` kernel test robot
  5 siblings, 0 replies; 9+ messages in thread
From: sean.wang @ 2024-05-07 19:22 UTC (permalink / raw
  To: marcel, johan.hedberg, luiz.dentz
  Cc: linux-bluetooth, linux-mediatek, linux-kernel, Hao Qin, Sean Wang

From: Hao Qin <hao.qin@mediatek.com>

Add the support of MT7922 bluetooth subsystem reset that was called the
auto revert to self-recover from the fatal error in the controller like
the host encounters HCI cmd timeout or the controller crashes.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Hao Qin <hao.qin@mediatek.com>
---
v3: split from the v2 to make the patch do one thing in a patch.
v4: rebase onto the latest code
---
 drivers/bluetooth/btusb.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 054e8c06bcf3..a70a5e12912b 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3039,7 +3039,16 @@ static int btusb_mtk_subsys_reset(struct hci_dev *hdev, u32 dev_id)
 	u32 val;
 	int err;
 
-	if (dev_id == 0x7925) {
+	if (dev_id == 0x7922) {
+		btusb_mtk_uhw_reg_read(data, MTK_BT_SUBSYS_RST, &val);
+		val |= 0x00002020;
+		btusb_mtk_uhw_reg_write(data, MTK_BT_SUBSYS_RST, val);
+		btusb_mtk_uhw_reg_write(data, MTK_EP_RST_OPT, 0x00010001);
+		btusb_mtk_uhw_reg_read(data, MTK_BT_SUBSYS_RST, &val);
+		val |= BIT(0);
+		btusb_mtk_uhw_reg_write(data, MTK_BT_SUBSYS_RST, val);
+		msleep(100);
+	} else if (dev_id == 0x7925) {
 		btusb_mtk_uhw_reg_read(data, MTK_BT_RESET_REG_CONNV3, &val);
 		val |= (1 << 5);
 		btusb_mtk_uhw_reg_write(data, MTK_BT_RESET_REG_CONNV3, val);
@@ -3079,6 +3088,9 @@ static int btusb_mtk_subsys_reset(struct hci_dev *hdev, u32 dev_id)
 	if (err < 0)
 		bt_dev_err(hdev, "Reset timeout");
 
+	if (dev_id == 0x7922)
+		btusb_mtk_uhw_reg_write(data, MTK_UDMA_INT_STA_BT, 0x000000FF);
+
 	btusb_mtk_id_get(data, 0x70010200, &val);
 	if (!val)
 		bt_dev_err(hdev, "Can't get device id, subsys reset fail.");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name
  2024-05-07 19:21 [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name sean.wang
                   ` (3 preceding siblings ...)
  2024-05-07 19:22 ` [PATCH v4 5/5] Bluetooth: btusb: mediatek: add MT7922 subsystem reset sean.wang
@ 2024-05-08  7:12 ` kernel test robot
  2024-05-08 14:37   ` Luiz Augusto von Dentz
  2024-05-08 11:22 ` kernel test robot
  5 siblings, 1 reply; 9+ messages in thread
From: kernel test robot @ 2024-05-08  7:12 UTC (permalink / raw
  To: sean.wang, marcel, johan.hedberg, luiz.dentz
  Cc: oe-kbuild-all, linux-bluetooth, linux-mediatek, linux-kernel,
	Sean Wang

Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bluetooth/master]
[also build test WARNING on bluetooth-next/master linus/master v6.9-rc7 next-20240507]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/sean-wang-kernel-org/Bluetooth-btmtk-apply-the-common-btmtk_fw_get_filename/20240508-032333
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
patch link:    https://lore.kernel.org/r/965cd14922aea67e2750ff2c2ecad773f8ba485a.1715109394.git.sean.wang%40kernel.org
patch subject: [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240508/202405081456.v2MvcQ0P-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240508/202405081456.v2MvcQ0P-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405081456.v2MvcQ0P-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/bluetooth/btmtk.c: In function 'btmtk_fw_get_filename':
>> drivers/bluetooth/btmtk.c:115:35: warning: 'mediatek/BT_RAM_CODE_MT' directive output truncated writing 23 bytes into a region of size 8 [-Wformat-truncation=]
     115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
         |                           ~~~~~~~~^~~~~~~~~~~~~~~
   drivers/bluetooth/btmtk.c:115:26: note: directive argument in the range [1, 256]
     115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
         |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/bluetooth/btmtk.c:114:17: note: 'snprintf' output between 41 and 43 bytes into a destination of size 8
     114 |                 snprintf(buf, sizeof(size),
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
     115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
         |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     116 |                          dev_id & 0xffff, (fw_ver & 0xff) + 1);
         |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +115 drivers/bluetooth/btmtk.c

   105	
   106	void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
   107				   u32 fw_flavor)
   108	{
   109		if (dev_id == 0x7925)
   110			snprintf(buf, size,
   111				 "mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
   112				 dev_id & 0xffff, dev_id & 0xffff, (fw_ver & 0xff) + 1);
   113		else if (dev_id == 0x7961 && fw_flavor)
   114			snprintf(buf, sizeof(size),
 > 115				 "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
   116				 dev_id & 0xffff, (fw_ver & 0xff) + 1);
   117		else
   118			snprintf(buf, size,
   119				 "mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
   120				 dev_id & 0xffff, (fw_ver & 0xff) + 1);
   121	}
   122	EXPORT_SYMBOL_GPL(btmtk_fw_get_filename);
   123	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name
  2024-05-07 19:21 [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name sean.wang
                   ` (4 preceding siblings ...)
  2024-05-08  7:12 ` [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name kernel test robot
@ 2024-05-08 11:22 ` kernel test robot
  5 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2024-05-08 11:22 UTC (permalink / raw
  To: sean.wang, marcel, johan.hedberg, luiz.dentz
  Cc: llvm, oe-kbuild-all, linux-bluetooth, linux-mediatek,
	linux-kernel, Sean Wang

Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bluetooth/master]
[also build test WARNING on bluetooth-next/master linus/master v6.9-rc7 next-20240508]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/sean-wang-kernel-org/Bluetooth-btmtk-apply-the-common-btmtk_fw_get_filename/20240508-032333
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
patch link:    https://lore.kernel.org/r/965cd14922aea67e2750ff2c2ecad773f8ba485a.1715109394.git.sean.wang%40kernel.org
patch subject: [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name
config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20240508/202405081828.e6IMNKPn-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 0ab4458df0688955620b72cc2c72a32dffad3615)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240508/202405081828.e6IMNKPn-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405081828.e6IMNKPn-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/bluetooth/btmtk.c:8:
   In file included from include/net/bluetooth/bluetooth.h:30:
   In file included from include/net/sock.h:38:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     547 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     560 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   In file included from drivers/bluetooth/btmtk.c:8:
   In file included from include/net/bluetooth/bluetooth.h:30:
   In file included from include/net/sock.h:38:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     573 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   In file included from drivers/bluetooth/btmtk.c:8:
   In file included from include/net/bluetooth/bluetooth.h:30:
   In file included from include/net/sock.h:38:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     584 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     594 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     604 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   In file included from drivers/bluetooth/btmtk.c:8:
   In file included from include/net/bluetooth/bluetooth.h:30:
   In file included from include/net/sock.h:46:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:10:
   In file included from include/linux/mm.h:2210:
   include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     522 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
>> drivers/bluetooth/btmtk.c:114:3: warning: 'snprintf' will always be truncated; specified size is 4, but format string expands to at least 41 [-Wformat-truncation]
     114 |                 snprintf(buf, sizeof(size),
         |                 ^
   8 warnings generated.


vim +/snprintf +114 drivers/bluetooth/btmtk.c

   105	
   106	void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
   107				   u32 fw_flavor)
   108	{
   109		if (dev_id == 0x7925)
   110			snprintf(buf, size,
   111				 "mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
   112				 dev_id & 0xffff, dev_id & 0xffff, (fw_ver & 0xff) + 1);
   113		else if (dev_id == 0x7961 && fw_flavor)
 > 114			snprintf(buf, sizeof(size),
   115				 "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
   116				 dev_id & 0xffff, (fw_ver & 0xff) + 1);
   117		else
   118			snprintf(buf, size,
   119				 "mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
   120				 dev_id & 0xffff, (fw_ver & 0xff) + 1);
   121	}
   122	EXPORT_SYMBOL_GPL(btmtk_fw_get_filename);
   123	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name
  2024-05-08  7:12 ` [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name kernel test robot
@ 2024-05-08 14:37   ` Luiz Augusto von Dentz
  2024-05-08 20:38     ` Sean Wang
  0 siblings, 1 reply; 9+ messages in thread
From: Luiz Augusto von Dentz @ 2024-05-08 14:37 UTC (permalink / raw
  To: kernel test robot
  Cc: sean.wang, marcel, johan.hedberg, oe-kbuild-all, linux-bluetooth,
	linux-mediatek, linux-kernel, Sean Wang

Hi Sean,

On Wed, May 8, 2024 at 3:13 AM kernel test robot <lkp@intel.com> wrote:
>
> Hi,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on bluetooth/master]
> [also build test WARNING on bluetooth-next/master linus/master v6.9-rc7 next-20240507]
> [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#_base_tree_information]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/sean-wang-kernel-org/Bluetooth-btmtk-apply-the-common-btmtk_fw_get_filename/20240508-032333
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
> patch link:    https://lore.kernel.org/r/965cd14922aea67e2750ff2c2ecad773f8ba485a.1715109394.git.sean.wang%40kernel.org
> patch subject: [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name
> config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240508/202405081456.v2MvcQ0P-lkp@intel.com/config)
> compiler: aarch64-linux-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240508/202405081456.v2MvcQ0P-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202405081456.v2MvcQ0P-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
>    drivers/bluetooth/btmtk.c: In function 'btmtk_fw_get_filename':
> >> drivers/bluetooth/btmtk.c:115:35: warning: 'mediatek/BT_RAM_CODE_MT' directive output truncated writing 23 bytes into a region of size 8 [-Wformat-truncation=]
>      115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
>          |                           ~~~~~~~~^~~~~~~~~~~~~~~
>    drivers/bluetooth/btmtk.c:115:26: note: directive argument in the range [1, 256]
>      115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
>          |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    drivers/bluetooth/btmtk.c:114:17: note: 'snprintf' output between 41 and 43 bytes into a destination of size 8
>      114 |                 snprintf(buf, sizeof(size),
>          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>      115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
>          |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>      116 |                          dev_id & 0xffff, (fw_ver & 0xff) + 1);
>          |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> vim +115 drivers/bluetooth/btmtk.c
>
>    105
>    106  void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
>    107                             u32 fw_flavor)
>    108  {
>    109          if (dev_id == 0x7925)
>    110                  snprintf(buf, size,
>    111                           "mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
>    112                           dev_id & 0xffff, dev_id & 0xffff, (fw_ver & 0xff) + 1);
>    113          else if (dev_id == 0x7961 && fw_flavor)
>    114                  snprintf(buf, sizeof(size),
>  > 115                           "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
>    116                           dev_id & 0xffff, (fw_ver & 0xff) + 1);
>    117          else
>    118                  snprintf(buf, size,
>    119                           "mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
>    120                           dev_id & 0xffff, (fw_ver & 0xff) + 1);
>    121  }
>    122  EXPORT_SYMBOL_GPL(btmtk_fw_get_filename);
>    123

Could you please fix the above?

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name
  2024-05-08 14:37   ` Luiz Augusto von Dentz
@ 2024-05-08 20:38     ` Sean Wang
  0 siblings, 0 replies; 9+ messages in thread
From: Sean Wang @ 2024-05-08 20:38 UTC (permalink / raw
  To: Luiz Augusto von Dentz
  Cc: kernel test robot, marcel, johan.hedberg, oe-kbuild-all,
	linux-bluetooth, linux-mediatek, linux-kernel, Sean Wang

Hi,

On Wed, May 8, 2024 at 7:37 AM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> Hi Sean,
>
> On Wed, May 8, 2024 at 3:13 AM kernel test robot <lkp@intel.com> wrote:
> >
> > Hi,
> >
> > kernel test robot noticed the following build warnings:
> >
> > [auto build test WARNING on bluetooth/master]
> > [also build test WARNING on bluetooth-next/master linus/master v6.9-rc7 next-20240507]
> > [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#_base_tree_information]
> >
> > url:    https://github.com/intel-lab-lkp/linux/commits/sean-wang-kernel-org/Bluetooth-btmtk-apply-the-common-btmtk_fw_get_filename/20240508-032333
> > base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
> > patch link:    https://lore.kernel.org/r/965cd14922aea67e2750ff2c2ecad773f8ba485a.1715109394.git.sean.wang%40kernel.org
> > patch subject: [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name
> > config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240508/202405081456.v2MvcQ0P-lkp@intel.com/config)
> > compiler: aarch64-linux-gcc (GCC) 13.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240508/202405081456.v2MvcQ0P-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202405081456.v2MvcQ0P-lkp@intel.com/
> >
> > All warnings (new ones prefixed by >>):
> >
> >    drivers/bluetooth/btmtk.c: In function 'btmtk_fw_get_filename':
> > >> drivers/bluetooth/btmtk.c:115:35: warning: 'mediatek/BT_RAM_CODE_MT' directive output truncated writing 23 bytes into a region of size 8 [-Wformat-truncation=]
> >      115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
> >          |                           ~~~~~~~~^~~~~~~~~~~~~~~
> >    drivers/bluetooth/btmtk.c:115:26: note: directive argument in the range [1, 256]
> >      115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
> >          |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >    drivers/bluetooth/btmtk.c:114:17: note: 'snprintf' output between 41 and 43 bytes into a destination of size 8
> >      114 |                 snprintf(buf, sizeof(size),
> >          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> >      115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
> >          |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >      116 |                          dev_id & 0xffff, (fw_ver & 0xff) + 1);
> >          |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> >
> > vim +115 drivers/bluetooth/btmtk.c
> >
> >    105
> >    106  void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
> >    107                             u32 fw_flavor)
> >    108  {
> >    109          if (dev_id == 0x7925)
> >    110                  snprintf(buf, size,
> >    111                           "mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
> >    112                           dev_id & 0xffff, dev_id & 0xffff, (fw_ver & 0xff) + 1);
> >    113          else if (dev_id == 0x7961 && fw_flavor)
> >    114                  snprintf(buf, sizeof(size),
> >  > 115                           "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
> >    116                           dev_id & 0xffff, (fw_ver & 0xff) + 1);
> >    117          else
> >    118                  snprintf(buf, size,
> >    119                           "mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
> >    120                           dev_id & 0xffff, (fw_ver & 0xff) + 1);
> >    121  }
> >    122  EXPORT_SYMBOL_GPL(btmtk_fw_get_filename);
> >    123
>
> Could you please fix the above?

No problem, I'll take care of it and send it over later.

                 Sean
>
> --
> Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-05-08 20:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-07 19:21 [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name sean.wang
2024-05-07 19:21 ` [PATCH v4 2/5] Bluetooth: btmtk: apply the common btmtk_fw_get_filename sean.wang
2024-05-07 19:21 ` [PATCH v4 3/5] Bluetooth: btusb: mediatek: refactor the function btusb_mtk_reset sean.wang
2024-05-07 19:22 ` [PATCH v4 4/5] Bluetooth: btusb: mediatek: reset the controller before downloading the fw sean.wang
2024-05-07 19:22 ` [PATCH v4 5/5] Bluetooth: btusb: mediatek: add MT7922 subsystem reset sean.wang
2024-05-08  7:12 ` [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name kernel test robot
2024-05-08 14:37   ` Luiz Augusto von Dentz
2024-05-08 20:38     ` Sean Wang
2024-05-08 11:22 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).