* RE: [v2] Bluetooth: btusb: Add WCN6855 devcoredump support
2023-04-10 9:53 Tim Jiang
@ 2023-04-10 10:33 ` bluez.test.bot
0 siblings, 0 replies; 13+ messages in thread
From: bluez.test.bot @ 2023-04-10 10:33 UTC (permalink / raw)
To: linux-bluetooth, quic_tjiang
[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]
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=738383
---Test result---
Test Summary:
CheckPatch PASS 0.88 seconds
GitLint PASS 0.34 seconds
SubjectPrefix PASS 0.12 seconds
BuildKernel PASS 32.15 seconds
CheckAllWarning PASS 34.95 seconds
CheckSparse PASS 39.76 seconds
CheckSmatch PASS 108.92 seconds
BuildKernel32 PASS 31.11 seconds
TestRunnerSetup PASS 435.81 seconds
TestRunner_l2cap-tester PASS 16.93 seconds
TestRunner_iso-tester PASS 16.96 seconds
TestRunner_bnep-tester PASS 5.57 seconds
TestRunner_mgmt-tester PASS 115.74 seconds
TestRunner_rfcomm-tester PASS 8.83 seconds
TestRunner_sco-tester PASS 8.14 seconds
TestRunner_ioctl-tester PASS 9.61 seconds
TestRunner_mesh-tester PASS 7.02 seconds
TestRunner_smp-tester PASS 8.02 seconds
TestRunner_userchan-tester PASS 5.84 seconds
IncrementalBuild PASS 29.34 seconds
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
@ 2023-04-13 6:43 Tim Jiang
2023-04-13 7:32 ` [v2] " bluez.test.bot
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Tim Jiang @ 2023-04-13 6:43 UTC (permalink / raw)
To: marcel
Cc: linux-kernel, linux-bluetooth, linux-arm-msm, quic_tjiang,
quic_bgodavar, quic_hemantg, mka
WCN6855 will report memdump via ACL data or HCI event when
it get crashed, so we collect memdump to debug firmware.
Signed-off-by: Tim Jiang <quic_tjiang@quicinc.com>
---
drivers/bluetooth/btusb.c | 222 ++++++++++++++++++++++++++++++++++++++
1 file changed, 222 insertions(+)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 2303b0a66323..f045bbb0ee09 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -733,6 +733,16 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
{}
};
+struct qca_dump_info {
+ /* fields for dump collection */
+ u16 id_vendor;
+ u16 id_product;
+ u32 fw_version;
+ u32 controller_id;
+ u32 ram_dump_size;
+ u16 ram_dump_seqno;
+};
+
#define BTUSB_MAX_ISOC_FRAMES 10
#define BTUSB_INTR_RUNNING 0
@@ -752,6 +762,7 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
#define BTUSB_WAKEUP_AUTOSUSPEND 14
#define BTUSB_USE_ALT3_FOR_WBS 15
#define BTUSB_ALT6_CONTINUOUS_TX 16
+#define BTUSB_HW_SSR_ACTIVE 17
struct btusb_data {
struct hci_dev *hdev;
@@ -814,6 +825,8 @@ struct btusb_data {
int oob_wake_irq; /* irq for out-of-band wake-on-bt */
unsigned cmd_timeout_cnt;
+
+ struct qca_dump_info qca_dump;
};
static void btusb_reset(struct hci_dev *hdev)
@@ -904,6 +917,11 @@ static void btusb_qca_cmd_timeout(struct hci_dev *hdev)
struct btusb_data *data = hci_get_drvdata(hdev);
struct gpio_desc *reset_gpio = data->reset_gpio;
+ if (test_bit(BTUSB_HW_SSR_ACTIVE, &data->flags)) {
+ bt_dev_info(hdev, "Ramdump in progress, defer cmd_timeout");
+ return;
+ }
+
if (++data->cmd_timeout_cnt < 5)
return;
@@ -3294,6 +3312,202 @@ static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev,
return 0;
}
+#define QCA_MEMDUMP_ACL_HANDLE 0x2EDD
+#define QCA_MEMDUMP_SIZE_MAX 0x100000
+#define QCA_MEMDUMP_VSE_CLASS 0x01
+#define QCA_MEMDUMP_MSG_TYPE 0x08
+#define QCA_MEMDUMP_PKT_SIZE 248
+#define QCA_LAST_SEQUENCE_NUM 0xffff
+
+struct qca_dump_hdr {
+ u8 vse_class;
+ u8 msg_type;
+ __le16 seqno;
+ u8 reserved;
+ union {
+ u8 data[0];
+ struct {
+ __le32 ram_dump_size;
+ u8 data0[0];
+ } __packed;
+ };
+} __packed;
+
+
+static void btusb_dump_hdr_qca(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ char buf[128];
+ struct btusb_data *btdata = hci_get_drvdata(hdev);
+
+ snprintf(buf, sizeof(buf), "Controller Name: 0x%x\n",
+ btdata->qca_dump.controller_id);
+ skb_put_data(skb, buf, strlen(buf));
+
+ snprintf(buf, sizeof(buf), "Firmware Version: 0x%x\n",
+ btdata->qca_dump.fw_version);
+ skb_put_data(skb, buf, strlen(buf));
+
+ snprintf(buf, sizeof(buf), "Driver: %s\nVendor: qca\n",
+ btusb_driver.name);
+ skb_put_data(skb, buf, strlen(buf));
+
+ snprintf(buf, sizeof(buf), "VID: 0x%x\nPID:0x%x\n",
+ btdata->qca_dump.id_vendor, btdata->qca_dump.id_product);
+ skb_put_data(skb, buf, strlen(buf));
+
+ snprintf(buf, sizeof(buf), "Lmp Subversion: 0x%x\n",
+ hdev->lmp_subver);
+ skb_put_data(skb, buf, strlen(buf));
+}
+
+static void btusb_coredump_qca(struct hci_dev *hdev)
+{
+ static const u8 param[] = { 0x26 };
+ struct sk_buff *skb;
+
+ skb = __hci_cmd_sync(hdev, 0xfc0c, 1, param, HCI_CMD_TIMEOUT);
+ if (IS_ERR(skb))
+ bt_dev_err(hdev, "%s: triggle crash failed (%ld)", __func__, PTR_ERR(skb));
+ kfree_skb(skb);
+}
+
+/*
+ * ==0: not a dump pkt.
+ * < 0: fails to handle a dump pkt
+ * > 0: otherwise.
+ */
+static int handle_dump_pkt_qca(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ int ret = 1;
+ u8 pkt_type;
+ u8 *sk_ptr;
+ unsigned int sk_len;
+ u16 seqno;
+ u32 dump_size;
+
+ struct hci_event_hdr *event_hdr;
+ struct hci_acl_hdr *acl_hdr;
+ struct qca_dump_hdr *dump_hdr;
+ struct btusb_data *btdata = hci_get_drvdata(hdev);
+ struct usb_device *udev = btdata->udev;
+
+ pkt_type = hci_skb_pkt_type(skb);
+ sk_ptr = skb->data;
+ sk_len = skb->len;
+
+ if (pkt_type == HCI_ACLDATA_PKT) {
+ acl_hdr = hci_acl_hdr(skb);
+ if (le16_to_cpu(acl_hdr->handle) != QCA_MEMDUMP_ACL_HANDLE)
+ return 0;
+ sk_ptr += HCI_ACL_HDR_SIZE;
+ sk_len -= HCI_ACL_HDR_SIZE;
+ event_hdr = (struct hci_event_hdr *)sk_ptr;
+ } else {
+ event_hdr = hci_event_hdr(skb);
+ }
+
+ if ((event_hdr->evt != HCI_VENDOR_PKT)
+ || (event_hdr->plen != (sk_len - HCI_EVENT_HDR_SIZE)))
+ return 0;
+
+ sk_ptr += HCI_EVENT_HDR_SIZE;
+ sk_len -= HCI_EVENT_HDR_SIZE;
+
+ dump_hdr = (struct qca_dump_hdr *)sk_ptr;
+ if ((sk_len < offsetof(struct qca_dump_hdr, data))
+ || (dump_hdr->vse_class != QCA_MEMDUMP_VSE_CLASS)
+ || (dump_hdr->msg_type != QCA_MEMDUMP_MSG_TYPE))
+ return 0;
+
+ /*it is dump pkt now*/
+ seqno = le16_to_cpu(dump_hdr->seqno);
+ if (seqno == 0) {
+ set_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags);
+ dump_size = le32_to_cpu(dump_hdr->ram_dump_size);
+ if (!dump_size || (dump_size > QCA_MEMDUMP_SIZE_MAX)) {
+ ret = -EILSEQ;
+ bt_dev_err(hdev, "Invalid memdump size(%u)",
+ dump_size);
+ goto out;
+ }
+
+ ret = hci_devcd_init(hdev, dump_size);
+ if (ret < 0) {
+ bt_dev_err(hdev, "memdump init error(%d)", ret);
+ goto out;
+ }
+
+ btdata->qca_dump.ram_dump_size = dump_size;
+ btdata->qca_dump.ram_dump_seqno = 0;
+ sk_ptr += offsetof(struct qca_dump_hdr, data0);
+ sk_len -= offsetof(struct qca_dump_hdr, data0);
+
+ usb_disable_autosuspend(udev);
+ bt_dev_info(hdev, "%s memdump size(%u)\n",
+ (pkt_type == HCI_ACLDATA_PKT) ? "ACL" : "event",
+ dump_size);
+ } else {
+ sk_ptr += offsetof(struct qca_dump_hdr, data);
+ sk_len -= offsetof(struct qca_dump_hdr, data);
+ }
+
+ if (!btdata->qca_dump.ram_dump_size) {
+ ret = -EINVAL;
+ bt_dev_err(hdev, "memdump is not active");
+ goto out;
+ }
+
+ if ((seqno > btdata->qca_dump.ram_dump_seqno + 1) && (seqno != QCA_LAST_SEQUENCE_NUM)) {
+ dump_size = QCA_MEMDUMP_PKT_SIZE * (seqno - btdata->qca_dump.ram_dump_seqno - 1);
+ hci_devcd_append_pattern(hdev, 0x0, dump_size);
+ bt_dev_err(hdev,
+ "expected memdump seqno(%u) is not received(%u)\n",
+ btdata->qca_dump.ram_dump_seqno, seqno);
+ btdata->qca_dump.ram_dump_seqno = seqno;
+ kfree_skb(skb);
+ return ret;
+ }
+
+ skb_pull(skb, skb->len - sk_len);
+ hci_devcd_append(hdev, skb);
+ btdata->qca_dump.ram_dump_seqno++;
+ if (seqno == QCA_LAST_SEQUENCE_NUM) {
+ bt_dev_info(hdev,
+ "memdump done: pkts(%u), total(%u)\n",
+ btdata->qca_dump.ram_dump_seqno, btdata->qca_dump.ram_dump_size);
+
+ hci_devcd_complete(hdev);
+ goto out;
+ }
+ return ret;
+
+out:
+ if (btdata->qca_dump.ram_dump_size)
+ usb_enable_autosuspend(udev);
+ btdata->qca_dump.ram_dump_size = 0;
+ btdata->qca_dump.ram_dump_seqno = 0;
+ clear_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags);
+
+ if (ret < 0)
+ kfree_skb(skb);
+ return ret;
+}
+
+static int btusb_recv_acl_qca(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ if (handle_dump_pkt_qca(hdev, skb))
+ return 0;
+ return hci_recv_frame(hdev, skb);
+}
+
+static int btusb_recv_evt_qca(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ if (handle_dump_pkt_qca(hdev, skb))
+ return 0;
+ return hci_recv_frame(hdev, skb);
+}
+
+
#define QCA_DFU_PACKET_LEN 4096
#define QCA_GET_TARGET_VERSION 0x09
@@ -3628,6 +3842,9 @@ static int btusb_setup_qca(struct hci_dev *hdev)
if (err < 0)
return err;
+ btdata->qca_dump.fw_version = le32_to_cpu(ver.patch_version);
+ btdata->qca_dump.controller_id = le32_to_cpu(ver.rom_version);
+
if (!(status & QCA_SYSCFG_UPDATED)) {
err = btusb_setup_qca_load_nvm(hdev, &ver, info);
if (err < 0)
@@ -4117,6 +4334,11 @@ static int btusb_probe(struct usb_interface *intf,
}
if (id->driver_info & BTUSB_QCA_WCN6855) {
+ data->qca_dump.id_vendor = id->idVendor;
+ data->qca_dump.id_product = id->idProduct;
+ data->recv_event = btusb_recv_evt_qca;
+ data->recv_acl = btusb_recv_acl_qca;
+ hci_devcd_register(hdev, btusb_coredump_qca, btusb_dump_hdr_qca, NULL);
data->setup_on_usb = btusb_setup_qca;
hdev->shutdown = btusb_shutdown_qca;
hdev->set_bdaddr = btusb_set_bdaddr_wcn6855;
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* RE: [v2] Bluetooth: btusb: Add WCN6855 devcoredump support
2023-04-13 6:43 [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support Tim Jiang
@ 2023-04-13 7:32 ` bluez.test.bot
2023-04-14 20:57 ` [PATCH v2] " Luiz Augusto von Dentz
` (2 subsequent siblings)
3 siblings, 0 replies; 13+ messages in thread
From: bluez.test.bot @ 2023-04-13 7:32 UTC (permalink / raw)
To: linux-bluetooth, quic_tjiang
[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]
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=739370
---Test result---
Test Summary:
CheckPatch PASS 0.85 seconds
GitLint PASS 0.34 seconds
SubjectPrefix PASS 0.12 seconds
BuildKernel PASS 32.05 seconds
CheckAllWarning PASS 34.86 seconds
CheckSparse PASS 39.41 seconds
CheckSmatch PASS 109.83 seconds
BuildKernel32 PASS 30.62 seconds
TestRunnerSetup PASS 437.68 seconds
TestRunner_l2cap-tester PASS 16.52 seconds
TestRunner_iso-tester PASS 16.32 seconds
TestRunner_bnep-tester PASS 5.23 seconds
TestRunner_mgmt-tester PASS 110.48 seconds
TestRunner_rfcomm-tester PASS 8.42 seconds
TestRunner_sco-tester PASS 7.88 seconds
TestRunner_ioctl-tester PASS 9.04 seconds
TestRunner_mesh-tester PASS 6.75 seconds
TestRunner_smp-tester PASS 7.69 seconds
TestRunner_userchan-tester PASS 5.50 seconds
IncrementalBuild PASS 29.10 seconds
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
2023-04-13 6:43 [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support Tim Jiang
2023-04-13 7:32 ` [v2] " bluez.test.bot
@ 2023-04-14 20:57 ` Luiz Augusto von Dentz
2023-04-18 1:02 ` Tim Jiang (QUIC)
2023-04-14 21:02 ` Dmitry Baryshkov
2023-04-24 1:46 ` kernel test robot
3 siblings, 1 reply; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2023-04-14 20:57 UTC (permalink / raw)
To: Tim Jiang
Cc: marcel, linux-kernel, linux-bluetooth, linux-arm-msm,
quic_bgodavar, quic_hemantg, mka
Hi Tim,
On Wed, Apr 12, 2023 at 11:46 PM Tim Jiang <quic_tjiang@quicinc.com> wrote:
>
> WCN6855 will report memdump via ACL data or HCI event when
> it get crashed, so we collect memdump to debug firmware.
>
> Signed-off-by: Tim Jiang <quic_tjiang@quicinc.com>
> ---
> drivers/bluetooth/btusb.c | 222 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 222 insertions(+)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 2303b0a66323..f045bbb0ee09 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -733,6 +733,16 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
> {}
> };
>
> +struct qca_dump_info {
> + /* fields for dump collection */
> + u16 id_vendor;
> + u16 id_product;
> + u32 fw_version;
> + u32 controller_id;
> + u32 ram_dump_size;
> + u16 ram_dump_seqno;
> +};
> +
> #define BTUSB_MAX_ISOC_FRAMES 10
>
> #define BTUSB_INTR_RUNNING 0
> @@ -752,6 +762,7 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
> #define BTUSB_WAKEUP_AUTOSUSPEND 14
> #define BTUSB_USE_ALT3_FOR_WBS 15
> #define BTUSB_ALT6_CONTINUOUS_TX 16
> +#define BTUSB_HW_SSR_ACTIVE 17
>
> struct btusb_data {
> struct hci_dev *hdev;
> @@ -814,6 +825,8 @@ struct btusb_data {
>
> int oob_wake_irq; /* irq for out-of-band wake-on-bt */
> unsigned cmd_timeout_cnt;
> +
> + struct qca_dump_info qca_dump;
> };
>
> static void btusb_reset(struct hci_dev *hdev)
> @@ -904,6 +917,11 @@ static void btusb_qca_cmd_timeout(struct hci_dev *hdev)
> struct btusb_data *data = hci_get_drvdata(hdev);
> struct gpio_desc *reset_gpio = data->reset_gpio;
>
> + if (test_bit(BTUSB_HW_SSR_ACTIVE, &data->flags)) {
> + bt_dev_info(hdev, "Ramdump in progress, defer cmd_timeout");
> + return;
> + }
> +
> if (++data->cmd_timeout_cnt < 5)
> return;
>
> @@ -3294,6 +3312,202 @@ static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev,
> return 0;
> }
>
> +#define QCA_MEMDUMP_ACL_HANDLE 0x2EDD
> +#define QCA_MEMDUMP_SIZE_MAX 0x100000
> +#define QCA_MEMDUMP_VSE_CLASS 0x01
> +#define QCA_MEMDUMP_MSG_TYPE 0x08
> +#define QCA_MEMDUMP_PKT_SIZE 248
> +#define QCA_LAST_SEQUENCE_NUM 0xffff
> +
> +struct qca_dump_hdr {
> + u8 vse_class;
> + u8 msg_type;
> + __le16 seqno;
> + u8 reserved;
> + union {
> + u8 data[0];
> + struct {
> + __le32 ram_dump_size;
> + u8 data0[0];
> + } __packed;
> + };
> +} __packed;
> +
> +
> +static void btusb_dump_hdr_qca(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + char buf[128];
> + struct btusb_data *btdata = hci_get_drvdata(hdev);
> +
> + snprintf(buf, sizeof(buf), "Controller Name: 0x%x\n",
> + btdata->qca_dump.controller_id);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "Firmware Version: 0x%x\n",
> + btdata->qca_dump.fw_version);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "Driver: %s\nVendor: qca\n",
> + btusb_driver.name);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "VID: 0x%x\nPID:0x%x\n",
> + btdata->qca_dump.id_vendor, btdata->qca_dump.id_product);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "Lmp Subversion: 0x%x\n",
> + hdev->lmp_subver);
> + skb_put_data(skb, buf, strlen(buf));
> +}
> +
> +static void btusb_coredump_qca(struct hci_dev *hdev)
> +{
> + static const u8 param[] = { 0x26 };
> + struct sk_buff *skb;
> +
> + skb = __hci_cmd_sync(hdev, 0xfc0c, 1, param, HCI_CMD_TIMEOUT);
> + if (IS_ERR(skb))
> + bt_dev_err(hdev, "%s: triggle crash failed (%ld)", __func__, PTR_ERR(skb));
> + kfree_skb(skb);
> +}
> +
> +/*
> + * ==0: not a dump pkt.
> + * < 0: fails to handle a dump pkt
> + * > 0: otherwise.
> + */
> +static int handle_dump_pkt_qca(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + int ret = 1;
> + u8 pkt_type;
> + u8 *sk_ptr;
> + unsigned int sk_len;
> + u16 seqno;
> + u32 dump_size;
> +
> + struct hci_event_hdr *event_hdr;
> + struct hci_acl_hdr *acl_hdr;
> + struct qca_dump_hdr *dump_hdr;
> + struct btusb_data *btdata = hci_get_drvdata(hdev);
> + struct usb_device *udev = btdata->udev;
> +
> + pkt_type = hci_skb_pkt_type(skb);
> + sk_ptr = skb->data;
> + sk_len = skb->len;
> +
> + if (pkt_type == HCI_ACLDATA_PKT) {
> + acl_hdr = hci_acl_hdr(skb);
> + if (le16_to_cpu(acl_hdr->handle) != QCA_MEMDUMP_ACL_HANDLE)
> + return 0;
> + sk_ptr += HCI_ACL_HDR_SIZE;
> + sk_len -= HCI_ACL_HDR_SIZE;
> + event_hdr = (struct hci_event_hdr *)sk_ptr;
> + } else {
> + event_hdr = hci_event_hdr(skb);
> + }
> +
> + if ((event_hdr->evt != HCI_VENDOR_PKT)
> + || (event_hdr->plen != (sk_len - HCI_EVENT_HDR_SIZE)))
> + return 0;
> +
> + sk_ptr += HCI_EVENT_HDR_SIZE;
> + sk_len -= HCI_EVENT_HDR_SIZE;
> +
> + dump_hdr = (struct qca_dump_hdr *)sk_ptr;
> + if ((sk_len < offsetof(struct qca_dump_hdr, data))
> + || (dump_hdr->vse_class != QCA_MEMDUMP_VSE_CLASS)
> + || (dump_hdr->msg_type != QCA_MEMDUMP_MSG_TYPE))
> + return 0;
> +
> + /*it is dump pkt now*/
> + seqno = le16_to_cpu(dump_hdr->seqno);
> + if (seqno == 0) {
> + set_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags);
> + dump_size = le32_to_cpu(dump_hdr->ram_dump_size);
> + if (!dump_size || (dump_size > QCA_MEMDUMP_SIZE_MAX)) {
> + ret = -EILSEQ;
> + bt_dev_err(hdev, "Invalid memdump size(%u)",
> + dump_size);
> + goto out;
> + }
> +
> + ret = hci_devcd_init(hdev, dump_size);
> + if (ret < 0) {
> + bt_dev_err(hdev, "memdump init error(%d)", ret);
> + goto out;
> + }
> +
> + btdata->qca_dump.ram_dump_size = dump_size;
> + btdata->qca_dump.ram_dump_seqno = 0;
> + sk_ptr += offsetof(struct qca_dump_hdr, data0);
> + sk_len -= offsetof(struct qca_dump_hdr, data0);
> +
> + usb_disable_autosuspend(udev);
> + bt_dev_info(hdev, "%s memdump size(%u)\n",
> + (pkt_type == HCI_ACLDATA_PKT) ? "ACL" : "event",
> + dump_size);
Lets not use bt_dev_info for devcd code, since the system should log
these events via devcd interface, so please convert any instance of
bt_dev_info to bt_dev_dbg.
> + } else {
> + sk_ptr += offsetof(struct qca_dump_hdr, data);
> + sk_len -= offsetof(struct qca_dump_hdr, data);
> + }
> +
> + if (!btdata->qca_dump.ram_dump_size) {
> + ret = -EINVAL;
> + bt_dev_err(hdev, "memdump is not active");
> + goto out;
> + }
> +
> + if ((seqno > btdata->qca_dump.ram_dump_seqno + 1) && (seqno != QCA_LAST_SEQUENCE_NUM)) {
> + dump_size = QCA_MEMDUMP_PKT_SIZE * (seqno - btdata->qca_dump.ram_dump_seqno - 1);
> + hci_devcd_append_pattern(hdev, 0x0, dump_size);
> + bt_dev_err(hdev,
> + "expected memdump seqno(%u) is not received(%u)\n",
> + btdata->qca_dump.ram_dump_seqno, seqno);
> + btdata->qca_dump.ram_dump_seqno = seqno;
> + kfree_skb(skb);
> + return ret;
> + }
> +
> + skb_pull(skb, skb->len - sk_len);
> + hci_devcd_append(hdev, skb);
> + btdata->qca_dump.ram_dump_seqno++;
> + if (seqno == QCA_LAST_SEQUENCE_NUM) {
> + bt_dev_info(hdev,
> + "memdump done: pkts(%u), total(%u)\n",
> + btdata->qca_dump.ram_dump_seqno, btdata->qca_dump.ram_dump_size);
Ditto.
> + hci_devcd_complete(hdev);
> + goto out;
> + }
> + return ret;
> +
> +out:
> + if (btdata->qca_dump.ram_dump_size)
> + usb_enable_autosuspend(udev);
> + btdata->qca_dump.ram_dump_size = 0;
> + btdata->qca_dump.ram_dump_seqno = 0;
> + clear_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags);
> +
> + if (ret < 0)
> + kfree_skb(skb);
> + return ret;
> +}
> +
> +static int btusb_recv_acl_qca(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + if (handle_dump_pkt_qca(hdev, skb))
> + return 0;
> + return hci_recv_frame(hdev, skb);
> +}
> +
> +static int btusb_recv_evt_qca(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + if (handle_dump_pkt_qca(hdev, skb))
> + return 0;
> + return hci_recv_frame(hdev, skb);
> +}
> +
> +
> #define QCA_DFU_PACKET_LEN 4096
>
> #define QCA_GET_TARGET_VERSION 0x09
> @@ -3628,6 +3842,9 @@ static int btusb_setup_qca(struct hci_dev *hdev)
> if (err < 0)
> return err;
>
> + btdata->qca_dump.fw_version = le32_to_cpu(ver.patch_version);
> + btdata->qca_dump.controller_id = le32_to_cpu(ver.rom_version);
> +
> if (!(status & QCA_SYSCFG_UPDATED)) {
> err = btusb_setup_qca_load_nvm(hdev, &ver, info);
> if (err < 0)
> @@ -4117,6 +4334,11 @@ static int btusb_probe(struct usb_interface *intf,
> }
>
> if (id->driver_info & BTUSB_QCA_WCN6855) {
> + data->qca_dump.id_vendor = id->idVendor;
> + data->qca_dump.id_product = id->idProduct;
> + data->recv_event = btusb_recv_evt_qca;
> + data->recv_acl = btusb_recv_acl_qca;
> + hci_devcd_register(hdev, btusb_coredump_qca, btusb_dump_hdr_qca, NULL);
> data->setup_on_usb = btusb_setup_qca;
> hdev->shutdown = btusb_shutdown_qca;
> hdev->set_bdaddr = btusb_set_bdaddr_wcn6855;
> --
> 2.17.1
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
2023-04-13 6:43 [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support Tim Jiang
2023-04-13 7:32 ` [v2] " bluez.test.bot
2023-04-14 20:57 ` [PATCH v2] " Luiz Augusto von Dentz
@ 2023-04-14 21:02 ` Dmitry Baryshkov
2023-04-18 1:02 ` Tim Jiang (QUIC)
2023-04-24 1:46 ` kernel test robot
3 siblings, 1 reply; 13+ messages in thread
From: Dmitry Baryshkov @ 2023-04-14 21:02 UTC (permalink / raw)
To: Tim Jiang
Cc: marcel, linux-kernel, linux-bluetooth, linux-arm-msm,
quic_bgodavar, quic_hemantg, mka
On Thu, 13 Apr 2023 at 09:44, Tim Jiang <quic_tjiang@quicinc.com> wrote:
>
> WCN6855 will report memdump via ACL data or HCI event when
> it get crashed, so we collect memdump to debug firmware.
Is it applicable only to wcn6855 or to some of earlier chips too?
>
> Signed-off-by: Tim Jiang <quic_tjiang@quicinc.com>
> ---
> drivers/bluetooth/btusb.c | 222 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 222 insertions(+)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 2303b0a66323..f045bbb0ee09 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -733,6 +733,16 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
> {}
> };
>
> +struct qca_dump_info {
> + /* fields for dump collection */
> + u16 id_vendor;
> + u16 id_product;
> + u32 fw_version;
> + u32 controller_id;
> + u32 ram_dump_size;
> + u16 ram_dump_seqno;
> +};
> +
> #define BTUSB_MAX_ISOC_FRAMES 10
>
> #define BTUSB_INTR_RUNNING 0
> @@ -752,6 +762,7 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
> #define BTUSB_WAKEUP_AUTOSUSPEND 14
> #define BTUSB_USE_ALT3_FOR_WBS 15
> #define BTUSB_ALT6_CONTINUOUS_TX 16
> +#define BTUSB_HW_SSR_ACTIVE 17
>
> struct btusb_data {
> struct hci_dev *hdev;
> @@ -814,6 +825,8 @@ struct btusb_data {
>
> int oob_wake_irq; /* irq for out-of-band wake-on-bt */
> unsigned cmd_timeout_cnt;
> +
> + struct qca_dump_info qca_dump;
> };
>
> static void btusb_reset(struct hci_dev *hdev)
> @@ -904,6 +917,11 @@ static void btusb_qca_cmd_timeout(struct hci_dev *hdev)
> struct btusb_data *data = hci_get_drvdata(hdev);
> struct gpio_desc *reset_gpio = data->reset_gpio;
>
> + if (test_bit(BTUSB_HW_SSR_ACTIVE, &data->flags)) {
> + bt_dev_info(hdev, "Ramdump in progress, defer cmd_timeout");
> + return;
> + }
> +
> if (++data->cmd_timeout_cnt < 5)
> return;
>
> @@ -3294,6 +3312,202 @@ static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev,
> return 0;
> }
>
> +#define QCA_MEMDUMP_ACL_HANDLE 0x2EDD
> +#define QCA_MEMDUMP_SIZE_MAX 0x100000
> +#define QCA_MEMDUMP_VSE_CLASS 0x01
> +#define QCA_MEMDUMP_MSG_TYPE 0x08
> +#define QCA_MEMDUMP_PKT_SIZE 248
> +#define QCA_LAST_SEQUENCE_NUM 0xffff
> +
> +struct qca_dump_hdr {
> + u8 vse_class;
> + u8 msg_type;
> + __le16 seqno;
> + u8 reserved;
> + union {
> + u8 data[0];
> + struct {
> + __le32 ram_dump_size;
> + u8 data0[0];
> + } __packed;
> + };
> +} __packed;
> +
> +
> +static void btusb_dump_hdr_qca(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + char buf[128];
> + struct btusb_data *btdata = hci_get_drvdata(hdev);
> +
> + snprintf(buf, sizeof(buf), "Controller Name: 0x%x\n",
> + btdata->qca_dump.controller_id);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "Firmware Version: 0x%x\n",
> + btdata->qca_dump.fw_version);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "Driver: %s\nVendor: qca\n",
> + btusb_driver.name);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "VID: 0x%x\nPID:0x%x\n",
> + btdata->qca_dump.id_vendor, btdata->qca_dump.id_product);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "Lmp Subversion: 0x%x\n",
> + hdev->lmp_subver);
> + skb_put_data(skb, buf, strlen(buf));
> +}
> +
> +static void btusb_coredump_qca(struct hci_dev *hdev)
> +{
> + static const u8 param[] = { 0x26 };
> + struct sk_buff *skb;
> +
> + skb = __hci_cmd_sync(hdev, 0xfc0c, 1, param, HCI_CMD_TIMEOUT);
> + if (IS_ERR(skb))
> + bt_dev_err(hdev, "%s: triggle crash failed (%ld)", __func__, PTR_ERR(skb));
> + kfree_skb(skb);
> +}
> +
> +/*
> + * ==0: not a dump pkt.
> + * < 0: fails to handle a dump pkt
> + * > 0: otherwise.
> + */
> +static int handle_dump_pkt_qca(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + int ret = 1;
> + u8 pkt_type;
> + u8 *sk_ptr;
> + unsigned int sk_len;
> + u16 seqno;
> + u32 dump_size;
> +
> + struct hci_event_hdr *event_hdr;
> + struct hci_acl_hdr *acl_hdr;
> + struct qca_dump_hdr *dump_hdr;
> + struct btusb_data *btdata = hci_get_drvdata(hdev);
> + struct usb_device *udev = btdata->udev;
> +
> + pkt_type = hci_skb_pkt_type(skb);
> + sk_ptr = skb->data;
> + sk_len = skb->len;
> +
> + if (pkt_type == HCI_ACLDATA_PKT) {
> + acl_hdr = hci_acl_hdr(skb);
> + if (le16_to_cpu(acl_hdr->handle) != QCA_MEMDUMP_ACL_HANDLE)
> + return 0;
> + sk_ptr += HCI_ACL_HDR_SIZE;
> + sk_len -= HCI_ACL_HDR_SIZE;
> + event_hdr = (struct hci_event_hdr *)sk_ptr;
> + } else {
> + event_hdr = hci_event_hdr(skb);
> + }
> +
> + if ((event_hdr->evt != HCI_VENDOR_PKT)
> + || (event_hdr->plen != (sk_len - HCI_EVENT_HDR_SIZE)))
> + return 0;
> +
> + sk_ptr += HCI_EVENT_HDR_SIZE;
> + sk_len -= HCI_EVENT_HDR_SIZE;
> +
> + dump_hdr = (struct qca_dump_hdr *)sk_ptr;
> + if ((sk_len < offsetof(struct qca_dump_hdr, data))
> + || (dump_hdr->vse_class != QCA_MEMDUMP_VSE_CLASS)
> + || (dump_hdr->msg_type != QCA_MEMDUMP_MSG_TYPE))
> + return 0;
> +
> + /*it is dump pkt now*/
> + seqno = le16_to_cpu(dump_hdr->seqno);
> + if (seqno == 0) {
> + set_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags);
> + dump_size = le32_to_cpu(dump_hdr->ram_dump_size);
> + if (!dump_size || (dump_size > QCA_MEMDUMP_SIZE_MAX)) {
> + ret = -EILSEQ;
> + bt_dev_err(hdev, "Invalid memdump size(%u)",
> + dump_size);
> + goto out;
> + }
> +
> + ret = hci_devcd_init(hdev, dump_size);
> + if (ret < 0) {
> + bt_dev_err(hdev, "memdump init error(%d)", ret);
> + goto out;
> + }
> +
> + btdata->qca_dump.ram_dump_size = dump_size;
> + btdata->qca_dump.ram_dump_seqno = 0;
> + sk_ptr += offsetof(struct qca_dump_hdr, data0);
> + sk_len -= offsetof(struct qca_dump_hdr, data0);
> +
> + usb_disable_autosuspend(udev);
> + bt_dev_info(hdev, "%s memdump size(%u)\n",
> + (pkt_type == HCI_ACLDATA_PKT) ? "ACL" : "event",
> + dump_size);
> + } else {
> + sk_ptr += offsetof(struct qca_dump_hdr, data);
> + sk_len -= offsetof(struct qca_dump_hdr, data);
> + }
> +
> + if (!btdata->qca_dump.ram_dump_size) {
> + ret = -EINVAL;
> + bt_dev_err(hdev, "memdump is not active");
> + goto out;
> + }
> +
> + if ((seqno > btdata->qca_dump.ram_dump_seqno + 1) && (seqno != QCA_LAST_SEQUENCE_NUM)) {
> + dump_size = QCA_MEMDUMP_PKT_SIZE * (seqno - btdata->qca_dump.ram_dump_seqno - 1);
> + hci_devcd_append_pattern(hdev, 0x0, dump_size);
> + bt_dev_err(hdev,
> + "expected memdump seqno(%u) is not received(%u)\n",
> + btdata->qca_dump.ram_dump_seqno, seqno);
> + btdata->qca_dump.ram_dump_seqno = seqno;
> + kfree_skb(skb);
> + return ret;
> + }
> +
> + skb_pull(skb, skb->len - sk_len);
> + hci_devcd_append(hdev, skb);
> + btdata->qca_dump.ram_dump_seqno++;
> + if (seqno == QCA_LAST_SEQUENCE_NUM) {
> + bt_dev_info(hdev,
> + "memdump done: pkts(%u), total(%u)\n",
> + btdata->qca_dump.ram_dump_seqno, btdata->qca_dump.ram_dump_size);
> +
> + hci_devcd_complete(hdev);
> + goto out;
> + }
> + return ret;
> +
> +out:
> + if (btdata->qca_dump.ram_dump_size)
> + usb_enable_autosuspend(udev);
> + btdata->qca_dump.ram_dump_size = 0;
> + btdata->qca_dump.ram_dump_seqno = 0;
> + clear_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags);
> +
> + if (ret < 0)
> + kfree_skb(skb);
> + return ret;
> +}
> +
> +static int btusb_recv_acl_qca(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + if (handle_dump_pkt_qca(hdev, skb))
> + return 0;
> + return hci_recv_frame(hdev, skb);
> +}
> +
> +static int btusb_recv_evt_qca(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + if (handle_dump_pkt_qca(hdev, skb))
> + return 0;
> + return hci_recv_frame(hdev, skb);
> +}
> +
> +
> #define QCA_DFU_PACKET_LEN 4096
>
> #define QCA_GET_TARGET_VERSION 0x09
> @@ -3628,6 +3842,9 @@ static int btusb_setup_qca(struct hci_dev *hdev)
> if (err < 0)
> return err;
>
> + btdata->qca_dump.fw_version = le32_to_cpu(ver.patch_version);
> + btdata->qca_dump.controller_id = le32_to_cpu(ver.rom_version);
> +
> if (!(status & QCA_SYSCFG_UPDATED)) {
> err = btusb_setup_qca_load_nvm(hdev, &ver, info);
> if (err < 0)
> @@ -4117,6 +4334,11 @@ static int btusb_probe(struct usb_interface *intf,
> }
>
> if (id->driver_info & BTUSB_QCA_WCN6855) {
> + data->qca_dump.id_vendor = id->idVendor;
> + data->qca_dump.id_product = id->idProduct;
> + data->recv_event = btusb_recv_evt_qca;
> + data->recv_acl = btusb_recv_acl_qca;
> + hci_devcd_register(hdev, btusb_coredump_qca, btusb_dump_hdr_qca, NULL);
> data->setup_on_usb = btusb_setup_qca;
> hdev->shutdown = btusb_shutdown_qca;
> hdev->set_bdaddr = btusb_set_bdaddr_wcn6855;
> --
> 2.17.1
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
2023-04-14 21:02 ` Dmitry Baryshkov
@ 2023-04-18 1:02 ` Tim Jiang (QUIC)
2023-04-18 9:02 ` Dmitry Baryshkov
0 siblings, 1 reply; 13+ messages in thread
From: Tim Jiang (QUIC) @ 2023-04-18 1:02 UTC (permalink / raw)
To: dmitry.baryshkov@linaro.org
Cc: marcel@holtmann.org, linux-kernel@vger.kernel.org,
linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Balakrishna Godavarthi (QUIC), Hemant Gupta (QUIC),
mka@chromium.org
Hi Dmitry:
-----Original Message-----
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Sent: Saturday, April 15, 2023 5:03 AM
To: Tim Jiang (QUIC) <quic_tjiang@quicinc.com>
Cc: marcel@holtmann.org; linux-kernel@vger.kernel.org; linux-bluetooth@vger.kernel.org; linux-arm-msm@vger.kernel.org; Balakrishna Godavarthi (QUIC) <quic_bgodavar@quicinc.com>; Hemant Gupta (QUIC) <quic_hemantg@quicinc.com>; mka@chromium.org
Subject: Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
On Thu, 13 Apr 2023 at 09:44, Tim Jiang <quic_tjiang@quicinc.com> wrote:
>
> WCN6855 will report memdump via ACL data or HCI event when it get
> crashed, so we collect memdump to debug firmware.
Is it applicable only to wcn6855 or to some of earlier chips too?
[Tim] Also applicable to earlier chips , but currently google only require us to support wcn6855
>
> Signed-off-by: Tim Jiang <quic_tjiang@quicinc.com>
> ---
> drivers/bluetooth/btusb.c | 222
> ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 222 insertions(+)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 2303b0a66323..f045bbb0ee09 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -733,6 +733,16 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
> {}
> };
>
> +struct qca_dump_info {
> + /* fields for dump collection */
> + u16 id_vendor;
> + u16 id_product;
> + u32 fw_version;
> + u32 controller_id;
> + u32 ram_dump_size;
> + u16 ram_dump_seqno;
> +};
> +
> #define BTUSB_MAX_ISOC_FRAMES 10
>
> #define BTUSB_INTR_RUNNING 0
> @@ -752,6 +762,7 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
> #define BTUSB_WAKEUP_AUTOSUSPEND 14
> #define BTUSB_USE_ALT3_FOR_WBS 15
> #define BTUSB_ALT6_CONTINUOUS_TX 16
> +#define BTUSB_HW_SSR_ACTIVE 17
>
> struct btusb_data {
> struct hci_dev *hdev;
> @@ -814,6 +825,8 @@ struct btusb_data {
>
> int oob_wake_irq; /* irq for out-of-band wake-on-bt */
> unsigned cmd_timeout_cnt;
> +
> + struct qca_dump_info qca_dump;
> };
>
> static void btusb_reset(struct hci_dev *hdev) @@ -904,6 +917,11 @@
> static void btusb_qca_cmd_timeout(struct hci_dev *hdev)
> struct btusb_data *data = hci_get_drvdata(hdev);
> struct gpio_desc *reset_gpio = data->reset_gpio;
>
> + if (test_bit(BTUSB_HW_SSR_ACTIVE, &data->flags)) {
> + bt_dev_info(hdev, "Ramdump in progress, defer cmd_timeout");
> + return;
> + }
> +
> if (++data->cmd_timeout_cnt < 5)
> return;
>
> @@ -3294,6 +3312,202 @@ static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev,
> return 0;
> }
>
> +#define QCA_MEMDUMP_ACL_HANDLE 0x2EDD #define QCA_MEMDUMP_SIZE_MAX
> +0x100000 #define QCA_MEMDUMP_VSE_CLASS 0x01 #define
> +QCA_MEMDUMP_MSG_TYPE 0x08 #define QCA_MEMDUMP_PKT_SIZE 248 #define
> +QCA_LAST_SEQUENCE_NUM 0xffff
> +
> +struct qca_dump_hdr {
> + u8 vse_class;
> + u8 msg_type;
> + __le16 seqno;
> + u8 reserved;
> + union {
> + u8 data[0];
> + struct {
> + __le32 ram_dump_size;
> + u8 data0[0];
> + } __packed;
> + };
> +} __packed;
> +
> +
> +static void btusb_dump_hdr_qca(struct hci_dev *hdev, struct sk_buff
> +*skb) {
> + char buf[128];
> + struct btusb_data *btdata = hci_get_drvdata(hdev);
> +
> + snprintf(buf, sizeof(buf), "Controller Name: 0x%x\n",
> + btdata->qca_dump.controller_id);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "Firmware Version: 0x%x\n",
> + btdata->qca_dump.fw_version);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "Driver: %s\nVendor: qca\n",
> + btusb_driver.name);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "VID: 0x%x\nPID:0x%x\n",
> + btdata->qca_dump.id_vendor, btdata->qca_dump.id_product);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "Lmp Subversion: 0x%x\n",
> + hdev->lmp_subver);
> + skb_put_data(skb, buf, strlen(buf)); }
> +
> +static void btusb_coredump_qca(struct hci_dev *hdev) {
> + static const u8 param[] = { 0x26 };
> + struct sk_buff *skb;
> +
> + skb = __hci_cmd_sync(hdev, 0xfc0c, 1, param, HCI_CMD_TIMEOUT);
> + if (IS_ERR(skb))
> + bt_dev_err(hdev, "%s: triggle crash failed (%ld)", __func__, PTR_ERR(skb));
> + kfree_skb(skb);
> +}
> +
> +/*
> + * ==0: not a dump pkt.
> + * < 0: fails to handle a dump pkt
> + * > 0: otherwise.
> + */
> +static int handle_dump_pkt_qca(struct hci_dev *hdev, struct sk_buff
> +*skb) {
> + int ret = 1;
> + u8 pkt_type;
> + u8 *sk_ptr;
> + unsigned int sk_len;
> + u16 seqno;
> + u32 dump_size;
> +
> + struct hci_event_hdr *event_hdr;
> + struct hci_acl_hdr *acl_hdr;
> + struct qca_dump_hdr *dump_hdr;
> + struct btusb_data *btdata = hci_get_drvdata(hdev);
> + struct usb_device *udev = btdata->udev;
> +
> + pkt_type = hci_skb_pkt_type(skb);
> + sk_ptr = skb->data;
> + sk_len = skb->len;
> +
> + if (pkt_type == HCI_ACLDATA_PKT) {
> + acl_hdr = hci_acl_hdr(skb);
> + if (le16_to_cpu(acl_hdr->handle) != QCA_MEMDUMP_ACL_HANDLE)
> + return 0;
> + sk_ptr += HCI_ACL_HDR_SIZE;
> + sk_len -= HCI_ACL_HDR_SIZE;
> + event_hdr = (struct hci_event_hdr *)sk_ptr;
> + } else {
> + event_hdr = hci_event_hdr(skb);
> + }
> +
> + if ((event_hdr->evt != HCI_VENDOR_PKT)
> + || (event_hdr->plen != (sk_len - HCI_EVENT_HDR_SIZE)))
> + return 0;
> +
> + sk_ptr += HCI_EVENT_HDR_SIZE;
> + sk_len -= HCI_EVENT_HDR_SIZE;
> +
> + dump_hdr = (struct qca_dump_hdr *)sk_ptr;
> + if ((sk_len < offsetof(struct qca_dump_hdr, data))
> + || (dump_hdr->vse_class != QCA_MEMDUMP_VSE_CLASS)
> + || (dump_hdr->msg_type != QCA_MEMDUMP_MSG_TYPE))
> + return 0;
> +
> + /*it is dump pkt now*/
> + seqno = le16_to_cpu(dump_hdr->seqno);
> + if (seqno == 0) {
> + set_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags);
> + dump_size = le32_to_cpu(dump_hdr->ram_dump_size);
> + if (!dump_size || (dump_size > QCA_MEMDUMP_SIZE_MAX)) {
> + ret = -EILSEQ;
> + bt_dev_err(hdev, "Invalid memdump size(%u)",
> + dump_size);
> + goto out;
> + }
> +
> + ret = hci_devcd_init(hdev, dump_size);
> + if (ret < 0) {
> + bt_dev_err(hdev, "memdump init error(%d)", ret);
> + goto out;
> + }
> +
> + btdata->qca_dump.ram_dump_size = dump_size;
> + btdata->qca_dump.ram_dump_seqno = 0;
> + sk_ptr += offsetof(struct qca_dump_hdr, data0);
> + sk_len -= offsetof(struct qca_dump_hdr, data0);
> +
> + usb_disable_autosuspend(udev);
> + bt_dev_info(hdev, "%s memdump size(%u)\n",
> + (pkt_type == HCI_ACLDATA_PKT) ? "ACL" : "event",
> + dump_size);
> + } else {
> + sk_ptr += offsetof(struct qca_dump_hdr, data);
> + sk_len -= offsetof(struct qca_dump_hdr, data);
> + }
> +
> + if (!btdata->qca_dump.ram_dump_size) {
> + ret = -EINVAL;
> + bt_dev_err(hdev, "memdump is not active");
> + goto out;
> + }
> +
> + if ((seqno > btdata->qca_dump.ram_dump_seqno + 1) && (seqno != QCA_LAST_SEQUENCE_NUM)) {
> + dump_size = QCA_MEMDUMP_PKT_SIZE * (seqno - btdata->qca_dump.ram_dump_seqno - 1);
> + hci_devcd_append_pattern(hdev, 0x0, dump_size);
> + bt_dev_err(hdev,
> + "expected memdump seqno(%u) is not received(%u)\n",
> + btdata->qca_dump.ram_dump_seqno, seqno);
> + btdata->qca_dump.ram_dump_seqno = seqno;
> + kfree_skb(skb);
> + return ret;
> + }
> +
> + skb_pull(skb, skb->len - sk_len);
> + hci_devcd_append(hdev, skb);
> + btdata->qca_dump.ram_dump_seqno++;
> + if (seqno == QCA_LAST_SEQUENCE_NUM) {
> + bt_dev_info(hdev,
> + "memdump done: pkts(%u), total(%u)\n",
> + btdata->qca_dump.ram_dump_seqno,
> + btdata->qca_dump.ram_dump_size);
> +
> + hci_devcd_complete(hdev);
> + goto out;
> + }
> + return ret;
> +
> +out:
> + if (btdata->qca_dump.ram_dump_size)
> + usb_enable_autosuspend(udev);
> + btdata->qca_dump.ram_dump_size = 0;
> + btdata->qca_dump.ram_dump_seqno = 0;
> + clear_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags);
> +
> + if (ret < 0)
> + kfree_skb(skb);
> + return ret;
> +}
> +
> +static int btusb_recv_acl_qca(struct hci_dev *hdev, struct sk_buff
> +*skb) {
> + if (handle_dump_pkt_qca(hdev, skb))
> + return 0;
> + return hci_recv_frame(hdev, skb); }
> +
> +static int btusb_recv_evt_qca(struct hci_dev *hdev, struct sk_buff
> +*skb) {
> + if (handle_dump_pkt_qca(hdev, skb))
> + return 0;
> + return hci_recv_frame(hdev, skb); }
> +
> +
> #define QCA_DFU_PACKET_LEN 4096
>
> #define QCA_GET_TARGET_VERSION 0x09
> @@ -3628,6 +3842,9 @@ static int btusb_setup_qca(struct hci_dev *hdev)
> if (err < 0)
> return err;
>
> + btdata->qca_dump.fw_version = le32_to_cpu(ver.patch_version);
> + btdata->qca_dump.controller_id = le32_to_cpu(ver.rom_version);
> +
> if (!(status & QCA_SYSCFG_UPDATED)) {
> err = btusb_setup_qca_load_nvm(hdev, &ver, info);
> if (err < 0)
> @@ -4117,6 +4334,11 @@ static int btusb_probe(struct usb_interface *intf,
> }
>
> if (id->driver_info & BTUSB_QCA_WCN6855) {
> + data->qca_dump.id_vendor = id->idVendor;
> + data->qca_dump.id_product = id->idProduct;
> + data->recv_event = btusb_recv_evt_qca;
> + data->recv_acl = btusb_recv_acl_qca;
> + hci_devcd_register(hdev, btusb_coredump_qca,
> + btusb_dump_hdr_qca, NULL);
> data->setup_on_usb = btusb_setup_qca;
> hdev->shutdown = btusb_shutdown_qca;
> hdev->set_bdaddr = btusb_set_bdaddr_wcn6855;
> --
> 2.17.1
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
2023-04-14 20:57 ` [PATCH v2] " Luiz Augusto von Dentz
@ 2023-04-18 1:02 ` Tim Jiang (QUIC)
0 siblings, 0 replies; 13+ messages in thread
From: Tim Jiang (QUIC) @ 2023-04-18 1:02 UTC (permalink / raw)
To: marcel@holtmann.org
Cc: marcel@holtmann.org, linux-kernel@vger.kernel.org,
linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Balakrishna Godavarthi (QUIC), Hemant Gupta (QUIC),
mka@chromium.org
Hi Luiz:
-----Original Message-----
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Sent: Saturday, April 15, 2023 4:58 AM
To: Tim Jiang (QUIC) <quic_tjiang@quicinc.com>
Cc: marcel@holtmann.org; linux-kernel@vger.kernel.org; linux-bluetooth@vger.kernel.org; linux-arm-msm@vger.kernel.org; Balakrishna Godavarthi (QUIC) <quic_bgodavar@quicinc.com>; Hemant Gupta (QUIC) <quic_hemantg@quicinc.com>; mka@chromium.org
Subject: Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
Hi Tim,
On Wed, Apr 12, 2023 at 11:46 PM Tim Jiang <quic_tjiang@quicinc.com> wrote:
>
> WCN6855 will report memdump via ACL data or HCI event when it get
> crashed, so we collect memdump to debug firmware.
>
> Signed-off-by: Tim Jiang <quic_tjiang@quicinc.com>
> ---
> drivers/bluetooth/btusb.c | 222
> ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 222 insertions(+)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 2303b0a66323..f045bbb0ee09 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -733,6 +733,16 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
> {}
> };
>
> +struct qca_dump_info {
> + /* fields for dump collection */
> + u16 id_vendor;
> + u16 id_product;
> + u32 fw_version;
> + u32 controller_id;
> + u32 ram_dump_size;
> + u16 ram_dump_seqno;
> +};
> +
> #define BTUSB_MAX_ISOC_FRAMES 10
>
> #define BTUSB_INTR_RUNNING 0
> @@ -752,6 +762,7 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
> #define BTUSB_WAKEUP_AUTOSUSPEND 14
> #define BTUSB_USE_ALT3_FOR_WBS 15
> #define BTUSB_ALT6_CONTINUOUS_TX 16
> +#define BTUSB_HW_SSR_ACTIVE 17
>
> struct btusb_data {
> struct hci_dev *hdev;
> @@ -814,6 +825,8 @@ struct btusb_data {
>
> int oob_wake_irq; /* irq for out-of-band wake-on-bt */
> unsigned cmd_timeout_cnt;
> +
> + struct qca_dump_info qca_dump;
> };
>
> static void btusb_reset(struct hci_dev *hdev) @@ -904,6 +917,11 @@
> static void btusb_qca_cmd_timeout(struct hci_dev *hdev)
> struct btusb_data *data = hci_get_drvdata(hdev);
> struct gpio_desc *reset_gpio = data->reset_gpio;
>
> + if (test_bit(BTUSB_HW_SSR_ACTIVE, &data->flags)) {
> + bt_dev_info(hdev, "Ramdump in progress, defer cmd_timeout");
> + return;
> + }
> +
> if (++data->cmd_timeout_cnt < 5)
> return;
>
> @@ -3294,6 +3312,202 @@ static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev,
> return 0;
> }
>
> +#define QCA_MEMDUMP_ACL_HANDLE 0x2EDD #define QCA_MEMDUMP_SIZE_MAX
> +0x100000 #define QCA_MEMDUMP_VSE_CLASS 0x01 #define
> +QCA_MEMDUMP_MSG_TYPE 0x08 #define QCA_MEMDUMP_PKT_SIZE 248 #define
> +QCA_LAST_SEQUENCE_NUM 0xffff
> +
> +struct qca_dump_hdr {
> + u8 vse_class;
> + u8 msg_type;
> + __le16 seqno;
> + u8 reserved;
> + union {
> + u8 data[0];
> + struct {
> + __le32 ram_dump_size;
> + u8 data0[0];
> + } __packed;
> + };
> +} __packed;
> +
> +
> +static void btusb_dump_hdr_qca(struct hci_dev *hdev, struct sk_buff
> +*skb) {
> + char buf[128];
> + struct btusb_data *btdata = hci_get_drvdata(hdev);
> +
> + snprintf(buf, sizeof(buf), "Controller Name: 0x%x\n",
> + btdata->qca_dump.controller_id);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "Firmware Version: 0x%x\n",
> + btdata->qca_dump.fw_version);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "Driver: %s\nVendor: qca\n",
> + btusb_driver.name);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "VID: 0x%x\nPID:0x%x\n",
> + btdata->qca_dump.id_vendor, btdata->qca_dump.id_product);
> + skb_put_data(skb, buf, strlen(buf));
> +
> + snprintf(buf, sizeof(buf), "Lmp Subversion: 0x%x\n",
> + hdev->lmp_subver);
> + skb_put_data(skb, buf, strlen(buf)); }
> +
> +static void btusb_coredump_qca(struct hci_dev *hdev) {
> + static const u8 param[] = { 0x26 };
> + struct sk_buff *skb;
> +
> + skb = __hci_cmd_sync(hdev, 0xfc0c, 1, param, HCI_CMD_TIMEOUT);
> + if (IS_ERR(skb))
> + bt_dev_err(hdev, "%s: triggle crash failed (%ld)", __func__, PTR_ERR(skb));
> + kfree_skb(skb);
> +}
> +
> +/*
> + * ==0: not a dump pkt.
> + * < 0: fails to handle a dump pkt
> + * > 0: otherwise.
> + */
> +static int handle_dump_pkt_qca(struct hci_dev *hdev, struct sk_buff
> +*skb) {
> + int ret = 1;
> + u8 pkt_type;
> + u8 *sk_ptr;
> + unsigned int sk_len;
> + u16 seqno;
> + u32 dump_size;
> +
> + struct hci_event_hdr *event_hdr;
> + struct hci_acl_hdr *acl_hdr;
> + struct qca_dump_hdr *dump_hdr;
> + struct btusb_data *btdata = hci_get_drvdata(hdev);
> + struct usb_device *udev = btdata->udev;
> +
> + pkt_type = hci_skb_pkt_type(skb);
> + sk_ptr = skb->data;
> + sk_len = skb->len;
> +
> + if (pkt_type == HCI_ACLDATA_PKT) {
> + acl_hdr = hci_acl_hdr(skb);
> + if (le16_to_cpu(acl_hdr->handle) != QCA_MEMDUMP_ACL_HANDLE)
> + return 0;
> + sk_ptr += HCI_ACL_HDR_SIZE;
> + sk_len -= HCI_ACL_HDR_SIZE;
> + event_hdr = (struct hci_event_hdr *)sk_ptr;
> + } else {
> + event_hdr = hci_event_hdr(skb);
> + }
> +
> + if ((event_hdr->evt != HCI_VENDOR_PKT)
> + || (event_hdr->plen != (sk_len - HCI_EVENT_HDR_SIZE)))
> + return 0;
> +
> + sk_ptr += HCI_EVENT_HDR_SIZE;
> + sk_len -= HCI_EVENT_HDR_SIZE;
> +
> + dump_hdr = (struct qca_dump_hdr *)sk_ptr;
> + if ((sk_len < offsetof(struct qca_dump_hdr, data))
> + || (dump_hdr->vse_class != QCA_MEMDUMP_VSE_CLASS)
> + || (dump_hdr->msg_type != QCA_MEMDUMP_MSG_TYPE))
> + return 0;
> +
> + /*it is dump pkt now*/
> + seqno = le16_to_cpu(dump_hdr->seqno);
> + if (seqno == 0) {
> + set_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags);
> + dump_size = le32_to_cpu(dump_hdr->ram_dump_size);
> + if (!dump_size || (dump_size > QCA_MEMDUMP_SIZE_MAX)) {
> + ret = -EILSEQ;
> + bt_dev_err(hdev, "Invalid memdump size(%u)",
> + dump_size);
> + goto out;
> + }
> +
> + ret = hci_devcd_init(hdev, dump_size);
> + if (ret < 0) {
> + bt_dev_err(hdev, "memdump init error(%d)", ret);
> + goto out;
> + }
> +
> + btdata->qca_dump.ram_dump_size = dump_size;
> + btdata->qca_dump.ram_dump_seqno = 0;
> + sk_ptr += offsetof(struct qca_dump_hdr, data0);
> + sk_len -= offsetof(struct qca_dump_hdr, data0);
> +
> + usb_disable_autosuspend(udev);
> + bt_dev_info(hdev, "%s memdump size(%u)\n",
> + (pkt_type == HCI_ACLDATA_PKT) ? "ACL" : "event",
> + dump_size);
Lets not use bt_dev_info for devcd code, since the system should log these events via devcd interface, so please convert any instance of bt_dev_info to bt_dev_dbg.
[Tim] Ok , will address it in V3 version.
> + } else {
> + sk_ptr += offsetof(struct qca_dump_hdr, data);
> + sk_len -= offsetof(struct qca_dump_hdr, data);
> + }
> +
> + if (!btdata->qca_dump.ram_dump_size) {
> + ret = -EINVAL;
> + bt_dev_err(hdev, "memdump is not active");
> + goto out;
> + }
> +
> + if ((seqno > btdata->qca_dump.ram_dump_seqno + 1) && (seqno != QCA_LAST_SEQUENCE_NUM)) {
> + dump_size = QCA_MEMDUMP_PKT_SIZE * (seqno - btdata->qca_dump.ram_dump_seqno - 1);
> + hci_devcd_append_pattern(hdev, 0x0, dump_size);
> + bt_dev_err(hdev,
> + "expected memdump seqno(%u) is not received(%u)\n",
> + btdata->qca_dump.ram_dump_seqno, seqno);
> + btdata->qca_dump.ram_dump_seqno = seqno;
> + kfree_skb(skb);
> + return ret;
> + }
> +
> + skb_pull(skb, skb->len - sk_len);
> + hci_devcd_append(hdev, skb);
> + btdata->qca_dump.ram_dump_seqno++;
> + if (seqno == QCA_LAST_SEQUENCE_NUM) {
> + bt_dev_info(hdev,
> + "memdump done: pkts(%u), total(%u)\n",
> + btdata->qca_dump.ram_dump_seqno,
> + btdata->qca_dump.ram_dump_size);
Ditto.
[Tim] will address it in V3 version
> + hci_devcd_complete(hdev);
> + goto out;
> + }
> + return ret;
> +
> +out:
> + if (btdata->qca_dump.ram_dump_size)
> + usb_enable_autosuspend(udev);
> + btdata->qca_dump.ram_dump_size = 0;
> + btdata->qca_dump.ram_dump_seqno = 0;
> + clear_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags);
> +
> + if (ret < 0)
> + kfree_skb(skb);
> + return ret;
> +}
> +
> +static int btusb_recv_acl_qca(struct hci_dev *hdev, struct sk_buff
> +*skb) {
> + if (handle_dump_pkt_qca(hdev, skb))
> + return 0;
> + return hci_recv_frame(hdev, skb); }
> +
> +static int btusb_recv_evt_qca(struct hci_dev *hdev, struct sk_buff
> +*skb) {
> + if (handle_dump_pkt_qca(hdev, skb))
> + return 0;
> + return hci_recv_frame(hdev, skb); }
> +
> +
> #define QCA_DFU_PACKET_LEN 4096
>
> #define QCA_GET_TARGET_VERSION 0x09
> @@ -3628,6 +3842,9 @@ static int btusb_setup_qca(struct hci_dev *hdev)
> if (err < 0)
> return err;
>
> + btdata->qca_dump.fw_version = le32_to_cpu(ver.patch_version);
> + btdata->qca_dump.controller_id = le32_to_cpu(ver.rom_version);
> +
> if (!(status & QCA_SYSCFG_UPDATED)) {
> err = btusb_setup_qca_load_nvm(hdev, &ver, info);
> if (err < 0)
> @@ -4117,6 +4334,11 @@ static int btusb_probe(struct usb_interface *intf,
> }
>
> if (id->driver_info & BTUSB_QCA_WCN6855) {
> + data->qca_dump.id_vendor = id->idVendor;
> + data->qca_dump.id_product = id->idProduct;
> + data->recv_event = btusb_recv_evt_qca;
> + data->recv_acl = btusb_recv_acl_qca;
> + hci_devcd_register(hdev, btusb_coredump_qca,
> + btusb_dump_hdr_qca, NULL);
> data->setup_on_usb = btusb_setup_qca;
> hdev->shutdown = btusb_shutdown_qca;
> hdev->set_bdaddr = btusb_set_bdaddr_wcn6855;
> --
> 2.17.1
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
2023-04-18 1:02 ` Tim Jiang (QUIC)
@ 2023-04-18 9:02 ` Dmitry Baryshkov
2023-04-18 9:07 ` Tim Jiang (QUIC)
0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Baryshkov @ 2023-04-18 9:02 UTC (permalink / raw)
To: Tim Jiang (QUIC)
Cc: marcel@holtmann.org, linux-kernel@vger.kernel.org,
linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Balakrishna Godavarthi (QUIC), Hemant Gupta (QUIC),
mka@chromium.org
On Tue, 18 Apr 2023 at 04:02, Tim Jiang (QUIC) <quic_tjiang@quicinc.com> wrote:
>
> Hi Dmitry:
>
> -----Original Message-----
> From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Sent: Saturday, April 15, 2023 5:03 AM
> To: Tim Jiang (QUIC) <quic_tjiang@quicinc.com>
> Cc: marcel@holtmann.org; linux-kernel@vger.kernel.org; linux-bluetooth@vger.kernel.org; linux-arm-msm@vger.kernel.org; Balakrishna Godavarthi (QUIC) <quic_bgodavar@quicinc.com>; Hemant Gupta (QUIC) <quic_hemantg@quicinc.com>; mka@chromium.org
> Subject: Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
>
> On Thu, 13 Apr 2023 at 09:44, Tim Jiang <quic_tjiang@quicinc.com> wrote:
> >
> > WCN6855 will report memdump via ACL data or HCI event when it get
> > crashed, so we collect memdump to debug firmware.
>
> Is it applicable only to wcn6855 or to some of earlier chips too?
> [Tim] Also applicable to earlier chips , but currently google only require us to support wcn6855
Since upstream is not a google kernel, please enable this feature for
all relevant chipsets.
>
> >
> > Signed-off-by: Tim Jiang <quic_tjiang@quicinc.com>
> > ---
> > drivers/bluetooth/btusb.c | 222
> > ++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 222 insertions(+)
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
2023-04-18 9:02 ` Dmitry Baryshkov
@ 2023-04-18 9:07 ` Tim Jiang (QUIC)
2023-04-18 9:10 ` Dmitry Baryshkov
0 siblings, 1 reply; 13+ messages in thread
From: Tim Jiang (QUIC) @ 2023-04-18 9:07 UTC (permalink / raw)
To: dmitry.baryshkov@linaro.org
Cc: marcel@holtmann.org, linux-kernel@vger.kernel.org,
linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Balakrishna Godavarthi (QUIC), Hemant Gupta (QUIC),
mka@chromium.org
Hi Dmitry:
-----Original Message-----
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Sent: Tuesday, April 18, 2023 5:03 PM
To: Tim Jiang (QUIC) <quic_tjiang@quicinc.com>
Cc: marcel@holtmann.org; linux-kernel@vger.kernel.org; linux-bluetooth@vger.kernel.org; linux-arm-msm@vger.kernel.org; Balakrishna Godavarthi (QUIC) <quic_bgodavar@quicinc.com>; Hemant Gupta (QUIC) <quic_hemantg@quicinc.com>; mka@chromium.org
Subject: Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
On Tue, 18 Apr 2023 at 04:02, Tim Jiang (QUIC) <quic_tjiang@quicinc.com> wrote:
>
> Hi Dmitry:
>
> -----Original Message-----
> From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Sent: Saturday, April 15, 2023 5:03 AM
> To: Tim Jiang (QUIC) <quic_tjiang@quicinc.com>
> Cc: marcel@holtmann.org; linux-kernel@vger.kernel.org;
> linux-bluetooth@vger.kernel.org; linux-arm-msm@vger.kernel.org;
> Balakrishna Godavarthi (QUIC) <quic_bgodavar@quicinc.com>; Hemant
> Gupta (QUIC) <quic_hemantg@quicinc.com>; mka@chromium.org
> Subject: Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump
> support
>
> On Thu, 13 Apr 2023 at 09:44, Tim Jiang <quic_tjiang@quicinc.com> wrote:
> >
> > WCN6855 will report memdump via ACL data or HCI event when it get
> > crashed, so we collect memdump to debug firmware.
>
> Is it applicable only to wcn6855 or to some of earlier chips too?
> [Tim] Also applicable to earlier chips , but currently google only
> require us to support wcn6855
Since upstream is not a google kernel, please enable this feature for all relevant chipsets.
[Tim] agreed , but the title of this gerrit unchanged, I raise a new gerrit for other relevant chipsets , is OK?
>
> >
> > Signed-off-by: Tim Jiang <quic_tjiang@quicinc.com>
> > ---
> > drivers/bluetooth/btusb.c | 222
> > ++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 222 insertions(+)
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
2023-04-18 9:07 ` Tim Jiang (QUIC)
@ 2023-04-18 9:10 ` Dmitry Baryshkov
2023-04-18 9:16 ` Tim Jiang (QUIC)
0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Baryshkov @ 2023-04-18 9:10 UTC (permalink / raw)
To: Tim Jiang (QUIC)
Cc: marcel@holtmann.org, linux-kernel@vger.kernel.org,
linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Balakrishna Godavarthi (QUIC), Hemant Gupta (QUIC),
mka@chromium.org
On Tue, 18 Apr 2023 at 12:07, Tim Jiang (QUIC) <quic_tjiang@quicinc.com> wrote:
>
> Hi Dmitry:
>
> -----Original Message-----
> From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Sent: Tuesday, April 18, 2023 5:03 PM
> To: Tim Jiang (QUIC) <quic_tjiang@quicinc.com>
> Cc: marcel@holtmann.org; linux-kernel@vger.kernel.org; linux-bluetooth@vger.kernel.org; linux-arm-msm@vger.kernel.org; Balakrishna Godavarthi (QUIC) <quic_bgodavar@quicinc.com>; Hemant Gupta (QUIC) <quic_hemantg@quicinc.com>; mka@chromium.org
> Subject: Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
>
> On Tue, 18 Apr 2023 at 04:02, Tim Jiang (QUIC) <quic_tjiang@quicinc.com> wrote:
> >
> > Hi Dmitry:
> >
> > -----Original Message-----
> > From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > Sent: Saturday, April 15, 2023 5:03 AM
> > To: Tim Jiang (QUIC) <quic_tjiang@quicinc.com>
> > Cc: marcel@holtmann.org; linux-kernel@vger.kernel.org;
> > linux-bluetooth@vger.kernel.org; linux-arm-msm@vger.kernel.org;
> > Balakrishna Godavarthi (QUIC) <quic_bgodavar@quicinc.com>; Hemant
> > Gupta (QUIC) <quic_hemantg@quicinc.com>; mka@chromium.org
> > Subject: Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump
> > support
> >
> > On Thu, 13 Apr 2023 at 09:44, Tim Jiang <quic_tjiang@quicinc.com> wrote:
> > >
> > > WCN6855 will report memdump via ACL data or HCI event when it get
> > > crashed, so we collect memdump to debug firmware.
> >
> > Is it applicable only to wcn6855 or to some of earlier chips too?
> > [Tim] Also applicable to earlier chips , but currently google only
> > require us to support wcn6855
>
> Since upstream is not a google kernel, please enable this feature for all relevant chipsets.
> [Tim] agreed , but the title of this gerrit unchanged, I raise a new gerrit for other relevant chipsets , is OK?
There is no gerrit here.
Also, is there any chance you can fix your email client to stop
putting old headers at the top of the email?
>
> >
> > >
> > > Signed-off-by: Tim Jiang <quic_tjiang@quicinc.com>
> > > ---
> > > drivers/bluetooth/btusb.c | 222
> > > ++++++++++++++++++++++++++++++++++++++
> > > 1 file changed, 222 insertions(+)
>
>
>
>
> --
> With best wishes
> Dmitry
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
2023-04-18 9:10 ` Dmitry Baryshkov
@ 2023-04-18 9:16 ` Tim Jiang (QUIC)
2023-04-18 16:59 ` Dmitry Baryshkov
0 siblings, 1 reply; 13+ messages in thread
From: Tim Jiang (QUIC) @ 2023-04-18 9:16 UTC (permalink / raw)
To: dmitry.baryshkov@linaro.org
Cc: marcel@holtmann.org, linux-kernel@vger.kernel.org,
linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Balakrishna Godavarthi (QUIC), Hemant Gupta (QUIC),
mka@chromium.org
Hi Dmitry:
> > On Thu, 13 Apr 2023 at 09:44, Tim Jiang <quic_tjiang@quicinc.com> wrote:
> > >
> > > WCN6855 will report memdump via ACL data or HCI event when it get
> > > crashed, so we collect memdump to debug firmware.
> >
> > Is it applicable only to wcn6855 or to some of earlier chips too?
> > [Tim] Also applicable to earlier chips , but currently google only
> > require us to support wcn6855
>
> Since upstream is not a google kernel, please enable this feature for all relevant chipsets.
> [Tim] agreed , but the title of this gerrit unchanged, I raise a new gerrit for other relevant chipsets , is OK?
There is no gerrit here.
Also, is there any chance you can fix your email client to stop putting old headers at the top of the email?
[Tim] sorry for confusion, I mean I will raise another new change for other relevant chipset, is OK ?
and I use office 365 to reply your email which will adding old headers automatically , unless I delete the old headers manually, thank you.
>
> >
> > >
> > > Signed-off-by: Tim Jiang <quic_tjiang@quicinc.com>
> > > ---
> > > drivers/bluetooth/btusb.c | 222
> > > ++++++++++++++++++++++++++++++++++++++
> > > 1 file changed, 222 insertions(+)
>
>
>
>
> --
> With best wishes
> Dmitry
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
2023-04-18 9:16 ` Tim Jiang (QUIC)
@ 2023-04-18 16:59 ` Dmitry Baryshkov
0 siblings, 0 replies; 13+ messages in thread
From: Dmitry Baryshkov @ 2023-04-18 16:59 UTC (permalink / raw)
To: Tim Jiang (QUIC)
Cc: marcel@holtmann.org, linux-kernel@vger.kernel.org,
linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Balakrishna Godavarthi (QUIC), Hemant Gupta (QUIC),
mka@chromium.org
On Tue, 18 Apr 2023 at 12:16, Tim Jiang (QUIC) <quic_tjiang@quicinc.com> wrote:
>
> Hi Dmitry:
>
> > > On Thu, 13 Apr 2023 at 09:44, Tim Jiang <quic_tjiang@quicinc.com> wrote:
> > > >
> > > > WCN6855 will report memdump via ACL data or HCI event when it get
> > > > crashed, so we collect memdump to debug firmware.
> > >
> > > Is it applicable only to wcn6855 or to some of earlier chips too?
> > > [Tim] Also applicable to earlier chips , but currently google only
> > > require us to support wcn6855
> >
> > Since upstream is not a google kernel, please enable this feature for all relevant chipsets.
> > [Tim] agreed , but the title of this gerrit unchanged, I raise a new gerrit for other relevant chipsets , is OK?
>
> There is no gerrit here.
>
> Also, is there any chance you can fix your email client to stop putting old headers at the top of the email?
> [Tim] sorry for confusion, I mean I will raise another new change for other relevant chipset, is OK ?
I'd suggest using a single patch.
> and I use office 365 to reply your email which will adding old headers automatically , unless I delete the old headers manually, thank you.
>
> >
> > >
> > > >
> > > > Signed-off-by: Tim Jiang <quic_tjiang@quicinc.com>
> > > > ---
> > > > drivers/bluetooth/btusb.c | 222
> > > > ++++++++++++++++++++++++++++++++++++++
> > > > 1 file changed, 222 insertions(+)
> >
> >
> >
> >
> > --
> > With best wishes
> > Dmitry
>
>
>
> --
> With best wishes
> Dmitry
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
2023-04-13 6:43 [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support Tim Jiang
` (2 preceding siblings ...)
2023-04-14 21:02 ` Dmitry Baryshkov
@ 2023-04-24 1:46 ` kernel test robot
3 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2023-04-24 1:46 UTC (permalink / raw)
To: Tim Jiang; +Cc: oe-kbuild-all
Hi Tim,
kernel test robot noticed the following build errors:
[auto build test ERROR on bluetooth/master]
[also build test ERROR on linus/master v6.3]
[cannot apply to bluetooth-next/master next-20230421]
[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/Tim-Jiang/Bluetooth-btusb-Add-WCN6855-devcoredump-support/20230413-144515
base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
patch link: https://lore.kernel.org/r/20230413064344.18714-1-quic_tjiang%40quicinc.com
patch subject: [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20230424/202304240910.XpoTSMkj-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 12.1.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/intel-lab-lkp/linux/commit/188ad414de75af0af685039e7877dc9c8199d19a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Tim-Jiang/Bluetooth-btusb-Add-WCN6855-devcoredump-support/20230413-144515
git checkout 188ad414de75af0af685039e7877dc9c8199d19a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304240910.XpoTSMkj-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/bluetooth/btusb.c: In function 'handle_dump_pkt_qca':
>> drivers/bluetooth/btusb.c:3384:23: error: implicit declaration of function 'hci_devcd_init'; did you mean 'hci_sock_init'? [-Werror=implicit-function-declaration]
3384 | ret = hci_devcd_init(hdev, dump_size);
| ^~~~~~~~~~~~~~
| hci_sock_init
>> drivers/bluetooth/btusb.c:3412:17: error: implicit declaration of function 'hci_devcd_append_pattern' [-Werror=implicit-function-declaration]
3412 | hci_devcd_append_pattern(hdev, 0x0, dump_size);
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/bluetooth/btusb.c:3422:9: error: implicit declaration of function 'hci_devcd_append'; did you mean 'hci_dev_open'? [-Werror=implicit-function-declaration]
3422 | hci_devcd_append(hdev, skb);
| ^~~~~~~~~~~~~~~~
| hci_dev_open
>> drivers/bluetooth/btusb.c:3429:17: error: implicit declaration of function 'hci_devcd_complete' [-Werror=implicit-function-declaration]
3429 | hci_devcd_complete(hdev);
| ^~~~~~~~~~~~~~~~~~
drivers/bluetooth/btusb.c: In function 'btusb_probe':
>> drivers/bluetooth/btusb.c:4295:17: error: implicit declaration of function 'hci_devcd_register'; did you mean 'of_device_register'? [-Werror=implicit-function-declaration]
4295 | hci_devcd_register(hdev, btusb_coredump_qca, btusb_dump_hdr_qca, NULL);
| ^~~~~~~~~~~~~~~~~~
| of_device_register
cc1: some warnings being treated as errors
vim +3384 drivers/bluetooth/btusb.c
3323
3324 /*
3325 * ==0: not a dump pkt.
3326 * < 0: fails to handle a dump pkt
3327 * > 0: otherwise.
3328 */
3329 static int handle_dump_pkt_qca(struct hci_dev *hdev, struct sk_buff *skb)
3330 {
3331 int ret = 1;
3332 u8 pkt_type;
3333 u8 *sk_ptr;
3334 unsigned int sk_len;
3335 u16 seqno;
3336 u32 dump_size;
3337
3338 struct hci_event_hdr *event_hdr;
3339 struct hci_acl_hdr *acl_hdr;
3340 struct qca_dump_hdr *dump_hdr;
3341 struct btusb_data *btdata = hci_get_drvdata(hdev);
3342 struct usb_device *udev = btdata->udev;
3343
3344 pkt_type = hci_skb_pkt_type(skb);
3345 sk_ptr = skb->data;
3346 sk_len = skb->len;
3347
3348 if (pkt_type == HCI_ACLDATA_PKT) {
3349 acl_hdr = hci_acl_hdr(skb);
3350 if (le16_to_cpu(acl_hdr->handle) != QCA_MEMDUMP_ACL_HANDLE)
3351 return 0;
3352 sk_ptr += HCI_ACL_HDR_SIZE;
3353 sk_len -= HCI_ACL_HDR_SIZE;
3354 event_hdr = (struct hci_event_hdr *)sk_ptr;
3355 } else {
3356 event_hdr = hci_event_hdr(skb);
3357 }
3358
3359 if ((event_hdr->evt != HCI_VENDOR_PKT)
3360 || (event_hdr->plen != (sk_len - HCI_EVENT_HDR_SIZE)))
3361 return 0;
3362
3363 sk_ptr += HCI_EVENT_HDR_SIZE;
3364 sk_len -= HCI_EVENT_HDR_SIZE;
3365
3366 dump_hdr = (struct qca_dump_hdr *)sk_ptr;
3367 if ((sk_len < offsetof(struct qca_dump_hdr, data))
3368 || (dump_hdr->vse_class != QCA_MEMDUMP_VSE_CLASS)
3369 || (dump_hdr->msg_type != QCA_MEMDUMP_MSG_TYPE))
3370 return 0;
3371
3372 /*it is dump pkt now*/
3373 seqno = le16_to_cpu(dump_hdr->seqno);
3374 if (seqno == 0) {
3375 set_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags);
3376 dump_size = le32_to_cpu(dump_hdr->ram_dump_size);
3377 if (!dump_size || (dump_size > QCA_MEMDUMP_SIZE_MAX)) {
3378 ret = -EILSEQ;
3379 bt_dev_err(hdev, "Invalid memdump size(%u)",
3380 dump_size);
3381 goto out;
3382 }
3383
> 3384 ret = hci_devcd_init(hdev, dump_size);
3385 if (ret < 0) {
3386 bt_dev_err(hdev, "memdump init error(%d)", ret);
3387 goto out;
3388 }
3389
3390 btdata->qca_dump.ram_dump_size = dump_size;
3391 btdata->qca_dump.ram_dump_seqno = 0;
3392 sk_ptr += offsetof(struct qca_dump_hdr, data0);
3393 sk_len -= offsetof(struct qca_dump_hdr, data0);
3394
3395 usb_disable_autosuspend(udev);
3396 bt_dev_info(hdev, "%s memdump size(%u)\n",
3397 (pkt_type == HCI_ACLDATA_PKT) ? "ACL" : "event",
3398 dump_size);
3399 } else {
3400 sk_ptr += offsetof(struct qca_dump_hdr, data);
3401 sk_len -= offsetof(struct qca_dump_hdr, data);
3402 }
3403
3404 if (!btdata->qca_dump.ram_dump_size) {
3405 ret = -EINVAL;
3406 bt_dev_err(hdev, "memdump is not active");
3407 goto out;
3408 }
3409
3410 if ((seqno > btdata->qca_dump.ram_dump_seqno + 1) && (seqno != QCA_LAST_SEQUENCE_NUM)) {
3411 dump_size = QCA_MEMDUMP_PKT_SIZE * (seqno - btdata->qca_dump.ram_dump_seqno - 1);
> 3412 hci_devcd_append_pattern(hdev, 0x0, dump_size);
3413 bt_dev_err(hdev,
3414 "expected memdump seqno(%u) is not received(%u)\n",
3415 btdata->qca_dump.ram_dump_seqno, seqno);
3416 btdata->qca_dump.ram_dump_seqno = seqno;
3417 kfree_skb(skb);
3418 return ret;
3419 }
3420
3421 skb_pull(skb, skb->len - sk_len);
> 3422 hci_devcd_append(hdev, skb);
3423 btdata->qca_dump.ram_dump_seqno++;
3424 if (seqno == QCA_LAST_SEQUENCE_NUM) {
3425 bt_dev_info(hdev,
3426 "memdump done: pkts(%u), total(%u)\n",
3427 btdata->qca_dump.ram_dump_seqno, btdata->qca_dump.ram_dump_size);
3428
> 3429 hci_devcd_complete(hdev);
3430 goto out;
3431 }
3432 return ret;
3433
3434 out:
3435 if (btdata->qca_dump.ram_dump_size)
3436 usb_enable_autosuspend(udev);
3437 btdata->qca_dump.ram_dump_size = 0;
3438 btdata->qca_dump.ram_dump_seqno = 0;
3439 clear_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags);
3440
3441 if (ret < 0)
3442 kfree_skb(skb);
3443 return ret;
3444 }
3445
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-04-24 1:47 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-13 6:43 [PATCH v2] Bluetooth: btusb: Add WCN6855 devcoredump support Tim Jiang
2023-04-13 7:32 ` [v2] " bluez.test.bot
2023-04-14 20:57 ` [PATCH v2] " Luiz Augusto von Dentz
2023-04-18 1:02 ` Tim Jiang (QUIC)
2023-04-14 21:02 ` Dmitry Baryshkov
2023-04-18 1:02 ` Tim Jiang (QUIC)
2023-04-18 9:02 ` Dmitry Baryshkov
2023-04-18 9:07 ` Tim Jiang (QUIC)
2023-04-18 9:10 ` Dmitry Baryshkov
2023-04-18 9:16 ` Tim Jiang (QUIC)
2023-04-18 16:59 ` Dmitry Baryshkov
2023-04-24 1:46 ` kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2023-04-10 9:53 Tim Jiang
2023-04-10 10:33 ` [v2] " bluez.test.bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.