Re: [PATCH v2] PM / sleep: Let devices force direct_complete

From: Alan Stern
Date: Thu May 14 2015 - 14:13:05 EST


On Thu, 14 May 2015, Tomeu Vizoso wrote:

> Introduce a new per-device flag power.force_direct_complete that will
> instruct the PM core to let that device remain in runtime suspend when
> the system goes into a sleep power state, regardless of the PM state of
> any of its descendants.
>
> This is needed because otherwise it would be needed to get dozens of
> drivers to implement the prepare() callback and be runtime PM active
> even if they don't have a 1-to-1 relationship with a piece of HW.
>
> This only applies to devices that aren't wakeup-capable, as those would
> need to setup their IRQs as wakeup-capable in their prepare() callbacks.
>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@xxxxxxxxxxxxx>

There's one little problem in this...

> @@ -1605,9 +1607,13 @@ static int device_prepare(struct device *dev, pm_message_t state)
> * will do the same thing with all of its descendants". This only
> * applies to suspend transitions, however.
> */
> - spin_lock_irq(&dev->power.lock);
> - dev->power.direct_complete = ret > 0 && state.event == PM_EVENT_SUSPEND;
> - spin_unlock_irq(&dev->power.lock);
> + if (state.event == PM_EVENT_SUSPEND) {
> + spin_lock_irq(&dev->power.lock);
> + dev->power.direct_complete = ret > 0 ||
> + (dev->power.force_direct_complete &&
> + !device_can_wakeup(dev));
> + spin_unlock_irq(&dev->power.lock);
> + }

When state.event is not PM_EVENT_SUSPEND, this fails to set
dev->power.direct_complete to 0. Sticking closer to the original code
arrangement would help.

Aside from that small issue:

Acked-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>

Alan Stern


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/