Re: [PATCH RFC 0/2] firmware: arm_scmi: clock: stop discovering every clock at boot
From: Cristian Marussi
Date: Fri Dec 04 2026 - 06:36:23 EST
On Wed, Dec 02, 2026 at 10:04:15AM +0200, Ghennadi Procopciuc wrote:
> On 11/13/2026 3:27 PM, Ghennadi Procopciuc via B4 Relay wrote:
> > Hi all,
> >
> > At probe, the SCMI clock protocol and clk-scmi discover and register
> > every clock the platform reports, whether or not a Linux consumer
> > references it. On platforms that report hundreds of clocks, this can
> > add tens of milliseconds or more to every boot.
> >
> > This is sent as RFC to get feedback on the direction before a final
> > version. The questions are listed at the end.
> >
> > The problem
> > ===========
> >
> > For each clock, probe sends a fixed number of messages:
> >
> > - CLOCK_ATTRIBUTES, in scmi_clock_protocol_init()
> > - CLOCK_GET_PERMISSIONS, if the platform supports it
> > - CLOCK_DESCRIBE_RATES, at least once even with the bounded iterators
> > - CLOCK_POSSIBLE_PARENTS_GET and CLOCK_NAME_GET, when applicable
> > - CLOCK_RATE_GET, from __clk_core_init() at registration
> >
> > The total cost is about N_clocks x messages_per_clock x message_latency.
> > It grows with the number of clocks the platform reports, not with the
> > number of clocks Linux uses. Three properties make it worth addressing:
> >
> > 1. It is paid on every boot. The result does not change between boots
> > with the same firmware, but nothing is cached. Every cold boot, warm
> > reboot or kexec pays it again, and so does every VM that has its own
> > SCMI clock provider.
> >
> > 2. It is on the critical path. scmi_clocks_probe() runs synchronously
> > and registers the provider only at the end. Every consumer of an SCMI
> > clock waits for the whole set to be discovered, and through fw_devlink
> > so do the devices that depend on those consumers. A storage controller
> > that needs one clock to mount the root filesystem waits for hundreds.
> >
> > 3. Most of the work is for clocks Linux has no use for. SoCs that run
> > several agents or partitions on one SCMI server often report the full
> > clock space to every agent. An agent may have only a dozen clocks
> > referenced in its device tree, and may not even be allowed to control
> > the others, but it still discovers and registers all of them.
> >
> > clk_disable_unused() adds to this. It walks every registered clock and,
> > for clocks with an is_prepared op, sends CLOCK_CONFIG_GET for each one,
> > including clocks Linux can never disable.
>
> Hi Sudeep, Cristian, Stephen, Brian,
>
Hi,
this seems to me in general a good optimization for a known issue in
the scenario you described; the concern, and the source of never-ending
debate around this kind of SCMI issues, is usually WHY the FW is exposing
such a huge set of clock to the SCMI agent for no use ?
Ideally the SCMI point of view is that a clock (or any other SCMI
resource in these regards...this has really been raised before for other
protocols) that is not supposed to be used at all in any capacity by a
specific agent should be hidden by the SCMI platform server from the view
of that agent, since the SCNI server is supposed to present a per-agent
view of strictly the resources needed by each agent....
....this has been usually ignored on a number of FW implentation to
ease the implementation itself, but is means basically that you are
presenting a set of non-contiguosly numbered IDs for such resources...
...so if we are gonna allow programatically such partially out-of-spec
behaviour and employ this optimization, we have to reason about what
could go wrong while doing that, since most of the protocol enumeration
logic across all the SCMI stack has been originally written assuming a
set of contiguos resources...I am not saying that is necesarily broken
all over the place but it is worth considering...
Thanks,
Cristian