Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btmtk: Fix MT7925 WMT command timeout due to sleep protection
@ 2026-05-31 18:07 Danny Messina
       [not found] ` <KL1PR03MB59762013DD64C282D57FA37AFA132@KL1PR03MB5976.apcprd03.prod.outlook.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Danny Messina @ 2026-05-31 18:07 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: peter.tsao, marcel, Luiz Augusto von Dentz

  The MediaTek MT7925 USB Bluetooth device (0e8d:0717) fails to initialize
  with repeated "Execution of wmt command timed out" errors:

    Bluetooth: hci0: Execution of wmt command timed out
    Bluetooth: hci0: Failed to send wmt patch dwnld (-110)
    Bluetooth: hci0: Failed to set up firmware (-110)

  USB capture (usbmon) confirms WMT commands reach the device — the
  Control OUT transfer completes with status 0 — but the device never
  responds on any endpoint. The control IN polling URB returns zero bytes
  indefinitely until HCI_INIT_TIMEOUT expires.

  The root cause is the MT7925 BT core's sleep protection register
  (0x18011100, bit 1 = SLPPROT_BYPASS). When SLPPROT is active the BT
  processor ignores incoming WMT commands.

  Two additional issues compound this:

  1. After repeated driver load/unload cycles without a hardware reset,
     the BT subsystem's WMT state machine becomes stuck. A subsystem
     reset via btmtk_usb_subsys_reset() restores it to a workable state.

  2. After btmtk_setup_firmware_79xx() activates the downloaded firmware
     (which ends with a 100ms activation delay), the chip re-enables
     SLPPROT. The subsequent FUNC_CTRL WMT command therefore also times
     out unless SLPPROT is bypassed again.

  Fix this for dev_id 0x7925 in btmtk_usb_setup():
    1. Call btmtk_usb_subsys_reset() to clear any stuck WMT state.
    2. Set 0x18011100 |= BIT(1) before firmware download.
    3. Set 0x18011100 |= BIT(1) again before FUNC_CTRL.

  Tested on a System76 Thelio desktop with MT7925 PCIe combo card,
  USB ID 0e8d:0717, kernel 6.18.7.

  Signed-off-by: Danny Messina <messinadm@gmail.com>
  ---
   drivers/bluetooth/btmtk.c | 33 +++++++++++++++++++++++++++++++++
   1 file changed, 33 insertions(+)

  diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
  --- a/drivers/bluetooth/btmtk.c
  +++ b/drivers/bluetooth/btmtk.c
  @@ -1326,6 +1326,24 @@
        case 0x7922:
        case 0x7925:
        case 0x7961:
  +             if (dev_id == 0x7925) {
  +                     u32 val = 0;
  +
  +                     /* Reset BT subsystem to clear any stuck WMT state */
  +                     err = btmtk_usb_subsys_reset(hdev, dev_id);
  +                     if (err < 0)
  +                             bt_dev_warn(hdev, "BT subsys reset
failed (%d), continuing", err);
  +
  +                     /* Bypass sleep protection so WMT commands
reach the BT core */
  +                     err = btmtk_usb_uhw_reg_read(hdev, 0x18011100, &val);
  +                     if (err < 0)
  +                             return err;
  +                     val |= BIT(1);
  +                     err = btmtk_usb_uhw_reg_write(hdev, 0x18011100, val);
  +                     if (err < 0)
  +                             return err;
  +             }
  +
                btmtk_fw_get_filename(fw_bin_name, sizeof(fw_bin_name), dev_id,
                                      fw_version, fw_flavor);

  @@ -1342,6 +1360,19 @@
                if (err < 0)
                        return err;

  +             /* Re-bypass sleep protection after firmware
activation for MT7925 */
  +             if (dev_id == 0x7925) {
  +                     u32 val = 0;
  +
  +                     err = btmtk_usb_uhw_reg_read(hdev, 0x18011100, &val);
  +                     if (err < 0)
  +                             return err;
  +                     val |= BIT(1);
  +                     err = btmtk_usb_uhw_reg_write(hdev, 0x18011100, val);
  +                     if (err < 0)
  +                             return err;
  +             }
  +
                /* Enable Bluetooth protocol */
                param = 1;
                wmt_params.op = BTMTK_WMT_FUNC_CTRL;

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

end of thread, other threads:[~2026-06-07 14:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-31 18:07 [PATCH] Bluetooth: btmtk: Fix MT7925 WMT command timeout due to sleep protection Danny Messina
     [not found] ` <KL1PR03MB59762013DD64C282D57FA37AFA132@KL1PR03MB5976.apcprd03.prod.outlook.com>
     [not found]   ` <200a9854dcce8a152b75f1c4497210c146f89cbc.camel@mediatek.com>
     [not found]     ` <KL1PR03MB597680711115B27DA7D42571FA132@KL1PR03MB5976.apcprd03.prod.outlook.com>
2026-06-03  8:37       ` Chris Lu (陸稚泓)
2026-06-03 12:27         ` Danny Messina
2026-06-04  6:28           ` Chris Lu (陸稚泓)
2026-06-07 14:46             ` Danny Messina

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