Skip to contentSkip to conversation

Add AMD PL Mailbox and RPMsg support for the AMD BRAM remoteproc

PATCH In review Ben Levinsky 3 participants 9 messages Nov 19 – Nov 22

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover Add AMD PL Mailbox and RPMsg support for the AMD BRAM remoteproc

This series adds a driver for the AMD PL Mailbox soft IP and uses it to add RPMsg support to the AMD MicroBlaze/V BRAM remoteproc driver.

Patches 1-2 add the PL Mailbox binding and driver, and patches 3-4 add RPMsg resources to the BRAM remoteproc binding and driver.

Claude (claude-opus-5.5) was used to help write the code and changelogs, as indicated by the Assisted-by tags.

Tested on a VEK385 board with the series applied to a 6.18 based AMD vendor kernel: RPMsg echo with bursts of 64 messages, over five remote processor start/stop cycles, with two MicroBlaze V designs.

Changes in v3:
- Drop "remoteproc: amd_mbv_bram: Bound device name formatting". The name is already bounded by rproc_mem_entry_init() and a DT node name can't contain '%', so there was nothing to fix.
- Drop "remoteproc: amd_mbv_bram: Restore reset GPIO direction after PL reconfig". The problem only shows when the PL is reprogrammed while the devices it contains are still bound, which isn't a supported flow.
- dt-bindings: mailbox: Reword the description, which no longer refers to a "register aperture" or "processor-facing interfaces".
- remoteproc: amd_mbv_bram: Add RPMsg support:
- Reject memory regions above 4 GiB, since the remote uses the physical address as device address.
- Validate all memory regions before registering any carveout.

v2: https://lore.kernel.org/r/[email protected]
v1: https://lore.kernel.org/r/[email protected]

Ben Levinsky (4):
dt-bindings: mailbox: Add AMD PL Mailbox IP
mailbox: Add AMD PL Mailbox soft IP controller
dt-bindings: remoteproc: Add RPMsg resources to AMD BRAM rproc
remoteproc: amd_mbv_bram: Add RPMsg support

 .../bindings/mailbox/amd,pl-mailbox-2.1.yaml  |  71 ++++
 .../bindings/remoteproc/amd,bram-rproc.yaml   |  21 +
 MAINTAINERS                                   |   7 +
 drivers/mailbox/Kconfig                       |  11 +
 drivers/mailbox/Makefile                      |   1 +
 drivers/mailbox/amd-pl-mailbox.c              | 378 ++++++++++++++++++
 drivers/remoteproc/Kconfig                    |   5 +
 drivers/remoteproc/amd_mbv_bram_rproc.c       | 295 +++++++++++++-
 8 files changed, 788 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/mailbox/amd,pl-mailbox-2.1.yaml
 create mode 100644 drivers/mailbox/amd-pl-mailbox.c

base-commit: f1715c0c04606ebbe832cc760abf49dfd6f2ae1f

Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 1/4 dt-bindings: mailbox: Add AMD PL Mailbox IP

Add a binding for the AMD PL Mailbox, a soft IP used to exchange 32-bit words between two processors through a pair of FIFOs.

The IP lives in programmable logic and isn't tied to a SoC, so the compatible names the IP and its version. The FIFO depth is set when the design is synthesized and can't be read from the hardware, hence property amd,pl-mailbox-depth.

Assisted-by Claude:claude-opus-5.5
---
 .../bindings/mailbox/amd,pl-mailbox-2.1.yaml  | 71 +++++++++++++++++++
 MAINTAINERS                                   |  6 ++
 2 files changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/amd,pl-mailbox-2.1.yaml
Documentation/devicetree/bindings/mailbox/amd,pl-mailbox-2.1.yaml new file +71 -0
new file mode 100644
index 000000000000..50ac14a4cbac
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/amd,pl-mailbox-2.1.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: AMD Programmable Logic Mailbox IP
+
+maintainers:
+  - Ben Levinsky <[email protected]>
+
+description: |
+  The AMD Programmable Logic Mailbox IP passes messages between two
+  processors through a pair of FIFOs. Each side of the IP has its own
+  registers, interrupt and clock, and is described by its own node.
+  Channel 0 is used to transmit and channel 1 to receive.
+
+  The Mailbox is a soft IP core instantiated in programmable logic, not a
+  SoC block, so the compatible names the IP core and its version (2.1).
+  The "pl" part distinguishes it from the IPI hardware that can also be
+  used as a mailbox.
+
+properties:
+  compatible:
+    const: amd,pl-mailbox-2.1
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  amd,pl-mailbox-depth:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 16
+    maximum: 8192
+    default: 16
+    description:
+      Depth of the send and receive FIFOs in 32-bit words. The depth is the
+      C_MAILBOX_DEPTH parameter chosen for each IP instance when the design
+      is synthesized, so instances in one design can differ, and it cannot
+      be read from the registers. Must match the synthesized depth.
+
+  '#mbox-cells':
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - '#mbox-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    mailbox@b2060000 {
+        compatible = "amd,pl-mailbox-2.1";
+        reg = <0xb2060000 0x10000>;
+        interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&pl_clk>;
+        amd,pl-mailbox-depth = <16>;
+        #mbox-cells = <1>;
+    };
+...
MAINTAINERS +6 -0
index ca1c59e1fc59..dc6a835f7bbc 100644
@@ -1315,6 +1315,12 @@ S:	Supported
 T:	git https://gitlab.freedesktop.org/agd5f/linux.git
 F:	drivers/gpu/drm/amd/pm/
 
+AMD PROGRAMMABLE LOGIC MAILBOX DRIVER
+M:	Ben Levinsky <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/mailbox/amd,pl-mailbox-2.1.yaml
+
 AMD PSTATE DRIVER
 M:	Huang Rui <[email protected]>
 M:	Mario Limonciello <[email protected]>
Signature · 1 line
2.34.1
#7 lore raw

PATCH v3 4/4 remoteproc: amd_mbv_bram: Add RPMsg support

In reply to Ben Levinsky

Add RPMsg support using the mailbox framework for virtqueue notifications and reserved memory regions for the vrings and buffer pool. Both are optional, the driver can still be used to only load, start and stop the remote processor.

Received notifications are processed in a work item since the mailbox RX callback may run in atomic context and the virtio RPMsg receive path takes a mutex.

The mailbox client API doesn't provide stubs when MAILBOX is not enabled, hence the new Kconfig dependency.

Assisted-by Claude:claude-opus-5.5
---
 drivers/remoteproc/Kconfig              |   5 +
 drivers/remoteproc/amd_mbv_bram_rproc.c | 295 +++++++++++++++++++++++-
 2 files changed, 299 insertions(+), 1 deletion(-)
drivers/remoteproc/Kconfig +5 -0
index 70dec8c3fe4e..2d3c51cbcbad 100644
@@ -26,10 +26,15 @@ config REMOTEPROC_CDEV
 config AMD_MBV_BRAM_REMOTEPROC
 	tristate "AMD MicroBlaze/V BRAM-based remoteproc support"
 	depends on OF && COMMON_CLK && (GPIOLIB || COMPILE_TEST)
+	depends on MAILBOX
 	help
 	  Say y or m here to support a MicroBlaze/V BRAM-based remote
 	  processor managed through the remoteproc framework.
 
+	  RPMsg communication additionally needs the mailbox controller
+	  referenced by the mboxes property, such as AMD_PL_MAILBOX, and
+	  RPMSG_VIRTIO.
+
 	  If unsure, say N.
 
 config IMX_REMOTEPROC
drivers/remoteproc/amd_mbv_bram_rproc.c +294 -1

364 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw

PATCH v3 2/4 mailbox: Add AMD PL Mailbox soft IP controller

In reply to Ben Levinsky

Add a driver for the AMD PL Mailbox IP. Each instance provides a TX and an RX channel. Transmit completion is detected by polling the TX FIFO empty status, while received words are read from a threaded interrupt handler until the RX FIFO is empty.

Since the hardware doesn't provide a message length, received data is passed to clients in chunks of at most one FIFO depth.

Assisted-by Claude:claude-opus-5.5
---
 MAINTAINERS                      |   1 +
 drivers/mailbox/Kconfig          |  11 +
 drivers/mailbox/Makefile         |   1 +
 drivers/mailbox/amd-pl-mailbox.c | 378 +++++++++++++++++++++++++++++++
 4 files changed, 391 insertions(+)
 create mode 100644 drivers/mailbox/amd-pl-mailbox.c
MAINTAINERS +1 -0
index dc6a835f7bbc..60f195c53aad 100644
@@ -1320,6 +1320,7 @@ M:	Ben Levinsky <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/mailbox/amd,pl-mailbox-2.1.yaml
+F:	drivers/mailbox/amd-pl-mailbox.c
 
 AMD PSTATE DRIVER
 M:	Huang Rui <[email protected]>
drivers/mailbox/Kconfig +11 -0
index ab869769e278..ea6bbc5bd2d2 100644
@@ -8,6 +8,17 @@ menuconfig MAILBOX
 
 if MAILBOX
 
+config AMD_PL_MAILBOX
+	tristate "AMD PL Mailbox soft IP controller"
+	depends on ARCH_ZYNQMP || COMPILE_TEST
+	depends on HAS_IOMEM
+	depends on OF
+	help
+	  Mailbox controller for the AMD Programmable Logic Mailbox soft IP.
+	  The controller exposes transmit and receive FIFO channels to mailbox
+	  clients. It supports interrupt-driven receive notification and
+	  polling-based transmit completion through the common mailbox framework.
+
 config ARM_MHU
 	tristate "ARM MHU Mailbox"
 	depends on ARM_AMBA
drivers/mailbox/Makefile +1 -0
index 45dc59bb3e7f..5614d7e1e2f8 100644
@@ -4,6 +4,7 @@
 obj-$(CONFIG_MAILBOX)		+= mailbox.o
 
 obj-$(CONFIG_MAILBOX_TEST)	+= mailbox-test.o
+obj-$(CONFIG_AMD_PL_MAILBOX)	+= amd-pl-mailbox.o
 
 obj-$(CONFIG_ARM_MHU)	+= arm_mhu.o arm_mhu_db.o
 
drivers/mailbox/amd-pl-mailbox.c new file +378 -0

378 lines not on this page · raw message

Signature · 1 line
2.34.1
#5 lore raw

PATCH v3 3/4 dt-bindings: remoteproc: Add RPMsg resources to AMD BRAM rproc

In reply to Ben Levinsky

Add optional mailbox channels and reserved memory regions to support RPMsg communication with the remote processor. The memory regions hold the vrings and the RPMsg buffer pool.

Assisted-by Claude:claude-opus-5.5
---
 .../bindings/remoteproc/amd,bram-rproc.yaml   | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
Documentation/devicetree/bindings/remoteproc/amd,bram-rproc.yaml +21 -0
index c0359f447ea8..462bd4be087d 100644
@@ -84,6 +84,23 @@ properties:
     description:
       GPIO specifier controlling the soft-core reset input.
 
+  mboxes:
+    maxItems: 2
+
+  mbox-names:
+    items:
+      - const: tx
+      - const: rx
+
+  memory-region:
+    maxItems: 3
+
+  memory-region-names:
+    items:
+      - const: vdev0vring0
+      - const: vdev0vring1
+      - const: vdev0buffer
+
 required:
   - compatible
   - reg
@@ -101,5 +118,9 @@ examples:
       clocks = <&pl_clk>;
       firmware-name = "firmware.elf";
       reset-gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
+      mboxes = <&mbv_mbox0 0>, <&mbv_mbox0 1>;
+      mbox-names = "tx", "rx";
+      memory-region = <&mbv_vring0>, <&mbv_vring1>, <&mbv_vdev0buffer>;
+      memory-region-names = "vdev0vring0", "vdev0vring1", "vdev0buffer";
     };
 ...
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v3 2/4] mailbox: Add AMD PL Mailbox soft IP controller

In reply to Ben Levinsky
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] mailbox: skipped error read in amd_pl_mbox_irq_thread() when ratelimited - [Medium] mailbox: lost…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] mailbox: skipped error read in amd_pl_mbox_irq_thread() when ratelimited
- [Medium] mailbox: lost RX threshold IRQ race in amd_pl_mbox_startup() --

commit d942eb10f8289caaed849b4d53047a9b3e47ae11
Author: Ben Levinsky <[email protected]>

mailbox: Add AMD PL Mailbox soft IP controller

This commit adds a mailbox controller driver for the AMD Programmable Logic Mailbox soft IP with polling-based TX completion and interrupt-driven RX handling.

Quoted 6 lines
drivers/mailbox/amd-pl-mailbox.c new file +0 -0
new file mode 100644
index 0000000000000..d1fe0f381dce5
@@ -0,0 +1,378 @@

[ ... ]

Quoted 2 lines
drivers/mailbox/amd-pl-mailbox.c new file +2 -0
+static int amd_pl_mbox_startup(struct mbox_chan *chan)
+{

[ ... ]

drivers/mailbox/amd-pl-mailbox.c line 186

Quoted 12 lines
drivers/mailbox/amd-pl-mailbox.c new file +12 -0
+	writel(AMD_PL_MBOX_CTRL_RX_RESET, mb->regs + AMD_PL_MBOX_CTRL);
+	/* Interrupt when the RX FIFO changes from empty to nonempty. */
+	writel(0, mb->regs + AMD_PL_MBOX_RECV_THRESHOLD);
+	writel(AMD_PL_MBOX_IRQ_RX_THRESHOLD | AMD_PL_MBOX_IRQ_ERROR,
+	       mb->regs + AMD_PL_MBOX_IRQ_STATUS);
+	irq_enable = readl(mb->regs + AMD_PL_MBOX_IRQ_ENABLE);
+	irq_enable |= AMD_PL_MBOX_IRQ_RX_THRESHOLD | AMD_PL_MBOX_IRQ_ERROR;
+	writel(irq_enable, mb->regs + AMD_PL_MBOX_IRQ_ENABLE);
+	enable_irq(mb->irq);
+
+	return 0;
+}

[Severity: Medium]
Can clearing AMD_PL_MBOX_IRQ_STATUS after resetting the RX FIFO lose an incoming receive interrupt and stall the RX channel?

With AMD_PL_MBOX_RECV_THRESHOLD set to 0, AMD_PL_MBOX_IRQ_RX_THRESHOLD only latches when the RX FIFO transitions from empty to nonempty. If the remote peer writes a word after AMD_PL_MBOX_CTRL_RX_RESET empties the FIFO and before AMD_PL_MBOX_IRQ_STATUS is cleared, that status write clears the latched event while the word stays unread in the FIFO. Later words then see a nonempty FIFO and never latch AMD_PL_MBOX_IRQ_RX_THRESHOLD again.

Clearing AMD_PL_MBOX_IRQ_STATUS before resetting the RX FIFO (or draining after enabling the interrupt) would avoid this race.

[ ... ]

Quoted 2 lines
drivers/mailbox/amd-pl-mailbox.c new file +2 -0
+static irqreturn_t amd_pl_mbox_irq_thread(int irq, void *data)
+{

[ ... ]

drivers/mailbox/amd-pl-mailbox.c line 281

Quoted 11 lines
drivers/mailbox/amd-pl-mailbox.c new file +11 -0
+	/*
+	 * Acknowledge before draining. The receive event latches when the RX
+	 * FIFO goes from empty to nonempty, so a word that arrives after the
+	 * drain has emptied the FIFO raises a new event.
+	 */
+	writel(pending_intr, mb->regs + AMD_PL_MBOX_IRQ_STATUS);
+
+	if (pending_intr & AMD_PL_MBOX_IRQ_ERROR)
+		dev_warn_ratelimited(mb->controller.dev,
+				     "mailbox FIFO error: %#x\n",
+				     readl(mb->regs + AMD_PL_MBOX_ERROR));

[Severity: Medium]
Does passing readl(mb->regs + AMD_PL_MBOX_ERROR) directly to dev_warn_ratelimited() skip reading the error register when logging is rate-limited or CONFIG_PRINTK is disabled?

dev_warn_ratelimited() only evaluates its variadic arguments when __ratelimit() succeeds, so once the burst limit is exceeded the clear-on-read AMD_PL_MBOX_ERROR register is not read and its sticky FIFO error bits remain set. Reading AMD_PL_MBOX_ERROR into a local variable before calling dev_warn_ratelimited() ensures the register is always cleared.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#8 lore raw

Re: [PATCH v3 4/4] remoteproc: amd_mbv_bram: Add RPMsg support

In reply to Ben Levinsky
Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [High] remoteproc: amd_mbv_bram: active mailboxes in amd_bram_rproc_stop() race - [Medium] remoteproc…

Thank you for your contribution! Sashiko AI review found 4 potential issues to consider:
- [High] remoteproc: amd_mbv_bram: active mailboxes in amd_bram_rproc_stop() race
- [Medium] remoteproc: amd_mbv_bram: unmapped vdev0buffer added to coredump segments
- [Medium] remoteproc: amd_mbv_bram: leaked carveouts on amd_bram_rproc_prepare() error
- [Low] remoteproc: amd_mbv_bram: dev_err_probe() used outside probe in prepare path
--

commit 8f91a29d9a83c18ff06a14340aaa60590fc44b4c
Author: Ben Levinsky <[email protected]>

remoteproc: amd_mbv_bram: Add RPMsg support

This commit adds optional RPMsg support to the AMD MicroBlaze/V BRAM remoteproc driver using mailbox channels for virtqueue notifications and reserved memory regions for vrings and buffers.

Quoted 4 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +0 -0
index e4a103cf84558..0b54a6cc3e62b 100644

[ ... ]

Quoted 1 line
drivers/remoteproc/amd_mbv_bram_rproc.c +0 -0
@@ -31,13 +36,266 @@

[ ... ]

Quoted 15 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +15 -0
+static int amd_bram_rproc_get_reserved_mem(struct amd_bram_rproc *priv, int i,
+					   const char **name,
+					   struct resource *res)
+{
+	struct device_node *np = priv->dev->of_node;
+	int ret;
+
+	ret = of_property_read_string_index(np, "memory-region-names", i, name);
+	if (ret)
+		return dev_err_probe(priv->dev, ret,
+				     "failed to read memory-region name %d\n", i);
+
+	ret = of_reserved_mem_region_to_resource(np, i, res);
+	if (ret)
+		return dev_err_probe(priv->dev, ret,

drivers/remoteproc/amd_mbv_bram_rproc.c line 233

Quoted 10 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +10 -0
+				     "failed to parse memory-region %d\n", i);
+
+	/* The remote uses the physical address as device address. */
+	if (res->end > U32_MAX)
+		return dev_err_probe(priv->dev, -EINVAL,
+				     "memory-region %d %pR is above 4 GiB\n",
+				     i, res);
+
+	return 0;
+}

[Severity: Low]
Should amd_bram_rproc_get_reserved_mem() use dev_err() instead of dev_err_probe()? This helper is only called from amd_bram_rproc_prepare() when booting the remote processor, never during probe.

[ ... ]

Quoted 26 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +26 -0
+static int amd_bram_rproc_add_reserved_mem(struct rproc *rproc)
+{
+	struct amd_bram_rproc *priv = rproc->priv;
+	struct rproc_mem_entry *mem;
+	int count;
+	int ret;
+	int i;
+
+	count = amd_bram_rproc_reserved_mem_count(priv);
+	if (count < 0)
+		return count;
+
+	for (i = 0; i < count; i++) {
+		struct resource res;
+		const char *name;
+
+		ret = amd_bram_rproc_get_reserved_mem(priv, i, &name, &res);
+		if (ret)
+			return ret;
+
+		if (!strcmp(name, "vdev0buffer"))
+			mem = rproc_of_resm_mem_entry_init(priv->dev, i,
+							   resource_size(&res),
+							   res.start, name);
+		else
+			mem = rproc_mem_entry_init(priv->dev, NULL,

drivers/remoteproc/amd_mbv_bram_rproc.c line 292

Quoted 10 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +10 -0
+						   (dma_addr_t)res.start,
+						   resource_size(&res), res.start,
+						   rproc_mem_entry_ioremap_wc,
+						   rproc_mem_entry_iounmap,
+						   "%s", name);
+		if (!mem)
+			return -ENOMEM;
+
+		rproc_add_carveout(rproc, mem);
+		rproc_coredump_add_segment(rproc, res.start, resource_size(&res));

[Severity: Medium]
Should the vdev0buffer region be excluded from
rproc_coredump_add_segment()?

rproc_of_resm_mem_entry_init() leaves mem->va and mem->alloc NULL because vdev0buffer is attached to the child virtio device as a DMA pool rather than mapped as a carveout. During coredump collection, rproc_copy_segment() calls rproc_da_to_va(), which skips carveouts with a NULL va, logs an invalid copy request error, and fills the vdev0buffer segment in the dump with 0xff.

Quoted 8 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +6 -0
+		dev_dbg(priv->dev, "reserved memory carveout %pR\n", &res);
+	}
+
+	return 0;
+}
+
 static int amd_bram_rproc_prepare(struct rproc *rproc)
 {

[ ... ]

Quoted 12 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +4 -0
@@ -68,6 +326,10 @@ static int amd_bram_rproc_prepare(struct rproc *rproc)
 		return ret;
 	}
 
+	ret = amd_bram_rproc_check_reserved_mem(priv);
+	if (ret)
+		return ret;
+
 	mem = rproc_mem_entry_init(priv->dev, NULL, (dma_addr_t)res.start,
 				   resource_size(&res), da,
 				   rproc_mem_entry_ioremap_wc,

drivers/remoteproc/amd_mbv_bram_rproc.c static int amd_bram_rproc_prepare(struct rproc *rproc) · line 345

Quoted 6 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +1 -1
@@ -79,7 +341,7 @@ static int amd_bram_rproc_prepare(struct rproc *rproc)
 	rproc_add_carveout(rproc, mem);
 	rproc_coredump_add_segment(rproc, da, resource_size(&res));
 
-	return 0;
+	return amd_bram_rproc_add_reserved_mem(rproc);
 }

[Severity: Medium]
Does an allocation failure in amd_bram_rproc_add_reserved_mem() leave the already-added carveouts and coredump segments on rproc->carveouts and rproc->dump_segments?

When rproc_prepare_device() fails in rproc_fw_boot(), it jumps to disable_iommu without calling rproc_resource_cleanup(). Any entries linked before the failure remain on the lists, causing duplicate carveouts and dump segments on subsequent boot attempts or leaking them if the device is unbound while offline. Also, the return value of rproc_coredump_add_segment() is not checked here or in amd_bram_rproc_add_reserved_mem().

drivers/remoteproc/amd_mbv_bram_rproc.c static int amd_bram_rproc_stop(struct rproc *rproc) · line 383

Quoted 7 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +3 -0
@@ -116,6 +378,9 @@ static int amd_bram_rproc_stop(struct rproc *rproc)
 		dev_err(priv->dev, "failed to assert reset: %d\n", ret);
 		return ret;
 	}
+	cancel_work_sync(&priv->rx_work);
+	bitmap_zero(priv->pending_notify_ids,
+		    ARRAY_SIZE(priv->notify_msgs));

[Severity: High]
Can a late mailbox RX interrupt race with amd_bram_rproc_stop() while priv->rx_chan and priv->tx_chan stay active across stop?

CPU0 CPU1
amd_bram_rproc_stop()
gpiod_set_value_cansleep(..., 1)
cancel_work_sync(&priv->rx_work)

                                  amd_pl_mbox_irq_thread()
                                    amd_bram_rproc_rx_callback()
                                      set_bit(..., pending_notify_ids)
  bitmap_zero(pending_notify_ids)
                                      schedule_work(&priv->rx_work)

rproc_resource_cleanup()
rproc_free_vring()
amd_bram_rproc_rx_work()
rproc_vq_interrupt() <-- races teardown

Because the mailbox channels are requested at probe time and only shut down on device unbind, RX interrupts remain enabled and any word already in the hardware RX FIFO when reset is asserted can still trigger amd_bram_rproc_rx_callback(). On the TX side, if the remote processor stops before draining a kick word from the hardware FIFO, the channel's active request never completes, leaving the mailbox core hrtimer polling while the processor is offline and delivering a stale notification on the next boot. Requesting the mailbox channels in .start() and freeing them in .stop() would synchronously disable the RX IRQ and reset both hardware FIFOs.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Reviewed-by on v3 1/4
#2 lore raw

Re: [PATCH v3 1/4] dt-bindings: mailbox: Add AMD PL Mailbox IP

In reply to Ben Levinsky
Quoted 9 lines · Ben Levinsky

Add a binding for the AMD PL Mailbox, a soft IP used to exchange 32-bit words between two processors through a pair of FIFOs.

The IP lives in programmable logic and isn't tied to a SoC, so the compatible names the IP and its version. The FIFO depth is set when the design is synthesized and can't be read from the hardware, hence property amd,pl-mailbox-depth.

Assisted-by Claude:claude-opus-5.5

Drop, wasn't even here before, so you must have added it.
https://lore.kernel.org/all/[email protected]/

Please run scripts/checkpatch.pl on the patches and fix reported warnings. After that, run also 'scripts/checkpatch.pl --strict' on the patches and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.

Quoted 89 lines
---
 .../bindings/mailbox/amd,pl-mailbox-2.1.yaml  | 71 +++++++++++++++++++
 MAINTAINERS                                   |  6 ++
 2 files changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/amd,pl-mailbox-2.1.yaml
Documentation/devicetree/bindings/mailbox/amd,pl-mailbox-2.1.yaml new file +71 -0
new file mode 100644
index 000000000000..50ac14a4cbac
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/amd,pl-mailbox-2.1.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: AMD Programmable Logic Mailbox IP
+
+maintainers:
+  - Ben Levinsky <[email protected]>
+
+description: |
+  The AMD Programmable Logic Mailbox IP passes messages between two
+  processors through a pair of FIFOs. Each side of the IP has its own
+  registers, interrupt and clock, and is described by its own node.
+  Channel 0 is used to transmit and channel 1 to receive.
+
+  The Mailbox is a soft IP core instantiated in programmable logic, not a
+  SoC block, so the compatible names the IP core and its version (2.1).
+  The "pl" part distinguishes it from the IPI hardware that can also be
+  used as a mailbox.
+
+properties:
+  compatible:
+    const: amd,pl-mailbox-2.1
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  amd,pl-mailbox-depth:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 16
+    maximum: 8192
+    default: 16
+    description:
+      Depth of the send and receive FIFOs in 32-bit words. The depth is the
+      C_MAILBOX_DEPTH parameter chosen for each IP instance when the design
+      is synthesized, so instances in one design can differ, and it cannot
+      be read from the registers. Must match the synthesized depth.
+
+  '#mbox-cells':
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - '#mbox-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    mailbox@b2060000 {
+        compatible = "amd,pl-mailbox-2.1";
+        reg = <0xb2060000 0x10000>;
+        interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&pl_clk>;
+        amd,pl-mailbox-depth = <16>;
+        #mbox-cells = <1>;
+    };
+...
MAINTAINERS +0 -0
index ca1c59e1fc59..dc6a835f7bbc 100644

MAINTAINERS S: Supported · line 1320

Quoted 6 lines
MAINTAINERS +3 -0
@@ -1315,6 +1315,12 @@ S:	Supported
 T:	git https://gitlab.freedesktop.org/agd5f/linux.git
 F:	drivers/gpu/drm/amd/pm/
 
+AMD PROGRAMMABLE LOGIC MAILBOX DRIVER
+M:	Ben Levinsky <[email protected]>
+L:	[email protected]

Drop list, there is no point in mentioning lkml for every driver. lkml is standard list, catch all.

Best regards,
Krzysztof

Reviewed-by on v3 3/4
#6 lore raw

Re: [PATCH v3 3/4] dt-bindings: remoteproc: Add RPMsg resources to AMD BRAM rproc

In reply to Ben Levinsky
Quoted 5 lines · Ben Levinsky

Add optional mailbox channels and reserved memory regions to support RPMsg communication with the remote processor. The memory regions hold the vrings and the RPMsg buffer pool.

Assisted-by Claude:claude-opus-5.5

Drop

Please run scripts/checkpatch.pl on the patches and fix reported warnings. After that, run also 'scripts/checkpatch.pl --strict' on the patches and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.

Quoted 5 lines
---
 .../bindings/remoteproc/amd,bram-rproc.yaml   | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

With this fixed:

Best regards,
Krzysztof