Bluetooth: Add filter for Qualcomm debug packets
PATCH 1/1 Bluetooth: Add filter for Qualcomm debug packets
Some Qualcomm Bluetooth controllers, e.g., QCNFA765 send debug packets as ACL frames with header 0x2EDC. The kernel misinterprets these as malformed ACL packets, causing repeated errors:
Bluetooth: hci0: ACL packet for unknown connection handle 3804
This can occur hundreds of times per minute, greatly cluttering logs. On my computer, I am observing approximately 7 messages per second when streaming audio to a speaker.
For Qualcomm controllers exchanging over UART, hci_qca.c already filters out these debug packets. This patch is for controllers not going through UART, but USB.
This patch filters these packets in btusb_recv_acl() before they reach the HCI layer, redirecting them to hci_recv_diag().
Tested on: Thinkpad T14 gen2 (AMD) with QCNFA765, kernel 6.16.9
--- drivers/bluetooth/btusb.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/bluetooth/btusb.c +9 -0
@@ -68,6 +68,9 @@ static struct usb_driver btusb_driver;#define BTUSB_ACTIONS_SEMI BIT(27)#define BTUSB_BARROT BIT(28) +/* Qualcomm firmware debug packets header */ +#define QCA_DEBUG_HEADER 0x2EDC +static const struct usb_device_id btusb_table[] = {/* Generic Bluetooth USB device */ {USB_DEVICE_INFO (0xe0 ,0x01 ,0x01 ) },
@@ -1229,6 +1232,12 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)static int btusb_recv_acl (struct btusb_data *data,struct sk_buff *skb) { +/* Drop QCA firmware debug packets sent as ACL frames */ +if (skb->len >=2 ) { +if (get_unaligned_le16 (skb->data) ==QCA_DEBUG_HEADER ) +return hci_recv_diag (data->hdev, skb); + } +/* Only queue ACL packet if intr_interval is set as it means * force_poll_sync has been enabled. */
Signature · 1 line
2.51.0
Luiz Augusto von Dentz
maintainerHi Pascal,
Quoted 40 lines · Pascal Giard
Some Qualcomm Bluetooth controllers, e.g., QCNFA765 send debug packets as ACL frames with header
0x2EDC. The kernel misinterprets these as malformed ACL packets, causing repeated errors:Bluetooth: hci0: ACL packet for unknown connection handle 3804
This can occur hundreds of times per minute, greatly cluttering logs. On my computer, I am observing approximately 7 messages per second when streaming audio to a speaker.
For Qualcomm controllers exchanging over UART,
hci_qca.calready filters out these debug packets. This patch is for controllers not going through UART, but USB.This patch filters these packets in
btusb_recv_acl()before they reach the HCI layer, redirecting them tohci_recv_diag().Tested on: Thinkpad T14 gen2 (AMD) with QCNFA765, kernel 6.16.9
Signed-off-by Pascal Giard <[email protected]>--- drivers/bluetooth/btusb.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/bluetooth/btusb.c +3
-0@@ -68,6 +68,9 @@ static struct usb_driver btusb_driver;#define BTUSB_ACTIONS_SEMI BIT(27)#define BTUSB_BARROT BIT(28) +/* Qualcomm firmware debug packets header */ +#define QCA_DEBUG_HEADER 0x2EDC +static const struct usb_device_id btusb_table[] = {/* Generic Bluetooth USB device */ {USB_DEVICE_INFO (0xe0 ,0x01 ,0x01 ) },
drivers/bluetooth/btusb.c static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count) · line 1239
Quoted 8 lines
drivers/bluetooth/btusb.c +5
-0@@ -1229,6 +1232,12 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)static int btusb_recv_acl (struct btusb_data *data,struct sk_buff *skb) { +/* Drop QCA firmware debug packets sent as ACL frames */ +if (skb->len >=2 ) { +if (get_unaligned_le16 (skb->data) ==QCA_DEBUG_HEADER ) +return hci_recv_diag (data->hdev, skb); + }
Well it turns out that handle 0x2EDC is actually a valid handle, so we can't just reclassify these packets just because Qualcomm thinks that it could reserve it for its own, so this needs to be using classify_pkt_type to reclassify the packets to the handle 0x2EDC to HCI_DIAG_PKT for the models affected.
Quoted 6 lines
drivers/bluetooth/btusb.c +0
-1/* Only queue ACL packet if intr_interval is set as it means * force_poll_sync has been enabled. */ --2.51.0
Signature · 1 line
Luiz Augusto von Dentz
Dear Luiz,
Quoted 45 lines · Luiz Augusto von Dentz
Hi Pascal,
Quoted 41 lines · Pascal Giard
Some Qualcomm Bluetooth controllers, e.g., QCNFA765 send debug packets as ACL frames with header
0x2EDC. The kernel misinterprets these as malformed ACL packets, causing repeated errors:Bluetooth: hci0: ACL packet for unknown connection handle 3804
This can occur hundreds of times per minute, greatly cluttering logs. On my computer, I am observing approximately 7 messages per second when streaming audio to a speaker.
For Qualcomm controllers exchanging over UART,
hci_qca.calready filters out these debug packets. This patch is for controllers not going through UART, but USB.This patch filters these packets in
btusb_recv_acl()before they reach the HCI layer, redirecting them tohci_recv_diag().Tested on: Thinkpad T14 gen2 (AMD) with QCNFA765, kernel 6.16.9
Signed-off-by Pascal Giard <[email protected]>--- drivers/bluetooth/btusb.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/bluetooth/btusb.c +3
-0@@ -68,6 +68,9 @@ static struct usb_driver btusb_driver;#define BTUSB_ACTIONS_SEMI BIT(27)#define BTUSB_BARROT BIT(28) +/* Qualcomm firmware debug packets header */ +#define QCA_DEBUG_HEADER 0x2EDC +static const struct usb_device_id btusb_table[] = {/* Generic Bluetooth USB device */ {USB_DEVICE_INFO (0xe0 ,0x01 ,0x01 ) },@@ -1229,6 +1232,12 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)
Quoted 13 lines
drivers/bluetooth/btusb.c static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count) · line 1239
Quoted 7 lines
drivers/bluetooth/btusb.c +5
-0static int btusb_recv_acl (struct btusb_data *data,struct sk_buff *skb) { +/* Drop QCA firmware debug packets sent as ACL frames */ +if (skb->len >=2 ) { +if (get_unaligned_le16 (skb->data) ==QCA_DEBUG_HEADER ) +return hci_recv_diag (data->hdev, skb); + }Well it turns out that handle
0x2EDCis actually a valid handle, so we can't just reclassify these packets just because Qualcomm thinks that it could reserve it for its own, so this needs to be usingclassify_pkt_typeto reclassify the packets to the handle0x2EDCtoHCI_DIAG_PKTfor the models affected.
Thank you for considering my patch. Based on your comment, I had a look at how btintel.c uses classify_pkt_type, and I think I understand what you are expecting of me.
Before I submit a new version, should I go very narrow (just the VID:PID=0x0489:0xe0d0 I know for certain has the issue) or should I lump in all modules with the WCN6855 chip? The latter seems somewhat reasonable to me given how hci_qca.c does it (even broader). Therefore, I'm thinking of reusing BTUSB_QCA_WCN6855.
Thanks,
-Pascal
--
Homepage (http://pascal.giard.info)
École de technologie supérieure (http://etsmtl.ca)
Luiz Augusto von Dentz
maintainerHi Pascal,
Quoted 68 lines · Pascal Giard
Dear Luiz,
Quoted 45 lines · Luiz Augusto von Dentz
Hi Pascal,
Quoted 41 lines · Pascal Giard
Some Qualcomm Bluetooth controllers, e.g., QCNFA765 send debug packets as ACL frames with header
0x2EDC. The kernel misinterprets these as malformed ACL packets, causing repeated errors:Bluetooth: hci0: ACL packet for unknown connection handle 3804
This can occur hundreds of times per minute, greatly cluttering logs. On my computer, I am observing approximately 7 messages per second when streaming audio to a speaker.
For Qualcomm controllers exchanging over UART,
hci_qca.calready filters out these debug packets. This patch is for controllers not going through UART, but USB.This patch filters these packets in
btusb_recv_acl()before they reach the HCI layer, redirecting them tohci_recv_diag().Tested on: Thinkpad T14 gen2 (AMD) with QCNFA765, kernel 6.16.9
Signed-off-by Pascal Giard <[email protected]>--- drivers/bluetooth/btusb.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/bluetooth/btusb.c +3
-0@@ -68,6 +68,9 @@ static struct usb_driver btusb_driver;#define BTUSB_ACTIONS_SEMI BIT(27)#define BTUSB_BARROT BIT(28) +/* Qualcomm firmware debug packets header */ +#define QCA_DEBUG_HEADER 0x2EDC +static const struct usb_device_id btusb_table[] = {/* Generic Bluetooth USB device */ {USB_DEVICE_INFO (0xe0 ,0x01 ,0x01 ) },@@ -1229,6 +1232,12 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)Quoted 13 lines
drivers/bluetooth/btusb.c static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count) · line 1239
Quoted 7 lines
drivers/bluetooth/btusb.c +5
-0static int btusb_recv_acl (struct btusb_data *data,struct sk_buff *skb) { +/* Drop QCA firmware debug packets sent as ACL frames */ +if (skb->len >=2 ) { +if (get_unaligned_le16 (skb->data) ==QCA_DEBUG_HEADER ) +return hci_recv_diag (data->hdev, skb); + }Well it turns out that handle
0x2EDCis actually a valid handle, so we can't just reclassify these packets just because Qualcomm thinks that it could reserve it for its own, so this needs to be usingclassify_pkt_typeto reclassify the packets to the handle0x2EDCtoHCI_DIAG_PKTfor the models affected.Thank you for considering my patch. Based on your comment, I had a look at how
btintel.cusesclassify_pkt_type, and I think I understand what you are expecting of me.
Quoted 5 lines
Before I submit a new version, should I go very narrow (just the VID:PID=0x0489:0xe0d0 I know for certain has the issue) or should I lump in all modules with the WCN6855 chip? The latter seems somewhat reasonable to me given how
hci_qca.cdoes it (even broader). Therefore, I'm thinking of reusingBTUSB_QCA_WCN6855.
I'm afraid you will need to figure it out, probably only qualcomm folks can tell which chips use this logic, also is it always enabled to send debug information or that requires a vendor command to enable debug traces to be sent using that handle?
Quoted 6 lines
Thanks,
-Pascal
--
Homepage (http://pascal.giard.info)
École de technologie supérieure (http://etsmtl.ca)
Signature · 1 line
Luiz Augusto von Dentz
Hi Luiz,
Quoted 78 lines · Luiz Augusto von Dentz
Hi Pascal,
Quoted 68 lines · Pascal Giard
Dear Luiz,
Quoted 45 lines · Luiz Augusto von Dentz
Hi Pascal,
Quoted 41 lines · Pascal Giard
Some Qualcomm Bluetooth controllers, e.g., QCNFA765 send debug packets as ACL frames with header
0x2EDC. The kernel misinterprets these as malformed ACL packets, causing repeated errors:Bluetooth: hci0: ACL packet for unknown connection handle 3804
This can occur hundreds of times per minute, greatly cluttering logs. On my computer, I am observing approximately 7 messages per second when streaming audio to a speaker.
For Qualcomm controllers exchanging over UART,
hci_qca.calready filters out these debug packets. This patch is for controllers not going through UART, but USB.This patch filters these packets in
btusb_recv_acl()before they reach the HCI layer, redirecting them tohci_recv_diag().Tested on: Thinkpad T14 gen2 (AMD) with QCNFA765, kernel 6.16.9
Signed-off-by Pascal Giard <[email protected]>--- drivers/bluetooth/btusb.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/bluetooth/btusb.c +3
-0@@ -68,6 +68,9 @@ static struct usb_driver btusb_driver;#define BTUSB_ACTIONS_SEMI BIT(27)#define BTUSB_BARROT BIT(28) +/* Qualcomm firmware debug packets header */ +#define QCA_DEBUG_HEADER 0x2EDC +static const struct usb_device_id btusb_table[] = {/* Generic Bluetooth USB device */ {USB_DEVICE_INFO (0xe0 ,0x01 ,0x01 ) },@@ -1229,6 +1232,12 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)Quoted 13 lines
drivers/bluetooth/btusb.c static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count) · line 1239
Quoted 7 lines
drivers/bluetooth/btusb.c +5
-0static int btusb_recv_acl (struct btusb_data *data,struct sk_buff *skb) { +/* Drop QCA firmware debug packets sent as ACL frames */ +if (skb->len >=2 ) { +if (get_unaligned_le16 (skb->data) ==QCA_DEBUG_HEADER ) +return hci_recv_diag (data->hdev, skb); + }Well it turns out that handle
0x2EDCis actually a valid handle, so we can't just reclassify these packets just because Qualcomm thinks that it could reserve it for its own, so this needs to be usingclassify_pkt_typeto reclassify the packets to the handle0x2EDCtoHCI_DIAG_PKTfor the models affected.Thank you for considering my patch. Based on your comment, I had a look at how
btintel.cusesclassify_pkt_type, and I think I understand what you are expecting of me.Quoted 5 lines
Before I submit a new version, should I go very narrow (just the VID:PID=0x0489:0xe0d0 I know for certain has the issue) or should I lump in all modules with the WCN6855 chip? The latter seems somewhat reasonable to me given how
hci_qca.cdoes it (even broader). Therefore, I'm thinking of reusingBTUSB_QCA_WCN6855.
Quoted 4 lines
I'm afraid you will need to figure it out, probably only qualcomm folks can tell which chips use this logic, also is it always enabled to send debug information or that requires a vendor command to enable debug traces to be sent using that handle?
I went with lumping in all WCN6855 chips. I have not sent any command to enable debug traces, so my understanding is that this is the default behavior on at least some controllers.
I have sent a new version of the patch for your consideration, where I have tried to follow the approach you suggested.
Thanks again!
-Pascal