Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH bluetooth-next v3] Bluetooth: btusb: Fix RTL8723DE warm reboot
@ 2026-12-03  5:33 Swapnil Shinde
  2026-12-04  2:04 ` [bluetooth-next,v3] " bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Swapnil Shinde @ 2026-12-03  5:33 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: linux-bluetooth, linux-kernel, Swapnil Shinde

On Realtek RTL8723DE combo adapters (0bda:b009 / 10ec:d723), enabling
USB runtime autosuspend puts the USB Bluetooth interface into L2/D2
suspend while the PCIe Wi-Fi MAC remains active, wedging the shared
power rail across a warm reboot when Bluetooth is toggled off mid-session.
Additionally, btusb_driver omits a .shutdown callback, leaving Realtek
firmware active across kernel_restart() when Bluetooth remains active.

Disable USB autosuspend per-device for 0x0bda:0xb009 during probe (and
re-enable it on disconnect), set HCI_QUIRK_NON_PERSISTENT_SETUP so
turning Bluetooth off and back on mid-session reloads firmware cleanly,
and add a .shutdown callback to clear remote wakeup, reset active
controllers, and stop USB URBs cleanly on reboot.

Signed-off-by: Swapnil Shinde <shindeswapnil028@gmail.com>
---
Changes in v3:
- Shorten commit title to satisfy the 80-character gitlint limit.

Changes in v2:
- Use per-device usb_disable_autosuspend() in btusb_probe() paired with
  usb_enable_autosuspend() in btusb_disconnect() instead of mutating
  module-global enable_autosuspend.
- Set HCI_QUIRK_NON_PERSISTENT_SETUP for 0x0bda:0xb009 so firmware is
  reloaded cleanly across userspace Bluetooth off -> on toggles.
- Guard hdev->shutdown() with if (!err) after usb_autopm_get_interface()
  in btusb_shutdown().
- Confirmed across cold boots, consecutive warm reboots, and runtime
  radio toggles on RTL8723DE with stock rtw88 (no rtw88 changes needed).

Full dmesg logs and reboot state test matrix:
https://github.com/sudo-WearTherinG/linux-rtl8723de-driver-patch

 drivers/bluetooth/btusb_main.c | 44 ++++++++++++++++++++++++++++++++--
 1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btusb_main.c b/drivers/bluetooth/btusb_main.c
index 7d510c3..6be87d2 100644
--- a/drivers/bluetooth/btusb_main.c
+++ b/drivers/bluetooth/btusb_main.c
@@ -1018,6 +1018,7 @@ struct btqca_data {
 #define BTUSB_HW_SSR_ACTIVE	17
 #define BTUSB_WAKEUP_BROKEN	18
 #define BTUSB_RESET		19
+#define BTUSB_NEEDS_SHUTDOWN_RESET	20
 
 #define BTUSB_PROTO_LEGACY	0x00
 #define BTUSB_PROTO_H4		0x01
@@ -2157,6 +2158,7 @@ static int btusb_open(struct hci_dev *hdev)
 	}
 
 	data->intf->needs_remote_wakeup = 1;
+	set_bit(BTUSB_NEEDS_SHUTDOWN_RESET, &data->flags);
 
 	if (data->proto == BTUSB_PROTO_LEGACY) {
 		if (test_and_set_bit(BTUSB_INTR_RUNNING, &data->flags))
@@ -4735,8 +4737,14 @@ static int btusb_probe(struct usb_interface *intf,
 		hdev->reset = btusb_rtl_reset;
 		hdev->hw_error = btusb_rtl_hw_error;
 
-		/* Realtek devices need to set remote wakeup on auto-suspend */
-		set_bit(BTUSB_WAKEUP_AUTOSUSPEND, &data->flags);
+		if (le16_to_cpu(data->udev->descriptor.idVendor) == 0x0bda &&
+		    le16_to_cpu(data->udev->descriptor.idProduct) == 0xb009) {
+			usb_disable_autosuspend(data->udev);
+			hci_set_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_SETUP);
+		} else {
+			/* Realtek devices need to set remote wakeup on auto-suspend */
+			set_bit(BTUSB_WAKEUP_AUTOSUSPEND, &data->flags);
+		}
 		set_bit(BTUSB_USE_ALT3_FOR_WBS, &data->flags);
 	}
 
@@ -4879,6 +4887,10 @@ static void btusb_disconnect(struct usb_interface *intf)
 	if (!data)
 		return;
 
+	if (le16_to_cpu(data->udev->descriptor.idVendor) == 0x0bda &&
+	    le16_to_cpu(data->udev->descriptor.idProduct) == 0xb009)
+		usb_enable_autosuspend(data->udev);
+
 	debugfs_remove(data->force_poll_sync_dentry);
 	data->force_poll_sync_dentry = NULL;
 
@@ -5105,10 +5117,38 @@ static void btusb_coredump(struct device *dev)
 }
 #endif
 
+static void btusb_shutdown(struct usb_interface *intf)
+{
+	struct btusb_data *data = usb_get_intfdata(intf);
+	struct hci_dev *hdev;
+	int err = -1;
+
+	if (!data || intf != data->intf)
+		return;
+
+	hdev = data->hdev;
+	data->intf->needs_remote_wakeup = 0;
+	data->udev->do_remote_wakeup = 0;
+
+	if (test_and_clear_bit(BTUSB_NEEDS_SHUTDOWN_RESET, &data->flags) &&
+	    hdev->shutdown) {
+		err = usb_autopm_get_interface(data->intf);
+		if (!err)
+			hdev->shutdown(hdev);
+	}
+
+	btusb_stop_traffic(data);
+	usb_kill_anchored_urbs(&data->tx_anchor);
+
+	if (!err)
+		usb_autopm_put_interface(data->intf);
+}
+
 static struct usb_driver btusb_driver = {
 	.name		= "btusb",
 	.probe		= btusb_probe,
 	.disconnect	= btusb_disconnect,
+	.shutdown	= btusb_shutdown,
 	.suspend	= pm_ptr(btusb_suspend),
 	.resume		= pm_ptr(btusb_resume),
 	.id_table	= btusb_table,
-- 
2.56.0


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

* RE: [bluetooth-next,v3] Bluetooth: btusb: Fix RTL8723DE warm reboot
  2026-12-03  5:33 [PATCH bluetooth-next v3] Bluetooth: btusb: Fix RTL8723DE warm reboot Swapnil Shinde
@ 2026-12-04  2:04 ` bluez.test.bot
  0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-12-04  2:04 UTC (permalink / raw)
  To: linux-bluetooth, shindeswapnil028

[-- Attachment #1: Type: text/plain, Size: 1020 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/1230190/

---Test result---

Test Summary:
CheckPatch                    PASS      0.46 seconds
VerifyFixes                   PASS      0.08 seconds
VerifySignedoff               PASS      0.08 seconds
GitLint                       PASS      0.20 seconds
SubjectPrefix                 PASS      0.07 seconds
BuildKernel                   PASS      17.48 seconds
CheckAllWarning               PASS      20.13 seconds
CheckSparse                   PASS      21.75 seconds
BuildKernel32                 PASS      17.54 seconds
CheckKernelLLVM               PASS      18.01 seconds
TestRunnerSetup               PASS      402.92 seconds
IncrementalBuild              PASS      16.50 seconds



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

---
Regards,
Linux Bluetooth


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

end of thread, other threads:[~2026-12-04  2:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  5:33 [PATCH bluetooth-next v3] Bluetooth: btusb: Fix RTL8723DE warm reboot Swapnil Shinde
2026-12-04  2:04 ` [bluetooth-next,v3] " bluez.test.bot

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