lkml.org 
[lkml]   [2018]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRE: [RFC] platform: detach from PM domains on shutdown
Date
Hi Uffe,

> -----Original Message-----
> From: Ulf Hansson [mailto:ulf.hansson@linaro.org]
> Sent: 2018年5月16日 17:53
> To: Peng Fan <peng.fan@nxp.com>
> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>; Fabio Estevam
> <fabio.estevam@nxp.com>; Greg Kroah-Hartman
> <gregkh@linuxfoundation.org>; Linux Kernel Mailing List
> <linux-kernel@vger.kernel.org>; Linux PM <linux-pm@vger.kernel.org>;
> dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [RFC] platform: detach from PM domains on shutdown
>
> On 15 May 2018 at 11:01, Peng Fan <peng.fan@nxp.com> wrote:
> > When reboot Linux, the PM domains attached to a device are not
> > shutdown. To SoCs which relys on reset the whole SoC, there is no need
> > to shutdown PM domains, but to Linux running in a virtual machine with
> > devices pass-through, we could not reset the whole SoC. Currently we
> > need Linux to shutdown its PM domains when reboot.
>
> I am not sure I understand exactly why the PM domain needs to be shutdown
> for these cases, could you please elaborate a bit on that.
>
> BTW, what platform are you running on and also what PM domains are being
> used?

It is on i.MX8 platform, with two Linux OSes running on hypervisor.
OS2 is assigned a display controller with SMMU. When OS2 reboot, OS1 is
not affected.

When OS2 firstly boots up, the power domain of display controller is powered up,
and display works well; then I reboot OS2, with `#reboot` in OS2 bash; OS2 display
not work well, because of the power domain not shutdown. This might be something
in the firmware that handling power domain well if the power domain is opened twice.
But open power domain twice seems not good, because when OS2 shutdown, the power
domain is still on.

>
> Anyway, it seems like there may be need for certain cases, but certainly not all -
> especially since it may slow down the shutdown process, when not needed.

Yes, adding this will slow down the shutdown process. I just thought
the line code was removed because of a false alarm warning, so add it back.

>
> Can we make this runtime configurable, via sysfs or whatever that makes
> sense!?

In my case, I need all the power domains assigned to OS2 needs to be shutdown
when reboot or shutdown. If runtime configuration is for all the power domains in one OS,
I am ok.

Something like this?
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 8075ddc70a17..bb34f00654da 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -616,6 +616,8 @@ static void platform_drv_shutdown(struct device *_dev)

if (drv->shutdown)
drv->shutdown(dev);
+ if (shutdown_pd)
+ dev_pm_domain_detach(_dev, true);
}

And in kernel/power/main.c create an attribute exposed to userspace to read/write shutdown_pd variable.

Thanks,
Peng.

/**

>
> >
> > commit 2d30bb0b3889 ("platform: Do not detach from PM domains on
> > shutdown"), removes what this patch tries to add, because of a warning.
> > commit e79aee49bcf9 ("PM: Avoid false-positive warnings in
> > dev_pm_domain_set()") already fixes the false alarm warning. So let's
> > detach the power domain to shutdown PM domains after driver shutdown.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >
> > I do not find a better place to shutdown power domain when reboot
> > Linux, so add back the line that commit 2d30bb0b3889 removes, because
> > it is a false alarm warning as commit e79aee49bcf9 describes.
> >
> > drivers/base/platform.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/base/platform.c b/drivers/base/platform.c index
> > 8075ddc70a17..a5929f24dc3c 100644
> > --- a/drivers/base/platform.c
> > +++ b/drivers/base/platform.c
> > @@ -616,6 +616,7 @@ static void platform_drv_shutdown(struct device
> > *_dev)
> >
> > if (drv->shutdown)
> > drv->shutdown(dev);
> > + dev_pm_domain_detach(_dev, true);
>
> This would somewhat work, but only for platform devices. To make this fully
> work, we need to call dev_pm_domain_detach() from amba, spi, etc as well.
>
> Perhaps another option to manage this more generally, an without having
> detach devices, could be to extend the struct dev_pm_domain with a new
> callback, "->shutdown()" and then make the driver core call it from
> device_shutdown().
>
> Typically, for genpd, I would probably count the number of calls being made to
> ->shutdown() per PM domain, then when it reaches the number of attached
> devices to it, allow to power off it.
>
> Let's see what Rafael thinks about it.
>
> Kind regards
> Uffe
\
 
 \ /
  Last update: 2018-05-16 14:55    [W:0.049 / U:52.072 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site