Re: [PATCH] nvmem: rockchip-otp: convert to runtime PM

From: Heiko Stuebner

Date: Thu Aug 27 2026 - 09:54:31 EST


Am Mittwoch, 19. August 2026, 14:33:45 Mitteleuropäische Sommerzeit schrieb Sascha Hauer:
> From: Stefan Kerkmann <s.kerkmann@xxxxxxxxxxxxxx>
>
> The driver enables the OTP clocks inside rockchip_otp_read() and drops
> them again before returning, so the controller is only alive for the
> duration of a nvmem read issued by Linux.
>
> On RK3588 that is not sufficient. Part of the OTP array is readable only
> from the secure world, and OP-TEE reads it through this same controller.
> Its clocks are in the normal world's CRU and are plain gates, so an SMC
> into OP-TEE hits a clock-gated controller unless Linux turns them on
> first. OP-TEE cannot do that without a CRU driver of its own, which
> would put both worlds on the same gate registers.
>
> Move the clock handling into runtime PM callbacks. A consumer can then
> take a DL_FLAG_PM_RUNTIME device link on the OTP and hold a reference
> for as long as it needs the controller, without knowing anything about
> its clock list. DEFINE_RUNTIME_DEV_PM_OPS() supplies the system sleep
> callbacks too, so holding one does not keep the clocks on over suspend.
>
> Enabling the clocks is now the callbacks' job alone, hence the dependency
> on PM: with CONFIG_PM=n they never run and a read would go out to a gated
> controller. Reads are otherwise unchanged.
>
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Stefan Kerkmann <s.kerkmann@xxxxxxxxxxxxxx>
> Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>

Reviewed-by: Heiko Stuebner <heiko@xxxxxxxxx>

> ---
> The driver enables the OTP clocks inside rockchip_otp_read() and drops
> them again before returning, so the controller is only alive for the
> duration of a nvmem read issued by Linux.

your commit message got duplicated here.


Heiko