From: Brian Norris <briannorris@chromium.org>
To: Peter Griffin <peter.griffin@linaro.org>
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>,
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 3/9] soc: google: Add CPM over MailBox Array driver
Date: Tue, 24 Nov 2026 11:05:23 -0800 [thread overview]
Message-ID: <awXf86suGgKeazZx@google.com> (raw)
In-Reply-To: <CADrjBPqnRrFeYT9J6NGxy+Xzy1PTZEz+BMs1_u2md7Ra6xPPDQ@mail.gmail.com>
On Tue, Nov 24, 2026 at 12:28:24PM +0000, Peter Griffin wrote:
> Hi Brian,
>
> Thanks for your series; it's great to see more Laguna support being posted.
>
> On Mon, 26 Oct 2026 at 21:45, Brian Norris <briannorris@chromium.org> wrote:
> >
> > The Central Power Manager (CPM) is a co-processor on the Google Tensor
> > SoCs, as used on Pixel phones. CPM supports power-management and a
> > number of other features.
> >
> > The Application Processor communicates with CPM over a pair of mailbox
> > channels (the "MailBox Array" (MBA)). CPM provides clock, power-domain,
> > reset, interrupt services, and more.
>
> [..]
>
> +++ b/drivers/soc/google/Kconfig
> @@ -0,0 +1,13 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +
> +config GOOGLE_CPM_MBA
> + tristate "Google Tensor CPM MailBox Array Interface"
> + depends on ARCH_GOOGLE || COMPILE_TEST
> + depends on MAILBOX
>
> Should we also have "depends on OF"?
Why, precisely? It's not actually a compilation dependency (I tested),
although it's needed at runtime. It doesn't seem like this is
consistently done simply for runtime dependencies, and instead work has
generally been done to ensure everything builds fine and fails closed
without CONFIG_OF.
Anyway, it's a bit academic, since ARCH_GOOGLE (ARM64) selects OF.
> + select AUXILIARY_BUS
> + help
> + Driver for interfacing with the Central Power Manager (CPM) MailBox
> + Array (MBA) found on Google Tensor SoCs. The driver provides APIs for
> + communication between the Application Processor and the CPM, and
> + is required by CPM client drivers such as clock, reset, power
> + domain, and more.
>
> > diff --git a/drivers/soc/google/google-cpm-mba.c b/drivers/soc/google/google-cpm-mba.c
> > new file mode 100644
> > index 000000000000..629a071e202c
> > --- /dev/null
> > +++ b/drivers/soc/google/google-cpm-mba.c
> > @@ -0,0 +1,964 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Google MailBox Array (MBA) CPM Interface
> > + *
> > + * Copyright 2023-2026 Google LLC
> > + */
> > +
> > +#include <linux/auxiliary_bus.h>
> > +#include <linux/bitfield.h>
> > +#include <linux/bits.h>
> > +#include <linux/cleanup.h>
> > +#include <linux/completion.h>
> > +#include <linux/device.h>
> > +#include <linux/jiffies.h>
> > +#include <linux/kref.h>
> > +#include <linux/list.h>
> > +#include <linux/lockdep.h>
> > +#include <linux/mailbox/goog-mba-message.h>
> > +#include <linux/mailbox_client.h>
> > +#include <linux/mailbox_controller.h>
> > +#include <linux/module.h>
> > +#include <linux/of.h>
> > +#include <linux/of_platform.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/spinlock.h>
>
> Missing `#include <linux/slab.h>` header here as later it calls
> kfree(), kzalloc_obj().
> This can cause "implicit declaration of function kfree / kzalloc_obj"
> errors with COMPILE_TEST. Also similar issue in clk-cpm.c
Ack, will fix.
> > +
> > +#include <soc/google/google-cpm-mba.h>
> > +
> > +#include "google-cpm-mba.h"
> > +
>
> [..]
> > +static bool cpm_iface_is_valid_req(struct cpm_data *cpm,
> > + struct cpm_request *cpm_req)
> > +{
> > + struct device *dev = cpm->dev;
> > +
> > + if (!cpm_req) {
> > + dev_err(dev, "cpm_req is NULL\n");
> > + return false;
> > + }
> > +
> > + if (!cpm_req->req_msg) {
> > + dev_err(dev, "cpm_req->req_msg is NULL\n");
> > + return false;
> > + }
> > +
> > + if (cpm_req->msg_type > RESPONSE_MSG || cpm_req->msg_type < ONEWAY_MSG) {
> > + dev_err(dev, "Invalid msg_type: %d\n", cpm_req->msg_type);
> > + return false;
> > + }
>
> Should cpm_req->dst_id also be range checked?
This will be refactored on v2, where dst_id will be u8 and so will
always be in-bounds.
> > +
> > + if (cpm_is_request_msg(cpm_req) && !cpm_req->resp_msg) {
> > + dev_err(dev, "cpm_req->resp_msg is NULL when msg_type is REQUEST_MSG\n");
> > + return false;
> > + }
> > +
> > + if (cpm_is_response_msg(cpm_req)) {
> > + if (!goog_mba_q_get_valid(&cpm_req->resp_context)) {
> > + dev_err(dev, "Invalid valid bit in resp_context: %#x\n",
> > + cpm_req->resp_context);
> > + return false;
> > + }
> > +
> > + if (!cpm_is_response_header(&cpm_req->resp_context)) {
> > + dev_err(dev, "Invalid response type in resp_context: %#x\n",
> > + cpm_req->resp_context);
> > + return false;
> > + }
> > + }
> > +
> > + return true;
> > +}
> > +
>
> [..]
>
> > +
> > +static int cpm_init_q_mode_proto(struct cpm_data *cpm)
> > +{
> > + struct cpm_payload msg_payload = {};
> > + struct cpm_request req = {
> > + .msg_type = ONEWAY_MSG,
> > + .req_msg = &msg_payload,
> > + };
> > +
> > + return __cpm_send_message(cpm, &req, GOOG_MBA_Q_INIT_PROTO_VAL, 0);
>
> Do we want this to have an infinite timeout? If the CPM firmware never
> responds, it will hang the boot (as MAX_SCHEDULE_TIMEOUT doesn't arm a
> timer).
> I guess it is game over anyway if the CPM firmware is dead, but it
> would be nice to log an error and return from probe()
Hmm, I suppose a timeout would be OK, although definitely fatal to any
useful purpose of the system.
> > +}
> > +
> > +static int cpm_init_q_mode(struct cpm_data *cpm)
> > +{
> > + int ret;
> > +
> > + ret = cpm_init_q_mode_proto(cpm);
> > + if (ret < 0)
> > + return ret;
> > +
> > + cpm->seq_num = GOOG_MBA_Q_MIN_SEQ_VAL;
> > +
> > + return 0;
> > +}
> > +
> > +static void cpm_adev_release(struct device *dev)
> > +{
> > + struct auxiliary_device *adev = to_auxiliary_dev(dev);
> > +
> > + of_node_put(dev->of_node);
> > + kfree(adev);
> > +}
> > +
> > +static void cpm_unregister_adev_action(void *data)
> > +{
> > + struct auxiliary_device *adev = data;
> > +
> > + auxiliary_device_delete(adev);
> > + auxiliary_device_uninit(adev);
> > +}
> > +
>
> Can we use devm_auxiliary_device_create() instead of open coding these?
Yes.
I think this (and some planned subsequent changes) have morphed a bit
over my development time, as there were some cases where we could not
reuse the same of_node. But this current patch can use it, and I also
think future changes will likely just use mfd / of_platform_populate()
if they require subnodes, so my initial concern is probably invalid.
> > +static int cpm_register_adev(struct cpm_data *cpm, const char *name)
> > +{
> > + struct auxiliary_device *adev;
> > + int ret;
> > +
> > + adev = kzalloc_obj(*adev, GFP_KERNEL);
> > + if (!adev)
> > + return -ENOMEM;
> > +
> > + adev->name = name;
> > + adev->id = 0;
> > + adev->dev.parent = cpm->dev;
> > + adev->dev.release = cpm_adev_release;
> > + device_set_of_node_from_dev(&adev->dev, cpm->dev);
> > +
> > + ret = auxiliary_device_init(adev);
> > + if (ret) {
> > + of_node_put(adev->dev.of_node);
> > + kfree(adev);
> > + return ret;
> > + }
> > +
> > + ret = auxiliary_device_add(adev);
> > + if (ret) {
> > + auxiliary_device_uninit(adev);
> > + return ret;
> > + }
> > +
> > + return devm_add_action_or_reset(cpm->dev, cpm_unregister_adev_action, adev);
> > +}
> > +
>
> [..]
>
> > +
> > +MODULE_DESCRIPTION("Google MBA CPM interface");
> > +MODULE_AUTHOR("Lucas Wei <lucaswei@google.com>");
>
> I think you should add Lucas Wei's SoB tag to the patch as part of the DCO
I keep going back and forth in my head on this one, since these drivers
did indeed start from the same source with the professed MODULE_AUTHOR.
But they've been massively rewritten, so they're similar in a sort of
Ship of Theseus way.
I suppose I'll retain the MODULE_AUTHOR() and update the SoB.
Regards,
Brian
next prev parent reply other threads:[~2026-11-24 19:05 UTC|newest]
Thread overview: 32+ 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-11-13 1:14 ` Brian Norris
2026-11-13 2:54 ` Chen-Yu Tsai
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-11-24 12:28 ` Peter Griffin
2026-11-24 19:05 ` Brian Norris [this message]
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
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
2026-11-24 13:19 ` Peter Griffin
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=awXf86suGgKeazZx@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
all inboxes | Powered by JetHome®