All of lore.kernel.org
 help / color / mirror / Atom feed
From: Swapnil Shinde <shindeswapnil028@gmail.com>
To: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	Swapnil Shinde <shindeswapnil028@gmail.com>
Subject: [PATCH] Bluetooth: btusb: Disable autosuspend and add shutdown reset for RTL8723DE
Date: Fri, 27 Nov 2026 06:16:44 +0530	[thread overview]
Message-ID: <20261127004644.8363-1-shindeswapnil028@gmail.com> (raw)

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 for 0x0bda:0xb009 during probe 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>
---
 drivers/bluetooth/btusb_main.c | 38 ++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btusb_main.c b/drivers/bluetooth/btusb_main.c
index 95398e2ca..5b1bff4ae 100644
--- a/drivers/bluetooth/btusb_main.c
+++ b/drivers/bluetooth/btusb_main.c
@@ -1016,6 +1016,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
@@ -2143,6 +2144,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))
@@ -4721,8 +4723,13 @@ 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) {
+			enable_autosuspend = false;
+		} 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);
 	}
 
@@ -5093,10 +5100,37 @@ 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);
+		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


             reply	other threads:[~2026-11-27  0:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  0:46 Swapnil Shinde [this message]
2026-11-27  4:21 ` Bluetooth: btusb: Disable autosuspend and add shutdown reset for RTL8723DE bluez.test.bot

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=20261127004644.8363-1-shindeswapnil028@gmail.com \
    --to=shindeswapnil028@gmail.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.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 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.