Devicetree
 help / color / mirror / Atom feed
From: Brian Norris <briannorris@chromium.org>
To: Jerome Brunet <jbrunet@baylibre.com>
Cc: "Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Brian Masney" <bmasney+clk@redhat.com>,
	"Jerome Brunet" <jbrunet+clk@baylibre.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Ulf Hansson" <ulfh@kernel.org>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Peter Griffin" <peter.griffin@linaro.org>,
	devicetree@vger.kernel.org,
	"Tudor Ambarus" <tudor.ambarus@linaro.org>,
	"André Draszik" <andre.draszik@linaro.org>,
	linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, "Radu Rendec" <radu@rendec.net>,
	linux-arm-kernel@lists.infradead.org,
	"Mariano Marciello" <mmarciello@google.com>,
	"Douglas Anderson" <dianders@chromium.org>,
	linux-clk@vger.kernel.org, "Jakub Głowacki" <jglow@google.com>
Subject: Re: [PATCH 5/9] clk: google: Add CPM clock driver
Date: Thu, 12 Nov 2026 15:26:16 -0800	[thread overview]
Message-ID: <avZLGHs0OPoC_VGb@google.com> (raw)
In-Reply-To: <179372634472.2573818.17532943286609086157.b4-review@b4>

Hi Jerome,

Thanks for the review, and sorry for some delay. There was a lot to dig
into here.

On Tue, Nov 03, 2026 at 06:19:04PM +0100, Jerome Brunet wrote:
> > Google Tensor SoCs (used on Pixel phones) manage many resources
> > (including most clocks) using a Central Power Manager (CPM)
> > co-processor. We communicate with CPM using mailboxes, abstracted in the
> > cpm_request_client(), etc., API.
> > 
> > The clock tree is largely not represented fully by this driver, because
> > CPM hides most of the divider, mux, and parent details, instead
> > maintaining its own internal table of mappings for divider and mux
> > values. The one exception is for some of the DPU clocks, where several
> > clocks and dividers are exposed directly, and the firmware API works on
> > divider values instead of clock rates. I attempt to represent this
> > properly with dividers and parents, although I don't have the full
> > display stack running to verify everything yet.
> >
> 
> As you say, the clock tree is not fully represented here. Beyond that, CPM
> owns the clocks themselves, as the driver acknowledges by setting
> CLK_GET_RATE_NOCACHE.
> 
> The driver keeps a partial copy of CPM's state in the kernel:
> 
> - Rate tables below hard-code what the FW has (or should have) instead
>   of rounding the rate, even though there seems to be a ROUND_RATE_OP_ID.

Aaah, ROUND_RATE would be lovely except ... the firmware implementation
has a giant "TBD" / "error: not supported" instead :(

If there are major must-haves (or, very-nice-to-haves) in this firmware
API, I can see if we can get them added, but that's usually easier on
not-yet-launched products, whereas Pixel 10 is more than a year old
already. I'll see what's possible though.

> - kernel handles PLL parenting and divider math for the DP clocks, while the
>   firmware can also switch them to what looks like the oscillator, out of
>   the kernel's view. So the math is likely duplicated as well

I'd have to do a little more research to be sure to what extent the
firmware actually changes any of these behind the scenes. I'd imagine
that for the only divider-exposed clock (DP), it probably doesn't, but
I'm not sure at the moment.

I get your point though; it's certainly not beautiful, and may be
difficult or impossible to maintain in general.

> This middle ground cannot be kept consistent. CCF assumes it knows the
> topology and computes rates from it, but the firmware makes the actual
> decisions. The DP clocks already show it: the tree can report a parent the
> hardware does not use, and .recalc_rate()/.determine_rate() can disagree
> with what CPM programmed.
> 
> I would advise to follow a model closer SCMI. What you are doing here looks
> a lot like it.
> (see drivers/firmware/arm_scmi/clock.c and drivers/clk/clk-scmi.c)
> 
>  - Put the LPCM service protocol (request word layout, dst_id, timeout,
>    error translation) in the CPM firmware/soc driver, behind a small API
>    shared by clk and reset. Philipp asked for the error helper on 6/9; the
>    whole request encoding is common, not just the errors.

I'll try to do some more sharing similar to what you're suggesting. But
full disclosure: the similarities are still somewhat rare in general.
Within a given service (so in this case, you're talking about
CPM_COMMON_LPCM_SERVICE, used by clock, reset, and *part* of pmdomain),
the protocol is largely shared.

But this series also touches CPM_COMMON_LPB_SERVICE (also in pmdomain)
and hints at some CPM_COMMON_PMIC_SERVICE support (RTC and PMIC); and
there are at least 5 more defined servies, as well as a few other
bespoke protocols. Those each have distinct request and response/status
encodings. (Unfortunately.)

So, I'll try to consolidate what I can, but it probably won't go super
far.

>  - Make the clock driver a thin CCF adapter: each CPM clock is an opaque
>    endpoint, and gate/rate requests go to the firmware. Get rates from the
>    firmware (round-rate op) instead of local tables. Model no topology the

As mentioned above, round-rate is a no-go :(

I also don't see any way to query firmware for supported rates. Off the
top of my head, the best I can come up with is sweeping through rates
on SET_RATE and guessing, until we find something that doesn't return
INVALID_ARGS...

>    kernel does not own. If parents must be exposed, the firmware should
>    describe them, as SCMI does, rather than the kernel hard-coding them.

I also do not think topology description is possible with any existing
firmware. I would think if we were revisiting how to do this more
sanely, it would make sense to stop exposing the topology at all, but
TBD.

Anyway, thanks for your thoughts. I'll see what I can do about
ROUND_RATE, but also am interested in your opinion on the best way
forward with the existing firmware API.

For some positive notes:

The vast majority of these clocks do not actually support multiple rates
(at least, not in the tables here), nor do they expose any topology. So
I think I can just remove their rate table, and only rely on
(1) GET_RATE or
(2) SET_RATE, which will only succeed if you get the exact supported rate.

On some other clocks that support multiple rates (e.g.,
HSIOS_MPHY_REF_TCX0_CLK), I don't believe we ever need clk_set_rate().
We only use clk_get_rate(). So, probably same story as the 1-rate
tables.

A few others (DSI0/DSI1) seem to never use any get/set_rate operations,
at least on any Pixel drivers. So that probably can also be omitted.

I think that _only_ leaves DP clocks.

All in all, maybe I can strip a lot of this down quite a bit, and work
on DP separately.

Brian

  reply	other threads:[~2026-11-12 23:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 21:43 [PATCH 0/9] google: Add support for Laguna CPM Brian Norris
2026-10-26 21:43 ` [PATCH 1/9] arm64: dts: google: Add Laguna CPM mailbox array Brian Norris
2026-10-28 13:10   ` Krzysztof Kozlowski
2026-10-26 21:43 ` [PATCH 2/9] dt-bindings: soc: google: Add Google Tensor CPM binding Brian Norris
2026-10-28 13:19   ` Krzysztof Kozlowski
2026-11-03  2:36     ` Brian Norris
2026-11-05 18:54       ` Krzysztof Kozlowski
2026-10-28 13:19   ` Krzysztof Kozlowski
2026-10-26 21:43 ` [PATCH 3/9] soc: google: Add CPM over MailBox Array driver Brian Norris
2026-10-28 13:27   ` Krzysztof Kozlowski
2026-11-03  2:07     ` Brian Norris
2026-10-26 21:43 ` [PATCH 4/9] pmdomain: google: Add CPM power-domain driver Brian Norris
2026-10-26 21:43 ` [PATCH 5/9] clk: google: Add CPM clock driver Brian Norris
2026-11-03 17:19   ` Jerome Brunet
2026-11-12 23:26     ` Brian Norris [this message]
2026-10-26 21:43 ` [PATCH 6/9] reset: google: Add CPM reset driver Brian Norris
2026-10-28 14:03   ` Philipp Zabel
2026-11-03  1:03     ` Brian Norris
2026-11-03  9:14       ` Philipp Zabel
2026-10-26 21:43 ` [PATCH 7/9] irqchip/google-cpm: Add CPM IRQ driver Brian Norris
2026-10-28 20:23   ` Thomas Gleixner
2026-10-26 21:43 ` [PATCH 8/9] arm64: dts: google: Add Laguna CPM node Brian Norris
2026-10-28 13:28   ` Krzysztof Kozlowski
2026-10-26 21:43 ` [PATCH 9/9] MAINTAINERS: Add entries for CPM drivers used on Tensor SoCs Brian Norris
2026-10-28 13:24 ` [PATCH 0/9] google: Add support for Laguna CPM Krzysztof Kozlowski
2026-11-03  2:06   ` Brian Norris
2026-11-05 18:56     ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=avZLGHs0OPoC_VGb@google.com \
    --to=briannorris@chromium.org \
    --cc=andre.draszik@linaro.org \
    --cc=bmasney+clk@redhat.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=jbrunet+clk@baylibre.com \
    --cc=jbrunet@baylibre.com \
    --cc=jglow@google.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mmarciello@google.com \
    --cc=p.zabel@pengutronix.de \
    --cc=peter.griffin@linaro.org \
    --cc=radu@rendec.net \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@kernel.org \
    --cc=tudor.ambarus@linaro.org \
    --cc=ulfh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox