Re: [RFC PATCH 1/3] pmdomain: core: Allow a non-CPU device in a CPU PM domain to do power on

From: Ulf Hansson

Date: Thu Aug 20 2026 - 06:06:36 EST


On Wed, Aug 19, 2026 at 7:52 PM Abel Vesa <abel.vesa@xxxxxxxxxxxxxxxx> wrote:
>
> On 26-08-19 17:14:51, Ulf Hansson wrote:
> > From: Ulf Hansson <ulfh@xxxxxxxxxx>
> >
> > A driver for a non-CPU device that is attached to a CPU PM domain (the
> > genpd has the GENPD_FLAG_CPU_DOMAIN configuration set), is currently not
> > able to power on the PM domain. More precisely, to power on a CPU PM domain
> > one of its corresponding CPUs needs to be woken up if they are idle.
> >
> > The current support for a non-CPU device is that its driver can only
> > prevent an already powered on CPU PM domain from being powered off. This
> > leads to problems for a driver while probing its device or when it needs to
> > call pm_runtime_get_sync() to turn on the power for it. From the driver
> > point of view it looks like it all works fine, but when accessing the
> > device it may end up with various errors as the device may not be fully
> > powered on.
> >
> > To fix the behavior for these types of devices, let's adjust the behaviour
> > in genpd_power_on() to wake up an idle CPU that belongs to it, in cases
> > when it's needed.
> >
> > Link: https://lore.kernel.org/all/CAPx+jO-sCierYj8jnoKQHckJG16dOBxnNrsZVYO=38R2cLV8nw@xxxxxxxxxxxxxx/
> > Signed-off-by: Ulf Hansson <ulfh@xxxxxxxxxx>
> > ---
> > drivers/pmdomain/core.c | 80 ++++++++++++++++++++++++++++++++++++++---
> > 1 file changed, 75 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
> > index 842c4169e290..7345c06f1d55 100644
> > --- a/drivers/pmdomain/core.c
> > +++ b/drivers/pmdomain/core.c
> > @@ -10,6 +10,7 @@
> > #include <linux/idr.h>
> > #include <linux/kernel.h>
> > #include <linux/io.h>
> > +#include <linux/iopoll.h>
> > #include <linux/platform_device.h>
> > #include <linux/pm_opp.h>
> > #include <linux/pm_runtime.h>
> > @@ -19,11 +20,14 @@
> > #include <linux/slab.h>
> > #include <linux/err.h>
> > #include <linux/sched.h>
> > +#include <linux/smp.h>
> > #include <linux/suspend.h>
> > #include <linux/export.h>
> > #include <linux/cpu.h>
> > #include <linux/debugfs.h>
> >
> > +#include <trace/events/ipi.h>
> > +
> > /* Provides a unique ID for each genpd device */
> > static DEFINE_IDA(genpd_ida);
> >
> > @@ -32,7 +36,9 @@ static const struct bus_type genpd_provider_bus_type = {
> > .name = "genpd_provider",
> > };
> >
> > -#define GENPD_RETRY_MAX_MS 250 /* Approximate */
> > +#define GENPD_RETRY_MAX_MS 250 /* Approximate */
> > +#define GENPD_CPU_ON_POLL_PERIOD_US 100 /* 100us */
> > +#define GENPD_CPU_ON_TIMEOUT_US 5000000 /* 5s */
> >
> > #define GENPD_DEV_CALLBACK(genpd, type, callback, dev) \
> > ({ \
> > @@ -1027,15 +1033,75 @@ static void genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
> > }
> > }
> >
> > +static bool genpd_check_status_on(struct generic_pm_domain *genpd)
> > +{
> > + bool is_on;
> > +
> > + genpd_lock(genpd);
> > + is_on = genpd_status_on(genpd);
> > + genpd_unlock(genpd);
> > +
> > + return is_on;
> > +}
>
> I'd change the genpd_status_on() to genpd_is_on_unlocked().
>
> And then this one would be just genpd_is_on().

Yep, that sounds like an improvement, thanks for the suggestion!

>
> The rest looks good, so:
>
> Reviewed-by: Abel Vesa <abel.vesa@xxxxxxxxxxxxxxxx>

Thanks!

Kind regards
Uffe