linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: Fix the autosuspend enable and disable
@ 2021-02-03  8:02 Hui Wang
  2021-02-03  9:20 ` bluez.test.bot
  2021-02-03 13:34 ` [PATCH] " Marcel Holtmann
  0 siblings, 2 replies; 3+ messages in thread
From: Hui Wang @ 2021-02-03  8:02 UTC (permalink / raw)
  To: linux-bluetooth, marcel; +Cc: hui.wang

I tried to disable the autosuspend on btusb through the module
parameter enable_autosuspend, this parameter is set to N, but the usb
bluetooth device is still runtime suspended.
$ cat /sys/module/btusb/parameters/enable_autosuspend
N
$ cat /sys/bus/usb/devices/3-10/power/runtime_status
suspended
$ cat /sys/bus/usb/devices/3-10/power/runtime_suspended_time
65187

We already set ".supports_autosuspend = 1" in the usb_driver, this
device will be set autosuspend enabled by usb core, we don't need
to call usb_enable_autosuspend() in the btusb_probe(). Instead if
users set the parameter enable_autosuspend to N, we need to call
usb_disable_autosuspend() in the btusb_probe(). After this change
and set the parameter to N, we could see the device is not runtime
suspended anymore.
$ cat /sys/module/btusb/parameters/enable_autosuspend
N
$ cat /sys/bus/usb/devices/3-10/power/runtime_status
active
$ cat /sys/bus/usb/devices/3-10/power/runtime_suspended_time
0

And if we disable the autosuspend in the btusb_probe(), we need to
enable the autosuspend in the disconnect(), this could guarantee
that the device could be runtime suspended after we rmmod the btusb.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 drivers/bluetooth/btusb.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index b14102fba601..e019a6d6e934 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -4639,8 +4639,8 @@ static int btusb_probe(struct usb_interface *intf,
 			data->diag = NULL;
 	}
 
-	if (enable_autosuspend)
-		usb_enable_autosuspend(data->udev);
+	if (!enable_autosuspend)
+		usb_disable_autosuspend(data->udev);
 
 	err = hci_register_dev(hdev);
 	if (err < 0)
@@ -4700,6 +4700,9 @@ static void btusb_disconnect(struct usb_interface *intf)
 		gpiod_put(data->reset_gpio);
 
 	hci_free_dev(hdev);
+
+	if (!enable_autosuspend)
+		usb_enable_autosuspend(data->udev);
 }
 
 #ifdef CONFIG_PM
-- 
2.25.1


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

* RE: Bluetooth: btusb: Fix the autosuspend enable and disable
  2021-02-03  8:02 [PATCH] Bluetooth: btusb: Fix the autosuspend enable and disable Hui Wang
@ 2021-02-03  9:20 ` bluez.test.bot
  2021-02-03 13:34 ` [PATCH] " Marcel Holtmann
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2021-02-03  9:20 UTC (permalink / raw)
  To: linux-bluetooth, hui.wang

[-- Attachment #1: Type: text/plain, Size: 1599 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=426817

---Test result---

##############################
    Test: CheckPatch - PASS
    

    ##############################
    Test: CheckGitLint - PASS
    

    ##############################
    Test: CheckBuildK - PASS
    

    ##############################
    Test: CheckTestRunner: Setup - PASS
    

    ##############################
    Test: CheckTestRunner: l2cap-tester - PASS
    Total: 40, Passed: 34 (85.0%), Failed: 0, Not Run: 6

    ##############################
    Test: CheckTestRunner: bnep-tester - PASS
    Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0

    ##############################
    Test: CheckTestRunner: mgmt-tester - PASS
    Total: 416, Passed: 398 (95.7%), Failed: 0, Not Run: 18

    ##############################
    Test: CheckTestRunner: rfcomm-tester - PASS
    Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0

    ##############################
    Test: CheckTestRunner: sco-tester - PASS
    Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0

    ##############################
    Test: CheckTestRunner: smp-tester - PASS
    Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0

    ##############################
    Test: CheckTestRunner: userchan-tester - PASS
    Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0

    

---
Regards,
Linux Bluetooth


[-- Attachment #2: l2cap-tester.log --]
[-- Type: application/octet-stream, Size: 43341 bytes --]

[-- Attachment #3: bnep-tester.log --]
[-- Type: application/octet-stream, Size: 3532 bytes --]

[-- Attachment #4: mgmt-tester.log --]
[-- Type: application/octet-stream, Size: 546153 bytes --]

[-- Attachment #5: rfcomm-tester.log --]
[-- Type: application/octet-stream, Size: 11652 bytes --]

[-- Attachment #6: sco-tester.log --]
[-- Type: application/octet-stream, Size: 9887 bytes --]

[-- Attachment #7: smp-tester.log --]
[-- Type: application/octet-stream, Size: 11798 bytes --]

[-- Attachment #8: userchan-tester.log --]
[-- Type: application/octet-stream, Size: 5428 bytes --]

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

* Re: [PATCH] Bluetooth: btusb: Fix the autosuspend enable and disable
  2021-02-03  8:02 [PATCH] Bluetooth: btusb: Fix the autosuspend enable and disable Hui Wang
  2021-02-03  9:20 ` bluez.test.bot
@ 2021-02-03 13:34 ` Marcel Holtmann
  1 sibling, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2021-02-03 13:34 UTC (permalink / raw)
  To: Hui Wang; +Cc: linux-bluetooth

Hi Hui,

> I tried to disable the autosuspend on btusb through the module
> parameter enable_autosuspend, this parameter is set to N, but the usb
> bluetooth device is still runtime suspended.
> $ cat /sys/module/btusb/parameters/enable_autosuspend
> N
> $ cat /sys/bus/usb/devices/3-10/power/runtime_status
> suspended
> $ cat /sys/bus/usb/devices/3-10/power/runtime_suspended_time
> 65187
> 
> We already set ".supports_autosuspend = 1" in the usb_driver, this
> device will be set autosuspend enabled by usb core, we don't need
> to call usb_enable_autosuspend() in the btusb_probe(). Instead if
> users set the parameter enable_autosuspend to N, we need to call
> usb_disable_autosuspend() in the btusb_probe(). After this change
> and set the parameter to N, we could see the device is not runtime
> suspended anymore.
> $ cat /sys/module/btusb/parameters/enable_autosuspend
> N
> $ cat /sys/bus/usb/devices/3-10/power/runtime_status
> active
> $ cat /sys/bus/usb/devices/3-10/power/runtime_suspended_time
> 0
> 
> And if we disable the autosuspend in the btusb_probe(), we need to
> enable the autosuspend in the disconnect(), this could guarantee
> that the device could be runtime suspended after we rmmod the btusb.
> 
> Signed-off-by: Hui Wang <hui.wang@canonical.com>
> ---
> drivers/bluetooth/btusb.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


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

end of thread, other threads:[~2021-02-03 13:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03  8:02 [PATCH] Bluetooth: btusb: Fix the autosuspend enable and disable Hui Wang
2021-02-03  9:20 ` bluez.test.bot
2021-02-03 13:34 ` [PATCH] " Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).