From: Brian Norris <briannorris@chromium.org>
To: Philipp Zabel <p.zabel@pengutronix.de>
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>,
"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 6/9] reset: google: Add CPM reset driver
Date: Mon, 2 Nov 2026 17:03:05 -0800 [thread overview]
Message-ID: <aukyyYhDCBUdIH16@google.com> (raw)
In-Reply-To: <8d57f0a1dc8a07838bf1320f9b79588196264ff5.camel@pengutronix.de>
Hi Philipp,
On Wed, Oct 28, 2026 at 03:03:24PM +0100, Philipp Zabel wrote:
> On Mo, 2026-10-26 at 14:43 -0700, Brian Norris wrote:
> > --- /dev/null
> > +++ b/drivers/reset/google/reset-cpm.c
> > @@ -0,0 +1,367 @@
> > +static int goog_cpm_rst_mba_check_ret(struct device *dev, int ret)
> > +{
> > + switch (ret) {
> > + case NO_ERROR:
> > + return 0;
> > + case ERR_LPCM_NOT_SUPPORTED:
> > + dev_err(dev, "the received request_id is invalid\n");
> > + return -EPROTO;
>
> -EOPNOTSUPP?
>
> > + case ERR_LPCM_INVALID_ARGS:
> > + dev_err(dev, "invalid lpcm_id or rst_id\n");
> > + return -EINVAL;
> > + case ERR_LPCM_TIMED_OUT:
> > + dev_err(dev, "operation timed out\n");
> > + return -ETIMEDOUT;
> > + case ERR_LPCM_GENERIC:
> > + dev_err(dev, "internal error occurred\n");
> > + return -EREMOTEIO;
> > + default:
> > + dev_err(dev, "unknown error response from CPM\n");
> > + return -EPROTO;
> > + }
> > +}
>
> Is this specific to reset functionality, or should this maybe live in
> CPM common code? I see that the return values in the power-domain
> driver are not translated, but the clock driver contains a near-
> identical copy of this function. Or maybe just printing the translated
> error with "%pe" is good enough?
Good question. Looking into the CPM firmware, it seems like these error
codes are more or less standardized (they're a common definition from
the Little Kernel project (https://github.com/littlekernel/lk)), so it's
probably fair to do the translations in a common helper on the Linux
side.
The strings are also probably unimportant, so %pe printing or similar
seems fair.
Regarding power-domain: it seems that the *use* of these "standardized"
error codes is somewhat haphazard. The LPB services within the CPM
firmware put error codes into different parts of the response payload,
and use a different style of error code. So indeed, the power-domain
driver cannot use the same helper.
All in all, even scouring any additional services we have in
not-yet-included-here CPM service drivers ... I only see clock and reset
drivers using these. So the "commonality" is actually quite limited.
Anyway, I'll see about a common helper, even if it's just for these two
drivers.
> > + return goog_cpm_rst_send_mba_mail(provider, lpcm_id, rst_id, DEASSERT_OP_ID);
> > +}
> > +
> > +static const struct reset_control_ops goog_cpm_rst_ops = {
> > + .assert = goog_cpm_rst_assert,
> > + .deassert = goog_cpm_rst_deassert,
> > +};
> > +
> > +static int goog_cpm_rst_debugfs_assert_set(void *data, u64 rst_id)
> > +{
> > + struct goog_cpm_rst_debugfs_entry *entry = data;
> > + unsigned long idx = to_rstc_idx(entry->lpcm_id, rst_id);
> > +
> > + return goog_cpm_rst_assert(&entry->provider->rcdev, idx);
>
> Calling into reset_control_ops like this bypasses all reference
> counting in the core and breaks reset controller API promises.
Yeah, sorry, I meant to take another pass at whether I should drop this
entirely, or at least try to explain it better when including it. I
clearly did not do that. More below.
> > +}
> > +
> > +static int goog_cpm_rst_debugfs_deassert_set(void *data, u64 rst_id)
> > +{
> > + struct goog_cpm_rst_debugfs_entry *entry = data;
> > + unsigned long idx = to_rstc_idx(entry->lpcm_id, rst_id);
> > +
> > + return goog_cpm_rst_deassert(&entry->provider->rcdev, idx);
> > +}
> > +
> > +DEFINE_DEBUGFS_ATTRIBUTE(goog_cpm_rst_assert_debugfs_fops, NULL,
> > + goog_cpm_rst_debugfs_assert_set, "%llu\n");
> > +
> > +DEFINE_DEBUGFS_ATTRIBUTE(goog_cpm_rst_deassert_debugfs_fops, NULL,
> > + goog_cpm_rst_debugfs_deassert_set, "%llu\n");
> > +
> > +static void goog_cpm_rst_add_debugfs(struct goog_cpm_rst_debugfs_entry *entry,
> > + struct dentry *debugfs_root,
> > + const char *name)
> > +{
> > + struct dentry *d = debugfs_create_dir(name, debugfs_root);
> > +
> > + debugfs_create_file("assert", 0220, d, entry,
> > + &goog_cpm_rst_assert_debugfs_fops);
> > + debugfs_create_file("deassert", 0220, d, entry,
> > + &goog_cpm_rst_deassert_debugfs_fops);
> > +}
>
> Please drop the debugfs functionality or explain what it is needed for.
Ack. I think I'll probably go with "drop", but some notes:
There's no real way to test and validate a "reset" driver without a
consumer. There is no direct (even for debug) interface into the reset
API, unlike in some other subsystems (e.g., GPIO). I believe the main
purpose here on Pixel drivers has been hardware+driver testing, so one
can test reset functionality before hooking it up to real client
drivers, and without adding fake drivers or extra debug code (a la
"printf debugging").
(One might observe these results either via /dev/mem-like access to
registers, or even through external debug peripherals/consoles that can
monitor the status of the underlying component that is being reset.)
This all would generally be in an early hardware bringup scenario, so
admittedly it probably doesn't have as much of a use case in the
upstream kernel -- it's a long shot for this kind of hardware/product
development to *actually* work directly on an upstream kernel, with
upstream drivers.
...but if I were imagining a better way to do this without bypassing
reference counting: perhaps it could be useful to a have a
debug-oriented "reset client" driver, that could bind to arbitrary reset
devices, if they're not already owned, and expose a sysfs or debugfs
interface like this? That could fill similar use cases for this sort of
hardware testing/validation area.
But anyway, I understand such a proposal should definitely come
separately from this driver submission.
---
Thanks for the review. I'll try to integrate the rest of the feedback in
v2.
Brian
next prev parent reply other threads:[~2026-11-03 1:03 UTC|newest]
Thread overview: 23+ 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-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-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 [this message]
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
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=aukyyYhDCBUdIH16@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=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