All of lore.kernel.org
 help / color / mirror / Atom feed
* Auto suspend not working on usb hid devices
@ 2015-01-11 13:23 vichy
  2015-01-11 15:53 ` Alan Stern
  0 siblings, 1 reply; 10+ messages in thread
From: vichy @ 2015-01-11 13:23 UTC (permalink / raw)
  To: linux-pm

hi all:
I list below environment I have that autosuspend seems doesn't work on
my platform.
1. kernel version 3.10.30
2. compile kernel with CONFIG_PM_RUNTIME=y
3. "echo 'rpm:rpm_suspend' > set_event"
4. insert hid devices and "echo auto > /sys/bus/usb/devices/6-1/power/control"
5. there is no any usb related runtime suspend output in trace.

Did I miss any kernel configuration to let it work?
Or where is the proper debug entry I can check why rpm_suspend isn't
been called on my system?

appreciate your help in advance,

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

* Re: Auto suspend not working on usb hid devices
  2015-01-11 13:23 Auto suspend not working on usb hid devices vichy
@ 2015-01-11 15:53 ` Alan Stern
  2015-01-12 10:45   ` vichy
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Stern @ 2015-01-11 15:53 UTC (permalink / raw)
  To: vichy; +Cc: linux-pm

On Sun, 11 Jan 2015, vichy wrote:

> hi all:
> I list below environment I have that autosuspend seems doesn't work on
> my platform.
> 1. kernel version 3.10.30
> 2. compile kernel with CONFIG_PM_RUNTIME=y
> 3. "echo 'rpm:rpm_suspend' > set_event"
> 4. insert hid devices and "echo auto > /sys/bus/usb/devices/6-1/power/control"
> 5. there is no any usb related runtime suspend output in trace.
> 
> Did I miss any kernel configuration to let it work?
> Or where is the proper debug entry I can check why rpm_suspend isn't
> been called on my system?

There are lots of reasons why a device might not be runtime suspended.  
There is no single debug entry that presents them.  Some information 
can be seen in the files in the device's /sys/.../power directory.

Alan Stern


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

* Re: Auto suspend not working on usb hid devices
  2015-01-11 15:53 ` Alan Stern
@ 2015-01-12 10:45   ` vichy
  2015-01-12 12:45     ` vichy
  0 siblings, 1 reply; 10+ messages in thread
From: vichy @ 2015-01-12 10:45 UTC (permalink / raw)
  To: Alan Stern; +Cc: linux-pm

hi alan:

2015-01-11 23:53 GMT+08:00 Alan Stern <stern@rowland.harvard.edu>:
> On Sun, 11 Jan 2015, vichy wrote:
>
>> hi all:
>> I list below environment I have that autosuspend seems doesn't work on
>> my platform.
>> 1. kernel version 3.10.30
>> 2. compile kernel with CONFIG_PM_RUNTIME=y
>> 3. "echo 'rpm:rpm_suspend' > set_event"
>> 4. insert hid devices and "echo auto > /sys/bus/usb/devices/6-1/power/control"
>> 5. there is no any usb related runtime suspend output in trace.
>>
>> Did I miss any kernel configuration to let it work?
>> Or where is the proper debug entry I can check why rpm_suspend isn't
>> been called on my system?
>
> There are lots of reasons why a device might not be runtime suspended.
> There is no single debug entry that presents them.  Some information
> can be seen in the files in the device's /sys/.../power directory.

I found the power/runtime_usage = 2 when device plug in and do nothing.
Except update_autosuspend will increase runtime_usage, is there any
function will increase it when we did not enable runtime
suspend/resume?

Thanks for your kind help,

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

* Re: Auto suspend not working on usb hid devices
  2015-01-12 10:45   ` vichy
@ 2015-01-12 12:45     ` vichy
  2015-01-12 15:18       ` Alan Stern
  0 siblings, 1 reply; 10+ messages in thread
From: vichy @ 2015-01-12 12:45 UTC (permalink / raw)
  To: Alan Stern; +Cc: linux-pm

hi alan:
> I found the power/runtime_usage = 2 when device plug in and do nothing.
> Except update_autosuspend will increase runtime_usage, is there any
> function will increase it when we did not enable runtime
> suspend/resume?
We found the runtime_usage will be 2 after calling usb_new_device.
in usb_new_device,
        pm_runtime_set_active(&udev->dev);
        pm_runtime_get_noresume(&udev->dev);  // after calling left
function, runtime_usage =1
        pm_runtime_use_autosuspend(&udev->dev);
        pm_runtime_enable(&udev->dev);

       /* By default, forbid autosuspend for all devices.  It will be
        * allowed for hubs during binding.
        */
       usb_disable_autosuspend(udev); // after calling left function,
runtime_usage =2

Under what circumstance, the runtime_usage will be 1 to let "echo auto
> power/control" work?
appreciate your kind help,

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

* Re: Auto suspend not working on usb hid devices
  2015-01-12 12:45     ` vichy
@ 2015-01-12 15:18       ` Alan Stern
  2015-01-13  9:35         ` vichy
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Stern @ 2015-01-12 15:18 UTC (permalink / raw)
  To: vichy; +Cc: linux-pm

On Mon, 12 Jan 2015, vichy wrote:

> hi alan:
> > I found the power/runtime_usage = 2 when device plug in and do nothing.
> > Except update_autosuspend will increase runtime_usage, is there any
> > function will increase it when we did not enable runtime
> > suspend/resume?
> We found the runtime_usage will be 2 after calling usb_new_device.
> in usb_new_device,
>         pm_runtime_set_active(&udev->dev);
>         pm_runtime_get_noresume(&udev->dev);  // after calling left
> function, runtime_usage =1
>         pm_runtime_use_autosuspend(&udev->dev);
>         pm_runtime_enable(&udev->dev);
> 
>        /* By default, forbid autosuspend for all devices.  It will be
>         * allowed for hubs during binding.
>         */
>        usb_disable_autosuspend(udev); // after calling left function,
> runtime_usage =2
> 
> Under what circumstance, the runtime_usage will be 1 to let "echo auto
> > power/control" work?

You need to look farther down in usb_new_device().  Near the end it 
does this:

	(void) usb_create_ep_devs(&udev->dev, &udev->ep0, udev);
	usb_mark_last_busy(udev);
	pm_runtime_put_sync_autosuspend(&udev->dev);
	return err;

The pm_runtime_put_async_autosuspend() call decrements runtime_usage 
back to 1.

Alan Stern


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

* Re: Auto suspend not working on usb hid devices
  2015-01-12 15:18       ` Alan Stern
@ 2015-01-13  9:35         ` vichy
  2015-01-13 12:11           ` vichy
  2015-01-13 15:37           ` Alan Stern
  0 siblings, 2 replies; 10+ messages in thread
From: vichy @ 2015-01-13  9:35 UTC (permalink / raw)
  To: Alan Stern; +Cc: linux-pm

hi alan:

2015-01-12 23:18 GMT+08:00 Alan Stern <stern@rowland.harvard.edu>:
> On Mon, 12 Jan 2015, vichy wrote:
>
>> hi alan:
>> > I found the power/runtime_usage = 2 when device plug in and do nothing.
>> > Except update_autosuspend will increase runtime_usage, is there any
>> > function will increase it when we did not enable runtime
>> > suspend/resume?
>> We found the runtime_usage will be 2 after calling usb_new_device.
>> in usb_new_device,
>>         pm_runtime_set_active(&udev->dev);
>>         pm_runtime_get_noresume(&udev->dev);  // after calling left
>> function, runtime_usage =1
>>         pm_runtime_use_autosuspend(&udev->dev);
>>         pm_runtime_enable(&udev->dev);
>>
>>        /* By default, forbid autosuspend for all devices.  It will be
>>         * allowed for hubs during binding.
>>         */
>>        usb_disable_autosuspend(udev); // after calling left function,
>> runtime_usage =2
>>
>> Under what circumstance, the runtime_usage will be 1 to let "echo auto
>> > power/control" work?
>
> You need to look farther down in usb_new_device().  Near the end it
> does this:
>
>         (void) usb_create_ep_devs(&udev->dev, &udev->ep0, udev);
>         usb_mark_last_busy(udev);
>         pm_runtime_put_sync_autosuspend(&udev->dev);
>         return err;
>
> The pm_runtime_put_async_autosuspend() call decrements runtime_usage
> back to 1.
I purposely dump runtime_usage after calling
pm_runtime_put_async_autosuspend(), but the value is still 2.
I found the value increase/decrease like below:
pm_runtime_get_noresume => 1
usb_disable_autosuspend => 2
usb_probe_device
    -> usb_autoresume_device => 3
usb_set_configuration
    ->usb_autoresume_device =>4
usb_set_configuration
    ->usb_autosuspend_device =>3
pm_runtime_put_sync_autosuspend => 2

so even after calling pm_runtime_put_async_autosuspend() at end fo
usb_new_device()
the runtime_usage will not be back to 1

Appreciate your kind help,

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

* Re: Auto suspend not working on usb hid devices
  2015-01-13  9:35         ` vichy
@ 2015-01-13 12:11           ` vichy
  2015-01-13 15:37           ` Alan Stern
  1 sibling, 0 replies; 10+ messages in thread
From: vichy @ 2015-01-13 12:11 UTC (permalink / raw)
  To: Alan Stern; +Cc: linux-pm

hi alan:


>> The pm_runtime_put_async_autosuspend() call decrements runtime_usage
>> back to 1.
> I purposely dump runtime_usage after calling
> pm_runtime_put_async_autosuspend(), but the value is still 2.
> I found the value increase/decrease like below:
> pm_runtime_get_noresume => 1
> usb_disable_autosuspend => 2
> usb_probe_device
>     -> usb_autoresume_device => 3
> usb_set_configuration
>     ->usb_autoresume_device =>4
> usb_set_configuration
>     ->usb_autosuspend_device =>3
> pm_runtime_put_sync_autosuspend => 2
>
> so even after calling pm_runtime_put_async_autosuspend() at end fo
> usb_new_device()
> the runtime_usage will not be back to 1

is there any rule for us to determine where we add those
usb_autoresume_device/usb_autosuspend_device in usb driver?

Sincerely appreciate your help,

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

* Re: Auto suspend not working on usb hid devices
  2015-01-13  9:35         ` vichy
  2015-01-13 12:11           ` vichy
@ 2015-01-13 15:37           ` Alan Stern
  2015-01-16 11:21             ` vichy
  1 sibling, 1 reply; 10+ messages in thread
From: Alan Stern @ 2015-01-13 15:37 UTC (permalink / raw)
  To: vichy; +Cc: linux-pm

On Tue, 13 Jan 2015, vichy wrote:

> I purposely dump runtime_usage after calling
> pm_runtime_put_async_autosuspend(), but the value is still 2.
> I found the value increase/decrease like below:

In usb_new_device():
> pm_runtime_get_noresume => 1
> usb_disable_autosuspend => 2
> usb_probe_device
>     -> usb_autoresume_device => 3

That's where you go wrong.  usb_probe_device() does this:

	if (!udriver->supports_autosuspend)
		error = usb_autoresume_device(udev);

and udriver->supports_autosuspend should be 1.  See the definition of 
usb_generic_driver at the end of generic.c.

> usb_set_configuration
>     ->usb_autoresume_device =>4
> usb_set_configuration
>     ->usb_autosuspend_device =>3
> pm_runtime_put_sync_autosuspend => 2
> 
> so even after calling pm_runtime_put_async_autosuspend() at end fo
> usb_new_device()
> the runtime_usage will not be back to 1

It would be 1 if udriver in usb_probe_device() was equal to 
usb_generic_driver.

> is there any rule for us to determine where we add those
> usb_autoresume_device/usb_autosuspend_device in usb driver?

The rule is very simple: You autoresume in places where you need the 
device to be active, and you autosuspend when you don't need the device 
to be active any more.

Alan Stern



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

* Re: Auto suspend not working on usb hid devices
  2015-01-13 15:37           ` Alan Stern
@ 2015-01-16 11:21             ` vichy
  2015-01-16 15:23               ` Alan Stern
  0 siblings, 1 reply; 10+ messages in thread
From: vichy @ 2015-01-16 11:21 UTC (permalink / raw)
  To: Alan Stern; +Cc: linux-pm

hi alan:

2015-01-13 23:37 GMT+08:00 Alan Stern <stern@rowland.harvard.edu>:
> On Tue, 13 Jan 2015, vichy wrote:
>
>> I purposely dump runtime_usage after calling
>> pm_runtime_put_async_autosuspend(), but the value is still 2.
>> I found the value increase/decrease like below:
>
> In usb_new_device():
>> pm_runtime_get_noresume => 1
>> usb_disable_autosuspend => 2
>> usb_probe_device
>>     -> usb_autoresume_device => 3
>
> That's where you go wrong.  usb_probe_device() does this:
>
>         if (!udriver->supports_autosuspend)
>                 error = usb_autoresume_device(udev);
>
> and udriver->supports_autosuspend should be 1.  See the definition of
> usb_generic_driver at the end of generic.c.
>
>> usb_set_configuration
>>     ->usb_autoresume_device =>4
>> usb_set_configuration
>>     ->usb_autosuspend_device =>3
>> pm_runtime_put_sync_autosuspend => 2
>>
>> so even after calling pm_runtime_put_async_autosuspend() at end fo
>> usb_new_device()
>> the runtime_usage will not be back to 1
>
> It would be 1 if udriver in usb_probe_device() was equal to
> usb_generic_driver.
>
>> is there any rule for us to determine where we add those
>> usb_autoresume_device/usb_autosuspend_device in usb driver?
>
> The rule is very simple: You autoresume in places where you need the
> device to be active, and you autosuspend when you don't need the device
> to be active any more.
>
I found the usb storage interface driver also set supports_autosuspend
=1 and I found the runtime_usage =1 .
But the device doesn't go into runtime suspend, even I put control as auto.
is there any condition purposely abandon usb storage device to do so?
sincerely thanks for your help,

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

* Re: Auto suspend not working on usb hid devices
  2015-01-16 11:21             ` vichy
@ 2015-01-16 15:23               ` Alan Stern
  0 siblings, 0 replies; 10+ messages in thread
From: Alan Stern @ 2015-01-16 15:23 UTC (permalink / raw)
  To: vichy; +Cc: linux-pm

On Fri, 16 Jan 2015, vichy wrote:

> I found the usb storage interface driver also set supports_autosuspend
> =1 and I found the runtime_usage =1 .
> But the device doesn't go into runtime suspend, even I put control as auto.
> is there any condition purposely abandon usb storage device to do so?

In order to suspend a USB storage device, you have to enable suspend 
not just for that device but also for all its children.  In particular, 
if the device is a disk or flash drive then you have to enable suspend 
for the corresponding SCSI device.

Alan Stern


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

end of thread, other threads:[~2015-01-16 15:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-11 13:23 Auto suspend not working on usb hid devices vichy
2015-01-11 15:53 ` Alan Stern
2015-01-12 10:45   ` vichy
2015-01-12 12:45     ` vichy
2015-01-12 15:18       ` Alan Stern
2015-01-13  9:35         ` vichy
2015-01-13 12:11           ` vichy
2015-01-13 15:37           ` Alan Stern
2015-01-16 11:21             ` vichy
2015-01-16 15:23               ` Alan Stern

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.