linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] soc: mediatek: Check if power domains can be powered on at boot time
@ 2020-09-28  3:31 Nicolas Boichat
  2020-10-01 15:03 ` Matthias Brugger
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Boichat @ 2020-09-28  3:31 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: Nicolas Boichat, Daniel Kurtz, Sascha Hauer, linux-arm-kernel,
	linux-kernel, linux-mediatek

In the error case, where a power domain cannot be powered on
successfully at boot time (in mtk_register_power_domains),
pm_genpd_init would still be called with is_off=false, and the
system would later try to disable the power domain again, triggering
warnings as disabled clocks are disabled again (and other potential
issues).

Also print a warning splat in that case, as this should never
happen.

Fixes: c84e358718a66f7 ("soc: Mediatek: Add SCPSYS power domain driver")
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
---

Changes in v2:
 - Add WARN_ON if the domain can't be powered on, to make it more
   obvious that this should not happen (there is already an error
   message).

 drivers/soc/mediatek/mtk-scpsys.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c
index f669d3754627..ca75b14931ec 100644
--- a/drivers/soc/mediatek/mtk-scpsys.c
+++ b/drivers/soc/mediatek/mtk-scpsys.c
@@ -524,6 +524,7 @@ static void mtk_register_power_domains(struct platform_device *pdev,
 	for (i = 0; i < num; i++) {
 		struct scp_domain *scpd = &scp->domains[i];
 		struct generic_pm_domain *genpd = &scpd->genpd;
+		bool on;
 
 		/*
 		 * Initially turn on all domains to make the domains usable
@@ -531,9 +532,9 @@ static void mtk_register_power_domains(struct platform_device *pdev,
 		 * software.  The unused domains will be switched off during
 		 * late_init time.
 		 */
-		genpd->power_on(genpd);
+		on = !WARN_ON(genpd->power_on(genpd) < 0);
 
-		pm_genpd_init(genpd, NULL, false);
+		pm_genpd_init(genpd, NULL, !on);
 	}
 
 	/*
-- 
2.28.0.681.g6f77f65b4e-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] soc: mediatek: Check if power domains can be powered on at boot time
  2020-09-28  3:31 [PATCH v2] soc: mediatek: Check if power domains can be powered on at boot time Nicolas Boichat
@ 2020-10-01 15:03 ` Matthias Brugger
  2020-10-05  1:08   ` Nicolas Boichat
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Brugger @ 2020-10-01 15:03 UTC (permalink / raw)
  To: Nicolas Boichat
  Cc: Daniel Kurtz, Sascha Hauer, linux-arm-kernel, linux-kernel,
	linux-mediatek



On 28/09/2020 05:31, Nicolas Boichat wrote:
> In the error case, where a power domain cannot be powered on
> successfully at boot time (in mtk_register_power_domains),
> pm_genpd_init would still be called with is_off=false, and the
> system would later try to disable the power domain again, triggering
> warnings as disabled clocks are disabled again (and other potential
> issues).
> 
> Also print a warning splat in that case, as this should never
> happen.
> 
> Fixes: c84e358718a66f7 ("soc: Mediatek: Add SCPSYS power domain driver")
> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>

Applied to v5.10-tmp/soc which will be v5.10-next/soc as soon as v5.10-rc1 gets 
published.

Nicolas can you please make sure that similar logic will be part of the series 
Enric is working on?

Thanks a lot.
Matthias

> ---
> 
> Changes in v2:
>   - Add WARN_ON if the domain can't be powered on, to make it more
>     obvious that this should not happen (there is already an error
>     message).
> 
>   drivers/soc/mediatek/mtk-scpsys.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c
> index f669d3754627..ca75b14931ec 100644
> --- a/drivers/soc/mediatek/mtk-scpsys.c
> +++ b/drivers/soc/mediatek/mtk-scpsys.c
> @@ -524,6 +524,7 @@ static void mtk_register_power_domains(struct platform_device *pdev,
>   	for (i = 0; i < num; i++) {
>   		struct scp_domain *scpd = &scp->domains[i];
>   		struct generic_pm_domain *genpd = &scpd->genpd;
> +		bool on;
>   
>   		/*
>   		 * Initially turn on all domains to make the domains usable
> @@ -531,9 +532,9 @@ static void mtk_register_power_domains(struct platform_device *pdev,
>   		 * software.  The unused domains will be switched off during
>   		 * late_init time.
>   		 */
> -		genpd->power_on(genpd);
> +		on = !WARN_ON(genpd->power_on(genpd) < 0);
>   
> -		pm_genpd_init(genpd, NULL, false);
> +		pm_genpd_init(genpd, NULL, !on);
>   	}
>   
>   	/*
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] soc: mediatek: Check if power domains can be powered on at boot time
  2020-10-01 15:03 ` Matthias Brugger
@ 2020-10-05  1:08   ` Nicolas Boichat
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Boichat @ 2020-10-05  1:08 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: Daniel Kurtz, Sascha Hauer, linux-arm Mailing List, lkml,
	moderated list:ARM/Mediatek SoC support

On Thu, Oct 1, 2020 at 11:03 PM Matthias Brugger <matthias.bgg@gmail.com> wrote:
>
>
>
> On 28/09/2020 05:31, Nicolas Boichat wrote:
> > In the error case, where a power domain cannot be powered on
> > successfully at boot time (in mtk_register_power_domains),
> > pm_genpd_init would still be called with is_off=false, and the
> > system would later try to disable the power domain again, triggering
> > warnings as disabled clocks are disabled again (and other potential
> > issues).
> >
> > Also print a warning splat in that case, as this should never
> > happen.
> >
> > Fixes: c84e358718a66f7 ("soc: Mediatek: Add SCPSYS power domain driver")
> > Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
>
> Applied to v5.10-tmp/soc which will be v5.10-next/soc as soon as v5.10-rc1 gets
> published.
>
> Nicolas can you please make sure that similar logic will be part of the series
> Enric is working on?

https://patchwork.kernel.org/patch/11811767/ the logic is a bit
different, and the whole scpsys driver would fail to probe, but I
think that's also reasonable behaviour.

Thanks,

>
> Thanks a lot.
> Matthias
>
> > ---
> >
> > Changes in v2:
> >   - Add WARN_ON if the domain can't be powered on, to make it more
> >     obvious that this should not happen (there is already an error
> >     message).
> >
> >   drivers/soc/mediatek/mtk-scpsys.c | 5 +++--
> >   1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c
> > index f669d3754627..ca75b14931ec 100644
> > --- a/drivers/soc/mediatek/mtk-scpsys.c
> > +++ b/drivers/soc/mediatek/mtk-scpsys.c
> > @@ -524,6 +524,7 @@ static void mtk_register_power_domains(struct platform_device *pdev,
> >       for (i = 0; i < num; i++) {
> >               struct scp_domain *scpd = &scp->domains[i];
> >               struct generic_pm_domain *genpd = &scpd->genpd;
> > +             bool on;
> >
> >               /*
> >                * Initially turn on all domains to make the domains usable
> > @@ -531,9 +532,9 @@ static void mtk_register_power_domains(struct platform_device *pdev,
> >                * software.  The unused domains will be switched off during
> >                * late_init time.
> >                */
> > -             genpd->power_on(genpd);
> > +             on = !WARN_ON(genpd->power_on(genpd) < 0);
> >
> > -             pm_genpd_init(genpd, NULL, false);
> > +             pm_genpd_init(genpd, NULL, !on);
> >       }
> >
> >       /*
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-05  1:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-28  3:31 [PATCH v2] soc: mediatek: Check if power domains can be powered on at boot time Nicolas Boichat
2020-10-01 15:03 ` Matthias Brugger
2020-10-05  1:08   ` Nicolas Boichat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).