Re: [PATCH 1/2] arm64: change ARCH_SPRD Kconfig to tristate

From: Geert Uytterhoeven
Date: Tue Mar 10 2020 - 04:47:32 EST


Hi Sandeep,

On Tue, Mar 10, 2020 at 5:27 AM Sandeep Patil <sspatil@xxxxxxxxxxx> wrote:
> On Mon, Mar 09, 2020 at 09:19:03PM -0700, Sandeep Patil wrote:
> > On Mon, Mar 09, 2020 at 11:32:06AM +0100, Geert Uytterhoeven wrote:
> > > On Mon, Mar 9, 2020 at 9:32 AM Chunyan Zhang <zhang.lyra@xxxxxxxxx> wrote:
> > > > On Mon, 9 Mar 2020 at 16:03, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
> > > > > On Thu, Mar 5, 2020 at 11:33 AM Chunyan Zhang <zhang.lyra@xxxxxxxxx> wrote:
> > > > > > From: Chunyan Zhang <chunyan.zhang@xxxxxxxxxx>
> > > > > >
> > > > > > The default value of Kconfig for almost all sprd drivers are the same with
> > > > > > ARCH_SPRD, making these drivers built as modules as default would be easier
> > > > > > if we can set ARCH_SPRD as 'm', so this patch change ARCH_SPRD to tristate.
> > > > > >
> > > > > > Signed-off-by: Chunyan Zhang <chunyan.zhang@xxxxxxxxxx>
> > > > >
> > > > > Can you actually boot a kernel on a Spreadtrum platform when all platform
> > > > > and driver support is modular?
> > > >
> > > > Yes, even if all drivers are modular.
> > >
> > > Cool. No hard dependencies on e.g. regulators that are turned off when
> > > unused?
> > >
> > > > But I hope serial can be builtin, then I can have a console to see
> > > > kernel output before loading modules.
> > >
> > > No dependency on the clock driver?
> > > Oh, I see you have a hack in the serial driver, to assume default
> > > values when the serial port's parent clock is not found. That may
> > > limit use of the other serial ports, depending on the actual serial
> > > hardware.
> > > And on Sharkl64, the serial port's clock is a fixed-clock anyway, so
> > > you don't even need the hack.
> > >
> > > But in general you cannot rely on that, especially if your SoC has clock
> > > and/or power domains.

So I gave it a try on my platform (R-Car), with just the serial driver
builtin. I can see the kernel booting using earlycon.
However, the serial driver is never probed, as the pin control driver is
missing. And after that, it would need the clock domain (power domain
and clock drivers), and more serial clock inputs (clock driver, again).
Fortunately DMA is optional (dmac driver, and optional iommu driver).

I guess core platform-specific drivers can be loaded from the initramfs,
after which the serial driver would be probed, finally. If the
initramfs includes a storage driver, anything else can be loaded from
e.g. eMMC.

> > > > Also, this's what Google GKI [1] asked :)

> > > > [1] https://arstechnica.com/gadgets/2019/11/google-outlines-plans-for-mainline-linux-kernel-support-in-android/
> > >
> > > Let's see how having everything modular works out on an SoC where all
> > > hardware is part of a clock and power domain.
> >
> > I'm curious, are there any problems that we should be aware of? We know about
> > the regulator sync state and consumer-supplier dependencies. [1]

Care must be taken, as probe deferral behaves differently after
late_initcall time (see driver_deferred_probe_check_state_continue),
which may cause issues with "optional" components like DMA controllers
and IOMMUs. Unused clocks and power domains are not turned off,
unlike for the builtin case.

On some SoCs, even the interrupt controller (GIC) may be part of a clock
and/or power domain, while the GIC driver is not aware of that.
For the clock, that is handled by CLK_IS_CRITICAL in the clock driver.
For power domains, that is not handled explicitly on Renesas SoCs, as
the GIC is always in the same power domain as other devices that are
Runtime PM-aware. But if those devices would have modular drivers, that
power domain could still be turned off.

So on a modern ARM system, I assume a generic kernel with no
vendor-specific drivers builtin can indeed work.
On older systems, without an ARM architectured timer, you will need at
least the platform-specific timer driver (and the clock driver) builtin.
Assumed the timer's power domain has been powered up by the firmware.

> (oops, forgot to paste the link to presentation)
> 1. https://linuxplumbersconf.org/event/4/contributions/402/attachments/320/544/Solving_issues_associated_with_modules_and_supplier-consumer_dependencies.pdf

Thanks, hadn't seen that presentation.
It matches my understanding.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds