linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* gs101 oriole: peripheral block 0 (peric0) fixes
@ 2024-01-27  0:35 André Draszik
  2024-01-27  0:35 ` [PATCH 1/5] clk: samsung: gs101: gpio_peric0_pclk needs to be kept on André Draszik
                   ` (5 more replies)
  0 siblings, 6 replies; 28+ messages in thread
From: André Draszik @ 2024-01-27  0:35 UTC (permalink / raw)
  To: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	semen.protsenko, alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi,
	mturquette, sboyd, linux-arm-kernel, linux-samsung-soc,
	linux-clk, devicetree

Hi,

While working on peric1, I've noticed a few issues in the peric0 area
and these patches are the result. They should all be pretty
self-explanatory.

Cheers,
Andre'

 arch/arm64/boot/dts/exynos/google/gs101.dtsi | 9 +++++----
 drivers/clk/samsung/clk-gs101.c              | 8 +++-----
 2 files changed, 8 insertions(+), 9 deletions(-)


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

* [PATCH 1/5] clk: samsung: gs101: gpio_peric0_pclk needs to be kept on
  2024-01-27  0:35 gs101 oriole: peripheral block 0 (peric0) fixes André Draszik
@ 2024-01-27  0:35 ` André Draszik
  2024-01-27  3:06   ` Sam Protsenko
                     ` (2 more replies)
  2024-01-27  0:35 ` [PATCH 2/5] arm64: dts: exynos: gs101: fix usi8 default mode André Draszik
                   ` (4 subsequent siblings)
  5 siblings, 3 replies; 28+ messages in thread
From: André Draszik @ 2024-01-27  0:35 UTC (permalink / raw)
  To: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	semen.protsenko, alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi,
	mturquette, sboyd, linux-arm-kernel, linux-samsung-soc,
	linux-clk, devicetree

This pclk clock is required any time we access the pinctrl registers of
this block.

Since pinctrl-samsung doesn't support a clock at the moment, we just
keep the kernel from disabling it at boot, until we have an update for
pinctrl-samsung to handle this required clock, at which point we'll be
able to drop the flag again.

Fixes: 893f133a040b ("clk: samsung: gs101: add support for cmu_peric0")
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/clk/samsung/clk-gs101.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/samsung/clk-gs101.c b/drivers/clk/samsung/clk-gs101.c
index 4a0520e825b6..61bb0dcf84ee 100644
--- a/drivers/clk/samsung/clk-gs101.c
+++ b/drivers/clk/samsung/clk-gs101.c
@@ -2848,7 +2848,7 @@ static const struct samsung_gate_clock peric0_gate_clks[] __initconst = {
 	GATE(CLK_GOUT_PERIC0_GPIO_PERIC0_PCLK,
 	     "gout_peric0_gpio_peric0_pclk", "mout_peric0_bus_user",
 	     CLK_CON_GAT_GOUT_BLK_PERIC0_UID_GPIO_PERIC0_IPCLKPORT_PCLK,
-	     21, 0, 0),
+	     21, CLK_IGNORE_UNUSED, 0),
 	/* Disabling this clock makes the system hang. Mark the clock as critical. */
 	GATE(CLK_GOUT_PERIC0_LHM_AXI_P_PERIC0_I_CLK,
 	     "gout_peric0_lhm_axi_p_peric0_i_clk", "mout_peric0_bus_user",
-- 
2.43.0.429.g432eaa2c6b-goog


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

* [PATCH 2/5] arm64: dts: exynos: gs101: fix usi8 default mode
  2024-01-27  0:35 gs101 oriole: peripheral block 0 (peric0) fixes André Draszik
  2024-01-27  0:35 ` [PATCH 1/5] clk: samsung: gs101: gpio_peric0_pclk needs to be kept on André Draszik
@ 2024-01-27  0:35 ` André Draszik
  2024-01-27  3:05   ` Sam Protsenko
                     ` (2 more replies)
  2024-01-27  0:35 ` [PATCH 3/5] arm64: dts: exynos: gs101: use correct clocks for usi8 André Draszik
                   ` (3 subsequent siblings)
  5 siblings, 3 replies; 28+ messages in thread
From: André Draszik @ 2024-01-27  0:35 UTC (permalink / raw)
  To: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	semen.protsenko, alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi,
	mturquette, sboyd, linux-arm-kernel, linux-samsung-soc,
	linux-clk, devicetree

While commit 6d44d1a1fb62 ("arm64: dts: exynos: gs101: define USI8 with
I2C configuration") states that the USI8 CONFIG is 0 at reset, the boot
loader has configured it by the time Linux runs and it has a different
value at this stage.

Since we want board DTS files to explicitly select the mode, we should
set it to none here so as to ensure things don't work by accident and
to make it clear that board DTS actually need to set the mode based on
the configuration.

Fixes: 6d44d1a1fb62 ("arm64: dts: exynos: gs101: define USI8 with I2C configuration")
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 arch/arm64/boot/dts/exynos/google/gs101.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
index aaac04df5e65..bc251e565be6 100644
--- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi
+++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
@@ -384,6 +384,7 @@ usi8: usi@109700c0 {
 				 <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_IPCLK_7>;
 			clock-names = "pclk", "ipclk";
 			samsung,sysreg = <&sysreg_peric0 0x101c>;
+			samsung,mode = <USI_V2_NONE>;
 			status = "disabled";
 
 			hsi2c_8: i2c@10970000 {
-- 
2.43.0.429.g432eaa2c6b-goog


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

* [PATCH 3/5] arm64: dts: exynos: gs101: use correct clocks for usi8
  2024-01-27  0:35 gs101 oriole: peripheral block 0 (peric0) fixes André Draszik
  2024-01-27  0:35 ` [PATCH 1/5] clk: samsung: gs101: gpio_peric0_pclk needs to be kept on André Draszik
  2024-01-27  0:35 ` [PATCH 2/5] arm64: dts: exynos: gs101: fix usi8 default mode André Draszik
@ 2024-01-27  0:35 ` André Draszik
  2024-01-27  3:22   ` Sam Protsenko
  2024-01-27  0:35 ` [PATCH 4/5] arm64: dts: exynos: gs101: use correct clocks for usi_uart André Draszik
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 28+ messages in thread
From: André Draszik @ 2024-01-27  0:35 UTC (permalink / raw)
  To: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	semen.protsenko, alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi,
	mturquette, sboyd, linux-arm-kernel, linux-samsung-soc,
	linux-clk, devicetree

Wrong pclk clocks have been used in this usi8 instance here. For USI
and I2C, we need the ipclk and pclk, where pclk is the bus clock.
Without it, nothing can work.
It is unclear what exactly is using USI8_USI_CLK, but it is not
required for the IP to be operational at this stage, while pclk is.
This also brings the DT in line with the clock names expected by the
usi and i2c drivers.

Update the DTSI accordingly.

Fixes: 6d44d1a1fb62 ("arm64: dts: exynos: gs101: define USI8 with I2C configuration")
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 arch/arm64/boot/dts/exynos/google/gs101.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
index bc251e565be6..e5b665be2d62 100644
--- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi
+++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
@@ -380,7 +380,7 @@ usi8: usi@109700c0 {
 			ranges;
 			#address-cells = <1>;
 			#size-cells = <1>;
-			clocks = <&cmu_peric0 CLK_GOUT_PERIC0_CLK_PERIC0_USI8_USI_CLK>,
+			clocks = <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_PCLK_7>,
 				 <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_IPCLK_7>;
 			clock-names = "pclk", "ipclk";
 			samsung,sysreg = <&sysreg_peric0 0x101c>;
@@ -397,7 +397,7 @@ hsi2c_8: i2c@10970000 {
 				pinctrl-names = "default";
 				pinctrl-0 = <&hsi2c8_bus>;
 				clocks = <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_IPCLK_7>,
-					 <&cmu_peric0 CLK_GOUT_PERIC0_CLK_PERIC0_USI8_USI_CLK>;
+					 <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_PCLK_7>;
 				clock-names = "hsi2c", "hsi2c_pclk";
 				status = "disabled";
 			};
-- 
2.43.0.429.g432eaa2c6b-goog


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

* [PATCH 4/5] arm64: dts: exynos: gs101: use correct clocks for usi_uart
  2024-01-27  0:35 gs101 oriole: peripheral block 0 (peric0) fixes André Draszik
                   ` (2 preceding siblings ...)
  2024-01-27  0:35 ` [PATCH 3/5] arm64: dts: exynos: gs101: use correct clocks for usi8 André Draszik
@ 2024-01-27  0:35 ` André Draszik
  2024-01-27  1:37   ` André Draszik
                     ` (2 more replies)
  2024-01-27  0:35 ` [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical André Draszik
  2024-01-27  3:01 ` gs101 oriole: peripheral block 0 (peric0) fixes Sam Protsenko
  5 siblings, 3 replies; 28+ messages in thread
From: André Draszik @ 2024-01-27  0:35 UTC (permalink / raw)
  To: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	semen.protsenko, alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi,
	mturquette, sboyd, linux-arm-kernel, linux-samsung-soc,
	linux-clk, devicetree

Wrong pclk clocks have been used in this usi8 instance here. For USI
and UART, we need the ipclk and pclk, where pclk is the bus clock.
Without it, nothing can work.
It is unclear what exactly is using USI0_UART_CLK, but it is not
required for the IP to be operational at this stage, while pclk is.
This also brings the DT in line with the clock names expected by the
usi and uart drivers.

Update the DTSI accordingly.

Fixes: d97b6c902a40 ("arm64: dts: exynos: gs101: update USI UART to use peric0 clocks")
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 arch/arm64/boot/dts/exynos/google/gs101.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
index e5b665be2d62..f93e937d2726 100644
--- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi
+++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
@@ -410,7 +410,7 @@ usi_uart: usi@10a000c0 {
 			ranges;
 			#address-cells = <1>;
 			#size-cells = <1>;
-			clocks = <&cmu_peric0 CLK_GOUT_PERIC0_CLK_PERIC0_USI0_UART_CLK>,
+			clocks = <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_0>,
 				 <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_0>;
 			clock-names = "pclk", "ipclk";
 			samsung,sysreg = <&sysreg_peric0 0x1020>;
@@ -422,7 +422,7 @@ serial_0: serial@10a00000 {
 				reg = <0x10a00000 0xc0>;
 				interrupts = <GIC_SPI 634
 					      IRQ_TYPE_LEVEL_HIGH 0>;
-				clocks = <&cmu_peric0 CLK_GOUT_PERIC0_CLK_PERIC0_USI0_UART_CLK>,
+				clocks = <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_0>,
 					 <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_0>;
 				clock-names = "uart", "clk_uart_baud0";
 				samsung,uart-fifosize = <256>;
-- 
2.43.0.429.g432eaa2c6b-goog


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

* [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical
  2024-01-27  0:35 gs101 oriole: peripheral block 0 (peric0) fixes André Draszik
                   ` (3 preceding siblings ...)
  2024-01-27  0:35 ` [PATCH 4/5] arm64: dts: exynos: gs101: use correct clocks for usi_uart André Draszik
@ 2024-01-27  0:35 ` André Draszik
  2024-01-27  1:38   ` André Draszik
                     ` (2 more replies)
  2024-01-27  3:01 ` gs101 oriole: peripheral block 0 (peric0) fixes Sam Protsenko
  5 siblings, 3 replies; 28+ messages in thread
From: André Draszik @ 2024-01-27  0:35 UTC (permalink / raw)
  To: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	semen.protsenko, alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi,
	mturquette, sboyd, linux-arm-kernel, linux-samsung-soc,
	linux-clk, devicetree

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 pclkk in the respective node and instead the two clocks
here were marked as critical.

We have fixed the gs101 DT and can therefore drop this incorrect
work-around here, the uart driver will claim these clocks as needed.

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
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!).

Fixes: 893f133a040b ("clk: samsung: gs101: add support for cmu_peric0")
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/clk/samsung/clk-gs101.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/samsung/clk-gs101.c b/drivers/clk/samsung/clk-gs101.c
index 61bb0dcf84ee..5c338ac9231c 100644
--- a/drivers/clk/samsung/clk-gs101.c
+++ b/drivers/clk/samsung/clk-gs101.c
@@ -2982,20 +2982,18 @@ static const struct samsung_gate_clock peric0_gate_clks[] __initconst = {
 	     "gout_peric0_peric0_top0_pclk_9", "mout_peric0_bus_user",
 	     CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP0_IPCLKPORT_PCLK_9,
 	     21, 0, 0),
-	/* Disabling this clock makes the system hang. Mark the clock as critical. */
 	GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_0,
 	     "gout_peric0_peric0_top1_ipclk_0", "dout_peric0_usi0_uart",
 	     CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_IPCLK_0,
-	     21, CLK_IS_CRITICAL, 0),
+	     21, 0, 0),
 	GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_2,
 	     "gout_peric0_peric0_top1_ipclk_2", "dout_peric0_usi14_usi",
 	     CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_IPCLK_2,
 	     21, 0, 0),
-	/* Disabling this clock makes the system hang. Mark the clock as critical. */
 	GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_0,
 	     "gout_peric0_peric0_top1_pclk_0", "mout_peric0_bus_user",
 	     CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_PCLK_0,
-	     21, CLK_IS_CRITICAL, 0),
+	     21, 0, 0),
 	GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_2,
 	     "gout_peric0_peric0_top1_pclk_2", "mout_peric0_bus_user",
 	     CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_PCLK_2,
-- 
2.43.0.429.g432eaa2c6b-goog


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

* Re: [PATCH 4/5] arm64: dts: exynos: gs101: use correct clocks for usi_uart
  2024-01-27  0:35 ` [PATCH 4/5] arm64: dts: exynos: gs101: use correct clocks for usi_uart André Draszik
@ 2024-01-27  1:37   ` André Draszik
  2024-01-27  3:23   ` Sam Protsenko
  2024-01-27  4:03   ` Tudor Ambarus
  2 siblings, 0 replies; 28+ messages in thread
From: André Draszik @ 2024-01-27  1:37 UTC (permalink / raw)
  To: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	semen.protsenko, alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi,
	mturquette, sboyd, linux-arm-kernel, linux-samsung-soc,
	linux-clk, devicetree

On Sat, 2024-01-27 at 00:35 +0000, André Draszik wrote:
> Wrong pclk clocks have been used in this usi8 instance here. For USI
                                           ^^^^
This should read 'uart', I'll send a v2 after collecting any other potential
feedback.

Cheers,
Andre'


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

* Re: [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical
  2024-01-27  0:35 ` [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical André Draszik
@ 2024-01-27  1:38   ` André Draszik
  2024-01-27  3:30   ` Sam Protsenko
  2024-01-29 16:44   ` Tudor Ambarus
  2 siblings, 0 replies; 28+ messages in thread
From: André Draszik @ 2024-01-27  1:38 UTC (permalink / raw)
  To: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	semen.protsenko, alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi,
	mturquette, sboyd, linux-arm-kernel, linux-samsung-soc,
	linux-clk, devicetree

On Sat, 2024-01-27 at 00:35 +0000, 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 pclkk in the respective node and instead the two clocks
               ^^^^^

'pclk', I'll send a v2 after collecting any other potential feedback.

Cheers,
Andre'


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

* Re: gs101 oriole: peripheral block 0 (peric0) fixes
  2024-01-27  0:35 gs101 oriole: peripheral block 0 (peric0) fixes André Draszik
                   ` (4 preceding siblings ...)
  2024-01-27  0:35 ` [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical André Draszik
@ 2024-01-27  3:01 ` Sam Protsenko
  5 siblings, 0 replies; 28+ messages in thread
From: Sam Protsenko @ 2024-01-27  3:01 UTC (permalink / raw)
  To: André Draszik
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree

On Fri, Jan 26, 2024 at 6:37 PM André Draszik <andre.draszik@linaro.org> wrote:
>
> Hi,
>
> While working on peric1, I've noticed a few issues in the peric0 area
> and these patches are the result. They should all be pretty
> self-explanatory.
>

Looks like "PATCH [00/xx]" is missing in the title.

> Cheers,
> Andre'
>
>  arch/arm64/boot/dts/exynos/google/gs101.dtsi | 9 +++++----
>  drivers/clk/samsung/clk-gs101.c              | 8 +++-----
>  2 files changed, 8 insertions(+), 9 deletions(-)
>

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

* Re: [PATCH 2/5] arm64: dts: exynos: gs101: fix usi8 default mode
  2024-01-27  0:35 ` [PATCH 2/5] arm64: dts: exynos: gs101: fix usi8 default mode André Draszik
@ 2024-01-27  3:05   ` Sam Protsenko
  2024-01-27  3:48   ` Tudor Ambarus
  2024-01-29  9:48   ` Peter Griffin
  2 siblings, 0 replies; 28+ messages in thread
From: Sam Protsenko @ 2024-01-27  3:05 UTC (permalink / raw)
  To: André Draszik
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree

On Fri, Jan 26, 2024 at 6:37 PM André Draszik <andre.draszik@linaro.org> wrote:
>
> While commit 6d44d1a1fb62 ("arm64: dts: exynos: gs101: define USI8 with
> I2C configuration") states that the USI8 CONFIG is 0 at reset, the boot
> loader has configured it by the time Linux runs and it has a different
> value at this stage.
>
> Since we want board DTS files to explicitly select the mode, we should
> set it to none here so as to ensure things don't work by accident and
> to make it clear that board DTS actually need to set the mode based on
> the configuration.
>
> Fixes: 6d44d1a1fb62 ("arm64: dts: exynos: gs101: define USI8 with I2C configuration")
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>

>  arch/arm64/boot/dts/exynos/google/gs101.dtsi | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> index aaac04df5e65..bc251e565be6 100644
> --- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> +++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> @@ -384,6 +384,7 @@ usi8: usi@109700c0 {
>                                  <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_IPCLK_7>;
>                         clock-names = "pclk", "ipclk";
>                         samsung,sysreg = <&sysreg_peric0 0x101c>;
> +                       samsung,mode = <USI_V2_NONE>;
>                         status = "disabled";
>
>                         hsi2c_8: i2c@10970000 {
> --
> 2.43.0.429.g432eaa2c6b-goog
>

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

* Re: [PATCH 1/5] clk: samsung: gs101: gpio_peric0_pclk needs to be kept on
  2024-01-27  0:35 ` [PATCH 1/5] clk: samsung: gs101: gpio_peric0_pclk needs to be kept on André Draszik
@ 2024-01-27  3:06   ` Sam Protsenko
  2024-01-27  3:51   ` Tudor Ambarus
  2024-01-29 12:54   ` Peter Griffin
  2 siblings, 0 replies; 28+ messages in thread
From: Sam Protsenko @ 2024-01-27  3:06 UTC (permalink / raw)
  To: André Draszik
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree

On Fri, Jan 26, 2024 at 6:37 PM André Draszik <andre.draszik@linaro.org> wrote:
>
> This pclk clock is required any time we access the pinctrl registers of
> this block.
>
> Since pinctrl-samsung doesn't support a clock at the moment, we just
> keep the kernel from disabling it at boot, until we have an update for
> pinctrl-samsung to handle this required clock, at which point we'll be
> able to drop the flag again.
>
> Fixes: 893f133a040b ("clk: samsung: gs101: add support for cmu_peric0")
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>

>  drivers/clk/samsung/clk-gs101.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/samsung/clk-gs101.c b/drivers/clk/samsung/clk-gs101.c
> index 4a0520e825b6..61bb0dcf84ee 100644
> --- a/drivers/clk/samsung/clk-gs101.c
> +++ b/drivers/clk/samsung/clk-gs101.c
> @@ -2848,7 +2848,7 @@ static const struct samsung_gate_clock peric0_gate_clks[] __initconst = {
>         GATE(CLK_GOUT_PERIC0_GPIO_PERIC0_PCLK,
>              "gout_peric0_gpio_peric0_pclk", "mout_peric0_bus_user",
>              CLK_CON_GAT_GOUT_BLK_PERIC0_UID_GPIO_PERIC0_IPCLKPORT_PCLK,
> -            21, 0, 0),
> +            21, CLK_IGNORE_UNUSED, 0),
>         /* Disabling this clock makes the system hang. Mark the clock as critical. */
>         GATE(CLK_GOUT_PERIC0_LHM_AXI_P_PERIC0_I_CLK,
>              "gout_peric0_lhm_axi_p_peric0_i_clk", "mout_peric0_bus_user",
> --
> 2.43.0.429.g432eaa2c6b-goog
>

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

* Re: [PATCH 3/5] arm64: dts: exynos: gs101: use correct clocks for usi8
  2024-01-27  0:35 ` [PATCH 3/5] arm64: dts: exynos: gs101: use correct clocks for usi8 André Draszik
@ 2024-01-27  3:22   ` Sam Protsenko
  2024-01-27  4:00     ` Tudor Ambarus
  2024-01-29 14:01     ` André Draszik
  0 siblings, 2 replies; 28+ messages in thread
From: Sam Protsenko @ 2024-01-27  3:22 UTC (permalink / raw)
  To: André Draszik
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree

On Fri, Jan 26, 2024 at 6:37 PM André Draszik <andre.draszik@linaro.org> wrote:
>
> Wrong pclk clocks have been used in this usi8 instance here. For USI
> and I2C, we need the ipclk and pclk, where pclk is the bus clock.
> Without it, nothing can work.

Empty line is missing here?

> It is unclear what exactly is using USI8_USI_CLK, but it is not
> required for the IP to be operational at this stage, while pclk is.

From [1] it looks like DIV_CLK_PERIC0_USI8_USI is a common parrent for
these two leaf gate clocks:
  1. GOUT_BLK_PERIC0_UID_RSTNSYNC_CLK_PERIC0_USI8_USI_IPCLKPORT_CLK
  2. GOUT_BLK_PERIC0_UID_PERIC0_TOP0_IPCLKPORT_IPCLK_7

So IIUC, you replace clock #1 with clock #2 in this patch? If so, I
think that's a right move, because in my experience RSTNSYNC clocks
shouldn't be used at all for consumer IP-cores. That's why I never
added RSTNSYNC clocks in clk-exynos850 driver at all -- I only see
them useful for store/restore ops during suspend/resume.

[1] https://android.googlesource.com/kernel/gs/+/refs/tags/android-12.0.0_r0.17/drivers/soc/google/cal-if/gs101/cmucal-node.c#2793

> This also brings the DT in line with the clock names expected by the
> usi and i2c drivers.
>
> Update the DTSI accordingly.
>
> Fixes: 6d44d1a1fb62 ("arm64: dts: exynos: gs101: define USI8 with I2C configuration")
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>

>  arch/arm64/boot/dts/exynos/google/gs101.dtsi | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> index bc251e565be6..e5b665be2d62 100644
> --- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> +++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> @@ -380,7 +380,7 @@ usi8: usi@109700c0 {
>                         ranges;
>                         #address-cells = <1>;
>                         #size-cells = <1>;
> -                       clocks = <&cmu_peric0 CLK_GOUT_PERIC0_CLK_PERIC0_USI8_USI_CLK>,
> +                       clocks = <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_PCLK_7>,
>                                  <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_IPCLK_7>;
>                         clock-names = "pclk", "ipclk";
>                         samsung,sysreg = <&sysreg_peric0 0x101c>;
> @@ -397,7 +397,7 @@ hsi2c_8: i2c@10970000 {
>                                 pinctrl-names = "default";
>                                 pinctrl-0 = <&hsi2c8_bus>;
>                                 clocks = <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_IPCLK_7>,
> -                                        <&cmu_peric0 CLK_GOUT_PERIC0_CLK_PERIC0_USI8_USI_CLK>;
> +                                        <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_PCLK_7>;
>                                 clock-names = "hsi2c", "hsi2c_pclk";
>                                 status = "disabled";
>                         };
> --
> 2.43.0.429.g432eaa2c6b-goog
>

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

* Re: [PATCH 4/5] arm64: dts: exynos: gs101: use correct clocks for usi_uart
  2024-01-27  0:35 ` [PATCH 4/5] arm64: dts: exynos: gs101: use correct clocks for usi_uart André Draszik
  2024-01-27  1:37   ` André Draszik
@ 2024-01-27  3:23   ` Sam Protsenko
  2024-01-27  4:03   ` Tudor Ambarus
  2 siblings, 0 replies; 28+ messages in thread
From: Sam Protsenko @ 2024-01-27  3:23 UTC (permalink / raw)
  To: André Draszik
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree

On Fri, Jan 26, 2024 at 6:37 PM André Draszik <andre.draszik@linaro.org> wrote:
>
> Wrong pclk clocks have been used in this usi8 instance here. For USI
> and UART, we need the ipclk and pclk, where pclk is the bus clock.
> Without it, nothing can work.

Missing empty line?

> It is unclear what exactly is using USI0_UART_CLK, but it is not
> required for the IP to be operational at this stage, while pclk is.
> This also brings the DT in line with the clock names expected by the
> usi and uart drivers.
>
> Update the DTSI accordingly.
>
> Fixes: d97b6c902a40 ("arm64: dts: exynos: gs101: update USI UART to use peric0 clocks")
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>

>  arch/arm64/boot/dts/exynos/google/gs101.dtsi | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> index e5b665be2d62..f93e937d2726 100644
> --- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> +++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> @@ -410,7 +410,7 @@ usi_uart: usi@10a000c0 {
>                         ranges;
>                         #address-cells = <1>;
>                         #size-cells = <1>;
> -                       clocks = <&cmu_peric0 CLK_GOUT_PERIC0_CLK_PERIC0_USI0_UART_CLK>,
> +                       clocks = <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_0>,
>                                  <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_0>;
>                         clock-names = "pclk", "ipclk";
>                         samsung,sysreg = <&sysreg_peric0 0x1020>;
> @@ -422,7 +422,7 @@ serial_0: serial@10a00000 {
>                                 reg = <0x10a00000 0xc0>;
>                                 interrupts = <GIC_SPI 634
>                                               IRQ_TYPE_LEVEL_HIGH 0>;
> -                               clocks = <&cmu_peric0 CLK_GOUT_PERIC0_CLK_PERIC0_USI0_UART_CLK>,
> +                               clocks = <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_0>,
>                                          <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_0>;
>                                 clock-names = "uart", "clk_uart_baud0";
>                                 samsung,uart-fifosize = <256>;
> --
> 2.43.0.429.g432eaa2c6b-goog
>

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

* Re: [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical
  2024-01-27  0:35 ` [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical André Draszik
  2024-01-27  1:38   ` André Draszik
@ 2024-01-27  3:30   ` Sam Protsenko
  2024-01-29 14:37     ` André Draszik
  2024-01-29 16:44   ` Tudor Ambarus
  2 siblings, 1 reply; 28+ messages in thread
From: Sam Protsenko @ 2024-01-27  3:30 UTC (permalink / raw)
  To: André Draszik
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree

On Fri, Jan 26, 2024 at 6:37 PM André Draszik <andre.draszik@linaro.org> 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.

Empty line is missing here?

> Unfortunately, in commit d97b6c902a40 ("arm64: dts: exynos: gs101:
> update USI UART to use peric0 clocks") the gs101 DT ended up specifying
> an incorrect pclkk in the respective node and instead the two clocks
> here were marked as critical.
>
> We have fixed the gs101 DT and can therefore drop this incorrect
> work-around here, the uart driver will claim these clocks as needed.
>
> 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

That's weird. Doesn't your bootloader setup serial clocks properly?
AFAIU, earlycon should rely on everything already configured in
bootloader.

>     * 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
> 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!).

That sounds... not ideal. The ability to enable earlycon just by
adding some string to bootargs can be very useful for developers.
Maybe just make those clocks CLK_IGNORE_UNUSED, if that keeps earlycon
functional? With corresponding comments of course.

>
> Fixes: 893f133a040b ("clk: samsung: gs101: add support for cmu_peric0")
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
>  drivers/clk/samsung/clk-gs101.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clk/samsung/clk-gs101.c b/drivers/clk/samsung/clk-gs101.c
> index 61bb0dcf84ee..5c338ac9231c 100644
> --- a/drivers/clk/samsung/clk-gs101.c
> +++ b/drivers/clk/samsung/clk-gs101.c
> @@ -2982,20 +2982,18 @@ static const struct samsung_gate_clock peric0_gate_clks[] __initconst = {
>              "gout_peric0_peric0_top0_pclk_9", "mout_peric0_bus_user",
>              CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP0_IPCLKPORT_PCLK_9,
>              21, 0, 0),
> -       /* Disabling this clock makes the system hang. Mark the clock as critical. */
>         GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_0,
>              "gout_peric0_peric0_top1_ipclk_0", "dout_peric0_usi0_uart",
>              CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_IPCLK_0,
> -            21, CLK_IS_CRITICAL, 0),
> +            21, 0, 0),
>         GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_2,
>              "gout_peric0_peric0_top1_ipclk_2", "dout_peric0_usi14_usi",
>              CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_IPCLK_2,
>              21, 0, 0),
> -       /* Disabling this clock makes the system hang. Mark the clock as critical. */
>         GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_0,
>              "gout_peric0_peric0_top1_pclk_0", "mout_peric0_bus_user",
>              CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_PCLK_0,
> -            21, CLK_IS_CRITICAL, 0),
> +            21, 0, 0),
>         GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_2,
>              "gout_peric0_peric0_top1_pclk_2", "mout_peric0_bus_user",
>              CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_PCLK_2,
> --
> 2.43.0.429.g432eaa2c6b-goog
>

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

* Re: [PATCH 2/5] arm64: dts: exynos: gs101: fix usi8 default mode
  2024-01-27  0:35 ` [PATCH 2/5] arm64: dts: exynos: gs101: fix usi8 default mode André Draszik
  2024-01-27  3:05   ` Sam Protsenko
@ 2024-01-27  3:48   ` Tudor Ambarus
  2024-01-29  9:48   ` Peter Griffin
  2 siblings, 0 replies; 28+ messages in thread
From: Tudor Ambarus @ 2024-01-27  3:48 UTC (permalink / raw)
  To: André Draszik, peter.griffin, robh+dt,
	krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, willmcvicker, semen.protsenko,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree



On 1/27/24 00:35, André Draszik wrote:
> While commit 6d44d1a1fb62 ("arm64: dts: exynos: gs101: define USI8 with
> I2C configuration") states that the USI8 CONFIG is 0 at reset, the boot
> loader has configured it by the time Linux runs and it has a different
> value at this stage.
> 

ah, I didn't think about this, nor checked it.

> Since we want board DTS files to explicitly select the mode, we should
> set it to none here so as to ensure things don't work by accident and
> to make it clear that board DTS actually need to set the mode based on
> the configuration.
> 
> Fixes: 6d44d1a1fb62 ("arm64: dts: exynos: gs101: define USI8 with I2C configuration")
> Signed-off-by: André Draszik <andre.draszik@linaro.org>

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>

> ---
>  arch/arm64/boot/dts/exynos/google/gs101.dtsi | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> index aaac04df5e65..bc251e565be6 100644
> --- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> +++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> @@ -384,6 +384,7 @@ usi8: usi@109700c0 {
>  				 <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_IPCLK_7>;
>  			clock-names = "pclk", "ipclk";
>  			samsung,sysreg = <&sysreg_peric0 0x101c>;
> +			samsung,mode = <USI_V2_NONE>;
>  			status = "disabled";
>  
>  			hsi2c_8: i2c@10970000 {

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

* Re: [PATCH 1/5] clk: samsung: gs101: gpio_peric0_pclk needs to be kept on
  2024-01-27  0:35 ` [PATCH 1/5] clk: samsung: gs101: gpio_peric0_pclk needs to be kept on André Draszik
  2024-01-27  3:06   ` Sam Protsenko
@ 2024-01-27  3:51   ` Tudor Ambarus
  2024-01-29 12:54   ` Peter Griffin
  2 siblings, 0 replies; 28+ messages in thread
From: Tudor Ambarus @ 2024-01-27  3:51 UTC (permalink / raw)
  To: André Draszik, peter.griffin, robh+dt,
	krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, willmcvicker, semen.protsenko,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree



On 1/27/24 00:35, André Draszik wrote:
> This pclk clock is required any time we access the pinctrl registers of
> this block.
> 
> Since pinctrl-samsung doesn't support a clock at the moment, we just
> keep the kernel from disabling it at boot, until we have an update for
> pinctrl-samsung to handle this required clock, at which point we'll be
> able to drop the flag again.
> 
> 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>

> ---
>  drivers/clk/samsung/clk-gs101.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/samsung/clk-gs101.c b/drivers/clk/samsung/clk-gs101.c
> index 4a0520e825b6..61bb0dcf84ee 100644
> --- a/drivers/clk/samsung/clk-gs101.c
> +++ b/drivers/clk/samsung/clk-gs101.c
> @@ -2848,7 +2848,7 @@ static const struct samsung_gate_clock peric0_gate_clks[] __initconst = {
>  	GATE(CLK_GOUT_PERIC0_GPIO_PERIC0_PCLK,
>  	     "gout_peric0_gpio_peric0_pclk", "mout_peric0_bus_user",
>  	     CLK_CON_GAT_GOUT_BLK_PERIC0_UID_GPIO_PERIC0_IPCLKPORT_PCLK,
> -	     21, 0, 0),
> +	     21, CLK_IGNORE_UNUSED, 0),
>  	/* Disabling this clock makes the system hang. Mark the clock as critical. */
>  	GATE(CLK_GOUT_PERIC0_LHM_AXI_P_PERIC0_I_CLK,
>  	     "gout_peric0_lhm_axi_p_peric0_i_clk", "mout_peric0_bus_user",

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

* Re: [PATCH 3/5] arm64: dts: exynos: gs101: use correct clocks for usi8
  2024-01-27  3:22   ` Sam Protsenko
@ 2024-01-27  4:00     ` Tudor Ambarus
  2024-01-29 16:33       ` Tudor Ambarus
  2024-01-29 14:01     ` André Draszik
  1 sibling, 1 reply; 28+ messages in thread
From: Tudor Ambarus @ 2024-01-27  4:00 UTC (permalink / raw)
  To: Sam Protsenko, André Draszik
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, willmcvicker, alim.akhtar, s.nawrocki,
	tomasz.figa, cw00.choi, mturquette, sboyd, linux-arm-kernel,
	linux-samsung-soc, linux-clk, devicetree



On 1/27/24 03:22, Sam Protsenko wrote:
> On Fri, Jan 26, 2024 at 6:37 PM André Draszik <andre.draszik@linaro.org> wrote:
>>
>> Wrong pclk clocks have been used in this usi8 instance here. For USI
>> and I2C, we need the ipclk and pclk, where pclk is the bus clock.
>> Without it, nothing can work.
> 
> Empty line is missing here?
> 
>> It is unclear what exactly is using USI8_USI_CLK, but it is not
>> required for the IP to be operational at this stage, while pclk is.
> 
> From [1] it looks like DIV_CLK_PERIC0_USI8_USI is a common parrent for
> these two leaf gate clocks:
>   1. GOUT_BLK_PERIC0_UID_RSTNSYNC_CLK_PERIC0_USI8_USI_IPCLKPORT_CLK
>   2. GOUT_BLK_PERIC0_UID_PERIC0_TOP0_IPCLKPORT_IPCLK_7
> 
> So IIUC, you replace clock #1 with clock #2 in this patch? If so, I

No, GOUT_BLK_PERIC0_UID_PERIC0_TOP0_IPCLKPORT_IPCLK_7 is already used by
IPCLK, the one that controls the clock frequency.

So I understand Andre' replaces a child of the USI8 with something else.

I don't think this works. We shall at least test it. I tested my usi8
patches with the eeprom that's populated on the battery connector. I'll
sync with Andre' offline and redo the tests on Monday.

> think that's a right move, because in my experience RSTNSYNC clocks
> shouldn't be used at all for consumer IP-cores. That's why I never
> added RSTNSYNC clocks in clk-exynos850 driver at all -- I only see
> them useful for store/restore ops during suspend/resume.
> 
> [1] https://android.googlesource.com/kernel/gs/+/refs/tags/android-12.0.0_r0.17/drivers/soc/google/cal-if/gs101/cmucal-node.c#2793
> 
>> This also brings the DT in line with the clock names expected by the
>> usi and i2c drivers.
>>
>> Update the DTSI accordingly.
>>
>> Fixes: 6d44d1a1fb62 ("arm64: dts: exynos: gs101: define USI8 with I2C configuration")
>> Signed-off-by: André Draszik <andre.draszik@linaro.org>
>> ---
> 
> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
> 
>>  arch/arm64/boot/dts/exynos/google/gs101.dtsi | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
>> index bc251e565be6..e5b665be2d62 100644
>> --- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi
>> +++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
>> @@ -380,7 +380,7 @@ usi8: usi@109700c0 {
>>                         ranges;
>>                         #address-cells = <1>;
>>                         #size-cells = <1>;
>> -                       clocks = <&cmu_peric0 CLK_GOUT_PERIC0_CLK_PERIC0_USI8_USI_CLK>,
>> +                       clocks = <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_PCLK_7>,
>>                                  <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_IPCLK_7>;
>>                         clock-names = "pclk", "ipclk";
>>                         samsung,sysreg = <&sysreg_peric0 0x101c>;
>> @@ -397,7 +397,7 @@ hsi2c_8: i2c@10970000 {
>>                                 pinctrl-names = "default";
>>                                 pinctrl-0 = <&hsi2c8_bus>;
>>                                 clocks = <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_IPCLK_7>,
>> -                                        <&cmu_peric0 CLK_GOUT_PERIC0_CLK_PERIC0_USI8_USI_CLK>;
>> +                                        <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_PCLK_7>;
>>                                 clock-names = "hsi2c", "hsi2c_pclk";
>>                                 status = "disabled";
>>                         };
>> --
>> 2.43.0.429.g432eaa2c6b-goog
>>

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

* Re: [PATCH 4/5] arm64: dts: exynos: gs101: use correct clocks for usi_uart
  2024-01-27  0:35 ` [PATCH 4/5] arm64: dts: exynos: gs101: use correct clocks for usi_uart André Draszik
  2024-01-27  1:37   ` André Draszik
  2024-01-27  3:23   ` Sam Protsenko
@ 2024-01-27  4:03   ` Tudor Ambarus
  2024-01-29 16:39     ` Tudor Ambarus
  2 siblings, 1 reply; 28+ messages in thread
From: Tudor Ambarus @ 2024-01-27  4:03 UTC (permalink / raw)
  To: André Draszik, peter.griffin, robh+dt,
	krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, willmcvicker, semen.protsenko,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree



On 1/27/24 00:35, André Draszik wrote:
> Wrong pclk clocks have been used in this usi8 instance here. For USI
> and UART, we need the ipclk and pclk, where pclk is the bus clock.
> Without it, nothing can work.
> It is unclear what exactly is using USI0_UART_CLK, but it is not
> required for the IP to be operational at this stage, while pclk is.
> This also brings the DT in line with the clock names expected by the
> usi and uart drivers.
> 
> Update the DTSI accordingly.
> 
> Fixes: d97b6c902a40 ("arm64: dts: exynos: gs101: update USI UART to use peric0 clocks")
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
>  arch/arm64/boot/dts/exynos/google/gs101.dtsi | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> index e5b665be2d62..f93e937d2726 100644
> --- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> +++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> @@ -410,7 +410,7 @@ usi_uart: usi@10a000c0 {
>  			ranges;
>  			#address-cells = <1>;
>  			#size-cells = <1>;
> -			clocks = <&cmu_peric0 CLK_GOUT_PERIC0_CLK_PERIC0_USI0_UART_CLK>,
> +			clocks = <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_0>,

As I said in the previous email, I don't think this is correct. This is
just a heads up for Krzysztof to not pick these 2 patches yet. We'll
come back on this matter on Monday.

>  				 <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_0>;
>  			clock-names = "pclk", "ipclk";
>  			samsung,sysreg = <&sysreg_peric0 0x1020>;
> @@ -422,7 +422,7 @@ serial_0: serial@10a00000 {
>  				reg = <0x10a00000 0xc0>;
>  				interrupts = <GIC_SPI 634
>  					      IRQ_TYPE_LEVEL_HIGH 0>;
> -				clocks = <&cmu_peric0 CLK_GOUT_PERIC0_CLK_PERIC0_USI0_UART_CLK>,
> +				clocks = <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_0>,
>  					 <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_0>;
>  				clock-names = "uart", "clk_uart_baud0";
>  				samsung,uart-fifosize = <256>;

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

* Re: [PATCH 2/5] arm64: dts: exynos: gs101: fix usi8 default mode
  2024-01-27  0:35 ` [PATCH 2/5] arm64: dts: exynos: gs101: fix usi8 default mode André Draszik
  2024-01-27  3:05   ` Sam Protsenko
  2024-01-27  3:48   ` Tudor Ambarus
@ 2024-01-29  9:48   ` Peter Griffin
  2 siblings, 0 replies; 28+ messages in thread
From: Peter Griffin @ 2024-01-29  9:48 UTC (permalink / raw)
  To: André Draszik
  Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, linux-kernel,
	kernel-team, tudor.ambarus, willmcvicker, semen.protsenko,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree

On Sat, 27 Jan 2024 at 00:37, André Draszik <andre.draszik@linaro.org> wrote:
>
> While commit 6d44d1a1fb62 ("arm64: dts: exynos: gs101: define USI8 with
> I2C configuration") states that the USI8 CONFIG is 0 at reset, the boot
> loader has configured it by the time Linux runs and it has a different
> value at this stage.
>
> Since we want board DTS files to explicitly select the mode, we should
> set it to none here so as to ensure things don't work by accident and
> to make it clear that board DTS actually need to set the mode based on
> the configuration.
>
> Fixes: 6d44d1a1fb62 ("arm64: dts: exynos: gs101: define USI8 with I2C configuration")
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>

>  arch/arm64/boot/dts/exynos/google/gs101.dtsi | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> index aaac04df5e65..bc251e565be6 100644
> --- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> +++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi
> @@ -384,6 +384,7 @@ usi8: usi@109700c0 {
>                                  <&cmu_peric0 CLK_GOUT_PERIC0_PERIC0_TOP0_IPCLK_7>;
>                         clock-names = "pclk", "ipclk";
>                         samsung,sysreg = <&sysreg_peric0 0x101c>;
> +                       samsung,mode = <USI_V2_NONE>;
>                         status = "disabled";
>
>                         hsi2c_8: i2c@10970000 {
> --
> 2.43.0.429.g432eaa2c6b-goog
>

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

* Re: [PATCH 1/5] clk: samsung: gs101: gpio_peric0_pclk needs to be kept on
  2024-01-27  0:35 ` [PATCH 1/5] clk: samsung: gs101: gpio_peric0_pclk needs to be kept on André Draszik
  2024-01-27  3:06   ` Sam Protsenko
  2024-01-27  3:51   ` Tudor Ambarus
@ 2024-01-29 12:54   ` Peter Griffin
  2 siblings, 0 replies; 28+ messages in thread
From: Peter Griffin @ 2024-01-29 12:54 UTC (permalink / raw)
  To: André Draszik
  Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, linux-kernel,
	kernel-team, tudor.ambarus, willmcvicker, semen.protsenko,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree

On Sat, 27 Jan 2024 at 00:37, André Draszik <andre.draszik@linaro.org> wrote:
>
> This pclk clock is required any time we access the pinctrl registers of
> this block.
>
> Since pinctrl-samsung doesn't support a clock at the moment, we just
> keep the kernel from disabling it at boot, until we have an update for
> pinctrl-samsung to handle this required clock, at which point we'll be
> able to drop the flag again.
>
> Fixes: 893f133a040b ("clk: samsung: gs101: add support for cmu_peric0")
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>

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

* Re: [PATCH 3/5] arm64: dts: exynos: gs101: use correct clocks for usi8
  2024-01-27  3:22   ` Sam Protsenko
  2024-01-27  4:00     ` Tudor Ambarus
@ 2024-01-29 14:01     ` André Draszik
  1 sibling, 0 replies; 28+ messages in thread
From: André Draszik @ 2024-01-29 14:01 UTC (permalink / raw)
  To: Sam Protsenko
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree

Hi Sam,

On Fri, 2024-01-26 at 21:22 -0600, Sam Protsenko wrote:
> From [1] it looks like DIV_CLK_PERIC0_USI8_USI is a common parrent for
> these two leaf gate clocks:
>   1. GOUT_BLK_PERIC0_UID_RSTNSYNC_CLK_PERIC0_USI8_USI_IPCLKPORT_CLK
>   2. GOUT_BLK_PERIC0_UID_PERIC0_TOP0_IPCLKPORT_IPCLK_7
> 
> So IIUC, you replace clock #1 with clock #2 in this patch? If so, I
> think that's a right move, because in my experience RSTNSYNC clocks

That is correct.

Cheers,
Andre'


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

* Re: [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical
  2024-01-27  3:30   ` Sam Protsenko
@ 2024-01-29 14:37     ` André Draszik
  2024-01-29 19:16       ` Sam Protsenko
  0 siblings, 1 reply; 28+ messages in thread
From: André Draszik @ 2024-01-29 14:37 UTC (permalink / raw)
  To: Sam Protsenko
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree

Hi Sam,

On Fri, 2024-01-26 at 21:30 -0600, Sam Protsenko wrote:
> On Fri, Jan 26, 2024 at 6:37 PM André Draszik <andre.draszik@linaro.org> wrote:
> 
> > 
> > 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
> 
> That's weird. Doesn't your bootloader setup serial clocks properly?
> AFAIU, earlycon should rely on everything already configured in
> bootloader.

I tried to explain that above, but let me try again...

The console UART, and I2C bus 8 are on the same cmu_peric0 controller, and
that cmu_peric0 has two clocks coming from cmu_top, ip and bus. For I2C8 & UART
to work, both of these clocks from cmu_top need to to be on as they are the
parent of the i2c8-(ip|pclk) and uart-(ip|pclk) each.

The bootloader leaves those clocks running, yes. So earlycon works (for a
while).

At some point into the boot, one of two things happens:
1) Linux will load the i2c driver. That driver does clock handling
(correctly), it will initialise and then it has nothing to do, therefore it
disables cmu_peric0's i2c8 ip and pclk clocks. Because at that stage nothing
appears to be using the cmu_peric0's ip clock (the real serial driver hasn't
initialised yet), Linux decides to also disable the parent ip clock coming
from cmu_top.

At this stage, the earlycon driver stops working, as the parent ip clock of
the uart ip clock is not running any more. No serial output can be observed
from this stage onwards. I think what is probably happening is that the
console uart FIFO doesn't get emptied anymore, and earlycon will simply wait
forever for space to become available in the FIFO (but I didn't debug this).

Anyway, the boot doesn't progress, the system appears to hang. In any case it's
not usable as we have no other means of using it at this stage (network /
usb / display etc.).

2) Alternatively, the UART driver will load at this stage. Again, it will
tweak the clocks and after probe it will leave its clocks disabled. The
serial console driver hasn't taken over at this stage and earlycon is still
active. Again, the system will hang, because IP and PCLK have been disabled
by the UART driver. Once the serial console is enabled, clocks are being
enabled again, but because earlycon is still waiting for progress, the
boot doesn't progress past disabling ip and pclk. It never gets to enabling
the serial console (re-enabling the clocks).

So in both cases we get some output from earlycon, but the system hangs once
the first consumer driver of an IP attached to cmu_peric0 has completed
probing.



> >     * 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
> > 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!).
> 
> That sounds... not ideal. The ability to enable earlycon just by
> adding some string to bootargs can be very useful for developers.
> Maybe just make those clocks CLK_IGNORE_UNUSED, if that keeps earlycon
> functional? With corresponding comments of course.

CLK_IGNORE_UNUSED doesn't help in this case, the i2c and uart drivers will load
and probe before earlycon gets disabled and as part of their probing disable
the cmu_top ip clock going to cmu_peric0

If earlycon is not enabled in kernel command line, everything works fine, the
kernel buffers its messages and once the real serial console driver starts,
all messages since boot are being printed.

Other than keeping it as CLK_IS_CRITICAL, there is no way that I can see to
way to make the hand-over from earlycon to the real serial driver work in
all cases.

They are not critical clocks for the system, though, so it's wrong to always
keep them running unconditionally.

We are past a stage where earlycon is generally required.

If it's required for some local development, people can revert this patch locally.


BTW, downstream doesn't suffer from this problem because downstream uses ACG
throughout and clocks are enabled automatically in hardware as required.


Cheers,
Andre'


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

* Re: [PATCH 3/5] arm64: dts: exynos: gs101: use correct clocks for usi8
  2024-01-27  4:00     ` Tudor Ambarus
@ 2024-01-29 16:33       ` Tudor Ambarus
  0 siblings, 0 replies; 28+ messages in thread
From: Tudor Ambarus @ 2024-01-29 16:33 UTC (permalink / raw)
  To: Sam Protsenko, André Draszik, Krzysztof Kozlowski
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, willmcvicker, alim.akhtar, s.nawrocki,
	tomasz.figa, cw00.choi, mturquette, sboyd, linux-arm-kernel,
	linux-samsung-soc, linux-clk, devicetree



On 1/27/24 04:00, Tudor Ambarus wrote:
>>> Wrong pclk clocks have been used in this usi8 instance here. For USI
>>> and I2C, we need the ipclk and pclk, where pclk is the bus clock.
>>> Without it, nothing can work.
>> Empty line is missing here?
>>
>>> It is unclear what exactly is using USI8_USI_CLK, but it is not
>>> required for the IP to be operational at this stage, while pclk is.
>> From [1] it looks like DIV_CLK_PERIC0_USI8_USI is a common parrent for
>> these two leaf gate clocks:
>>   1. GOUT_BLK_PERIC0_UID_RSTNSYNC_CLK_PERIC0_USI8_USI_IPCLKPORT_CLK
>>   2. GOUT_BLK_PERIC0_UID_PERIC0_TOP0_IPCLKPORT_IPCLK_7
>>
>> So IIUC, you replace clock #1 with clock #2 in this patch? If so, I
> No, GOUT_BLK_PERIC0_UID_PERIC0_TOP0_IPCLKPORT_IPCLK_7 is already used by
> IPCLK, the one that controls the clock frequency.
> 
> So I understand Andre' replaces a child of the USI8 with something else.
> 
> I don't think this works. We shall at least test it. I tested my usi8
> patches with the eeprom that's populated on the battery connector. I'll
> sync with Andre' offline and redo the tests on Monday.

Andre' is right, I messed up the bus clocks for USI. I tested the IPCLK,
the one that feeds USI clients, but I failed to correctly test the bus
clock. I retested by removing the clk_ignore_unused bootargs param and
verified that the patch is correct.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Tested-by: Tudor Ambarus <tudor.ambarus@linaro.org>

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

* Re: [PATCH 4/5] arm64: dts: exynos: gs101: use correct clocks for usi_uart
  2024-01-27  4:03   ` Tudor Ambarus
@ 2024-01-29 16:39     ` Tudor Ambarus
  0 siblings, 0 replies; 28+ messages in thread
From: Tudor Ambarus @ 2024-01-29 16:39 UTC (permalink / raw)
  To: André Draszik, peter.griffin, robh+dt,
	krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, willmcvicker, semen.protsenko,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree



On 1/27/24 04:03, Tudor Ambarus wrote:
> We'll
> come back on this matter on Monday.

I tested (correctly this time) and the patch is good:

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Tested-by: Tudor Ambarus <tudor.ambarus@linaro.org>

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

* Re: [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical
  2024-01-27  0:35 ` [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical André Draszik
  2024-01-27  1:38   ` André Draszik
  2024-01-27  3:30   ` Sam Protsenko
@ 2024-01-29 16:44   ` Tudor Ambarus
  2 siblings, 0 replies; 28+ messages in thread
From: Tudor Ambarus @ 2024-01-29 16:44 UTC (permalink / raw)
  To: André Draszik, peter.griffin, robh+dt,
	krzysztof.kozlowski+dt, conor+dt
  Cc: linux-kernel, kernel-team, willmcvicker, semen.protsenko,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree



On 1/27/24 00:35, 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 pclkk in the respective node and instead the two clocks
> here were marked as critical.
> 
> We have fixed the gs101 DT and can therefore drop this incorrect
> work-around here, the uart driver will claim these clocks as needed.
> 
> 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
> 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!).
> 
> Fixes: 893f133a040b ("clk: samsung: gs101: add support for cmu_peric0")
> Signed-off-by: André Draszik <andre.draszik@linaro.org>

I find the logic fine:

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>

> ---
>  drivers/clk/samsung/clk-gs101.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/clk/samsung/clk-gs101.c b/drivers/clk/samsung/clk-gs101.c
> index 61bb0dcf84ee..5c338ac9231c 100644
> --- a/drivers/clk/samsung/clk-gs101.c
> +++ b/drivers/clk/samsung/clk-gs101.c
> @@ -2982,20 +2982,18 @@ static const struct samsung_gate_clock peric0_gate_clks[] __initconst = {
>  	     "gout_peric0_peric0_top0_pclk_9", "mout_peric0_bus_user",
>  	     CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP0_IPCLKPORT_PCLK_9,
>  	     21, 0, 0),
> -	/* Disabling this clock makes the system hang. Mark the clock as critical. */
>  	GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_0,
>  	     "gout_peric0_peric0_top1_ipclk_0", "dout_peric0_usi0_uart",
>  	     CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_IPCLK_0,
> -	     21, CLK_IS_CRITICAL, 0),
> +	     21, 0, 0),
>  	GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_IPCLK_2,
>  	     "gout_peric0_peric0_top1_ipclk_2", "dout_peric0_usi14_usi",
>  	     CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_IPCLK_2,
>  	     21, 0, 0),
> -	/* Disabling this clock makes the system hang. Mark the clock as critical. */
>  	GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_0,
>  	     "gout_peric0_peric0_top1_pclk_0", "mout_peric0_bus_user",
>  	     CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_PCLK_0,
> -	     21, CLK_IS_CRITICAL, 0),
> +	     21, 0, 0),
>  	GATE(CLK_GOUT_PERIC0_PERIC0_TOP1_PCLK_2,
>  	     "gout_peric0_peric0_top1_pclk_2", "mout_peric0_bus_user",
>  	     CLK_CON_GAT_GOUT_BLK_PERIC0_UID_PERIC0_TOP1_IPCLKPORT_PCLK_2,

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

* Re: [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical
  2024-01-29 14:37     ` André Draszik
@ 2024-01-29 19:16       ` Sam Protsenko
  2024-01-30  9:31         ` André Draszik
  0 siblings, 1 reply; 28+ messages in thread
From: Sam Protsenko @ 2024-01-29 19:16 UTC (permalink / raw)
  To: André Draszik
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree

On Mon, Jan 29, 2024 at 8:37 AM André Draszik <andre.draszik@linaro.org> wrote:
>
> Hi Sam,
>
> On Fri, 2024-01-26 at 21:30 -0600, Sam Protsenko wrote:
> > On Fri, Jan 26, 2024 at 6:37 PM André Draszik <andre.draszik@linaro.org> wrote:
> >
> > >
> > > 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
> >
> > That's weird. Doesn't your bootloader setup serial clocks properly?
> > AFAIU, earlycon should rely on everything already configured in
> > bootloader.
>
> I tried to explain that above, but let me try again...
>
> The console UART, and I2C bus 8 are on the same cmu_peric0 controller, and
> that cmu_peric0 has two clocks coming from cmu_top, ip and bus. For I2C8 & UART
> to work, both of these clocks from cmu_top need to to be on as they are the
> parent of the i2c8-(ip|pclk) and uart-(ip|pclk) each.
>
> The bootloader leaves those clocks running, yes. So earlycon works (for a
> while).
>
> At some point into the boot, one of two things happens:
> 1) Linux will load the i2c driver. That driver does clock handling
> (correctly), it will initialise and then it has nothing to do, therefore it
> disables cmu_peric0's i2c8 ip and pclk clocks. Because at that stage nothing
> appears to be using the cmu_peric0's ip clock (the real serial driver hasn't
> initialised yet), Linux decides to also disable the parent ip clock coming
> from cmu_top.
>
> At this stage, the earlycon driver stops working, as the parent ip clock of
> the uart ip clock is not running any more. No serial output can be observed
> from this stage onwards. I think what is probably happening is that the
> console uart FIFO doesn't get emptied anymore, and earlycon will simply wait
> forever for space to become available in the FIFO (but I didn't debug this).
>
> Anyway, the boot doesn't progress, the system appears to hang. In any case it's
> not usable as we have no other means of using it at this stage (network /
> usb / display etc.).
>
> 2) Alternatively, the UART driver will load at this stage. Again, it will
> tweak the clocks and after probe it will leave its clocks disabled. The
> serial console driver hasn't taken over at this stage and earlycon is still
> active. Again, the system will hang, because IP and PCLK have been disabled
> by the UART driver. Once the serial console is enabled, clocks are being
> enabled again, but because earlycon is still waiting for progress, the
> boot doesn't progress past disabling ip and pclk. It never gets to enabling
> the serial console (re-enabling the clocks).
>
> So in both cases we get some output from earlycon, but the system hangs once
> the first consumer driver of an IP attached to cmu_peric0 has completed
> probing.
>
>
>
> > >     * 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
> > > 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!).
> >
> > That sounds... not ideal. The ability to enable earlycon just by
> > adding some string to bootargs can be very useful for developers.
> > Maybe just make those clocks CLK_IGNORE_UNUSED, if that keeps earlycon
> > functional? With corresponding comments of course.
>
> CLK_IGNORE_UNUSED doesn't help in this case, the i2c and uart drivers will load
> and probe before earlycon gets disabled and as part of their probing disable
> the cmu_top ip clock going to cmu_peric0
>
> If earlycon is not enabled in kernel command line, everything works fine, the
> kernel buffers its messages and once the real serial console driver starts,
> all messages since boot are being printed.
>
> Other than keeping it as CLK_IS_CRITICAL, there is no way that I can see to
> way to make the hand-over from earlycon to the real serial driver work in
> all cases.
>
> They are not critical clocks for the system, though, so it's wrong to always
> keep them running unconditionally.
>
> We are past a stage where earlycon is generally required.
>
> If it's required for some local development, people can revert this patch locally.
>

That sounds reasonable. But I wonder if that bit (about making this
clock CLK_IS_CRITICAL to make earlycon functional) can be documented
somewhere. Perhaps in the serial driver (earlycon function), or
somewhere in device tree bindings? Because otherwise it might remain
an arcane knowledge and people won't be able to use earlycon later.
Anyways, for this patch:

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>

and if you think it makes sense to document the bit above, please do.

>
> BTW, downstream doesn't suffer from this problem because downstream uses ACG
> throughout and clocks are enabled automatically in hardware as required.
>

Yes, using QCH clocks (HWACG) seems like a correct way to fix this,
and would be nice to have otherwise. Alas, it doesn't seems very easy
to implement, and should probably be based on top of regular clock
driver anyway. I thought about it for a while, but never came up with
particular ideas on how to implement HWACG support in Samsung CCF
framework properly.

>
> Cheers,
> Andre'
>

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

* Re: [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical
  2024-01-29 19:16       ` Sam Protsenko
@ 2024-01-30  9:31         ` André Draszik
  2024-01-30  9:39           ` Tudor Ambarus
  0 siblings, 1 reply; 28+ messages in thread
From: André Draszik @ 2024-01-30  9:31 UTC (permalink / raw)
  To: Sam Protsenko
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, tudor.ambarus, willmcvicker,
	alim.akhtar, s.nawrocki, tomasz.figa, cw00.choi, mturquette,
	sboyd, linux-arm-kernel, linux-samsung-soc, linux-clk,
	devicetree

On Mon, 2024-01-29 at 13:16 -0600, Sam Protsenko wrote:
> That sounds reasonable. But I wonder if that bit (about making this
> clock CLK_IS_CRITICAL to make earlycon functional) can be documented
> somewhere. Perhaps in the serial driver (earlycon function), or
> somewhere in device tree bindings? Because otherwise it might remain
> an arcane knowledge and people won't be able to use earlycon later.
> Anyways, for this patch:
> 
> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
> 
> and if you think it makes sense to document the bit above, please do.

Will do on top of
https://lore.kernel.org/all/20240119104526.1221243-6-tudor.ambarus@linaro.org/
once that is in.

Cheers,
Andre'


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

* Re: [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical
  2024-01-30  9:31         ` André Draszik
@ 2024-01-30  9:39           ` Tudor Ambarus
  0 siblings, 0 replies; 28+ messages in thread
From: Tudor Ambarus @ 2024-01-30  9:39 UTC (permalink / raw)
  To: André Draszik, Sam Protsenko
  Cc: peter.griffin, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	linux-kernel, kernel-team, willmcvicker, alim.akhtar, s.nawrocki,
	tomasz.figa, cw00.choi, mturquette, sboyd, linux-arm-kernel,
	linux-samsung-soc, linux-clk, devicetree



On 1/30/24 09:31, André Draszik wrote:
> On Mon, 2024-01-29 at 13:16 -0600, Sam Protsenko wrote:
>> That sounds reasonable. But I wonder if that bit (about making this
>> clock CLK_IS_CRITICAL to make earlycon functional) can be documented
>> somewhere. Perhaps in the serial driver (earlycon function), or
>> somewhere in device tree bindings? Because otherwise it might remain
>> an arcane knowledge and people won't be able to use earlycon later.
>> Anyways, for this patch:
>>
>> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
>>
>> and if you think it makes sense to document the bit above, please do.
> 
> Will do on top of
> https://lore.kernel.org/all/20240119104526.1221243-6-tudor.ambarus@linaro.org/
> once that is in.
> 
It was applied, it's in linux-next. I like the dt bindings idea, it's
the first thing I check when dealing with new hardware. No idea though
how to add comments just for a specific compatible. Shall be a
description somewhere...

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

end of thread, other threads:[~2024-01-30  9:40 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-27  0:35 gs101 oriole: peripheral block 0 (peric0) fixes André Draszik
2024-01-27  0:35 ` [PATCH 1/5] clk: samsung: gs101: gpio_peric0_pclk needs to be kept on André Draszik
2024-01-27  3:06   ` Sam Protsenko
2024-01-27  3:51   ` Tudor Ambarus
2024-01-29 12:54   ` Peter Griffin
2024-01-27  0:35 ` [PATCH 2/5] arm64: dts: exynos: gs101: fix usi8 default mode André Draszik
2024-01-27  3:05   ` Sam Protsenko
2024-01-27  3:48   ` Tudor Ambarus
2024-01-29  9:48   ` Peter Griffin
2024-01-27  0:35 ` [PATCH 3/5] arm64: dts: exynos: gs101: use correct clocks for usi8 André Draszik
2024-01-27  3:22   ` Sam Protsenko
2024-01-27  4:00     ` Tudor Ambarus
2024-01-29 16:33       ` Tudor Ambarus
2024-01-29 14:01     ` André Draszik
2024-01-27  0:35 ` [PATCH 4/5] arm64: dts: exynos: gs101: use correct clocks for usi_uart André Draszik
2024-01-27  1:37   ` André Draszik
2024-01-27  3:23   ` Sam Protsenko
2024-01-27  4:03   ` Tudor Ambarus
2024-01-29 16:39     ` Tudor Ambarus
2024-01-27  0:35 ` [PATCH 5/5] clk: samsung: gs101: don't mark non-essential clocks as critical André Draszik
2024-01-27  1:38   ` André Draszik
2024-01-27  3:30   ` Sam Protsenko
2024-01-29 14:37     ` André Draszik
2024-01-29 19:16       ` Sam Protsenko
2024-01-30  9:31         ` André Draszik
2024-01-30  9:39           ` Tudor Ambarus
2024-01-29 16:44   ` Tudor Ambarus
2024-01-27  3:01 ` gs101 oriole: peripheral block 0 (peric0) fixes Sam Protsenko

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).