devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: dts: rockchip: rk3588: Fix USB PD clocks
@ 2023-12-16  2:10 Sam Edwards
  2023-12-24 19:54 ` Heiko Stuebner
  0 siblings, 1 reply; 2+ messages in thread
From: Sam Edwards @ 2023-12-16  2:10 UTC (permalink / raw)
  To: Heiko Stuebner, Rob Herring
  Cc: linux-rockchip, linux-arm-kernel, linux-kernel, devicetree,
	Daniel Kukieła, Sven Rademakers, Joshua Riek, Sam Edwards

The QoS blocks saved/restored when toggling the PD_USB power domain are
clocked by ACLK_USB. Attempting to access these memory regions without
that clock running will result in an indefinite CPU stall.

The PD_USB node wasn't specifying this clock dependency, resulting in
hangs when trying to toggle the power domain (either on or off), unless
we get "lucky" and have ACLK_USB running for another reason at the time.
This "luck" can result from the bootloader leaving USB powered/clocked,
and if no built-in driver wants USB, Linux will disable the unused
PD+CLK on boot when {pd,clk}_ignore_unused aren't given. This can also
be unlucky because the two cleanup tasks run in parallel and race: if
the CLK is disabled first, the PD deactivation stalls the boot. In any
case, the PD cannot then be reenabled (if e.g. the driver loads later)
once the clock has been stopped.

Fix this by specifying a dependency on ACLK_USB, instead of only
ACLK_USB_ROOT. The child-parent relationship means the former implies
the latter anyway. By the same token, remove the redundant HCLK_USB_ROOT
reference, since that's also implied by its HCLK_HOST* grandchildren.

Fixes: c9211fa2602b8 ("arm64: dts: rockchip: Add base DT for rk3588 SoC")
Signed-off-by: Sam Edwards <CFSworks@gmail.com>
---

Hi list,

Feel free to tell me to knock the HCLK_USB_ROOT change out of there, since it's
not strictly necessary for this fix. It was a "while I'm at it, let's remove
this redundant reference" thing. :)

I also do not know quite enough about debugfs to know how to manually request
clocks and PDs, but if such a mechanism exists, it would be a good way to
confirm the correctness of this fix: ensure ACLK_USB is stopped, then try to
toggle PD_USB a few times.

Cheers,
Sam

---
 arch/arm64/boot/dts/rockchip/rk3588s.dtsi | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi
index fd1b5d02ba16..32d7e49f03d3 100644
--- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi
@@ -1341,8 +1341,7 @@ power-domain@RK3588_PD_RGA31 {
 			power-domain@RK3588_PD_USB {
 				reg = <RK3588_PD_USB>;
 				clocks = <&cru PCLK_PHP_ROOT>,
-					 <&cru ACLK_USB_ROOT>,
-					 <&cru HCLK_USB_ROOT>,
+					 <&cru ACLK_USB>,
 					 <&cru HCLK_HOST0>,
 					 <&cru HCLK_HOST_ARB0>,
 					 <&cru HCLK_HOST1>,
-- 
2.41.0


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

* Re: [PATCH] arm64: dts: rockchip: rk3588: Fix USB PD clocks
  2023-12-16  2:10 [PATCH] arm64: dts: rockchip: rk3588: Fix USB PD clocks Sam Edwards
@ 2023-12-24 19:54 ` Heiko Stuebner
  0 siblings, 0 replies; 2+ messages in thread
From: Heiko Stuebner @ 2023-12-24 19:54 UTC (permalink / raw)
  To: Sam Edwards, Rob Herring
  Cc: Heiko Stuebner, Sam Edwards, linux-rockchip, Joshua Riek,
	linux-arm-kernel, Daniel Kukieła, linux-kernel, devicetree,
	Sven Rademakers

On Fri, 15 Dec 2023 19:10:19 -0700, Sam Edwards wrote:
> The QoS blocks saved/restored when toggling the PD_USB power domain are
> clocked by ACLK_USB. Attempting to access these memory regions without
> that clock running will result in an indefinite CPU stall.
> 
> The PD_USB node wasn't specifying this clock dependency, resulting in
> hangs when trying to toggle the power domain (either on or off), unless
> we get "lucky" and have ACLK_USB running for another reason at the time.
> This "luck" can result from the bootloader leaving USB powered/clocked,
> and if no built-in driver wants USB, Linux will disable the unused
> PD+CLK on boot when {pd,clk}_ignore_unused aren't given. This can also
> be unlucky because the two cleanup tasks run in parallel and race: if
> the CLK is disabled first, the PD deactivation stalls the boot. In any
> case, the PD cannot then be reenabled (if e.g. the driver loads later)
> once the clock has been stopped.
> 
> [...]

Applied, thanks!

[1/1] arm64: dts: rockchip: rk3588: Fix USB PD clocks
      commit: 44de8996ed5a10f08f2fe947182da6535edcfae5

I've changed the patch to only add the ACLK_USB.
For the HCLK_* type, Rockchip added both the root as well as the
actual controller clocks, so I guess it should be the same
for the ACLK-type. Powerdomains are strange with their clock-
synchronization, so I'm opting for better save than sorry ;-)

Best regards,
-- 
Heiko Stuebner <heiko@sntech.de>

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

end of thread, other threads:[~2023-12-24 19:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-16  2:10 [PATCH] arm64: dts: rockchip: rk3588: Fix USB PD clocks Sam Edwards
2023-12-24 19:54 ` Heiko Stuebner

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