2013-06-09 16:28:44

by Morales, Alejandra

[permalink] [raw]
Subject: Questions about Runtime Power Management

Dear all,

I am currently involved in the implementation of my master thesis, for what I am trying to create a user space power management tool. As a part of this work I am developing a kernel module, and one of the first things I need to do is getting the current power state of some devices of my computer, essentially hard drives and network devices (ethernet and wireless cards).

For the hard drives, I get the pointers to the struct device that represents each one iterating over scsi_bus_type and selecting those whose driver is named "sd". Then, I obtain the runtime power state:

dev->power.runtime_status;

I did a test with an external USB hard drive, checking the runtime power state before and after issuing a sleep command with hdparm -Y. The drive effectively spinned down, but the runtime power state didn't change from active to suspended.

In the case of net devices, I get the corresponding structures this way:

struct net_device *netdev = first_net_device(&init_net);
? ??
while (netdev) {

struct device *dev = &netdev->dev;
? ? ? ??
/* code... */

netdev = next_net_device(netdev);
}

For every net_device I get its embedded struct device and then I check the same field as before, but in this case runtime power management is disabled, so I always get the device is suspended, even though it is configured and working properly. In fact, the whole device struct seems to be empty. ?

Taking this into account, my questions are:

- Is it possible that I am not getting the correct struct device for every hardware device?
- Am I checking the correct field of the struct dev_pm_info?
- Do scsi device drivers implement the runtime_status updates when drives effectively change their state?
- Is runtime power management supported by net devices?

Any answer would be really appreciated. Thanks in advance.

Best regards,

Alejandra Morales Ruiz
Master Thesis Student
Technische Universit?t M?nchen
Fakult?t f?r Informatik


2013-06-10 08:37:40

by Oliver Neukum

[permalink] [raw]
Subject: Re: Questions about Runtime Power Management

On Sunday 09 June 2013 16:28:21 Morales, Alejandra wrote:

> I did a test with an external USB hard drive, checking the runtime power state before and after issuing a sleep command with hdparm -Y. The drive effectively spinned down, but the runtime power state didn't change from active to suspended.

Hard disks, as opposed to USB storage devices, don't do kernel based runtime PM.
If you give a drive commands by hdparm, implementation is the job of the disk and
nothing else in the system learns about it.

> - Do scsi device drivers implement the runtime_status updates when drives effectively change their state?
> - Is runtime power management supported by net devices?
>
> Any answer would be really appreciated. Thanks in advance.

You are approaching this from the wrong side. "net device" is the function of
a device. It is effectively impossible to even define what runtime PM would mean
in that case. You need to approach the question from the side of implementation.
Is your device USB, PCI, SCSI, FibreChannel, ... ?

As far as SCSI is concerned, yes SCSI devices can do runtime PM (in principle)
The most mature implementation is USB.

You need to furthermore realise that there are forms of runtime PM independent
of the generic kernel based runtime PM (hdparm, USB LPM, ...)

HTH
Oliver

2013-06-11 07:53:15

by Morales, Alejandra

[permalink] [raw]
Subject: Re: Questions about Runtime Power Management

2013/6/10 Oliver Neukum <[email protected]>
>
> On Sunday 09 June 2013 16:28:21 Morales, Alejandra wrote:
>
> > I did a test with an external USB hard drive, checking the runtime power state before and after issuing a sleep command with hdparm -Y. The drive effectively spinned down, but the runtime power state didn't change from active to suspended.
>
> Hard disks, as opposed to USB storage devices, don't do kernel based runtime PM.
> If you give a drive commands by hdparm, implementation is the job of the disk and
> nothing else in the system learns about it.
>
> > - Do scsi device drivers implement the runtime_status updates when drives effectively change their state?
> > - Is runtime power management supported by net devices?
> >
> > Any answer would be really appreciated. Thanks in advance.
>
> You are approaching this from the wrong side. "net device" is the function of
> a device. It is effectively impossible to even define what runtime PM would mean
> in that case. You need to approach the question from the side of implementation.
> Is your device USB, PCI, SCSI, FibreChannel, ... ?
>
> As far as SCSI is concerned, yes SCSI devices can do runtime PM (in principle)
> The most mature implementation is USB.
>
> You need to furthermore realise that there are forms of runtime PM independent
> of the generic kernel based runtime PM (hdparm, USB LPM, ...)


Thanks Oliver, that was helpful. I will try now to do my testing using USB devices as it will likely be easier.

Alejandra-

2013-06-11 08:20:18

by Oliver Neukum

[permalink] [raw]
Subject: Re: Questions about Runtime Power Management

On Tuesday 11 June 2013 07:53:10 Morales, Alejandra wrote:
> 2013/6/10 Oliver Neukum <[email protected]>

> > You need to furthermore realise that there are forms of runtime PM independent
> > of the generic kernel based runtime PM (hdparm, USB LPM, ...)
>
>
> Thanks Oliver, that was helpful. I will try now to do my testing using USB devices as it will likely be easier.

Note:

1. for most usb devices the default for runtime PM is off (powertop will help)
2. all a device's interface drivers must support it (look at the kernel source for .supports_autosuspend = 1)
3. If you want the HCD to go to D3 you need ACPI 5.0

HTH
Oliver

2013-06-16 15:07:38

by Ming Lei

[permalink] [raw]
Subject: Re: Questions about Runtime Power Management

On Mon, Jun 10, 2013 at 12:28 AM, Morales, Alejandra
<[email protected]> wrote:

> - Is runtime power management supported by net devices?

Currently, 'struct net_device' doesn't support runtime power management,
and I submitted one patch to add the support for solving accessing
suspended device by 'ethtool', but it was rejected.

http://marc.info/?t=135054860600003&r=1&w=2

But the physical device of the net device can support runtime PM, for example,
some PCIe network devices support runtime PM on link change, and usbnet
devices support auto suspend.

Generally, the physical device is the parent of the net device, which is
a class device.

Thanks,
--
Ming Lei

2013-06-16 22:14:09

by Oliver Neukum

[permalink] [raw]
Subject: Re: Questions about Runtime Power Management

On Sunday 16 June 2013 23:07:36 Ming Lei wrote:
> On Mon, Jun 10, 2013 at 12:28 AM, Morales, Alejandra
> <[email protected]> wrote:
>
> > - Is runtime power management supported by net devices?
>
> Currently, 'struct net_device' doesn't support runtime power management,
> and I submitted one patch to add the support for solving accessing
> suspended device by 'ethtool', but it was rejected.
>
> http://marc.info/?t=135054860600003&r=1&w=2

And the discussion is still useful and true.

> But the physical device of the net device can support runtime PM, for example,
> some PCIe network devices support runtime PM on link change, and usbnet
> devices support auto suspend.

There is a design behind runtime PM. Runtime PM is involved if a device looses
capabilities in a power saving state. Or if it is a dependency among runtime PM
of devices. Therefore it is not used for things like Energy Efficient Ethernet.

Regards
Oliver