mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Bluetooth: btusb: Preparation for upcoming Qualcomm QCC2072 support
@ 2026-07-13 12:01 Zijun Hu
  2026-07-13 12:01 ` [PATCH v2 1/5] Bluetooth: coredump: Introduce and apply hci_devcd_state_name() Zijun Hu
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Zijun Hu @ 2026-07-13 12:01 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Zijun Hu, linux-bluetooth, linux-kernel, Zijun Hu

This series collects the btusb and devcoredump changes required by the
upcoming Qualcomm QCC2072 support.

Posting them as a standalone series because the QCC2072 driver itself is
larger and will take longer to review. These prerequisites are small and
self-contained, so they can hopefully be reviewed and merged on their own
in the meantime.

Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
---
Changes in v2:
- btusb: drop "Build the driver from multiple source files"; the split
  into btusb_main.c needs more discussion and will be sent separately
- coredump: implement hci_devcd_state_name() with a switch returning
  "Unknown" for out-of-range states, instead of an array lookup
- btusb: make btusb_recv_{event,acl}() take struct hci_dev * directly,
  instead of adding separate btusb_recv_{event,acl}_hdev() wrappers
- Link to v1: https://lore.kernel.org/r/20260708-btusb_prep_qcc2072-v1-0-d835b187fd01@oss.qualcomm.com

---
Zijun Hu (5):
      Bluetooth: coredump: Introduce and apply hci_devcd_state_name()
      Bluetooth: coredump: Allow drivers to pad dump header to fixed size
      Bluetooth: btusb: Add an indirect recv_intr() hook to btusb_data
      Bluetooth: btusb: Make btusb_recv_{event,acl}() take struct hci_dev *
      Bluetooth: btusb: Add a simple static btusb_prepare_reset()

 drivers/bluetooth/btusb.c        | 33 +++++++++++++++++--------
 include/net/bluetooth/coredump.h | 11 +++++++++
 net/bluetooth/coredump.c         | 52 ++++++++++++++++++++++++++++++----------
 3 files changed, 74 insertions(+), 22 deletions(-)
---
base-commit: eab19cb7618e5c50fd1f8c1efdc4e66e16575975
change-id: 20260708-btusb_prep_qcc2072-23604a4e81d1

Best regards,
-- 
Zijun Hu <zijun.hu@oss.qualcomm.com>


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

* [PATCH v2 1/5] Bluetooth: coredump: Introduce and apply hci_devcd_state_name()
  2026-07-13 12:01 [PATCH v2 0/5] Bluetooth: btusb: Preparation for upcoming Qualcomm QCC2072 support Zijun Hu
@ 2026-07-13 12:01 ` Zijun Hu
  2026-07-13 12:01 ` [PATCH v2 2/5] Bluetooth: coredump: Allow drivers to pad dump header to fixed size Zijun Hu
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Zijun Hu @ 2026-07-13 12:01 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Zijun Hu, linux-bluetooth, linux-kernel, Zijun Hu

Introduce hci_devcd_state_name() to make devcoredump state more
readable, and apply it in coredump.c. Also remove a trailing space
in two bt_dev_dbg() format strings while applying it.

Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
---
 include/net/bluetooth/coredump.h |  7 +++++++
 net/bluetooth/coredump.c         | 45 +++++++++++++++++++++++++++++++++-------
 2 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/include/net/bluetooth/coredump.h b/include/net/bluetooth/coredump.h
index 72f51b587a04..ab85a6adfffd 100644
--- a/include/net/bluetooth/coredump.h
+++ b/include/net/bluetooth/coredump.h
@@ -60,6 +60,8 @@ struct hci_devcoredump {
 
 #ifdef CONFIG_DEV_COREDUMP
 
+const char *hci_devcd_state_name(enum devcoredump_state state);
+
 void hci_devcd_reset(struct hci_dev *hdev);
 void hci_devcd_rx(struct work_struct *work);
 void hci_devcd_timeout(struct work_struct *work);
@@ -74,6 +76,11 @@ int hci_devcd_abort(struct hci_dev *hdev);
 
 #else
 
+static inline const char *hci_devcd_state_name(enum devcoredump_state state)
+{
+	return "";
+}
+
 static inline void hci_devcd_reset(struct hci_dev *hdev) {}
 static inline void hci_devcd_rx(struct work_struct *work) {}
 static inline void hci_devcd_timeout(struct work_struct *work) {}
diff --git a/net/bluetooth/coredump.c b/net/bluetooth/coredump.c
index c0f027fab583..913bbba559f8 100644
--- a/net/bluetooth/coredump.c
+++ b/net/bluetooth/coredump.c
@@ -30,8 +30,9 @@ struct hci_devcoredump_skb_pattern {
 
 #define DBG_UNEXPECTED_STATE() \
 	bt_dev_dbg(hdev, \
-		   "Unexpected packet (%d) for state (%d). ", \
-		   hci_dmp_cb(skb)->pkt_type, hdev->dump.state)
+		   "Unexpected packet (%d) for state %s.", \
+		   hci_dmp_cb(skb)->pkt_type, \
+		   hci_devcd_state_name(hdev->dump.state))
 
 #define MAX_DEVCOREDUMP_HDR_SIZE	512	/* bytes */
 
@@ -50,8 +51,9 @@ static int hci_devcd_update_hdr_state(char *buf, size_t size, int state)
 /* Call with hci_dev_lock only. */
 static int hci_devcd_update_state(struct hci_dev *hdev, int state)
 {
-	bt_dev_dbg(hdev, "Updating devcoredump state from %d to %d.",
-		   hdev->dump.state, state);
+	bt_dev_dbg(hdev, "Updating devcoredump state from %s to %s.",
+		   hci_devcd_state_name(hdev->dump.state),
+		   hci_devcd_state_name(state));
 
 	hdev->dump.state = state;
 
@@ -245,7 +247,7 @@ static void hci_devcd_dump(struct hci_dev *hdev)
 	struct sk_buff *skb;
 	u32 size;
 
-	bt_dev_dbg(hdev, "state %d", hdev->dump.state);
+	bt_dev_dbg(hdev, "state %s", hci_devcd_state_name(hdev->dump.state));
 
 	size = hdev->dump.tail - hdev->dump.head;
 
@@ -368,8 +370,9 @@ void hci_devcd_rx(struct work_struct *work)
 			break;
 
 		default:
-			bt_dev_dbg(hdev, "Unknown packet (%d) for state (%d). ",
-				   hci_dmp_cb(skb)->pkt_type, hdev->dump.state);
+			bt_dev_dbg(hdev, "Unknown packet (%d) for state %s.",
+				   hci_dmp_cb(skb)->pkt_type,
+				   hci_devcd_state_name(hdev->dump.state));
 			break;
 		}
 
@@ -549,3 +552,31 @@ int hci_devcd_abort(struct hci_dev *hdev)
 	return 0;
 }
 EXPORT_SYMBOL(hci_devcd_abort);
+
+const char *hci_devcd_state_name(enum devcoredump_state state)
+{
+	const char *state_name = "Unknown";
+
+	switch (state) {
+	case HCI_DEVCOREDUMP_IDLE:
+		state_name = "IDLE";
+		break;
+	case HCI_DEVCOREDUMP_ACTIVE:
+		state_name = "ACTIVE";
+		break;
+	case HCI_DEVCOREDUMP_DONE:
+		state_name = "DONE";
+		break;
+	case HCI_DEVCOREDUMP_ABORT:
+		state_name = "ABORT";
+		break;
+	case HCI_DEVCOREDUMP_TIMEOUT:
+		state_name = "TIMEOUT";
+		break;
+	default:
+		break;
+	}
+
+	return state_name;
+}
+EXPORT_SYMBOL(hci_devcd_state_name);

-- 
2.34.1


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

* [PATCH v2 2/5] Bluetooth: coredump: Allow drivers to pad dump header to fixed size
  2026-07-13 12:01 [PATCH v2 0/5] Bluetooth: btusb: Preparation for upcoming Qualcomm QCC2072 support Zijun Hu
  2026-07-13 12:01 ` [PATCH v2 1/5] Bluetooth: coredump: Introduce and apply hci_devcd_state_name() Zijun Hu
@ 2026-07-13 12:01 ` Zijun Hu
  2026-07-13 12:01 ` [PATCH v2 3/5] Bluetooth: btusb: Add an indirect recv_intr() hook to btusb_data Zijun Hu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Zijun Hu @ 2026-07-13 12:01 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Zijun Hu, linux-bluetooth, linux-kernel, Zijun Hu

To let a driver easily separate header and data in the generated
coredump, allow a vendor driver to pad its header to a fixed size by:
 - exposing MAX_HCI_DEVCD_HDR_SIZE as the max header size
 - exposing HCI_DEVCD_HDR_END as the header-ending marker

Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
---
 include/net/bluetooth/coredump.h | 4 ++++
 net/bluetooth/coredump.c         | 7 ++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/net/bluetooth/coredump.h b/include/net/bluetooth/coredump.h
index ab85a6adfffd..b668277bdb76 100644
--- a/include/net/bluetooth/coredump.h
+++ b/include/net/bluetooth/coredump.h
@@ -8,6 +8,10 @@
 
 #define DEVCOREDUMP_TIMEOUT	msecs_to_jiffies(10000)	/* 10 sec */
 
+/* total size shared by coredump and driver's dmp_hdr() */
+#define MAX_HCI_DEVCD_HDR_SIZE	512
+#define HCI_DEVCD_HDR_END	"--- Start dump ---\n"
+
 typedef void (*coredump_t)(struct hci_dev *hdev);
 typedef void (*dmp_hdr_t)(struct hci_dev *hdev, struct sk_buff *skb);
 typedef void (*notify_change_t)(struct hci_dev *hdev, int state);
diff --git a/net/bluetooth/coredump.c b/net/bluetooth/coredump.c
index 913bbba559f8..af444b48b82d 100644
--- a/net/bluetooth/coredump.c
+++ b/net/bluetooth/coredump.c
@@ -34,8 +34,6 @@ struct hci_devcoredump_skb_pattern {
 		   hci_dmp_cb(skb)->pkt_type, \
 		   hci_devcd_state_name(hdev->dump.state))
 
-#define MAX_DEVCOREDUMP_HDR_SIZE	512	/* bytes */
-
 static int hci_devcd_update_hdr_state(char *buf, size_t size, int state)
 {
 	int len = 0;
@@ -63,7 +61,6 @@ static int hci_devcd_update_state(struct hci_dev *hdev, int state)
 
 static int hci_devcd_mkheader(struct hci_dev *hdev, struct sk_buff *skb)
 {
-	char dump_start[] = "--- Start dump ---\n";
 	char hdr[80];
 	int hdr_len;
 
@@ -74,7 +71,7 @@ static int hci_devcd_mkheader(struct hci_dev *hdev, struct sk_buff *skb)
 	if (hdev->dump.dmp_hdr)
 		hdev->dump.dmp_hdr(hdev, skb);
 
-	skb_put_data(skb, dump_start, strlen(dump_start));
+	skb_put_data(skb, HCI_DEVCD_HDR_END, strlen(HCI_DEVCD_HDR_END));
 
 	return skb->len;
 }
@@ -154,7 +151,7 @@ static int hci_devcd_prepare(struct hci_dev *hdev, u32 dump_size)
 	int dump_hdr_size;
 	int err = 0;
 
-	skb = alloc_skb(MAX_DEVCOREDUMP_HDR_SIZE, GFP_ATOMIC);
+	skb = alloc_skb(MAX_HCI_DEVCD_HDR_SIZE, GFP_ATOMIC);
 	if (!skb)
 		return -ENOMEM;
 

-- 
2.34.1


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

* [PATCH v2 3/5] Bluetooth: btusb: Add an indirect recv_intr() hook to btusb_data
  2026-07-13 12:01 [PATCH v2 0/5] Bluetooth: btusb: Preparation for upcoming Qualcomm QCC2072 support Zijun Hu
  2026-07-13 12:01 ` [PATCH v2 1/5] Bluetooth: coredump: Introduce and apply hci_devcd_state_name() Zijun Hu
  2026-07-13 12:01 ` [PATCH v2 2/5] Bluetooth: coredump: Allow drivers to pad dump header to fixed size Zijun Hu
@ 2026-07-13 12:01 ` Zijun Hu
  2026-07-13 12:01 ` [PATCH v2 4/5] Bluetooth: btusb: Make btusb_recv_{event,acl}() take struct hci_dev * Zijun Hu
  2026-07-13 12:01 ` [PATCH v2 5/5] Bluetooth: btusb: Add a simple static btusb_prepare_reset() Zijun Hu
  4 siblings, 0 replies; 6+ messages in thread
From: Zijun Hu @ 2026-07-13 12:01 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Zijun Hu, linux-bluetooth, linux-kernel, Zijun Hu

Allow a vendor driver to assemble and handle its non-BT frames from the
interrupt endpoint.

Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
---
 drivers/bluetooth/btusb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 4c3193ec2d52..9c3a6d7d8f1e 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1032,6 +1032,7 @@ struct btusb_data {
 
 	int (*recv_event)(struct hci_dev *hdev, struct sk_buff *skb);
 	int (*recv_acl)(struct hci_dev *hdev, struct sk_buff *skb);
+	int (*recv_intr)(struct btusb_data *data, void *buffer, int count);
 	int (*recv_bulk)(struct btusb_data *data, void *buffer, int count);
 
 	int (*setup_on_usb)(struct hci_dev *hdev);
@@ -1504,7 +1505,7 @@ static void btusb_intr_complete(struct urb *urb)
 	if (urb->status == 0) {
 		hdev->stat.byte_rx += urb->actual_length;
 
-		if (btusb_recv_intr(data, urb->transfer_buffer,
+		if (data->recv_intr(data, urb->transfer_buffer,
 				    urb->actual_length) < 0) {
 			bt_dev_err(hdev, "corrupted event packet");
 			hdev->stat.err_rx++;
@@ -2711,7 +2712,7 @@ static int btusb_recv_bulk_intel(struct btusb_data *data, void *buffer,
 	 * same way as the ones received from the interrupt endpoint.
 	 */
 	if (btintel_test_flag(hdev, INTEL_BOOTLOADER))
-		return btusb_recv_intr(data, buffer, count);
+		return data->recv_intr(data, buffer, count);
 
 	return btusb_recv_bulk(data, buffer, count);
 }
@@ -4174,6 +4175,7 @@ static int btusb_probe(struct usb_interface *intf,
 	spin_lock_init(&data->rxlock);
 
 	data->recv_event = hci_recv_frame;
+	data->recv_intr = btusb_recv_intr;
 	data->recv_bulk = btusb_recv_bulk;
 
 	if (id->driver_info & BTUSB_INTEL_COMBINED) {

-- 
2.34.1


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

* [PATCH v2 4/5] Bluetooth: btusb: Make btusb_recv_{event,acl}() take struct hci_dev *
  2026-07-13 12:01 [PATCH v2 0/5] Bluetooth: btusb: Preparation for upcoming Qualcomm QCC2072 support Zijun Hu
                   ` (2 preceding siblings ...)
  2026-07-13 12:01 ` [PATCH v2 3/5] Bluetooth: btusb: Add an indirect recv_intr() hook to btusb_data Zijun Hu
@ 2026-07-13 12:01 ` Zijun Hu
  2026-07-13 12:01 ` [PATCH v2 5/5] Bluetooth: btusb: Add a simple static btusb_prepare_reset() Zijun Hu
  4 siblings, 0 replies; 6+ messages in thread
From: Zijun Hu @ 2026-07-13 12:01 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Zijun Hu, linux-bluetooth, linux-kernel, Zijun Hu

Vendor-specific files need to hand BT frames back to btusb after
filtering out non-BT frames, but these helpers take struct btusb_data *,
which is private to btusb.c:

  int btusb_recv_event(struct btusb_data *data, struct sk_buff *skb)
  int btusb_recv_acl(struct btusb_data *data, struct sk_buff *skb)

Change both to take struct hci_dev * so btusb and vendor files can share
them.

Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
---
 drivers/bluetooth/btusb.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 9c3a6d7d8f1e..f4f911c3de52 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1253,14 +1253,16 @@ static inline void btusb_free_frags(struct btusb_data *data)
 	spin_unlock_irqrestore(&data->rxlock, flags);
 }
 
-static int btusb_recv_event(struct btusb_data *data, struct sk_buff *skb)
+static int btusb_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
 {
+	struct btusb_data *data = hci_get_drvdata(hdev);
+
 	if (data->intr_interval) {
 		/* Trigger dequeue immediately if an event is received */
 		schedule_delayed_work(&data->rx_work, 0);
 	}
 
-	return data->recv_event(data->hdev, skb);
+	return data->recv_event(hdev, skb);
 }
 
 static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)
@@ -1320,7 +1322,7 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)
 			}
 
 			/* Complete frame */
-			btusb_recv_event(data, skb);
+			btusb_recv_event(data->hdev, skb);
 			skb = NULL;
 		}
 	}
@@ -1331,13 +1333,15 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)
 	return err;
 }
 
-static int btusb_recv_acl(struct btusb_data *data, struct sk_buff *skb)
+static int btusb_recv_acl(struct hci_dev *hdev, struct sk_buff *skb)
 {
+	struct btusb_data *data = hci_get_drvdata(hdev);
+
 	/* Only queue ACL packet if intr_interval is set as it means
 	 * force_poll_sync has been enabled.
 	 */
 	if (!data->intr_interval)
-		return data->recv_acl(data->hdev, skb);
+		return data->recv_acl(hdev, skb);
 
 	skb_queue_tail(&data->acl_q, skb);
 	schedule_delayed_work(&data->rx_work, data->intr_interval);
@@ -1392,7 +1396,7 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)
 
 		if (!hci_skb_expect(skb)) {
 			/* Complete frame */
-			btusb_recv_acl(data, skb);
+			btusb_recv_acl(data->hdev, skb);
 			skb = NULL;
 		}
 	}

-- 
2.34.1


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

* [PATCH v2 5/5] Bluetooth: btusb: Add a simple static btusb_prepare_reset()
  2026-07-13 12:01 [PATCH v2 0/5] Bluetooth: btusb: Preparation for upcoming Qualcomm QCC2072 support Zijun Hu
                   ` (3 preceding siblings ...)
  2026-07-13 12:01 ` [PATCH v2 4/5] Bluetooth: btusb: Make btusb_recv_{event,acl}() take struct hci_dev * Zijun Hu
@ 2026-07-13 12:01 ` Zijun Hu
  4 siblings, 0 replies; 6+ messages in thread
From: Zijun Hu @ 2026-07-13 12:01 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Zijun Hu, linux-bluetooth, linux-kernel, Zijun Hu

Add btusb_prepare_reset() to do cleanup before a reset, and apply
it to btusb_mtk_reset() as well.

Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
---
 drivers/bluetooth/btusb.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index f4f911c3de52..8d3bd98fce8a 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2075,6 +2075,14 @@ static void btusb_stop_traffic(struct btusb_data *data)
 	usb_kill_anchored_urbs(&data->ctrl_anchor);
 }
 
+static void btusb_prepare_reset(struct hci_dev *hdev)
+{
+	struct btusb_data *data = hci_get_drvdata(hdev);
+
+	btusb_stop_traffic(data);
+	usb_kill_anchored_urbs(&data->tx_anchor);
+}
+
 static int btusb_close(struct hci_dev *hdev)
 {
 	struct btusb_data *data = hci_get_drvdata(hdev);
@@ -2917,8 +2925,7 @@ static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data)
 	/* Release MediaTek ISO data interface */
 	btusb_mtk_release_iso_intf(hdev);
 
-	btusb_stop_traffic(data);
-	usb_kill_anchored_urbs(&data->tx_anchor);
+	btusb_prepare_reset(hdev);
 
 	/* Toggle the hard reset line. The MediaTek device is going to
 	 * yank itself off the USB and then replug. The cleanup is handled

-- 
2.34.1


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

end of thread, other threads:[~2026-07-13 12:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-13 12:01 [PATCH v2 0/5] Bluetooth: btusb: Preparation for upcoming Qualcomm QCC2072 support Zijun Hu
2026-07-13 12:01 ` [PATCH v2 1/5] Bluetooth: coredump: Introduce and apply hci_devcd_state_name() Zijun Hu
2026-07-13 12:01 ` [PATCH v2 2/5] Bluetooth: coredump: Allow drivers to pad dump header to fixed size Zijun Hu
2026-07-13 12:01 ` [PATCH v2 3/5] Bluetooth: btusb: Add an indirect recv_intr() hook to btusb_data Zijun Hu
2026-07-13 12:01 ` [PATCH v2 4/5] Bluetooth: btusb: Make btusb_recv_{event,acl}() take struct hci_dev * Zijun Hu
2026-07-13 12:01 ` [PATCH v2 5/5] Bluetooth: btusb: Add a simple static btusb_prepare_reset() Zijun Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox