[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK9=C2Vr4rgj8wfT+Ogow1H-7Lu=6XdWA2Qe++6523P76pMZzQ@mail.gmail.com>
Date: Thu, 25 Sep 2025 10:41:58 +0530
From: Anup Patel <apatel@...tanamicro.com>
To: Paul Walmsley <pjw@...nel.org>
Cc: Michael Turquette <mturquette@...libre.com>, Stephen Boyd <sboyd@...nel.org>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Jassi Brar <jassisinghbrar@...il.com>, Thomas Gleixner <tglx@...utronix.de>,
"Rafael J . Wysocki" <rafael@...nel.org>, Mika Westerberg <mika.westerberg@...ux.intel.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Linus Walleij <linus.walleij@...aro.org>, Bartosz Golaszewski <brgl@...ev.pl>,
Uwe Kleine-König <ukleinek@...nel.org>,
devicetree@...r.kernel.org, Andrew Jones <ajones@...tanamicro.com>,
Alexandre Ghiti <alex@...ti.fr>, Atish Patra <atish.patra@...ux.dev>,
Leyfoon Tan <leyfoon.tan@...rfivetech.com>, Anup Patel <anup@...infault.org>,
linux-kernel@...r.kernel.org, Samuel Holland <samuel.holland@...ive.com>,
linux-acpi@...r.kernel.org, Palmer Dabbelt <palmer@...belt.com>,
Paul Walmsley <paul.walmsley@...ive.com>, linux-riscv@...ts.infradead.org,
Len Brown <lenb@...nel.org>, linux-clk@...r.kernel.org,
Rahul Pathak <rpathak@...tanamicro.com>
Subject: Re: [PATCH v10 07/24] mailbox: Add RISC-V SBI message proxy (MPXY)
based mailbox driver
Hi Paul,
On Thu, Sep 25, 2025 at 5:57 AM Paul Walmsley <pjw@...nel.org> wrote:
>
> On Mon, 18 Aug 2025, Anup Patel wrote:
>
> > Add a mailbox controller driver for the new SBI message proxy extension
> > which is part of the SBI v3.0 specification.
> > ---
> > drivers/mailbox/Kconfig | 11 +
> > drivers/mailbox/Makefile | 2 +
> > drivers/mailbox/riscv-sbi-mpxy-mbox.c | 994 ++++++++++++++++++++++++++
> > 3 files changed, 1007 insertions(+)
> > create mode 100644 drivers/mailbox/riscv-sbi-mpxy-mbox.c
> >
> > diff --git a/drivers/mailbox/riscv-sbi-mpxy-mbox.c b/drivers/mailbox/riscv-sbi-mpxy-mbox.c
> > new file mode 100644
> > index 000000000000..21404baa6df0
> > --- /dev/null
> > +++ b/drivers/mailbox/riscv-sbi-mpxy-mbox.c
>
> [ ... ]
>
> > +
> > +static int mpxy_mbox_populate_channels(struct mpxy_mbox *mbox)
> > +{
> > + u32 i, *channel_ids __free(kfree) = NULL;
> > + struct mpxy_mbox_channel *mchan;
> > + int rc;
> > +
> > + /* Find-out of number of channels */
> > + rc = mpxy_get_channel_count(&mbox->channel_count);
> > + if (rc)
> > + return dev_err_probe(mbox->dev, rc, "failed to get number of MPXY channels\n");
> > + if (!mbox->channel_count)
> > + return dev_err_probe(mbox->dev, -ENODEV, "no MPXY channels available\n");
> > +
> > + /* Allocate and fetch all channel IDs */
> > + channel_ids = kcalloc(mbox->channel_count, sizeof(*channel_ids), GFP_KERNEL);
>
> Should this be devm_kcalloc() ?
>
The usage of channel_ids array is limited only to this function
(mpxy_mbox_populate_channels()) hence we are using scoped
kcalloc() so that channel_ids will be automatically freed when
mpxy_mbox_populate_channels() returns.
(Refer, "__free(kfree)" attribute in the channel_ids declaration)
The scope of memory allocated using devm_kcalloc() is the entire
lifespan of the device which is not needed for channel_ids.
Regards,
Anup
Powered by blists - more mailing lists