All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: Add debugfs to force toggling remote wakeup
@ 2024-04-22  7:25 Archie Pusaka
  2024-04-22  7:56 ` bluez.test.bot
  2024-04-24 19:04 ` [PATCH] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 10+ messages in thread
From: Archie Pusaka @ 2024-04-22  7:25 UTC (permalink / raw)
  To: linux-bluetooth, Luiz Augusto von Dentz, Johan Hedberg,
	Marcel Holtmann
  Cc: CrosBT Upstreaming, Archie Pusaka, Abhishek Pandit-Subedi,
	linux-kernel

From: Archie Pusaka <apusaka@chromium.org>

Sometimes we want the controller to not wake the host up, e.g. to
save the battery. Add some debugfs knobs to force the wake by BT
behavior.

Signed-off-by: Archie Pusaka <apusaka@chromium.org>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@google.com>

---

 drivers/bluetooth/btusb.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 8bede0a335668..846b15fc3c04c 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -873,6 +873,9 @@ struct btusb_data {
 	unsigned cmd_timeout_cnt;
 
 	struct qca_dump_info qca_dump;
+
+	bool force_enable_remote_wake;
+	bool force_disable_remote_wake;
 };
 
 static void btusb_reset(struct hci_dev *hdev)
@@ -4596,6 +4599,10 @@ static int btusb_probe(struct usb_interface *intf,
 
 	debugfs_create_file("force_poll_sync", 0644, hdev->debugfs, data,
 			    &force_poll_sync_fops);
+	debugfs_create_bool("force_enable_remote_wake", 0644, hdev->debugfs,
+			    &data->force_enable_remote_wake);
+	debugfs_create_bool("force_disable_remote_wake", 0644, hdev->debugfs,
+			    &data->force_disable_remote_wake);
 
 	return 0;
 
@@ -4702,6 +4709,18 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
 		}
 	}
 
+	if (!PMSG_IS_AUTO(message)) {
+		if (data->force_enable_remote_wake) {
+			data->udev->do_remote_wakeup = 1;
+			if (test_bit(BTUSB_WAKEUP_AUTOSUSPEND, &data->flags))
+				data->udev->reset_resume = 0;
+		} else if (data->force_disable_remote_wake) {
+			data->udev->do_remote_wakeup = 0;
+			if (test_bit(BTUSB_WAKEUP_AUTOSUSPEND, &data->flags))
+				data->udev->reset_resume = 1;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.44.0.769.g3c40516874-goog


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

end of thread, other threads:[~2024-06-06 12:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-22  7:25 [PATCH] Bluetooth: btusb: Add debugfs to force toggling remote wakeup Archie Pusaka
2024-04-22  7:56 ` bluez.test.bot
2024-04-24 19:04 ` [PATCH] " Luiz Augusto von Dentz
2024-04-26  9:08   ` Archie Pusaka
2024-04-26 17:04     ` Abhishek Pandit-Subedi
2024-04-30 16:45       ` Luiz Augusto von Dentz
2024-05-01 16:34         ` Abhishek Pandit-Subedi
2024-05-01 16:52           ` Luiz Augusto von Dentz
2024-05-01 16:57             ` Abhishek Pandit-Subedi
2024-06-06 12:21               ` Archie Pusaka

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.