linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc: mediatek: Check if power domains can be powered on at boot time
@ 2020-07-30  4:01 Nicolas Boichat
  2020-09-11  7:04 ` Nicolas Boichat
  2020-09-21 17:07 ` Matthias Brugger
  0 siblings, 2 replies; 4+ messages in thread
From: Nicolas Boichat @ 2020-07-30  4:01 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).

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

---

 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 f669d3754627dad..0055a52a49733d5 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 = genpd->power_on(genpd) >= 0;
 
-		pm_genpd_init(genpd, NULL, false);
+		pm_genpd_init(genpd, NULL, !on);
 	}
 
 	/*
-- 
2.28.0.rc0.142.g3c755180ce-goog


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

* Re: [PATCH] soc: mediatek: Check if power domains can be powered on at boot time
  2020-07-30  4:01 [PATCH] soc: mediatek: Check if power domains can be powered on at boot time Nicolas Boichat
@ 2020-09-11  7:04 ` Nicolas Boichat
  2020-09-21 17:07 ` Matthias Brugger
  1 sibling, 0 replies; 4+ messages in thread
From: Nicolas Boichat @ 2020-09-11  7:04 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: Daniel Kurtz, Sascha Hauer, linux-arm Mailing List, lkml,
	moderated list:ARM/Mediatek SoC support, Enric Balletbo i Serra

Matthias, gentle ping on the patch below >>>

Thanks!

On Thu, Jul 30, 2020 at 12:01 PM Nicolas Boichat <drinkcat@chromium.org> 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).
>
> Fixes: c84e358718a66f7 ("soc: Mediatek: Add SCPSYS power domain driver")
> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
>
> ---
>
>  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 f669d3754627dad..0055a52a49733d5 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 = genpd->power_on(genpd) >= 0;
>
> -               pm_genpd_init(genpd, NULL, false);
> +               pm_genpd_init(genpd, NULL, !on);
>         }
>
>         /*
> --
> 2.28.0.rc0.142.g3c755180ce-goog
>

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

* Re: [PATCH] soc: mediatek: Check if power domains can be powered on at boot time
  2020-07-30  4:01 [PATCH] soc: mediatek: Check if power domains can be powered on at boot time Nicolas Boichat
  2020-09-11  7:04 ` Nicolas Boichat
@ 2020-09-21 17:07 ` Matthias Brugger
  2020-09-22  2:55   ` Nicolas Boichat
  1 sibling, 1 reply; 4+ messages in thread
From: Matthias Brugger @ 2020-09-21 17:07 UTC (permalink / raw)
  To: Nicolas Boichat
  Cc: Daniel Kurtz, Sascha Hauer, linux-arm-kernel, linux-kernel,
	linux-mediatek

Hi Nicolas,

Thanks for the patch.

On 30/07/2020 06:01, 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).
> 
> Fixes: c84e358718a66f7 ("soc: Mediatek: Add SCPSYS power domain driver")
> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
> 
> ---
> 
>   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 f669d3754627dad..0055a52a49733d5 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 = genpd->power_on(genpd) >= 0;

Is this something we expect? On probing we realize that some domains can't be 
turned on?

I understand that this would be a bug in the driver. Therefore we should at most 
provide a warning instead of working around the bug, hiding it. Or do I got this 
wrong?

Regards,
Matthias

>   
> -		pm_genpd_init(genpd, NULL, false);
> +		pm_genpd_init(genpd, NULL, !on);
>   	}
>   
>   	/*
> 

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

* Re: [PATCH] soc: mediatek: Check if power domains can be powered on at boot time
  2020-09-21 17:07 ` Matthias Brugger
@ 2020-09-22  2:55   ` Nicolas Boichat
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Boichat @ 2020-09-22  2:55 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: Daniel Kurtz, Sascha Hauer, linux-arm Mailing List, lkml,
	moderated list:ARM/Mediatek SoC support

Hi,

On Tue, Sep 22, 2020 at 1:07 AM Matthias Brugger <matthias.bgg@gmail.com> wrote:
>
> Hi Nicolas,
>
> Thanks for the patch.
>
> On 30/07/2020 06:01, 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).
> >
> > Fixes: c84e358718a66f7 ("soc: Mediatek: Add SCPSYS power domain driver")
> > Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
> >
> > ---
> >
> >   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 f669d3754627dad..0055a52a49733d5 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 = genpd->power_on(genpd) >= 0;
>
> Is this something we expect? On probing we realize that some domains can't be
> turned on?
>
> I understand that this would be a bug in the driver. Therefore we should at most
> provide a warning instead of working around the bug, hiding it. Or do I got this
> wrong?

No, you get this right. That's a bug (we see this on unreleased HW),
and we will fix it.

Now, we already get this (somewhat subtle) error message on boot:
mtk-scpsys 10006000.power-controller: Failed to power on domain adsp

But without this patch, there is an unbalance later on (that is
possibly a bit confusing):
[    6.510811] ------------[ cut here ]------------
[    6.515417] adsp_sel already disabled
[    6.519089] WARNING: CPU: 5 PID: 180 at drivers/clk/clk.c:958
clk_core_disable+0x1ec/0x22c
...
[    6.658393]  clk_core_disable+0x1ec/0x22c
[    6.662395]  clk_disable+0x34/0x48
[    6.665791]  scpsys_clk_disable+0x34/0x58
[    6.669791]  scpsys_power_off+0x374/0x3ec
[    6.673790]  _genpd_power_off+0x40/0x98
[    6.677616]  genpd_power_off+0x168/0x208
[    6.681530]  genpd_power_off_work_fn+0x38/0x54
[    6.685964]  process_one_work+0x208/0x3c8
[    6.689964]  worker_thread+0x23c/0x3e8
[    6.693703]  kthread+0x11c/0x12c
[    6.696923]  ret_from_fork+0x10/0x18
[    6.700487] ---[ end trace 91ddada49c4d717c ]---

But I get your point, we should probably add something like
WARN_ON(!on) to make it clearer, at the time when the issue occurs,
that something is not right...

Thanks,

> Regards,
> Matthias
>
> >
> > -             pm_genpd_init(genpd, NULL, false);
> > +             pm_genpd_init(genpd, NULL, !on);
> >       }
> >
> >       /*
> >

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

end of thread, other threads:[~2020-09-22  2:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-30  4:01 [PATCH] soc: mediatek: Check if power domains can be powered on at boot time Nicolas Boichat
2020-09-11  7:04 ` Nicolas Boichat
2020-09-21 17:07 ` Matthias Brugger
2020-09-22  2:55   ` 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).