Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwrng: rockchip - handle reset deassertion errors in probe
@ 2026-11-29 19:25 Jiawen Liu
  2026-11-30 11:43 ` Nicolas Frattaroli
  0 siblings, 1 reply; 2+ messages in thread
From: Jiawen Liu @ 2026-11-29 19:25 UTC (permalink / raw)
  To: Daniel Golle, Aurelien Jarno, Nicolas Frattaroli, Olivia Mackall,
	Herbert Xu, Heiko Stuebner
  Cc: linux-crypto, linux-arm-kernel, linux-rockchip

The RK3588 RNG uses an SCMI reset. After assertion succeeds, the
deassert request can fail before reaching firmware, for example if SCMI
cannot allocate a transmit transfer. rk_rng_probe() ignores the error
and can register an RNG that remains in reset and cannot supply data.

Return the deassertion error through dev_err_probe() before setting up
runtime PM or registering the hwrng. Keep the reset delay and rely on
the existing managed resource cleanup.

Verification
included static control-flow review, git diff --check, checkpatch, and
driver object builds for ARM64 Rockchip with SCMI reset enabled and for
x86-64 COMPILE_TEST with reset and PM disabled. Runtime and hardware
reproduction was not performed.

Fixes: 8eff8eb83fc0 ("hwrng: rockchip - add support for rk3588's standalone TRNG")
Signed-off-by: Jiawen Liu <liu1298662399@gmail.com>
---
 drivers/char/hw_random/rockchip-rng.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/char/hw_random/rockchip-rng.c b/drivers/char/hw_random/rockchip-rng.c
index fc389832c72f5..e6259831c3e7e 100644
--- a/drivers/char/hw_random/rockchip-rng.c
+++ b/drivers/char/hw_random/rockchip-rng.c
@@ -414,7 +414,9 @@ static int rk_rng_probe(struct platform_device *pdev)
 
 		reset_control_assert(rst);
 		udelay(2);
-		reset_control_deassert(rst);
+		ret = reset_control_deassert(rst);
+		if (ret)
+			return dev_err_probe(dev, ret, "Failed to deassert reset\n");
 	}
 
 	platform_set_drvdata(pdev, rk_rng);
-- 
2.34.1


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

* Re: [PATCH] hwrng: rockchip - handle reset deassertion errors in probe
  2026-11-29 19:25 [PATCH] hwrng: rockchip - handle reset deassertion errors in probe Jiawen Liu
@ 2026-11-30 11:43 ` Nicolas Frattaroli
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Frattaroli @ 2026-11-30 11:43 UTC (permalink / raw)
  To: Daniel Golle, Aurelien Jarno, Olivia Mackall, Herbert Xu,
	Heiko Stuebner, Jiawen Liu
  Cc: linux-crypto, linux-arm-kernel, linux-rockchip

On Sunday, 29 November 2026 20:25:33 Central European Standard Time Jiawen Liu wrote:
> The RK3588 RNG uses an SCMI reset. After assertion succeeds, the
> deassert request can fail before reaching firmware, for example if SCMI
> cannot allocate a transmit transfer. rk_rng_probe() ignores the error
> and can register an RNG that remains in reset and cannot supply data.
> 
> Return the deassertion error through dev_err_probe() before setting up
> runtime PM or registering the hwrng. Keep the reset delay and rely on
> the existing managed resource cleanup.
> 
> Verification
> included static control-flow review, git diff --check, checkpatch, and
> driver object builds for ARM64 Rockchip with SCMI reset enabled and for
> x86-64 COMPILE_TEST with reset and PM disabled. Runtime and hardware
> reproduction was not performed.
> 
> Fixes: 8eff8eb83fc0 ("hwrng: rockchip - add support for rk3588's standalone TRNG")
> Signed-off-by: Jiawen Liu <liu1298662399@gmail.com>
> ---
>  drivers/char/hw_random/rockchip-rng.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/hw_random/rockchip-rng.c b/drivers/char/hw_random/rockchip-rng.c
> index fc389832c72f5..e6259831c3e7e 100644
> --- a/drivers/char/hw_random/rockchip-rng.c
> +++ b/drivers/char/hw_random/rockchip-rng.c
> @@ -414,7 +414,9 @@ static int rk_rng_probe(struct platform_device *pdev)
>  
>  		reset_control_assert(rst);
>  		udelay(2);
> -		reset_control_deassert(rst);
> +		ret = reset_control_deassert(rst);
> +		if (ret)
> +			return dev_err_probe(dev, ret, "Failed to deassert reset\n");
>  	}
>  
>  	platform_set_drvdata(pdev, rk_rng);
> 

Anyone can inspect the publicly available RK3588 SCMI reset implementation
in TF-A[1] and see that there is no possibility for an implemented reset to
ever return an error. That's not by happenstance either: there's simply no
meaningful way for the hardware to communicate a failure here.

For the case where the SCMI reset is not implemented, SCMI_NOT_FOUND or
SCMI_NOT_SUPPORTED can be returned[2], but since Rockchip hardware will
work fine without explicitly triggering a reset, I believe it is in the
user's interest to not error out driver probe in this scenario. Plus the
prior assert call would've already failed the same way, which is not
handled in this patch.

Consequently, this does nothing and only adds dead code (and a string to
.text), and should therefore not be applied.

Kind regards,
Nicolas Frattaroli

[1]: https://github.com/TrustedFirmware-A/trusted-firmware-a/blob/main/plat/rockchip/rk3588/drivers/scmi/rk3588_rstd.c#L30-L39
[2]: https://github.com/TrustedFirmware-A/trusted-firmware-a/blob/main/plat/rockchip/common/scmi/scmi_rstd.c#L59-L74




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

end of thread, other threads:[~2026-11-30 11:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 19:25 [PATCH] hwrng: rockchip - handle reset deassertion errors in probe Jiawen Liu
2026-11-30 11:43 ` Nicolas Frattaroli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox