Re: [PATCH RFC 0/3] clk: Restore the clocks of a provider after a hibernation
From: Jerome Brunet
Date: Sun Nov 15 2026 - 17:34:15 EST
> When a hibernation image is restored, the clock hardware has been through
> a power cycle and a boot kernel, while the clock framework in the image
> still holds the rates, parents and enable state the consumers asked for
> before the image was created. The consumers ask for the same rates again
> when they resume, the framework sees no change, and the clocks the boot
> kernel did not touch keep whatever the boot firmware left in them.
>
> Whether the kernel that loads the image probed a given controller at
> all depends on whether its driver is built in or available from the
> initramfs. On the Qualcomm Glymur CRD, the display clock controller
> driver is a module that it does not probe, so after the restore the DPU
> runs at the 333MHz the firmware configured the PLL for instead of the
> 717MHz the framework believes it runs at, underflows, and the panel
> shows a solid blue screen.
>
> The first patch adds clk_restore_context_dev(), which re-applies the
> cached state of the clocks registered by a provider device, parents
> first, as an alternative to the global clk_restore_context() that
> depends on every clock implementing the restore_context operation. The
> second one adds a hibernation restore callback to the Qualcomm clock
> controller common code, which redoes the probe time configuration and
> restores the clocks, and the third one uses it for the Glymur display
> clock controller.
>
> Sent as RFC, as the same applies to every clock controller and I would
> like to know whether this is the right level to handle it at before
> wiring up the rest. In particular:
>
> - Instead of programming the cached state into the hardware, the
> framework could read the parents and rates back from the hardware
> after the restore, so that the consumers asking for the same rates
> again go through the normal clk_set_rate() path. Would that be
> preferred?
I would much prefer this approach. IMO, we should not try to restore
the cached values. There is no way to be sure we would get it right:
the HW may require a specific sequence to reach the final state,
intermediate values, timings, who knows what else! I'd rather not go
down that path.
Consumers know (or should know) what they need, so they should release
their clocks when suspending and request what they need again when
resuming.
On the provider side, it should just resync with the HW from its
.restore callback: re-read the parents and rates, a bit like
CLK_GET_RATE_NOCACHE does, as well as the accuracy, phase and duty
cycle, and re-enable the CLK_IS_CRITICAL clocks.
CCF should provide a helper for this. It is likely going to redo a fair
share of what __clk_core_init() does. The prototype could be fairly
simple, something like clk_resume_hw_sync(struct device *dev), to
resync the clocks registered by that device.
>
> - Programming the cached rate of a clock that is not enabled may not
> work on every clock type, for example on an RCG whose source is off.
What I'm suggesting should not have such problem I think
>
> - The Qualcomm callback finds its state through devres, which only
> covers drivers that call qcom_cc_really_probe() once per device.
>
> Clocks left enabled by the firmware but not by the framework stay
> enabled, and the phase and duty cycle are not restored.
CCF has no sync_state support (yet!), so the unused clocks of providers
built as modules are never disabled, even on a normal boot. You would
not be creating a new problem here.
Anything cached needs to be resynced though, including the phase and
duty cycle, everything else.
--
Jerome