* [PATCH v2 1/2] Bluetooth: btusb: mediatek: Fix leaked runtime PM reference in reset
@ 2026-08-19 9:52 Jiajia Liu
2026-08-19 9:52 ` [PATCH v2 2/2] Bluetooth: btusb: Fix leaked runtime PM reference in btusb_reset Jiajia Liu
2026-08-19 10:38 ` [v2,1/2] Bluetooth: btusb: mediatek: Fix leaked runtime PM reference in reset bluez.test.bot
0 siblings, 2 replies; 3+ messages in thread
From: Jiajia Liu @ 2026-08-19 9:52 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Ying Hsu, Archie Pusaka,
Abhishek Pandit-Subedi, Matthias Brugger,
AngeloGioacchino Del Regno, Jing Cai, Sean Wang, Chris Lu
Cc: linux-bluetooth, linux-kernel, linux-arm-kernel, linux-mediatek,
Jiajia Liu
MT7925 on HP Pro Mini 260 sometimes timed out during reloading driver
and reset usb device. btusb_suspend is not called again after closing
bluetooth interface.
usbcore: registered new interface driver btusb
Bluetooth: hci0: HW/SW Version: 0x00000000, Build Time: 20260605184935
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 3-10: reset high-speed USB device number 4 using xhci_hcd
Bluetooth: hci0: HW/SW Version: 0x00000000, Build Time: 20260605184935
Bluetooth: hci0: Device setup in 1856545 usecs
Bluetooth: hci0: AOSP extensions version v1.00
Bluetooth: hci0: AOSP quality report is supported
Bluetooth: MGMT ver 1.23
btusb_mtk_reset calls usb_autopm_get_interface to resume the device
before driving the hardware reset, but never calls the matching
usb_autopm_put_interface. Every hardware reset therefore leaks a PM
usage reference of the interface, preventing the device from being
runtime suspended again until it is unbound.
Add BTUSB_USB_RESET_ACTIVE flag and set it before usb_queue_reset_device.
Release the PM reference in btusb_disconnect if this flag is set.
Fixes: 25b6d7593a3a ("Bluetooth: btmtk: introduce btmtk reset work")
Assisted-by: Claude:qwen3.8-max
Signed-off-by: Jiajia Liu <liujiajia@kylinos.cn>
---
Changes in v2:
- Fix the race window (sashiko)
Add and set BTUSB_USB_RESET_ACTIVE flag before usb_queue_reset_device.
Release PM reference in btusb_disconnect if this flag is set.
Changes in v1:
- add usb_autopm_put_interface after usb_queue_reset_device
---
drivers/bluetooth/btusb.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 184e95c1625e..45a726bed0dd 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -957,6 +957,7 @@ struct qca_dump_info {
#define BTUSB_USE_ALT3_FOR_WBS 15
#define BTUSB_ALT6_CONTINUOUS_TX 16
#define BTUSB_HW_SSR_ACTIVE 17
+#define BTUSB_USB_RESET_ACTIVE 18
struct btusb_data {
struct hci_dev *hdev;
@@ -2915,6 +2916,7 @@ static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data)
err = btmtk_usb_subsys_reset(hdev, btmtk_data->dev_id);
+ set_bit(BTUSB_USB_RESET_ACTIVE, &data->flags);
usb_queue_reset_device(data->intf);
clear_bit(BTMTK_HW_RESET_ACTIVE, &btmtk_data->flags);
@@ -4497,6 +4499,9 @@ static void btusb_disconnect(struct usb_interface *intf)
if (data->reset_gpio)
gpiod_put(data->reset_gpio);
+ if (test_bit(BTUSB_USB_RESET_ACTIVE, &data->flags))
+ usb_autopm_put_interface_no_suspend(data->intf);
+
if (intf == data->intf) {
if (data->isoc)
usb_driver_release_interface(&btusb_driver, data->isoc);
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH v2 2/2] Bluetooth: btusb: Fix leaked runtime PM reference in btusb_reset
2026-08-19 9:52 [PATCH v2 1/2] Bluetooth: btusb: mediatek: Fix leaked runtime PM reference in reset Jiajia Liu
@ 2026-08-19 9:52 ` Jiajia Liu
2026-08-19 10:38 ` [v2,1/2] Bluetooth: btusb: mediatek: Fix leaked runtime PM reference in reset bluez.test.bot
1 sibling, 0 replies; 3+ messages in thread
From: Jiajia Liu @ 2026-08-19 9:52 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Ying Hsu, Archie Pusaka,
Abhishek Pandit-Subedi, Matthias Brugger,
AngeloGioacchino Del Regno, Jing Cai, Sean Wang, Chris Lu
Cc: linux-bluetooth, linux-kernel, linux-arm-kernel, linux-mediatek,
Jiajia Liu
btusb_reset calls usb_autopm_get_interface to resume the device
before queuing a reset of it, but never calls the matching
usb_autopm_put_interface.
usb_queue_reset_device ends up in usb_reset_device(), and since
btusb provides no pre_reset/post_reset callbacks the interface is
merely unbound and rebound: the interface device object survives
this cycle, and so does its PM usage count, which is not cleared
when the driver is unbound.
As a result every reset permanently leaks a PM usage reference,
preventing the interface from being runtime suspended again until
it is unbound.
Set BTUSB_USB_RESET_ACTIVE flag before usb_queue_device_reset so
that the reference can be released in btusb_disconnect.
Fixes: c9209b269afd ("Bluetooth: btusb: Introduce generic USB reset")
Assisted-by: Claude:qwen3.8-max
Signed-off-by: Jiajia Liu <liujiajia@kylinos.cn>
---
Changes in v2:
- Fix the race window (sashiko)
set BTUSB_USB_RESET_ACTIVE flag before usb_queue_reset_device.
Changes in v1:
- add usb_autopm_put_interface after usb_queue_reset_device
---
drivers/bluetooth/btusb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 45a726bed0dd..ed5d6d0f2c1b 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1041,6 +1041,7 @@ static void btusb_reset(struct hci_dev *hdev)
}
bt_dev_err(hdev, "Resetting usb device.");
+ set_bit(BTUSB_USB_RESET_ACTIVE, &data->flags);
usb_queue_reset_device(data->intf);
}
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [v2,1/2] Bluetooth: btusb: mediatek: Fix leaked runtime PM reference in reset
2026-08-19 9:52 [PATCH v2 1/2] Bluetooth: btusb: mediatek: Fix leaked runtime PM reference in reset Jiajia Liu
2026-08-19 9:52 ` [PATCH v2 2/2] Bluetooth: btusb: Fix leaked runtime PM reference in btusb_reset Jiajia Liu
@ 2026-08-19 10:38 ` bluez.test.bot
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-08-19 10:38 UTC (permalink / raw)
To: linux-bluetooth, liujiajia
[-- Attachment #1: Type: text/plain, Size: 1181 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/project/bluetooth/list/?series=1148367
---Test result---
Test Summary:
CheckPatch PASS 1.04 seconds
VerifyFixes PASS 0.10 seconds
VerifySignedoff PASS 0.10 seconds
GitLint PASS 0.50 seconds
SubjectPrefix PASS 0.20 seconds
BuildKernel PASS 18.90 seconds
CheckAllWarning PASS 21.45 seconds
CheckSparse PASS 21.55 seconds
BuildKernel32 PASS 18.68 seconds
CheckKernelLLVM SKIP 0.00 seconds
TestRunnerSetup PASS 319.97 seconds
IncrementalBuild PASS 20.72 seconds
Details
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found
https://github.com/bluez/bluetooth-next/pull/615
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-19 10:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-19 9:52 [PATCH v2 1/2] Bluetooth: btusb: mediatek: Fix leaked runtime PM reference in reset Jiajia Liu
2026-08-19 9:52 ` [PATCH v2 2/2] Bluetooth: btusb: Fix leaked runtime PM reference in btusb_reset Jiajia Liu
2026-08-19 10:38 ` [v2,1/2] Bluetooth: btusb: mediatek: Fix leaked runtime PM reference in reset bluez.test.bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.