From: Paul Menzel <pmenzel@molgen.mpg.de>
To: Arkadiusz Bokowy <arkadiusz.bokowy@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: btusb: Fixup quirk for reading ext features on some Barrot controllers
Date: Mon, 25 Aug 2025 19:44:03 +0200 [thread overview]
Message-ID: <56e1103c-fa6c-4549-b720-02cb3abc9420@molgen.mpg.de> (raw)
In-Reply-To: <20250825172504.339117-1-arkadiusz.bokowy@gmail.com>
Dear Arkadiusz,
Thank you for your patch. For the summary, just a small nit to use a
statement: Add quirk to fix up reading ext features on some Barrot
controllers
Am 25.08.25 um 19:25 schrieb Arkadiusz Bokowy:
> Apparently, some Barrot based USB Bluetooth dongles erroneously sent one
s/sent/send/
> extra random byte for the HCI_OP_READ_LOCAL_EXT_FEATURES command. The
> consequence of that is that the next HCI transfer is misaligned by one
> byte causing undefined behavior. In most cases the response event for the
> next command fails with random error code.
>
> Since the HCI_OP_READ_LOCAL_EXT_FEATURES command is used during HCI
> controller initialization, the initialization fails rendering the USB
> dongle not usable.
>
>> [59.464099] usb 1-1.3: new full-speed USB device number 11 using xhci_hcd
>> [59.561617] usb 1-1.3: New USB device found, idVendor=33fa, idProduct=0012, bcdDevice=88.91
>> [59.561642] usb 1-1.3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
>> [59.561656] usb 1-1.3: Product: UGREEN BT6.0 Adapter
>> [61.720116] Bluetooth: hci1: command 0x1005 tx timeout
>> [61.720167] Bluetooth: hci1: Opcode 0x1005 failed: -110
Although in the log, maybe mention, that you tested with the 33fa:0012
device.
> This patch was not tested with the 33fa:0010 device, however, Internet
> search suggest that the cause for the issue with this particular device
> is exactly the same, e.g.: https://github.com/bluez/bluez/issues/1326
You could use:
Link: https://github.com/bluez/bluez/issues/1326
> Signed-off-by: Arkadiusz Bokowy <arkadiusz.bokowy@gmail.com>
> ---
> drivers/bluetooth/btusb.c | 30 ++++++++++++++++++++++++++++++
> include/net/bluetooth/hci.h | 9 +++++++++
> 2 files changed, 39 insertions(+)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 8085fabad..b89efe482 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -66,6 +66,7 @@ static struct usb_driver btusb_driver;
> #define BTUSB_INTEL_BROKEN_INITIAL_NCMD BIT(25)
> #define BTUSB_INTEL_NO_WBS_SUPPORT BIT(26)
> #define BTUSB_ACTIONS_SEMI BIT(27)
> +#define BTUSB_BARROT BIT(28)
>
> static const struct usb_device_id btusb_table[] = {
> /* Generic Bluetooth USB device */
> @@ -810,6 +811,10 @@ static const struct usb_device_id quirks_table[] = {
> { USB_DEVICE(0x0cb5, 0xc547), .driver_info = BTUSB_REALTEK |
> BTUSB_WIDEBAND_SPEECH },
>
> + /* Barrot Technology Bluetooth devices */
> + { USB_DEVICE(0x33fa, 0x0010), .driver_info = BTUSB_BARROT },
> + { USB_DEVICE(0x33fa, 0x0012), .driver_info = BTUSB_BARROT },
> +
> /* Actions Semiconductor ATS2851 based devices */
> { USB_DEVICE(0x10d7, 0xb012), .driver_info = BTUSB_ACTIONS_SEMI },
>
> @@ -1120,6 +1125,21 @@ static void btusb_qca_reset(struct hci_dev *hdev)
> btusb_reset(hdev);
> }
>
> +static int btusb_barrot_urb_quirk(struct btusb_data *data, struct sk_buff *skb)
> +{
> + struct hci_dev *hdev = data->hdev;
> + struct hci_ev_cmd_complete *ev;
> +
> + if (hci_test_quirk(hdev, HCI_QUIRK_FIXUP_LOCAL_EXT_FEATURES_URB_BUFFER) &&
> + hci_event_hdr(skb)->evt == HCI_EV_CMD_COMPLETE) {
> + ev = (struct hci_ev_cmd_complete *)(hci_event_hdr(skb) + 1);
> + if (__le16_to_cpu(ev->opcode) == HCI_OP_READ_LOCAL_EXT_FEATURES)
> + return 1;
> + }
> +
> + return 0;
> +}
> +
> static inline void btusb_free_frags(struct btusb_data *data)
> {
> unsigned long flags;
> @@ -1192,6 +1212,13 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)
> }
>
> if (!hci_skb_expect(skb)) {
> + /* Discard one extra byte sent by some Barrot USB
> + * controllers. Otherwise, the rest of the transfer
> + * will be misaligned by one byte.
> + */
> + if (btusb_barrot_urb_quirk(data, skb) && count == 1)
> + count = 0;
> +
> /* Complete frame */
> btusb_recv_event(data, skb);
> skb = NULL;
> @@ -4218,6 +4245,9 @@ static int btusb_probe(struct usb_interface *intf,
> hci_set_quirk(hdev, HCI_QUIRK_BROKEN_WRITE_AUTH_PAYLOAD_TIMEOUT);
> }
>
> + if (id->driver_info & BTUSB_BARROT)
> + hci_set_quirk(hdev, HCI_QUIRK_FIXUP_LOCAL_EXT_FEATURES_URB_BUFFER);
> +
> if (!reset)
> hci_set_quirk(hdev, HCI_QUIRK_RESET_ON_CLOSE);
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index df1847b74..ec9b47a39 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -351,6 +351,15 @@ enum {
> */
> HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE,
>
> + /*
> + * When this quirk is set, the URB buffer with response event for the
> + * HCI_OP_READ_LOCAL_EXT_FEATURES command needs to be trimmed by one byte.
> + * This is required for some Barrot controllers which erroneously transfer
> + * an extra random byte at the end of the buffer which misaligns the rest
> + * of the HCI communication.
> + */
> + HCI_QUIRK_FIXUP_LOCAL_EXT_FEATURES_URB_BUFFER,
> +
> /*
> * When this quirk is set, the reserved bits of Primary/Secondary_PHY
> * inside the LE Extended Advertising Report events are discarded.
Great patch.
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Kind regards,
Paul
next prev parent reply other threads:[~2025-08-25 17:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-25 17:25 [PATCH] Bluetooth: btusb: Fixup quirk for reading ext features on some Barrot controllers Arkadiusz Bokowy
2025-08-25 17:44 ` Paul Menzel [this message]
2025-08-25 17:59 ` bluez.test.bot
2025-08-25 18:32 ` [PATCH] " Luiz Augusto von Dentz
2025-08-25 18:49 ` Arkadiusz Bokowy
2025-08-25 18:56 ` Luiz Augusto von Dentz
2025-08-25 19:37 ` Arkadiusz Bokowy
2025-08-25 20:08 ` Luiz Augusto von Dentz
2025-08-25 20:16 ` Arkadiusz Bokowy
2025-08-26 4:44 ` Arkadiusz Bokowy
2025-08-26 13:45 ` Luiz Augusto von Dentz
2025-08-26 16:23 ` Arkadiusz Bokowy
2025-08-26 16:36 ` Luiz Augusto von Dentz
2025-08-26 17:03 ` [PATCH v2] Bluetooth: btusb: Check for unexpected bytes when defragmenting HCI frames Arkadiusz Bokowy
2025-08-26 17:33 ` [v2] " bluez.test.bot
2025-08-26 19:31 ` [PATCH v2] " Luiz Augusto von Dentz
2025-08-27 13:42 ` Luiz Augusto von Dentz
2025-08-27 15:02 ` Arkadiusz Bokowy
2025-08-27 15:20 ` Luiz Augusto von Dentz
2025-08-27 16:40 ` [PATCH v3] " Arkadiusz Bokowy
2025-08-27 17:05 ` [v3] " bluez.test.bot
2025-08-27 6:03 ` [PATCH v2] " Paul Menzel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56e1103c-fa6c-4549-b720-02cb3abc9420@molgen.mpg.de \
--to=pmenzel@molgen.mpg.de \
--cc=arkadiusz.bokowy@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).