Re: [RFC/RFT][PATCH v2 3/7] PM / sleep: Make async suspend/resume of devices use device links

From: Rafael J. Wysocki
Date: Sat Sep 10 2016 - 18:13:10 EST


On Sat, Sep 10, 2016 at 3:31 PM, Lukas Wunner <lukas@xxxxxxxxx> wrote:
> On Thu, Sep 08, 2016 at 11:28:33PM +0200, Rafael J. Wysocki wrote:
>> Make the device suspend/resume part of the core system
>> suspend/resume code use device links to ensure that supplier
>> and consumer devices will be suspended and resumed in the right
>> order in case of async suspend/resume.
>>
>> The idea, roughly, is to use dpm_wait() to wait for all consumers
>> before a supplier device suspend and to wait for all suppliers
>> before a consumer device resume.
>
> For devices with a parent/child relationship, if the child does not
> utilize direct_complete, the parent is not allowed to utilize it
> either and is runtime resumed upon system sleep.
>
> Don't we need the same for supplier/consumer relationships?
>
> The code enforcing this is in __device_suspend() and looks like this:
>
> if (parent) {
> spin_lock_irq(&parent->power.lock);
>
> dev->parent->power.direct_complete = false;
> if (dev->power.wakeup_path
> && !dev->parent->power.ignore_children)
> dev->parent->power.wakeup_path = true;
>
> spin_unlock_irq(&parent->power.lock);
> }
>
> I guess we need to iterate over the suppliers here and execute
> the block for each of them.

You are right about the direct_complete thing, but the wakeup_path
thing is another matter. It is about forwarding wakeup signals up the
hierarchy and I'd confine it to parents at least for the time being.

Thanks,
Rafael