Hi Archie,
On Mon, Apr 22, 2024 at 3:25 AM Archie Pusaka <[email protected]> wrote:
>
> From: Archie Pusaka <[email protected]>
>
> 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 <[email protected]>
> Reviewed-by: Abhishek Pandit-Subedi <[email protected]>
>
> ---
>
> 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
There is a D-Bus interface available to overwrite the wakeup setting:
https://github.com/bluez/bluez/blob/master/doc/org.bluez.Device.rst#boolean-wakeallowed-readwrite
Or do you want a master switch for it? On the other hand aren't we
getting into the rfkill area if you really want to switch off radio
activity while suspended? That seems like a better idea then just
disable remote wakeup.
--
Luiz Augusto von Dentz
Hi Luiz,
On Thu, 25 Apr 2024 at 03:05, Luiz Augusto von Dentz
<[email protected]> wrote:
>
> Hi Archie,
>
> On Mon, Apr 22, 2024 at 3:25 AM Archie Pusaka <[email protected]> wrote:
> >
> > From: Archie Pusaka <[email protected]>
> >
> > 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 <[email protected]>
> > Reviewed-by: Abhishek Pandit-Subedi <[email protected]>
> >
> > ---
> >
> > 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
>
> There is a D-Bus interface available to overwrite the wakeup setting:
>
> https://github.com/bluez/bluez/blob/master/doc/org.bluez.Device.rst#boolean-wakeallowed-readwrite
>
> Or do you want a master switch for it? On the other hand aren't we
> getting into the rfkill area if you really want to switch off radio
> activity while suspended? That seems like a better idea then just
> disable remote wakeup.
Yes, the initial idea was a master switch.
Thanks for your suggestions.
Let me discuss it with Abhishek.
>
> --
> Luiz Augusto von Dentz
Thanks,
Archie