Thread (32 messages) 32 messages, 4 authors, 2025-09-26

Re: [PATCH v10 07/24] mailbox: Add RISC-V SBI message proxy (MPXY) based mailbox driver

From: Anup Patel <hidden>
Date: 2025-09-25 05:12:11
Also in: linux-acpi, linux-clk, linux-riscv, lkml

Hi Paul,

On Thu, Sep 25, 2025 at 5:57 AM Paul Walmsley [off-list ref] wrote:
On Mon, 18 Aug 2025, Anup Patel wrote:
quoted
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
[ ... ]
quoted
+
+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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help