Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: Pick the MediaTek ACL OUT endpoint by number
@ 2026-11-30 12:27 Alexey Charkov
  2026-11-30 16:26 ` bluez.test.bot
  2026-11-30 18:03 ` [PATCH] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 3+ messages in thread
From: Alexey Charkov @ 2026-11-30 12:27 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz; +Cc: linux-bluetooth, Alexey Charkov

Some MT7921 modules list two bulk OUT endpoints on their HCI interface:

T:  Bus=02 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=  4 Spd=5000 MxCh= 0
D:  Ver= 3.20 Cls=ef(misc ) Sub=02 Prot=01 MxPS= 9 #Cfgs=  1
P:  Vendor=0e8d ProdID=7961 Rev= 1.00
S:  Manufacturer=MediaTek Inc.
S:  Product=Wireless_Device
C:* #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=160mA
I:* If#= 0 Alt= 0 #EPs= 5 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=81(I) Atr=03(Int.) MxPS=  64 Ivl=125us
E:  Ad=01(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=8f(I) Atr=03(Int.) MxPS=   2 Ivl=125us

usb_find_common_endpoints() picks 0x01 for ACL OUT. With it the controller
scans, but connections never complete. ACL data goes through 0x02, the
endpoint that pairs with the bulk IN 0x82.

This follows the module, not the link speed. The same module lists the
same endpoints at High-Speed and fails the same way there, as it does with
every Bluetooth and Wi-Fi firmware version tried. An ALFA AWUS036AXML also
lists both at High-Speed, while a COMFAST CF-953AX at SuperSpeed has only
0x02.

Prefer the bulk OUT endpoint that shares its number with the bulk IN one,
so modules with a single bulk OUT keep their current selection.

Signed-off-by: Alexey Charkov <alchark@flipper.net>
---
 drivers/bluetooth/btusb_main.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/bluetooth/btusb_main.c b/drivers/bluetooth/btusb_main.c
index 95398e2ca098..b95098a98767 100644
--- a/drivers/bluetooth/btusb_main.c
+++ b/drivers/bluetooth/btusb_main.c
@@ -2995,6 +2995,33 @@ static int btusb_recv_event_realtek(struct hci_dev *hdev, struct sk_buff *skb)
 	return hci_recv_frame(hdev, skb);
 }
 
+/*
+ * The ACL OUT endpoint shares its number with the bulk IN one. Some modules
+ * list an extra bulk OUT endpoint ahead of it.
+ */
+static void btusb_mtk_find_bulk_tx_ep(struct usb_interface *intf,
+				      struct btusb_data *data)
+{
+	struct usb_host_interface *alt = intf->cur_altsetting;
+	int num = usb_endpoint_num(data->bulk_rx_ep);
+	int i;
+
+	if (usb_endpoint_num(data->bulk_tx_ep) == num)
+		return;
+
+	for (i = 0; i < alt->desc.bNumEndpoints; i++) {
+		struct usb_endpoint_descriptor *ep = &alt->endpoint[i].desc;
+
+		if (usb_endpoint_is_bulk_out(ep) && usb_endpoint_num(ep) == num) {
+			dev_dbg(&intf->dev, "using bulk OUT 0x%02x instead of 0x%02x\n",
+				ep->bEndpointAddress,
+				data->bulk_tx_ep->bEndpointAddress);
+			data->bulk_tx_ep = ep;
+			return;
+		}
+	}
+}
+
 static void btusb_mtk_claim_iso_intf(struct btusb_data *data)
 {
 	struct btmtk_data *btmtk_data;
@@ -4621,6 +4648,7 @@ static int btusb_probe(struct usb_interface *intf,
 		hdev->reset = btmtk_reset_sync;
 		hdev->set_bdaddr = btmtk_set_bdaddr;
 		hdev->send = btusb_send_frame_mtk;
+		btusb_mtk_find_bulk_tx_ep(intf, data);
 		hci_set_quirk(hdev, HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN);
 		hci_set_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_SETUP);
 		data->recv_acl = btmtk_usb_recv_acl;

---
base-commit: e5aad2bdbbee783611d32599f89cea3f12f9593d
change-id: 20261130-btusb-mt-usb30-a91fd203a083

Best regards,
--  
Alexey Charkov <alchark@flipper.net>


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

* RE: Bluetooth: btusb: Pick the MediaTek ACL OUT endpoint by number
  2026-11-30 12:27 [PATCH] Bluetooth: btusb: Pick the MediaTek ACL OUT endpoint by number Alexey Charkov
@ 2026-11-30 16:26 ` bluez.test.bot
  2026-11-30 18:03 ` [PATCH] " Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-11-30 16:26 UTC (permalink / raw)
  To: linux-bluetooth, alchark

[-- Attachment #1: Type: text/plain, Size: 1214 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/series/1226739/

---Test result---

Test Summary:
CheckPatch                    PASS      0.55 seconds
VerifyFixes                   PASS      0.09 seconds
VerifySignedoff               PASS      0.09 seconds
GitLint                       FAIL      0.26 seconds
SubjectPrefix                 PASS      0.09 seconds
BuildKernel                   PASS      21.98 seconds
CheckAllWarning               PASS      25.72 seconds
CheckSparse                   PASS      27.57 seconds
BuildKernel32                 PASS      22.55 seconds
CheckKernelLLVM               PASS      22.75 seconds
TestRunnerSetup               PASS      501.69 seconds
IncrementalBuild              PASS      21.54 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
Bluetooth: btusb: Pick the MediaTek ACL OUT endpoint by number

42: B2 Line has trailing whitespace: "--  "


https://github.com/bluez/bluetooth-next/pull/1256

---
Regards,
Linux Bluetooth


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

* Re: [PATCH] Bluetooth: btusb: Pick the MediaTek ACL OUT endpoint by number
  2026-11-30 12:27 [PATCH] Bluetooth: btusb: Pick the MediaTek ACL OUT endpoint by number Alexey Charkov
  2026-11-30 16:26 ` bluez.test.bot
@ 2026-11-30 18:03 ` Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2026-11-30 18:03 UTC (permalink / raw)
  To: Alexey Charkov; +Cc: Marcel Holtmann, linux-bluetooth

Hi Alexey,

On Mon, Nov 30, 2026 at 7:27 AM Alexey Charkov <alchark@flipper.net> wrote:
>
> Some MT7921 modules list two bulk OUT endpoints on their HCI interface:
>
> T:  Bus=02 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=  4 Spd=5000 MxCh= 0
> D:  Ver= 3.20 Cls=ef(misc ) Sub=02 Prot=01 MxPS= 9 #Cfgs=  1
> P:  Vendor=0e8d ProdID=7961 Rev= 1.00
> S:  Manufacturer=MediaTek Inc.
> S:  Product=Wireless_Device
> C:* #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=160mA
> I:* If#= 0 Alt= 0 #EPs= 5 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=81(I) Atr=03(Int.) MxPS=  64 Ivl=125us
> E:  Ad=01(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
> E:  Ad=82(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
> E:  Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
> E:  Ad=8f(I) Atr=03(Int.) MxPS=   2 Ivl=125us
>
> usb_find_common_endpoints() picks 0x01 for ACL OUT. With it the controller
> scans, but connections never complete. ACL data goes through 0x02, the
> endpoint that pairs with the bulk IN 0x82.

We probably need someone from mediatek to attest this is how it is
supposed to work or perhaps there is a bug in the firmware, etc.

> This follows the module, not the link speed. The same module lists the
> same endpoints at High-Speed and fails the same way there, as it does with
> every Bluetooth and Wi-Fi firmware version tried. An ALFA AWUS036AXML also
> lists both at High-Speed, while a COMFAST CF-953AX at SuperSpeed has only
> 0x02.
>
> Prefer the bulk OUT endpoint that shares its number with the bulk IN one,
> so modules with a single bulk OUT keep their current selection.
>
> Signed-off-by: Alexey Charkov <alchark@flipper.net>
> ---
>  drivers/bluetooth/btusb_main.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
>
> diff --git a/drivers/bluetooth/btusb_main.c b/drivers/bluetooth/btusb_main.c
> index 95398e2ca098..b95098a98767 100644
> --- a/drivers/bluetooth/btusb_main.c
> +++ b/drivers/bluetooth/btusb_main.c
> @@ -2995,6 +2995,33 @@ static int btusb_recv_event_realtek(struct hci_dev *hdev, struct sk_buff *skb)
>         return hci_recv_frame(hdev, skb);
>  }
>
> +/*
> + * The ACL OUT endpoint shares its number with the bulk IN one. Some modules
> + * list an extra bulk OUT endpoint ahead of it.
> + */
> +static void btusb_mtk_find_bulk_tx_ep(struct usb_interface *intf,
> +                                     struct btusb_data *data)
> +{
> +       struct usb_host_interface *alt = intf->cur_altsetting;
> +       int num = usb_endpoint_num(data->bulk_rx_ep);
> +       int i;
> +
> +       if (usb_endpoint_num(data->bulk_tx_ep) == num)
> +               return;
> +
> +       for (i = 0; i < alt->desc.bNumEndpoints; i++) {
> +               struct usb_endpoint_descriptor *ep = &alt->endpoint[i].desc;
> +
> +               if (usb_endpoint_is_bulk_out(ep) && usb_endpoint_num(ep) == num) {
> +                       dev_dbg(&intf->dev, "using bulk OUT 0x%02x instead of 0x%02x\n",
> +                               ep->bEndpointAddress,
> +                               data->bulk_tx_ep->bEndpointAddress);
> +                       data->bulk_tx_ep = ep;
> +                       return;
> +               }
> +       }
> +}
> +
>  static void btusb_mtk_claim_iso_intf(struct btusb_data *data)
>  {
>         struct btmtk_data *btmtk_data;
> @@ -4621,6 +4648,7 @@ static int btusb_probe(struct usb_interface *intf,
>                 hdev->reset = btmtk_reset_sync;
>                 hdev->set_bdaddr = btmtk_set_bdaddr;
>                 hdev->send = btusb_send_frame_mtk;
> +               btusb_mtk_find_bulk_tx_ep(intf, data);
>                 hci_set_quirk(hdev, HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN);
>                 hci_set_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_SETUP);
>                 data->recv_acl = btmtk_usb_recv_acl;
>
> ---
> base-commit: e5aad2bdbbee783611d32599f89cea3f12f9593d
> change-id: 20261130-btusb-mt-usb30-a91fd203a083
>
> Best regards,
> --
> Alexey Charkov <alchark@flipper.net>
>


-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2026-11-30 18:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 12:27 [PATCH] Bluetooth: btusb: Pick the MediaTek ACL OUT endpoint by number Alexey Charkov
2026-11-30 16:26 ` bluez.test.bot
2026-11-30 18:03 ` [PATCH] " Luiz Augusto von Dentz

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