mbox series

[0/3] Clock fixes for Ingenic SoCs

Message ID 20220208010048.211691-1-aidanmacdonald.0x0@gmail.com (mailing list archive)
Headers show
Series Clock fixes for Ingenic SoCs | expand

Message

Aidan MacDonald Feb. 8, 2022, 1 a.m. UTC
I ran across a problem trying to get Linux running on an Ingenic X1000 SoC:
since the memory clock isn't referenced by any driver, it appears unused and
gets disabled automatically. After that, the system hangs on any RAM access.

There is a hack in board-ingenic.c to forcibly enable the CPU clock, but this
is insufficient for the X1000 since the memory clock has its own gate and mux
that isn't tied to the CPU.

This patch series fixes the bug by adding CLK_IS_CRITICAL flags to important
clocks, which seems to be the approach used in many other SoC clock drivers.

It's my first time submitting patches to the kernel so let me know if I
messed anything up.

Aidan MacDonald (3):
  clk: ingenic: Allow specifying common clock flags
  clk: ingenic: Mark critical clocks in Ingenic SoCs
  mips: ingenic: Do not manually reference the CPU clock

 arch/mips/generic/board-ingenic.c | 26 --------------------------
 drivers/clk/ingenic/cgu.c         |  2 +-
 drivers/clk/ingenic/cgu.h         |  3 +++
 drivers/clk/ingenic/jz4725b-cgu.c |  2 ++
 drivers/clk/ingenic/jz4740-cgu.c  |  2 ++
 drivers/clk/ingenic/jz4760-cgu.c  |  2 ++
 drivers/clk/ingenic/jz4770-cgu.c  |  1 +
 drivers/clk/ingenic/jz4780-cgu.c  |  3 +++
 drivers/clk/ingenic/x1000-cgu.c   |  3 +++
 drivers/clk/ingenic/x1830-cgu.c   |  3 +++
 10 files changed, 20 insertions(+), 27 deletions(-)

Comments

Paul Cercueil Feb. 9, 2022, 3:44 p.m. UTC | #1
Hi Aidan,

Le mar., févr. 8 2022 at 01:00:45 +0000, Aidan MacDonald 
<aidanmacdonald.0x0@gmail.com> a écrit :
> I ran across a problem trying to get Linux running on an Ingenic 
> X1000 SoC:
> since the memory clock isn't referenced by any driver, it appears 
> unused and
> gets disabled automatically. After that, the system hangs on any RAM 
> access.
> 
> There is a hack in board-ingenic.c to forcibly enable the CPU clock, 
> but this
> is insufficient for the X1000 since the memory clock has its own gate 
> and mux
> that isn't tied to the CPU.
> 
> This patch series fixes the bug by adding CLK_IS_CRITICAL flags to 
> important
> clocks, which seems to be the approach used in many other SoC clock 
> drivers.
> 
> It's my first time submitting patches to the kernel so let me know if 
> I
> messed anything up.

You did everything good.

I think the CI20 suffered from the same problem, it would only boot as 
long as the "clk_ignore_unused" flag was added on the command line. I 
will need to try it there to see if it improved the situation.

I tested the patchset on JZ4770 and it works fine. So:

Reviewed-by: Paul Cercueil <paul@crapouillou.net>

@Stephen: I don't see any changes pending on board-ingenic.c so it 
should be safe for you to also take [PATCH 3/3] in the clk tree.

Cheers,
-Paul

> Aidan MacDonald (3):
>   clk: ingenic: Allow specifying common clock flags
>   clk: ingenic: Mark critical clocks in Ingenic SoCs
>   mips: ingenic: Do not manually reference the CPU clock
> 
>  arch/mips/generic/board-ingenic.c | 26 --------------------------
>  drivers/clk/ingenic/cgu.c         |  2 +-
>  drivers/clk/ingenic/cgu.h         |  3 +++
>  drivers/clk/ingenic/jz4725b-cgu.c |  2 ++
>  drivers/clk/ingenic/jz4740-cgu.c  |  2 ++
>  drivers/clk/ingenic/jz4760-cgu.c  |  2 ++
>  drivers/clk/ingenic/jz4770-cgu.c  |  1 +
>  drivers/clk/ingenic/jz4780-cgu.c  |  3 +++
>  drivers/clk/ingenic/x1000-cgu.c   |  3 +++
>  drivers/clk/ingenic/x1830-cgu.c   |  3 +++
>  10 files changed, 20 insertions(+), 27 deletions(-)
> 
> --
> 2.34.1
>
Aidan MacDonald Feb. 9, 2022, 11:38 p.m. UTC | #2
On Wed, Feb 09, 2022 at 03:44:02PM +0000, Paul Cercueil wrote:
> Hi Aidan,
> 
> Le mar., févr. 8 2022 at 01:00:45 +0000, Aidan MacDonald 
> <aidanmacdonald.0x0@gmail.com> a écrit :
> > I ran across a problem trying to get Linux running on an Ingenic 
> > X1000 SoC:
> > since the memory clock isn't referenced by any driver, it appears 
> > unused and
> > gets disabled automatically. After that, the system hangs on any RAM 
> > access.
> > 
> > There is a hack in board-ingenic.c to forcibly enable the CPU clock, 
> > but this
> > is insufficient for the X1000 since the memory clock has its own gate 
> > and mux
> > that isn't tied to the CPU.
> > 
> > This patch series fixes the bug by adding CLK_IS_CRITICAL flags to 
> > important
> > clocks, which seems to be the approach used in many other SoC clock 
> > drivers.
> > 
> > It's my first time submitting patches to the kernel so let me know if 
> > I
> > messed anything up.
> 
> You did everything good.
> 
> I think the CI20 suffered from the same problem, it would only boot as 
> long as the "clk_ignore_unused" flag was added on the command line. I 
> will need to try it there to see if it improved the situation.
> 
> I tested the patchset on JZ4770 and it works fine. So:
> 
> Reviewed-by: Paul Cercueil <paul@crapouillou.net>
> 
> @Stephen: I don't see any changes pending on board-ingenic.c so it 
> should be safe for you to also take [PATCH 3/3] in the clk tree.
> 
> Cheers,
> -Paul

Thanks Paul. I've just sent two other small fixes which are basically
independent of this series, if you want to test them at the same time.
One is for the TCU driver and the other is for the pinctrl driver.

Regards,
Aidan

> 
> > Aidan MacDonald (3):
> >   clk: ingenic: Allow specifying common clock flags
> >   clk: ingenic: Mark critical clocks in Ingenic SoCs
> >   mips: ingenic: Do not manually reference the CPU clock
> > 
> >  arch/mips/generic/board-ingenic.c | 26 --------------------------
> >  drivers/clk/ingenic/cgu.c         |  2 +-
> >  drivers/clk/ingenic/cgu.h         |  3 +++
> >  drivers/clk/ingenic/jz4725b-cgu.c |  2 ++
> >  drivers/clk/ingenic/jz4740-cgu.c  |  2 ++
> >  drivers/clk/ingenic/jz4760-cgu.c  |  2 ++
> >  drivers/clk/ingenic/jz4770-cgu.c  |  1 +
> >  drivers/clk/ingenic/jz4780-cgu.c  |  3 +++
> >  drivers/clk/ingenic/x1000-cgu.c   |  3 +++
> >  drivers/clk/ingenic/x1830-cgu.c   |  3 +++
> >  10 files changed, 20 insertions(+), 27 deletions(-)
> > 
> > --
> > 2.34.1
> > 
> 
>