Re: [PATCH 3/5] PM: runtime: Propagate last_busy from dependent to dependency

From: Andy Shevchenko

Date: Sat Oct 03 2026 - 11:22:07 EST


On Fri, Oct 02, 2026 at 04:03:07PM -0700, Brian Norris wrote:
> When a child device suspends, it does not update the last_busy timestamp
> for its parent. If that parent configured autosuspend and didn't
> otherwise maintain its last_busy timestamp, it may now be immediately
> eligible to suspend. This is probably not expected -- the parent should
> wait for its autosuspend delay before suspending.
>
> The effect of this behavior is that a parent device may suspend sooner
> than its autosuspend delay, simply because its usage was accounted by
> its children, and not by direct references to the parent device.
>
> This was noticed in several cases, and some have implemented
> workarounds, such as in commit c537d3457542 ("iio: adc: stm32-adc: fix
> runtime autosuspend delay when slow polling"). At the same time, Ulf
> suggested these problems "should be solved in the runtime PM core".
>
> Instead of working around the problem in drivers, we propagate last_busy
> timestamps from a dependent device to its dependencies any time it may
> allow a dependency to suspend -- i.e., when releasing a refcount for its
> parent or suppliers. We take care to only propagate the timestamp if it
> is larger than the existing busy timestamp.
>
> Note that this works best if the dependent device is using autosuspend
> (and therefore updates its last_busy timestamps appropriately), but even
> for a non-autosuspend child, this is still somewhat useful --
> non-autosuspend devices still automatically update their last_busy every
> time they resume.

> Link: https://lore.kernel.org/all/CAPDyKFp=KTf8=zGBSzPYqhjnZpY8xwvjCeM1e-WTKT1QLSxaDA@xxxxxxxxxxxxxx/

Because Linus might complain on odd Link tags, please make sure you have a
reference to it in the text and place it in a form like

Link: $URL [1]

and respectively in the text use [1] as a reference.

> Cc: Ulf Hansson <ulfh@xxxxxxxxxx>

Can go under the '---' cutter, so it won't pollute the commit message in the
Git history.

> Signed-off-by: Brian Norris <briannorris@xxxxxxxxxxxx>
> ---

Cc: ...

...

> +/*
> + * Propagate last_busy timestamp from one device to another. This can, for
> + * example, prevent overactive suspend when a dependency's usage is primarily
> + * driven by one of its dependents.
> + */
> +static void rpm_propagate_last_busy(struct device *dev, struct device *target)
> +{
> + s64 busy = atomic64_read(&dev->power.last_busy);
> + s64 target_busy = atomic64_read(&target->power.last_busy);
> +
> + while (target_busy < busy)

But here you already have an outdated ones, no? Why is this not a problem?

> + if (atomic64_try_cmpxchg(&target->power.last_busy, &target_busy, busy))
> + return;
> +}

--
With Best Regards,
Andy Shevchenko