Skip to contentSkip to conversation

Bluetooth: btintel_pcie: Add support for device coredump

PATCH Superseded Kiran K 2 participants 3 messages Feb 27, 2025 – Mar 3, 2025 Bluetooth drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kiran K

author
#0 lore raw

PATCH 1/1 Bluetooth: btintel_pcie: Add support for device coredump

1. Driver registers device coredump callback
2. Dumps firmware traces as part of coredump

---
 drivers/bluetooth/btintel.h      |   1 -
 drivers/bluetooth/btintel_pcie.c | 259 ++++++++++++++++++++++++++++++-
 drivers/bluetooth/btintel_pcie.h |  38 +++++
 3 files changed, 291 insertions(+), 7 deletions(-)
drivers/bluetooth/btintel.h +0 -1
index 4c21e69887a3..19530ea14905 100644
@@ -190,7 +190,6 @@ enum {
 struct btintel_data {
 	DECLARE_BITMAP(flags, __INTEL_NUM_FLAGS);
 	int (*acpi_reset_method)(struct hci_dev *hdev);
-	u32	cnvi_top;
 };
 
 #define btintel_set_flag(hdev, nr)					\
drivers/bluetooth/btintel_pcie.c +253 -6

339 lines not on this page · raw message

drivers/bluetooth/btintel_pcie.h +38 -0
index d17808ebe725..873178019cad 100644
@@ -56,6 +56,15 @@
 #define BTINTEL_PCIE_CSR_MSIX_IVAR_BASE		(BTINTEL_PCIE_CSR_MSIX_BASE + 0x0880)
 #define BTINTEL_PCIE_CSR_MSIX_IVAR(cause)	(BTINTEL_PCIE_CSR_MSIX_IVAR_BASE + (cause))
 
+/* IOSF Debug Register */
+#define BTINTEL_PCIE_DBGC_BASE_ADDR			(0xf3800300)
+#define BTINTEL_PCIE_DBGC_CUR_DBGBUFF_STATUS		(BTINTEL_PCIE_DBGC_BASE_ADDR + 0x1C)
+#define BTINTEL_PCIE_DBGC_DBGBUFF_WRAP_ARND		(BTINTEL_PCIE_DBGC_BASE_ADDR + 0x2C)
+
+#define BTINTEL_PCIE_DBG_IDX_BIT_MASK		0x0F
+#define BTINTEL_PCIE_DBGC_DBG_BUF_IDX(data)	(((data) >> 24) & BTINTEL_PCIE_DBG_IDX_BIT_MASK)
+#define BTINTEL_PCIE_DBG_OFFSET_BIT_MASK	0xFFFFFF
+
 /* The DRAM buffer count, each buffer size, and
  * fragment buffer size
  */
@@ -97,6 +106,19 @@ enum {
 enum {
 	BTINTEL_PCIE_CORE_HALTED,
 	BTINTEL_PCIE_HWEXP_INPROGRESS,
+	BTINTEL_PCIE_COREDUMP_INPROGRESS
+};
+
+enum btintel_pcie_tlv_type {
+	BTINTEL_CNVI_BT,
+	BTINTEL_WRITE_PTR,
+	BTINTEL_WRAP_CTR,
+	BTINTEL_TRIGGER_REASON,
+	BTINTEL_FW_SHA,
+	BTINTEL_CNVR_TOP,
+	BTINTEL_CNVI_TOP,
+	BTINTEL_DUMP_TIME,
+	BTINTEL_FW_BUILD,
 };
 
 #define BTINTEL_PCIE_MSIX_NON_AUTO_CLEAR_CAUSE	BIT(7)
@@ -371,6 +393,21 @@ struct btintel_pcie_dbgc {
 	struct data_buf *bufs;
 };
 
+struct btintel_pcie_dump_header {
+	const char	*driver_name;
+	u32		cnvi_top;
+	u32		cnvr_top;
+	u16		fw_timestamp;
+	u8		fw_build_type;
+	u32		fw_build_num;
+	u32		fw_git_sha1;
+	u32		cnvi_bt;
+	u32		write_ptr;
+	u32		wrap_ctr;
+	u16		trigger_reason;
+	int		state;
+};
+
 /* struct btintel_pcie_data
  * @pdev: pci device
  * @hdev: hdev device
@@ -452,6 +489,7 @@ struct btintel_pcie_data {
 	struct rxq	rxq;
 	u32	alive_intr_ctxt;
 	struct btintel_pcie_dbgc	dbgc;
+	struct btintel_pcie_dump_header dmp_hdr;
 };
 
 static inline u32 btintel_pcie_rd_reg32(struct btintel_pcie_data *data,
Signature · 1 line
2.43.0
#1 lore raw

Hi Kiran,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Kiran-K/Bluetooth-btintel_pcie-Add-support-for-device-coredump/20250227-181131
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
patch link:    https://lore.kernel.org/r/20250227102625.20642-1-kiran.k%40intel.com
patch subject: [PATCH v1] Bluetooth: btintel_pcie: Add support for device coredump
config: sparc-randconfig-r071-20250302 (https://download.01.org/0day-ci/archive/20250302/[email protected]/config)
compiler: sparc-linux-gcc (GCC) 14.2.0

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 <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

New smatch warnings:
drivers/bluetooth/btintel_pcie.c:493 btintel_pcie_read_dram_buffers() error: snprintf() is printing too much 100 vs 70

vim +493 drivers/bluetooth/btintel_pcie.c

b8cc1a1cce30cc Kiran K 2025-02-27  454  static int btintel_pcie_read_dram_buffers(struct btintel_pcie_data *data)
b8cc1a1cce30cc Kiran K 2025-02-27  455  {
b8cc1a1cce30cc Kiran K 2025-02-27  456  	u32 offset, prev_size, wr_ptr_status, dump_size, i;
b8cc1a1cce30cc Kiran K 2025-02-27  457  	struct btintel_pcie_dbgc *dbgc = &data->dbgc;
b8cc1a1cce30cc Kiran K 2025-02-27  458  	u8 buf_idx, dump_time_len, fw_build;
b8cc1a1cce30cc Kiran K 2025-02-27  459  	struct hci_dev *hdev = data->hdev;
b8cc1a1cce30cc Kiran K 2025-02-27  460  	struct intel_tlv *tlv;
b8cc1a1cce30cc Kiran K 2025-02-27  461  	struct timespec64 now;
b8cc1a1cce30cc Kiran K 2025-02-27  462  	struct sk_buff *skb;
b8cc1a1cce30cc Kiran K 2025-02-27  463  	struct tm tm_now;
b8cc1a1cce30cc Kiran K 2025-02-27  464  	char buf[100];
b8cc1a1cce30cc Kiran K 2025-02-27  465  	u16 hdr_len;
b8cc1a1cce30cc Kiran K 2025-02-27  466  	int ret;
b8cc1a1cce30cc Kiran K 2025-02-27  467  
b8cc1a1cce30cc Kiran K 2025-02-27  468  	wr_ptr_status = btintel_pcie_rd_dev_mem(data, BTINTEL_PCIE_DBGC_CUR_DBGBUFF_STATUS);
b8cc1a1cce30cc Kiran K 2025-02-27  469  	offset = wr_ptr_status & BTINTEL_PCIE_DBG_OFFSET_BIT_MASK;
b8cc1a1cce30cc Kiran K 2025-02-27  470  
b8cc1a1cce30cc Kiran K 2025-02-27  471  	buf_idx = BTINTEL_PCIE_DBGC_DBG_BUF_IDX(wr_ptr_status);
b8cc1a1cce30cc Kiran K 2025-02-27  472  	if (buf_idx > dbgc->count) {
b8cc1a1cce30cc Kiran K 2025-02-27  473  		bt_dev_warn(hdev, "Buffer index is invalid");
b8cc1a1cce30cc Kiran K 2025-02-27  474  		return -EINVAL;
b8cc1a1cce30cc Kiran K 2025-02-27  475  	}
b8cc1a1cce30cc Kiran K 2025-02-27  476  
b8cc1a1cce30cc Kiran K 2025-02-27  477  	prev_size = buf_idx * BTINTEL_PCIE_DBGC_BUFFER_SIZE;
b8cc1a1cce30cc Kiran K 2025-02-27  478  	if (prev_size + offset >= prev_size)
b8cc1a1cce30cc Kiran K 2025-02-27  479  		data->dmp_hdr.write_ptr = prev_size + offset;
b8cc1a1cce30cc Kiran K 2025-02-27  480  	else
b8cc1a1cce30cc Kiran K 2025-02-27  481  		return -EINVAL;
b8cc1a1cce30cc Kiran K 2025-02-27  482  
b8cc1a1cce30cc Kiran K 2025-02-27  483  	ktime_get_real_ts64(&now);
b8cc1a1cce30cc Kiran K 2025-02-27  484  	time64_to_tm(now.tv_sec, 0, &tm_now);
b8cc1a1cce30cc Kiran K 2025-02-27  485  	dump_time_len = snprintf(buf, sizeof(buf), "Dump Time: %02d-%02d-%04ld %02d:%02d:%02d",
b8cc1a1cce30cc Kiran K 2025-02-27  486  				 tm_now.tm_mday, tm_now.tm_mon + 1, tm_now.tm_year + 1900,
b8cc1a1cce30cc Kiran K 2025-02-27  487  				 tm_now.tm_hour, tm_now.tm_min, tm_now.tm_sec);
b8cc1a1cce30cc Kiran K 2025-02-27  488  
b8cc1a1cce30cc Kiran K 2025-02-27  489  	fw_build = snprintf(buf + dump_time_len, sizeof(buf),
                                                                                         ^^^^^^^^^^^

This size should be "sizeof(buf) - dump_time_len". It's better to use scnprintf() here vs snprintf(). The scnprintf() function returns the number of bytes which were actually printed vs the number which were printed if there was enough space.

b8cc1a1cce30cc Kiran K 2025-02-27  490  			    "Firmware Timestamp: Year %u WW %02u buildtype %u build %u",
b8cc1a1cce30cc Kiran K 2025-02-27  491  			    2000 + (data->dmp_hdr.fw_timestamp >> 8),
b8cc1a1cce30cc Kiran K 2025-02-27  492  			    data->dmp_hdr.fw_timestamp & 0xff, data->dmp_hdr.fw_build_type,
b8cc1a1cce30cc Kiran K 2025-02-27 @493  			    data->dmp_hdr.fw_build_num);
b8cc1a1cce30cc Kiran K 2025-02-27  494  
b8cc1a1cce30cc Kiran K 2025-02-27  495  	hdr_len = sizeof(*tlv) + sizeof(data->dmp_hdr.cnvi_bt) +
b8cc1a1cce30cc Kiran K 2025-02-27  496  		  sizeof(*tlv) + sizeof(data->dmp_hdr.write_ptr) +
b8cc1a1cce30cc Kiran K 2025-02-27  497  		  sizeof(*tlv) + sizeof(data->dmp_hdr.wrap_ctr) +
b8cc1a1cce30cc Kiran K 2025-02-27  498  		  sizeof(*tlv) + sizeof(data->dmp_hdr.trigger_reason) +
b8cc1a1cce30cc Kiran K 2025-02-27  499  		  sizeof(*tlv) + sizeof(data->dmp_hdr.fw_git_sha1) +
b8cc1a1cce30cc Kiran K 2025-02-27  500  		  sizeof(*tlv) + sizeof(data->dmp_hdr.cnvr_top) +
b8cc1a1cce30cc Kiran K 2025-02-27  501  		  sizeof(*tlv) + sizeof(data->dmp_hdr.cnvi_top) +
b8cc1a1cce30cc Kiran K 2025-02-27  502  		  sizeof(*tlv) + dump_time_len +
b8cc1a1cce30cc Kiran K 2025-02-27  503  		  sizeof(*tlv) + fw_build;
b8cc1a1cce30cc Kiran K 2025-02-27  504  
b8cc1a1cce30cc Kiran K 2025-02-27  505  	dump_size = hdr_len + sizeof(hdr_len);
b8cc1a1cce30cc Kiran K 2025-02-27  506  
b8cc1a1cce30cc Kiran K 2025-02-27  507  	skb = alloc_skb(dump_size, GFP_KERNEL);
b8cc1a1cce30cc Kiran K 2025-02-27  508  	if (!skb)
b8cc1a1cce30cc Kiran K 2025-02-27  509  		return -ENOMEM;
b8cc1a1cce30cc Kiran K 2025-02-27  510  
b8cc1a1cce30cc Kiran K 2025-02-27  511  	/* Add debug buffers data length to dump size */
b8cc1a1cce30cc Kiran K 2025-02-27  512  	dump_size += BTINTEL_PCIE_DBGC_BUFFER_SIZE * dbgc->count;
b8cc1a1cce30cc Kiran K 2025-02-27  513  
b8cc1a1cce30cc Kiran K 2025-02-27  514  	ret = hci_devcd_init(hdev, dump_size);
b8cc1a1cce30cc Kiran K 2025-02-27  515  	if (ret) {
b8cc1a1cce30cc Kiran K 2025-02-27  516  		bt_dev_err(hdev, "Failed to init devcoredump, err %d", ret);
b8cc1a1cce30cc Kiran K 2025-02-27  517  		kfree_skb(skb);
b8cc1a1cce30cc Kiran K 2025-02-27  518  		return ret;
b8cc1a1cce30cc Kiran K 2025-02-27  519  	}
b8cc1a1cce30cc Kiran K 2025-02-27  520  
b8cc1a1cce30cc Kiran K 2025-02-27  521  	skb_put_data(skb, &hdr_len, sizeof(hdr_len));
b8cc1a1cce30cc Kiran K 2025-02-27  522  
b8cc1a1cce30cc Kiran K 2025-02-27  523  	btintel_pcie_copy_tlv(skb, BTINTEL_CNVI_BT, &data->dmp_hdr.cnvi_bt,
b8cc1a1cce30cc Kiran K 2025-02-27  524  			      sizeof(data->dmp_hdr.cnvi_bt));
b8cc1a1cce30cc Kiran K 2025-02-27  525  
b8cc1a1cce30cc Kiran K 2025-02-27  526  	btintel_pcie_copy_tlv(skb, BTINTEL_WRITE_PTR, &data->dmp_hdr.write_ptr,
b8cc1a1cce30cc Kiran K 2025-02-27  527  			      sizeof(data->dmp_hdr.write_ptr));
b8cc1a1cce30cc Kiran K 2025-02-27  528  
b8cc1a1cce30cc Kiran K 2025-02-27  529  	data->dmp_hdr.wrap_ctr = btintel_pcie_rd_dev_mem(data,
b8cc1a1cce30cc Kiran K 2025-02-27  530  							 BTINTEL_PCIE_DBGC_DBGBUFF_WRAP_ARND);
b8cc1a1cce30cc Kiran K 2025-02-27  531  
b8cc1a1cce30cc Kiran K 2025-02-27  532  	btintel_pcie_copy_tlv(skb, BTINTEL_WRAP_CTR, &data->dmp_hdr.wrap_ctr,
b8cc1a1cce30cc Kiran K 2025-02-27  533  			      sizeof(data->dmp_hdr.wrap_ctr));
b8cc1a1cce30cc Kiran K 2025-02-27  534  
b8cc1a1cce30cc Kiran K 2025-02-27  535  	btintel_pcie_copy_tlv(skb, BTINTEL_TRIGGER_REASON, &data->dmp_hdr.trigger_reason,
b8cc1a1cce30cc Kiran K 2025-02-27  536  			      sizeof(data->dmp_hdr.trigger_reason));
b8cc1a1cce30cc Kiran K 2025-02-27  537  
b8cc1a1cce30cc Kiran K 2025-02-27  538  	btintel_pcie_copy_tlv(skb, BTINTEL_FW_SHA, &data->dmp_hdr.fw_git_sha1,
b8cc1a1cce30cc Kiran K 2025-02-27  539  			      sizeof(data->dmp_hdr.fw_git_sha1));
b8cc1a1cce30cc Kiran K 2025-02-27  540  
b8cc1a1cce30cc Kiran K 2025-02-27  541  	btintel_pcie_copy_tlv(skb, BTINTEL_CNVR_TOP, &data->dmp_hdr.cnvr_top,
b8cc1a1cce30cc Kiran K 2025-02-27  542  			      sizeof(data->dmp_hdr.cnvr_top));
b8cc1a1cce30cc Kiran K 2025-02-27  543  
b8cc1a1cce30cc Kiran K 2025-02-27  544  	btintel_pcie_copy_tlv(skb, BTINTEL_CNVI_TOP, &data->dmp_hdr.cnvi_top,
b8cc1a1cce30cc Kiran K 2025-02-27  545  			      sizeof(data->dmp_hdr.cnvi_top));
b8cc1a1cce30cc Kiran K 2025-02-27  546  
b8cc1a1cce30cc Kiran K 2025-02-27  547  	btintel_pcie_copy_tlv(skb, BTINTEL_DUMP_TIME, buf, dump_time_len);
b8cc1a1cce30cc Kiran K 2025-02-27  548  
b8cc1a1cce30cc Kiran K 2025-02-27  549  	btintel_pcie_copy_tlv(skb, BTINTEL_FW_BUILD, buf + dump_time_len, fw_build);
b8cc1a1cce30cc Kiran K 2025-02-27  550  
b8cc1a1cce30cc Kiran K 2025-02-27  551  	ret = hci_devcd_append(hdev, skb);
b8cc1a1cce30cc Kiran K 2025-02-27  552  	if (ret)
b8cc1a1cce30cc Kiran K 2025-02-27  553  		goto exit_err;
b8cc1a1cce30cc Kiran K 2025-02-27  554  
b8cc1a1cce30cc Kiran K 2025-02-27  555  	for (i = 0; i < dbgc->count; i++) {
b8cc1a1cce30cc Kiran K 2025-02-27  556  		ret = btintel_pcie_add_dmp_data(hdev, dbgc->bufs[i].data,
b8cc1a1cce30cc Kiran K 2025-02-27  557  						BTINTEL_PCIE_DBGC_BUFFER_SIZE);
b8cc1a1cce30cc Kiran K 2025-02-27  558  		if (ret)
b8cc1a1cce30cc Kiran K 2025-02-27  559  			break;
b8cc1a1cce30cc Kiran K 2025-02-27  560  	}
b8cc1a1cce30cc Kiran K 2025-02-27  561  
b8cc1a1cce30cc Kiran K 2025-02-27  562  exit_err:
b8cc1a1cce30cc Kiran K 2025-02-27  563  	hci_devcd_complete(hdev);
b8cc1a1cce30cc Kiran K 2025-02-27  564  	return ret;
b8cc1a1cce30cc Kiran K 2025-02-27  565  }
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author
#2 lore raw

Hi Dan,

Thanks for your comment.

Quoted 23 lines

Subject: Re: [PATCH v1] Bluetooth: btintel_pcie: Add support for device coredump

Hi Kiran,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Kiran-K/Bluetooth-
btintel_pcie-Add-support-for-device-coredump/20250227-181131
base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-
next.git master
patch link: https://lore.kernel.org/r/20250227102625.20642-1-
kiran.k%40intel.com
patch subject: [PATCH v1] Bluetooth: btintel_pcie: Add support for device coredump
config: sparc-randconfig-r071-20250302 (https://download.01.org/0day-
ci/archive/20250302/[email protected]/config)
compiler: sparc-linux-gcc (GCC) 14.2.0

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

Quoted 7 lines
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

New smatch warnings:
drivers/bluetooth/btintel_pcie.c:493 btintel_pcie_read_dram_buffers() error:
snprintf() is printing too much 100 vs 70

Ack. I have fixed this issue in v2 version of the patch.

Quoted 182 lines

vim +493 drivers/bluetooth/btintel_pcie.c

b8cc1a1cce30cc Kiran K 2025-02-27 454 static int btintel_pcie_read_dram_buffers(struct btintel_pcie_data *data)

b8cc1a1cce30cc Kiran K 2025-02-27  455  {
b8cc1a1cce30cc Kiran K 2025-02-27  456  	u32 offset, prev_size,

wr_ptr_status, dump_size, i;
b8cc1a1cce30cc Kiran K 2025-02-27 457 struct btintel_pcie_dbgc *dbgc
= &data->dbgc;
b8cc1a1cce30cc Kiran K 2025-02-27 458 u8 buf_idx, dump_time_len,
fw_build;
b8cc1a1cce30cc Kiran K 2025-02-27 459 struct hci_dev *hdev = data-

Quoted 1 line

hdev;

b8cc1a1cce30cc Kiran K 2025-02-27  460  	struct intel_tlv *tlv;
b8cc1a1cce30cc Kiran K 2025-02-27  461  	struct timespec64 now;
b8cc1a1cce30cc Kiran K 2025-02-27  462  	struct sk_buff *skb;
b8cc1a1cce30cc Kiran K 2025-02-27  463  	struct tm tm_now;
b8cc1a1cce30cc Kiran K 2025-02-27  464  	char buf[100];
b8cc1a1cce30cc Kiran K 2025-02-27  465  	u16 hdr_len;
b8cc1a1cce30cc Kiran K 2025-02-27  466  	int ret;
b8cc1a1cce30cc Kiran K 2025-02-27  467
b8cc1a1cce30cc Kiran K 2025-02-27  468  	wr_ptr_status =

btintel_pcie_rd_dev_mem(data,
BTINTEL_PCIE_DBGC_CUR_DBGBUFF_STATUS);
b8cc1a1cce30cc Kiran K 2025-02-27 469 offset = wr_ptr_status &
BTINTEL_PCIE_DBG_OFFSET_BIT_MASK;
b8cc1a1cce30cc Kiran K 2025-02-27 470
b8cc1a1cce30cc Kiran K 2025-02-27 471 buf_idx =
BTINTEL_PCIE_DBGC_DBG_BUF_IDX(wr_ptr_status);

b8cc1a1cce30cc Kiran K 2025-02-27  472  	if (buf_idx > dbgc->count) {
b8cc1a1cce30cc Kiran K 2025-02-27  473  		bt_dev_warn(hdev,
"Buffer index is invalid");
b8cc1a1cce30cc Kiran K 2025-02-27  474  		return -EINVAL;
b8cc1a1cce30cc Kiran K 2025-02-27  475  	}
b8cc1a1cce30cc Kiran K 2025-02-27  476
b8cc1a1cce30cc Kiran K 2025-02-27  477  	prev_size = buf_idx *

BTINTEL_PCIE_DBGC_BUFFER_SIZE;
b8cc1a1cce30cc Kiran K 2025-02-27 478 if (prev_size + offset >=
prev_size)
b8cc1a1cce30cc Kiran K 2025-02-27 479 data-

Quoted 1 line

dmp_hdr.write_ptr = prev_size + offset;

b8cc1a1cce30cc Kiran K 2025-02-27  480  	else
b8cc1a1cce30cc Kiran K 2025-02-27  481  		return -EINVAL;
b8cc1a1cce30cc Kiran K 2025-02-27  482
b8cc1a1cce30cc Kiran K 2025-02-27  483  	ktime_get_real_ts64(&now);
b8cc1a1cce30cc Kiran K 2025-02-27  484  	time64_to_tm(now.tv_sec, 0,

&tm_now);
b8cc1a1cce30cc Kiran K 2025-02-27 485 dump_time_len = snprintf(buf,
sizeof(buf), "Dump Time: %02d-%02d-%04ld %02d:%02d:%02d", b8cc1a1cce30cc Kiran K 2025-02-27 486 tm_now.tm_mday, tm_now.tm_mon + 1, tm_now.tm_year + 1900, b8cc1a1cce30cc Kiran K 2025-02-27 487 tm_now.tm_hour, tm_now.tm_min, tm_now.tm_sec); b8cc1a1cce30cc Kiran K 2025-02-27 488
b8cc1a1cce30cc Kiran K 2025-02-27 489 fw_build = snprintf(buf +
dump_time_len, sizeof(buf),

                                                                                        ^^^^^^^^^^^

This size should be "sizeof(buf) - dump_time_len". It's better to use scnprintf() here vs snprintf(). The scnprintf() function returns the number of bytes which were actually printed vs the number which were printed if there was enough space.

b8cc1a1cce30cc Kiran K 2025-02-27 490 "Firmware
Timestamp: Year %u WW %02u buildtype %u build %u",
b8cc1a1cce30cc Kiran K 2025-02-27 491 2000 + (data-

Quoted 1 line

dmp_hdr.fw_timestamp >> 8),

b8cc1a1cce30cc Kiran K 2025-02-27 492 data-

Quoted 1 line

dmp_hdr.fw_timestamp & 0xff, data->dmp_hdr.fw_build_type,

b8cc1a1cce30cc Kiran K 2025-02-27 @493 data-

Quoted 1 line

dmp_hdr.fw_build_num);

b8cc1a1cce30cc Kiran K 2025-02-27 494
b8cc1a1cce30cc Kiran K 2025-02-27 495 hdr_len = sizeof(*tlv) +
sizeof(data->dmp_hdr.cnvi_bt) +
b8cc1a1cce30cc Kiran K 2025-02-27 496 sizeof(*tlv) +
sizeof(data->dmp_hdr.write_ptr) +
b8cc1a1cce30cc Kiran K 2025-02-27 497 sizeof(*tlv) +
sizeof(data->dmp_hdr.wrap_ctr) +
b8cc1a1cce30cc Kiran K 2025-02-27 498 sizeof(*tlv) +
sizeof(data->dmp_hdr.trigger_reason) +
b8cc1a1cce30cc Kiran K 2025-02-27 499 sizeof(*tlv) +
sizeof(data->dmp_hdr.fw_git_sha1) +
b8cc1a1cce30cc Kiran K 2025-02-27 500 sizeof(*tlv) +
sizeof(data->dmp_hdr.cnvr_top) +
b8cc1a1cce30cc Kiran K 2025-02-27 501 sizeof(*tlv) +
sizeof(data->dmp_hdr.cnvi_top) +
b8cc1a1cce30cc Kiran K 2025-02-27 502 sizeof(*tlv) +
dump_time_len +
b8cc1a1cce30cc Kiran K 2025-02-27 503 sizeof(*tlv) +
fw_build;
b8cc1a1cce30cc Kiran K 2025-02-27 504
b8cc1a1cce30cc Kiran K 2025-02-27 505 dump_size = hdr_len +
sizeof(hdr_len);
b8cc1a1cce30cc Kiran K 2025-02-27 506
b8cc1a1cce30cc Kiran K 2025-02-27 507 skb = alloc_skb(dump_size,
GFP_KERNEL);

b8cc1a1cce30cc Kiran K 2025-02-27  508  	if (!skb)
b8cc1a1cce30cc Kiran K 2025-02-27  509  		return -ENOMEM;
b8cc1a1cce30cc Kiran K 2025-02-27  510
b8cc1a1cce30cc Kiran K 2025-02-27  511  	/* Add debug buffers data

length to dump size */
b8cc1a1cce30cc Kiran K 2025-02-27 512 dump_size +=
BTINTEL_PCIE_DBGC_BUFFER_SIZE * dbgc->count;
b8cc1a1cce30cc Kiran K 2025-02-27 513
b8cc1a1cce30cc Kiran K 2025-02-27 514 ret = hci_devcd_init(hdev,
dump_size);

b8cc1a1cce30cc Kiran K 2025-02-27  515  	if (ret) {
b8cc1a1cce30cc Kiran K 2025-02-27  516  		bt_dev_err(hdev,
"Failed to init devcoredump, err %d", ret);
b8cc1a1cce30cc Kiran K 2025-02-27  517  		kfree_skb(skb);
b8cc1a1cce30cc Kiran K 2025-02-27  518  		return ret;
b8cc1a1cce30cc Kiran K 2025-02-27  519  	}
b8cc1a1cce30cc Kiran K 2025-02-27  520
b8cc1a1cce30cc Kiran K 2025-02-27  521  	skb_put_data(skb, &hdr_len,

sizeof(hdr_len));
b8cc1a1cce30cc Kiran K 2025-02-27 522
b8cc1a1cce30cc Kiran K 2025-02-27 523 btintel_pcie_copy_tlv(skb,
BTINTEL_CNVI_BT, &data->dmp_hdr.cnvi_bt,
b8cc1a1cce30cc Kiran K 2025-02-27 524 sizeof(data-

Quoted 1 line

dmp_hdr.cnvi_bt));

b8cc1a1cce30cc Kiran K 2025-02-27 525
b8cc1a1cce30cc Kiran K 2025-02-27 526 btintel_pcie_copy_tlv(skb,
BTINTEL_WRITE_PTR, &data->dmp_hdr.write_ptr,
b8cc1a1cce30cc Kiran K 2025-02-27 527 sizeof(data-

Quoted 1 line

dmp_hdr.write_ptr));

b8cc1a1cce30cc Kiran K 2025-02-27 528
b8cc1a1cce30cc Kiran K 2025-02-27 529 data->dmp_hdr.wrap_ctr =
btintel_pcie_rd_dev_mem(data,
b8cc1a1cce30cc Kiran K 2025-02-27 530

			 BTINTEL_PCIE_DBGC_DBGBUFF_WRAP_ARND);

b8cc1a1cce30cc Kiran K 2025-02-27 531
b8cc1a1cce30cc Kiran K 2025-02-27 532 btintel_pcie_copy_tlv(skb,
BTINTEL_WRAP_CTR, &data->dmp_hdr.wrap_ctr,
b8cc1a1cce30cc Kiran K 2025-02-27 533 sizeof(data-

Quoted 1 line

dmp_hdr.wrap_ctr));

b8cc1a1cce30cc Kiran K 2025-02-27 534
b8cc1a1cce30cc Kiran K 2025-02-27 535 btintel_pcie_copy_tlv(skb,
BTINTEL_TRIGGER_REASON, &data->dmp_hdr.trigger_reason,
b8cc1a1cce30cc Kiran K 2025-02-27 536 sizeof(data-

Quoted 1 line

dmp_hdr.trigger_reason));

b8cc1a1cce30cc Kiran K 2025-02-27 537
b8cc1a1cce30cc Kiran K 2025-02-27 538 btintel_pcie_copy_tlv(skb,
BTINTEL_FW_SHA, &data->dmp_hdr.fw_git_sha1,
b8cc1a1cce30cc Kiran K 2025-02-27 539 sizeof(data-

Quoted 1 line

dmp_hdr.fw_git_sha1));

b8cc1a1cce30cc Kiran K 2025-02-27 540
b8cc1a1cce30cc Kiran K 2025-02-27 541 btintel_pcie_copy_tlv(skb,
BTINTEL_CNVR_TOP, &data->dmp_hdr.cnvr_top,
b8cc1a1cce30cc Kiran K 2025-02-27 542 sizeof(data-

Quoted 1 line

dmp_hdr.cnvr_top));

b8cc1a1cce30cc Kiran K 2025-02-27 543
b8cc1a1cce30cc Kiran K 2025-02-27 544 btintel_pcie_copy_tlv(skb,
BTINTEL_CNVI_TOP, &data->dmp_hdr.cnvi_top,
b8cc1a1cce30cc Kiran K 2025-02-27 545 sizeof(data-

Quoted 1 line

dmp_hdr.cnvi_top));

b8cc1a1cce30cc Kiran K 2025-02-27 546
b8cc1a1cce30cc Kiran K 2025-02-27 547 btintel_pcie_copy_tlv(skb,
BTINTEL_DUMP_TIME, buf, dump_time_len);
b8cc1a1cce30cc Kiran K 2025-02-27 548
b8cc1a1cce30cc Kiran K 2025-02-27 549 btintel_pcie_copy_tlv(skb,
BTINTEL_FW_BUILD, buf + dump_time_len, fw_build);
b8cc1a1cce30cc Kiran K 2025-02-27 550
b8cc1a1cce30cc Kiran K 2025-02-27 551 ret = hci_devcd_append(hdev,
skb);

b8cc1a1cce30cc Kiran K 2025-02-27  552  	if (ret)
b8cc1a1cce30cc Kiran K 2025-02-27  553  		goto exit_err;
b8cc1a1cce30cc Kiran K 2025-02-27  554
b8cc1a1cce30cc Kiran K 2025-02-27  555  	for (i = 0; i < dbgc->count; i++) {
b8cc1a1cce30cc Kiran K 2025-02-27  556  		ret =
btintel_pcie_add_dmp_data(hdev, dbgc->bufs[i].data,
b8cc1a1cce30cc Kiran K 2025-02-27  557
		BTINTEL_PCIE_DBGC_BUFFER_SIZE);
b8cc1a1cce30cc Kiran K 2025-02-27  558  		if (ret)
b8cc1a1cce30cc Kiran K 2025-02-27  559  			break;
b8cc1a1cce30cc Kiran K 2025-02-27  560  	}
b8cc1a1cce30cc Kiran K 2025-02-27  561 b8cc1a1cce30cc Kiran K 2025-02-27
562  exit_err:
b8cc1a1cce30cc Kiran K 2025-02-27  563  	hci_devcd_complete(hdev);
b8cc1a1cce30cc Kiran K 2025-02-27  564  	return ret;
b8cc1a1cce30cc Kiran K 2025-02-27  565  }
Quoted 4 lines

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

Thanks,
Kiran