mbox series

[v3,0/2] gs101 oriole: UART clock fixes

Message ID 20240710-gs101-non-essential-clocks-2-v3-0-5dcb8d040d1c@linaro.org
Headers show
Series gs101 oriole: UART clock fixes | expand

Message

André Draszik July 10, 2024, 1:29 p.m. UTC
Hi,

This series fixes two issues in the gs101 clocking / uart handling & related
device tree binding:
1) the binding omitted specifying the required number of clocks for the UART
2) an incorrect work-around in the gs101 clock driver

The 2nd point is essentially the last remaining patch [1] with all review
comments addressed, from the series [2] that was sent earlier this year, see
lore links below.

As requested, I'm also documenting (in the binding) the hand-over issue
between earlycon and (real) console driver that we have on gs101, see [3].
While doing that, I noticed the omission mentioned in point 1) above, hence
this series.

To avoid confusion, I'm marking this whole series as v3 because the patch to
clk-gs101.c had been sent as v2 previously, and this supersedes it.

Signed-off-by: André Draszik <andre.draszik@linaro.org>

[1] https://lore.kernel.org/all/20240130093812.1746512-6-andre.draszik@linaro.org/
[2] https://lore.kernel.org/all/20240130093812.1746512-1-andre.draszik@linaro.org/
[3] https://lore.kernel.org/all/d45de3b2bb6b48653842cf1f74e58889ed6783ae.camel@linaro.org/

---
André Draszik (2):
      dt-bindings: serial: samsung: fix maxItems for gs101 & document earlycon requirements
      clk: samsung: gs101: don't mark non-essential (UART) clocks critical

 Documentation/devicetree/bindings/serial/samsung_uart.yaml | 14 ++++++++++++++
 drivers/clk/samsung/clk-gs101.c                            |  6 ++----
 2 files changed, 16 insertions(+), 4 deletions(-)
---
base-commit: 523b23f0bee3014a7a752c9bb9f5c54f0eddae88
change-id: 20240430-gs101-non-essential-clocks-2-6a3280fa1be8

Best regards,

Comments

Marek Szyprowski July 10, 2024, 2:35 p.m. UTC | #1
On 10.07.2024 15:29, André Draszik wrote:
> The peric0_top1_ipclk_0 and peric0_top1_pclk_0 are the clocks going to
> peric0/uart_usi, with pclk being the bus clock. Without pclk running,
> any bus access will hang.
> Unfortunately, in commit d97b6c902a40 ("arm64: dts: exynos: gs101:
> update USI UART to use peric0 clocks") the gs101 DT ended up specifying
> an incorrect pclk in the respective node and instead the two clocks
> here were marked as critical.
>
> Since then, the DT has been updated to use the correct clock in
> commit 21e4e8807bfc ("arm64: dts: exynos: gs101: use correct clocks for
> usi_uart") and the driver here should be corrected and the work-around
> removed.
>
> Note that this commit has the side-effect of causing earlycon to stop
> to work sometime into the boot for two reasons:
>      * peric0_top1_ipclk_0 requires its parent gout_cmu_peric0_ip to be
>        running, but because earlycon doesn't deal with clocks that
>        parent will be disabled when none of the other drivers that
>        actually deal with clocks correctly require it to be running and
>        the real serial driver (which does deal with clocks) hasn't taken
>        over yet
>      * hand-over between earlycon and serial driver appears to be
>        fragile and clocks get enabled and disabled a few times, which
>        also causes register access to hang while earlycon is still
>        active
> (A wordier explanation can also be found in [1])
>
> Nonetheless we shouldn't keep these clocks running unconditionally just
> for earlycon. Clocks should be disabled where possible. If earlycon is
> required in the future, e.g. for debug, this commit can simply be
> reverted (locally!).
>
> Link: https://lore.kernel.org/all/d45de3b2bb6b48653842cf1f74e58889ed6783ae.camel@linaro.org/ [1]
> Fixes: 893f133a040b ("clk: samsung: gs101: add support for cmu_peric0")
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>

Frankly speaking I'm not sure that anyone will find this comment and do 
local reverts before getting angry that earlycon doesn't work for his 
device and wasting his time.

I think that it would be much better to check if earlycon is specified 
in kernel's cmdline and if so, simply mark those problematic clocks 
critical in this driver. Make this code hidden under 
IS_ENABLED(CONFIG_SERIAL_EARLYCON) to avoid polluting release builds. 
Any comments?

Best regards
André Draszik July 12, 2024, 5 a.m. UTC | #2
On Wed, 2024-07-10 at 16:35 +0200, Marek Szyprowski wrote:
> I think that it would be much better to check if earlycon is specified 
> in kernel's cmdline and if so, simply mark those problematic clocks 
> critical in this driver. Make this code hidden under 
> IS_ENABLED(CONFIG_SERIAL_EARLYCON) to avoid polluting release builds. 
> Any comments?

Good idea, I've found that i.MX appears to suffer from a similar problem,
and I'm testing something similar now:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clk/imx/clk.c#n157


Cheers,
Andre'