Re: /sys/devices/.../power/state broken?

Alan Stern
2006-12-12T15:42:12Z

On Tue, 12 Dec 2006, Brice Goglin wrote:

> Hi,
>
> I know that .../power/state files are deprecated, but I like using them
> for basic testing of a driver's suspend/resume routines. Anyway, echoing
> something in the .../power/state in current -git does not seem to work
> anymore.

It does work, but the results depend on the device you want to suspend.
For instance, USB devices have no problem at all. PCI devices will ignore
your writes because .../power/state can't handle the new multi-stage
suspend and resume mechanism.

I've been using the patch below to force my tests to work. The fact
remains, this way of doing things won't be valid much longer.

> For instance, the driver's suspend routine is not called
> anymore when writing 3 while it was at least in 2.6.17 and 2.6.18. And
> reading the contents of the file afterwards now returns 0 while it
> seemed to return 2 before.
>
> I didn't have time to git-bisect the problem so far, I will if nobody
> has any idea.
>
> And if somebody knows what to use instead of .../power/state to test a
> driver's suspend/resume, I'd be happy to hear it too. The explanation in
> feature-removal-schedule.txt did not help a lot, neither did the thread
> I found on linux-pm :)

There is no general-purpose replacement. Probably each bus will end up
implementing its own special-purpose sysfs interface for suspend/resume
(or not, as the case may be).

Alan Stern

Index: usb-2.6/drivers/base/power/sysfs.c
===================================================================
--- usb-2.6.orig/drivers/base/power/sysfs.c
+++ usb-2.6/drivers/base/power/sysfs.c
@@ -45,10 +45,6 @@ static ssize_t state_store(struct device
pm_message_t state;
int error = -EINVAL;

- /* disallow incomplete suspend sequences */
- if (dev->bus && (dev->bus->suspend_late || dev->bus->resume_early))
- return error;
-
state.event = PM_EVENT_SUSPEND;
/* Older apps expected to write "3" here - confused with PCI D3 */
if ((n == 1) && !strcmp(buf, "3"))