Re: [RFC/RFT][PATCH -mm 1/4] PM: Introduce set_target method in pm_ops

David Brownell
2007-06-25T02:11:17Z

On Sunday 24 June 2007, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rjw@sisk.pl>
>
> Some drivers may need to use ACPI to determine the low power states in which
> to place their devices, but to provide the drivers with this information the
> ACPI core needs to know what sleep state the system is going to enter.

It also needs to export that to things like the ACPI-to-PCI glue
code. So it would be good if you defined the missing routine now,
saving the effort of patching it in later:

int acpi_get_target_sleep_state(void);

It doesn't need EXPORT_SYMBOL().

> Namely, the device's state should not be too high power for given system sleep
> state and, if the device is supposed to be able to wake up the system, its state
> should not be too low power for the wake up to be possible). However,
> pm_ops->prepare() is only called after the drivers' .suspend() callbacks have
> been executed,

That's a critical point that should show up in your doc updates.

> so we need an additional means to pass the information of the
> target system sleep state to the ACPI core. For this purpose, we can introduce
> an additional member function in 'struct pm_ops'.
>
> Additionally, the at91 platform code incorrectly assumes that pm_ops->prepare()
> will be called before devices are suspended and uses it for setting the target
> system sleep state, so pm_ops->prepare() should to be replaced with the new
> operation, pm_ops->set_target(), for this architecture.

That was originally correct ... but as you pointed out, the
semantics there changed in RC5.

Which means this patch is a *BUGFIX*, preventing what would
otherwise be a regression in 2.6.22 ... and so it should
be merged for RC6 or so.

Another way to describe the changes is that set_target() now
does what prepare() used to do, while prepare() serves a
new role. A role which still needs to be well-described in
the documentation you provided, by the way... it seems to
do whatever needs to be done after devices suspend but
before nonboot CPUs are disabled.

- Dave