[PATCH] soc: mediatek: Check if power domains can be powered on at boot time

Nicolas Boichat drinkcat at chromium.org
Mon Sep 21 22:55:11 EDT 2020


Hi,

On Tue, Sep 22, 2020 at 1:07 AM Matthias Brugger <matthias.bgg at 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 at 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);
> >       }
> >
> >       /*
> >



More information about the linux-arm-kernel mailing list