Linux clock framework development
 help / color / mirror / Atom feed
* [PATCH RFC 0/2] clk: introduce CLK_GET_RATE_RECALC_ANCESTORS flag for firmware-controlled clocks
@ 2026-12-06  2:42 Alexey Klimov
  2026-12-06  2:42 ` [PATCH RFC 1/2] clk: add CLK_GET_RATE_RECALC_ANCESTORS flag Alexey Klimov
  2026-12-06  2:42 ` [PATCH RFC 2/2] clk: samsung: acpm: recalculate parent chain rates on Exynos850 Alexey Klimov
  0 siblings, 2 replies; 5+ messages in thread
From: Alexey Klimov @ 2026-12-06  2:42 UTC (permalink / raw)
  To: Stephen Boyd, Brian Masney, Jerome Brunet, Tudor Ambarus,
	Krzysztof Kozlowski, Sylwester Nawrocki, Chanwoo Choi,
	Peter Griffin, Alim Akhtar
  Cc: Sam Protsenko, Thomas Turner, linux-clk, linux-samsung-soc,
	Claude Opus 5.5

On Exynos850 the ACPM clocks are registered as children of the CMU clocks,
because the ACPM firmware has no rate read call, and ->recalc_rate() is
currently implemented to return the parent rate.
The rate of the parent chain is changed behind the clock framework's back:
the ACPM firmware reprograms the PLL on a set_rate request,
Initially the problem was described here:
https://lore.kernel.org/linux-samsung-soc/DLAZXSNZK6QC.1VFAX37XCXBOV@linaro.org/
Then was discussed again after submitting acpm enablement patches for
exynos850.

This is an attempt to solve it by adding CLK_GET_RATE_RECALC_ANCESTORS
flag that forces rate updates up the tree.

CLK_GET_RATE_NOCACHE only recalculates the clock itself from the cached
rate of its parent, so clk_get_rate() on the ACPM clocks keeps returning
the boot rate, and clk_set_rate() can drop a request because of the stale
cached rate.

Downstream kernel implements the get_rate() meachanism by reading hw
registers of CMU block directly and then matching the values to the entry
in some table that contains PLL rate for such set of values. The current
thinking process is that caching the last rate requested from the firmware
in the driver is not an option, since the ACPM may not set the requested
rate and, it is also expected that for DVFS clocks the thermal hw block
can change the rate without a request to firmware (the latter needs a
bit of testing to confirm though).

First commit adds a CLK_GET_RATE_RECALC_ANCESTORS flag. For a clock with
that flag, the framework re-reads the rates of all its ancestors from the
root down when the rate is read or set. The subtree of the topmost ancestor
whose rate changed is recalculated, so that siblings stay consistent.
Existing CLK_GET_RATE_NOCACHE users are not meant to be affected.

Second commit uses the flag for the Exynos850 ACPM clocks.

Explicit clk_recalc_ancestors() call was considered instead of a flag but
seems there are no good places to call it. The TMU changes are asynchronous
and the consumers like cpufreq or devfreq are generic.

Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
---
Alexey Klimov (2):
      clk: add CLK_GET_RATE_RECALC_ANCESTORS flag
      clk: samsung: acpm: recalculate parent chain rates on Exynos850

 drivers/clk/clk.c              |  82 ++++++++++++++--
 drivers/clk/clk_test.c         | 217 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/samsung/clk-acpm.c |   8 +-
 include/linux/clk-provider.h   |   5 +
 4 files changed, 304 insertions(+), 8 deletions(-)
---
base-commit: 0b5bb03d26a268f2606e3f574b277a1105136328
change-id: 20261204-e850_acpm_clks_unstale-a853b7e3a79b

Best regards,
-- 
Alexey Klimov <alexey.klimov@linaro.org>


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

end of thread, other threads:[~2026-12-06  3:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-06  2:42 [PATCH RFC 0/2] clk: introduce CLK_GET_RATE_RECALC_ANCESTORS flag for firmware-controlled clocks Alexey Klimov
2026-12-06  2:42 ` [PATCH RFC 1/2] clk: add CLK_GET_RATE_RECALC_ANCESTORS flag Alexey Klimov
2026-12-06  3:05   ` sashiko-bot
2026-12-06  2:42 ` [PATCH RFC 2/2] clk: samsung: acpm: recalculate parent chain rates on Exynos850 Alexey Klimov
2026-12-06  2:59   ` sashiko-bot

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