Skip to contentSkip to conversation

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

PATCH Superseded Ben Levinsky 5 participants 28 messages Oct 14 – Oct 26 4 messages not in the archive

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#3 lore raw

PATCH 2/6 remoteproc: amd_mbv_bram: Restore reset GPIO direction after PL reconfig

In reply to Ben Levinsky

Partial reconfiguration of the programmable logic restores the AXI GPIO that drives the soft-core reset to its hardware default direction, but gpiolib keeps its cached output direction. gpiod_set_value_cansleep() then only updates the data register, so the processor never sees a reset transition: remoteproc reports it as running while the newly loaded firmware never starts.

Use gpiod_direction_output() for every reset transition so the output direction is re-established, and assert reset briefly before releasing it so each start produces a clean reset pulse after the firmware has been loaded.

Fixes f87b4998994e ("remoteproc: Add AMD MicroBlaze/V BRAM-based remote processor driver")
Assisted-by LLM sparse
---
 drivers/remoteproc/amd_mbv_bram_rproc.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/remoteproc/amd_mbv_bram_rproc.c +20 -3
index 6cf33c7b7e64..da621f62f7df 100644
@@ -16,6 +16,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/gpio/consumer.h>
 #include <linux/module.h>
@@ -94,8 +95,24 @@ static int amd_bram_rproc_start(struct rproc *rproc)
 		return ret;
 	}
 
+	/*
+	 * Partial reconfiguration restores the PL GPIO hardware defaults but
+	 * leaves gpiolib's cached direction unchanged. Re-establish the output
+	 * direction and generate a reset pulse after firmware has been loaded.
+	 * gpiod_set_value_cansleep() is insufficient here because it changes the
+	 * value without restoring an output direction lost during DFX.
+	 */
+	ret = gpiod_direction_output(priv->reset, 1);
+	if (ret) {
+		dev_err(priv->dev, "failed to assert reset: %d\n", ret);
+		clk_disable_unprepare(priv->clk);
+		return ret;
+	}
+	/* Hold reset asserted long enough to provide a clean reset pulse. */
+	usleep_range(10, 20);
+
 	/* Deassert reset and let the processor run. */
-	ret = gpiod_set_value_cansleep(priv->reset, 0);
+	ret = gpiod_direction_output(priv->reset, 0);
 	if (ret) {
 		dev_err(priv->dev, "failed to deassert reset: %d\n", ret);
 		clk_disable_unprepare(priv->clk);
@@ -110,8 +127,8 @@ static int amd_bram_rproc_stop(struct rproc *rproc)
 	struct amd_bram_rproc *priv = rproc->priv;
 	int ret;
 
-	/* Assert reset before disabling the processor clock. */
-	ret = gpiod_set_value_cansleep(priv->reset, 1);
+	/* Restore the output direction after DFX and assert reset. */
+	ret = gpiod_direction_output(priv->reset, 1);
 	if (ret) {
 		dev_err(priv->dev, "failed to assert reset: %d\n", ret);
 		return ret;
Signature · 1 line
2.34.1
#0 lore raw

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

This series adds a mailbox controller for the AMD programmable-logic (PL) Mailbox soft IP and uses it to add RPMsg support to the AMD MicroBlaze/V BRAM remoteproc driver, so that a soft processor in the PL can communicate with Linux over virtio-rpmsg.

Patches 1-2 fix the existing BRAM remoteproc driver:
- Pass the device name to rproc_mem_entry_init() through a constant format string instead of using it as the format.
- Drive the reset GPIO with gpiod_direction_output() so a start still produces a reset pulse after the PL has been reconfigured, which restores the AXI GPIO to its default direction.

Patches 3-4 add the binding and the mailbox-framework controller for the PL Mailbox IP. The controller exposes independent TX and RX channels. Its interface clock is enabled only while a channel is started. RX uses the receive-threshold interrupt and delivers up to one FIFO depth of words per message, with the depth taken from the device tree. TX completion is reported by mailbox-core polling of the send-threshold status bit.

Patches 5-6 extend the BRAM remoteproc binding and driver with optional mailbox channels and named reserved-memory regions for the vrings and the shared RPMsg buffer pool. The driver registers the carveouts, exposes the loaded resource table, requests the mailbox channels only while the remote processor clock is enabled, sends virtqueue notification IDs through the mailbox framework, and defers received notifications to process context. Without mailboxes the driver keeps supporting load, start and stop only.

The series applies to v7.3-rc7 and uses the remoteproc wc-ioremap and optional resource-table helpers merged for v7.3-rc1.

Ben Levinsky (6):
remoteproc: amd_mbv_bram: Bound device name formatting
remoteproc: amd_mbv_bram: Restore reset GPIO direction after PL
reconfig
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

 .../mailbox/amd,zynqmp-pl-mbox-2.1.yaml       |  74 ++++
 .../bindings/remoteproc/amd,bram-rproc.yaml   |  31 ++
 MAINTAINERS                                   |   7 +
 drivers/mailbox/Kconfig                       |  10 +
 drivers/mailbox/Makefile                      |   1 +
 drivers/mailbox/amd-pl-mailbox.c              | 369 ++++++++++++++++++
 drivers/remoteproc/Kconfig                    |   6 +-
 drivers/remoteproc/amd_mbv_bram_rproc.c       | 256 +++++++++++-
 8 files changed, 748 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml
 create mode 100644 drivers/mailbox/amd-pl-mailbox.c

base-commit: 0fcb05b72344f40806cbe810de8872f1698bf053

Signature · 1 line
2.34.1
#5 lore raw

PATCH 3/6 dt-bindings: mailbox: Add AMD PL Mailbox IP

Document the AMD programmable-logic Mailbox IP used for bidirectional FIFO communication between two processor-facing interfaces.

The same IP is used on ZynqMP, Versal, Versal NET and Versal Gen 2. Name each SoC in its compatible, and use amd,zynqmp-pl-mbox-2.1 as the fallback that drivers match.

Define the transmit and receive channel indices together with the register aperture, interrupt, and interface clock. Describe the FIFO depth chosen when the IP is configured, so that the driver can size received messages to it.

Assisted-by LLM sparse
---
 .../mailbox/amd,zynqmp-pl-mbox-2.1.yaml       | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +74 -0
new file mode 100644
index 000000000000..2cc0d106b888
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/amd,zynqmp-pl-mbox-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 provides bidirectional message passing
+  between two processor-facing interfaces. Each interface writes messages to
+  a send FIFO and reads messages from a receive FIFO. The register aperture,
+  interrupt, and clock described by a node belong to one processor-facing
+  interface. Channel 0 represents transmit and channel 1 represents receive
+  for that interface.
+
+properties:
+  compatible:
+    oneOf:
+      - const: amd,zynqmp-pl-mbox-2.1
+      - items:
+          - enum:
+              - amd,versal-pl-mbox-2.1
+              - amd,versal-net-pl-mbox-2.1
+              - amd,versal2-pl-mbox-2.1
+          - const: amd,zynqmp-pl-mbox-2.1
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  amd,mbox-pl-fifo-len:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 16
+    maximum: 8192
+    default: 16
+    description:
+      Depth of the send and receive FIFOs in 32-bit words, as configured by
+      the C_MAILBOX_DEPTH parameter of the IP. Must match the configured
+      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,zynqmp-pl-mbox-2.1";
+        reg = <0xb2060000 0x10000>;
+        interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&pl_clk>;
+        amd,mbox-pl-fifo-len = <16>;
+        #mbox-cells = <1>;
+    };
+...
Signature · 1 line
2.34.1
#23 lore raw

PATCH 5/6 dt-bindings: remoteproc: Add RPMsg resources to AMD BRAM rproc

In reply to Ben Levinsky

Describe the optional mailbox channels and named reserved-memory regions used for RPMsg communication with a BRAM-based MicroBlaze remote processor.

The three named memory regions provide the two virtio vrings and the shared RPMsg buffer pool. Firmware and its loaded resource table remain in the executable BRAM described by reg.

Assisted-by LLM sparse
---
 .../bindings/remoteproc/amd,bram-rproc.yaml   | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
Documentation/devicetree/bindings/remoteproc/amd,bram-rproc.yaml +31 -0
index c0359f447ea8..daff8e615ab6 100644
@@ -84,6 +84,33 @@ 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
+
+dependentRequired:
+  mboxes:
+    - mbox-names
+  mbox-names:
+    - mboxes
+  memory-region:
+    - memory-region-names
+  memory-region-names:
+    - memory-region
+
 required:
   - compatible
   - reg
@@ -101,5 +128,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
#15 lore raw

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

In reply to Ben Levinsky

Add a mailbox-framework controller for the AMD programmable-logic Mailbox soft IP. Expose separate transmit and receive FIFO channels.

Enable the interface clock only while a channel is started, before any register access, and disable it last when the channel shuts down. Keep provider probe free of register accesses and leave the IRQ disabled until a client starts the receive channel. Initialize each FIFO when its channel starts, use receive-threshold interrupts for incoming words, and poll the send-threshold status for transmit completion. Stop that polling from accessing registers once the transmit channel begins to shut down.

Carry mailbox payloads in struct zynqmp_ipi_message, limited to the FIFO depth given by the device tree. The FIFO transfers 32-bit words and the hardware conveys neither a byte count nor the FIFO occupancy, so a transmit length that is not a multiple of four is zero-padded to a whole word.

On a receive-threshold interrupt, read up to one FIFO depth of words and deliver them as one message, then acknowledge the interrupt. The event latches only when the FIFO goes from empty to nonempty, so a word that arrives between the drain and the acknowledge, or words left by the bounded drain, raise no new event. If the FIFO is nonempty after the acknowledge, toggle the threshold to latch a new event for them.

Assisted-by LLM sparse
---
 MAINTAINERS                      |   7 +
 drivers/mailbox/Kconfig          |  10 +
 drivers/mailbox/Makefile         |   1 +
 drivers/mailbox/amd-pl-mailbox.c | 369 +++++++++++++++++++++++++++++++
 4 files changed, 387 insertions(+)
 create mode 100644 drivers/mailbox/amd-pl-mailbox.c
MAINTAINERS +7 -0
index f53047aa8d3c..4e28e0c311c0 100644
@@ -1287,6 +1287,13 @@ 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,zynqmp-pl-mbox-2.1.yaml
+F:	drivers/mailbox/amd-pl-mailbox.c
+
 AMD PSTATE DRIVER
 M:	Huang Rui <[email protected]>
 M:	Mario Limonciello <[email protected]>
drivers/mailbox/Kconfig +10 -0
index ab869769e278..3c3f262c903c 100644
@@ -8,6 +8,16 @@ menuconfig MAILBOX
 
 if MAILBOX
 
+config AMD_PL_MAILBOX
+	tristate "AMD PL Mailbox soft IP controller"
+	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 +369 -0

369 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/6 remoteproc: amd_mbv_bram: Bound device name formatting

In reply to Ben Levinsky

rproc_mem_entry_init() interprets its name argument as a printf format string. Passing the device name directly allows percent conversions in a DT-derived platform device name to consume nonexistent variadic arguments.

Pass the device name through a constant format so it is always handled as data. Limit the formatted name to 31 characters to match the space available in rproc_mem_entry::name while leaving room for its terminating null byte.

Fixes f87b4998994e ("remoteproc: Add AMD MicroBlaze/V BRAM-based remote processor driver")
---
 drivers/remoteproc/amd_mbv_bram_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/amd_mbv_bram_rproc.c +1 -1
index e4a103cf8455..6cf33c7b7e64 100644
@@ -72,7 +72,7 @@ static int amd_bram_rproc_prepare(struct rproc *rproc)
 				   resource_size(&res), da,
 				   rproc_mem_entry_ioremap_wc,
 				   rproc_mem_entry_iounmap,
-				   dev_name(priv->dev));
+				   "%.31s", dev_name(priv->dev));
 	if (!mem)
 		return -ENOMEM;
 
Signature · 1 line
2.34.1
#27 lore raw

PATCH 6/6 remoteproc: amd_mbv_bram: Add RPMsg support

In reply to Ben Levinsky

Register named reserved-memory carveouts and expose the firmware resource table after it has been loaded into BRAM. This lets remoteproc create virtqueues backed by reserved shared DDR without deriving carveout roles from DT node names. Map the shared-memory carveouts with the common rproc_mem_entry_ioremap_wc() and rproc_mem_entry_iounmap() callbacks.

Use the mailbox framework to send virtqueue notification IDs. Defer received notifications to process context before dispatching them to the remoteproc virtqueues. Keep mailbox payload storage valid until transmit completion and order write-combined vring updates before each kick.

For designs where the mailbox and remote processor share a clock, request the mailbox channels only after enabling that clock, while the processor is still held in reset. Release the channels before disabling the clock during stop.

The mailboxes are optional. Without them the driver keeps supporting load, start, and stop only.

Select the mailbox framework, the AMD PL Mailbox controller and the virtio RPMsg bus, which the driver uses for notifications and RPMsg channels. Selecting MAILBOX while depending on GPIOLIB creates a Kconfig recursive dependency, because GPIOLIB is selected by drivers that are reachable from MAILBOX, so select GPIOLIB as well instead of depending on it. The driver always needs GPIO for the reset line. Depend on HAS_IOMEM, which the selected mailbox controller and the write-combined carveout mappings require.

Assisted-by LLM sparse
---
 drivers/remoteproc/Kconfig              |   6 +-
 drivers/remoteproc/amd_mbv_bram_rproc.c | 231 +++++++++++++++++++++++-
 2 files changed, 235 insertions(+), 2 deletions(-)
drivers/remoteproc/Kconfig +5 -1
index 5b56b2dcc725..9ebbbf76289f 100644
@@ -25,7 +25,11 @@ 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 OF && COMMON_CLK && HAS_IOMEM
+	select GPIOLIB
+	select MAILBOX
+	select AMD_PL_MAILBOX
+	select RPMSG_VIRTIO
 	help
 	  Say y or m here to support a MicroBlaze/V BRAM-based remote
 	  processor managed through the remoteproc framework.
drivers/remoteproc/amd_mbv_bram_rproc.c +230 -1

305 lines not on this page · raw message

Signature · 1 line
2.34.1
#16 lore raw

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

In reply to Ben Levinsky
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] io: endianness bug when reading/writing FIFO data with readl/writel - [High] mailbox: missed RX…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] io: endianness bug when reading/writing FIFO data with readl/writel
- [High] mailbox: missed RX interrupt edge transition when FIFO is completely full --

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

mailbox: Add AMD PL Mailbox soft IP controller

Adds a mailbox framework controller for the AMD programmable-logic Mailbox soft IP. The controller exposes separate transmit and receive FIFO channels, supporting interrupt-driven receive notifications and polling-based transmit completion.

Quoted 5 lines
drivers/mailbox/amd-pl-mailbox.c new file +0 -0
new file mode 100644
index 0000000000000..bd6595332f533

[ ... ]

Quoted 13 lines
drivers/mailbox/amd-pl-mailbox.c new file +13 -0
+static int amd_pl_mbox_send_data(struct mbox_chan *chan, void *data)
+{
+	struct amd_pl_mbox *mb = chan->con_priv;
+	struct zynqmp_ipi_message *msg = data;
+	size_t offset;
+
+	if (chan != &mb->chans[AMD_PL_MBOX_CHAN_TX])
+		return -EINVAL;
+
+	/* The TX FIFO is empty here, since TX completion waits for it. */
+	if (!msg || !msg->len || msg->len > mb->fifo_len * sizeof(u32))
+		return -EINVAL;
+

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

Quoted 10 lines
drivers/mailbox/amd-pl-mailbox.c new file +10 -0
+	for (offset = 0; offset < msg->len; offset += sizeof(u32)) {
+		size_t count = min(sizeof(u32), msg->len - offset);
+		u32 word = 0;
+
+		if (readl(mb->regs + AMD_PL_MBOX_STATUS) &
+		    AMD_PL_MBOX_STS_TX_FULL)
+			return -EBUSY;
+
+		memcpy(&word, &msg->data[offset], count);
+		writel(word, mb->regs + AMD_PL_MBOX_WRDATA);

[Severity: High]
Will this corrupt the byte order of the stream payload on big-endian architectures? writel performs implicit CPU-to-device byteswapping. For bulk FIFO stream data, should this use writesl to preserve the byte layout of the zynqmp_ipi_message stream when crossing endianness boundaries?

Quoted 4 lines
drivers/mailbox/amd-pl-mailbox.c new file +4 -0
+	}
+
+	return 0;
+}

[ ... ]

Quoted 7 lines
drivers/mailbox/amd-pl-mailbox.c new file +7 -0
+static void amd_pl_mbox_rx(struct amd_pl_mbox *mb)
+{
+	/* data[] follows a size_t in a kzalloc() buffer: u32 aligned. */
+	u32 *rx_words = (u32 *)mb->rx_msg->data;
+	u32 words;
+
+	/*

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

Quoted 10 lines
drivers/mailbox/amd-pl-mailbox.c new file +10 -0
+	 * The hardware reports neither the peer's message length nor the FIFO
+	 * occupancy. Read until the FIFO is empty, up to one FIFO depth, and
+	 * deliver the words as one message.
+	 */
+	for (words = 0; words < mb->fifo_len; words++) {
+		if (readl(mb->regs + AMD_PL_MBOX_STATUS) &
+		    AMD_PL_MBOX_STS_RX_EMPTY)
+			break;
+
+		rx_words[words] = readl(mb->regs + AMD_PL_MBOX_RDDATA);

[Severity: High]
Similarly, does using readl for stream data cause byte swapping issues on big-endian systems? Should this use readsl to read the FIFO without unwanted endianness conversion?

Quoted 14 lines
drivers/mailbox/amd-pl-mailbox.c new file +14 -0
+	}
+
+	if (words) {
+		mb->rx_msg->len = words * sizeof(u32);
+		mbox_chan_received_data(&mb->chans[AMD_PL_MBOX_CHAN_RX],
+					mb->rx_msg);
+	}
+}
+
+static void amd_pl_mbox_rx_rearm(struct amd_pl_mbox *mb)
+{
+	/*
+	 * The receive event latches only when the FIFO goes from empty to
+	 * nonempty. A word that arrived after the drain, but before the event

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

Quoted 10 lines
drivers/mailbox/amd-pl-mailbox.c new file +10 -0
+	 * was acknowledged, had its event cleared, and words left by the
+	 * bounded drain never raised one. Raise the threshold and lower it
+	 * again to latch a new event, so that the interrupt fires for them.
+	 * This cannot latch an event while the FIFO is full, which happens only
+	 * if the peer writes a full FIFO depth during one interrupt.
+	 */
+	if (!(readl(mb->regs + AMD_PL_MBOX_STATUS) &
+	      AMD_PL_MBOX_STS_RX_EMPTY)) {
+		writel(mb->fifo_len - 1, mb->regs + AMD_PL_MBOX_RECV_THRESHOLD);
+		writel(0, mb->regs + AMD_PL_MBOX_RECV_THRESHOLD);

[Severity: High]
Can this permanently lose the RX interrupt if the FIFO becomes completely full?

If the FIFO has exactly fifo_len words, both occupancy > fifo_len - 1 and occupancy > 0 evaluate to true. Without a false-to-true edge transition, the hardware might not latch the new event, leaving data stuck in the FIFO.

Quoted 2 lines
drivers/mailbox/amd-pl-mailbox.c new file +2 -0
+	}
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#4 lore raw

Re: [PATCH 2/6] remoteproc: amd_mbv_bram: Restore reset GPIO direction after PL reconfig

In reply to Ben Levinsky
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] remoteproc: amd_mbv_bram: returning error from stop() leaks resources during unbind --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] remoteproc: amd_mbv_bram: returning error from stop() leaks resources during unbind --

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

remoteproc: amd_mbv_bram: Restore reset GPIO direction after PL reconfig

Partial reconfiguration of the programmable logic restores the AXI GPIO that drives the soft-core reset to its hardware default direction, but gpiolib keeps its cached output direction. gpiod_set_value_cansleep() then only updates the data register, so the processor never sees a reset transition: remoteproc reports it as running while the newly loaded firmware never starts.

Quoted 4 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +0 -0
index 6cf33c7b7e641..da621f62f7df5 100644

[ ... ]

Quoted 11 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +2 -2
@@ -110,8 +127,8 @@ static int amd_bram_rproc_stop(struct rproc *rproc)
 	struct amd_bram_rproc *priv = rproc->priv;
 	int ret;
 
-	/* Assert reset before disabling the processor clock. */
-	ret = gpiod_set_value_cansleep(priv->reset, 1);
+	/* Restore the output direction after DFX and assert reset. */
+	ret = gpiod_direction_output(priv->reset, 1);
 	if (ret) {
 		dev_err(priv->dev, "failed to assert reset: %d\n", ret);
 		return ret;

drivers/remoteproc/amd_mbv_bram_rproc.c

Quoted 7 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +0 -0
 	}
 
 	/* Disable clock after asserting reset */
 	clk_disable_unprepare(priv->clk);
 
 	return 0;
 }

[Severity: High]
Does this error path bypass local clock teardown and cause the core remoteproc to abort its cleanup?

If gpiod_direction_output() fails in amd_bram_rproc_stop() during device unbind or module removal, it returns an error. This propagates to __rproc_shutdown():

drivers/remoteproc/remoteproc_core.c:__rproc_shutdown() {
	...
	ret = rproc_stop(rproc, crashed);
	if (ret) {
		atomic_inc(&rproc->power);
		goto out;
	}

	/* clean up all acquired resources */
	rproc_resource_cleanup(rproc);
	...
}

This causes __rproc_shutdown() to abort early and skip rproc_resource_cleanup().

Since rproc_del() proceeds unconditionally:

drivers/remoteproc/remoteproc_core.c:rproc_del() {
	...
	__rproc_shutdown(rproc, true);

	rproc_delete_debug_dir(rproc);
	...
}

the error from __rproc_shutdown() is ignored.

Can this result in the rproc object and driver memory being freed by devm while leaving the clock enabled, core remoteproc resources (carveouts, IOMMU mappings, trace files) leaked, and any local mailboxes/works uncancelled?

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

Re: [PATCH 6/6] remoteproc: amd_mbv_bram: Add RPMsg support

In reply to Ben Levinsky
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] remoteproc: UAF due to flawed rx_work teardown and early returns - [Medium] remoteproc: memory…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] remoteproc: UAF due to flawed rx_work teardown and early returns
- [Medium] remoteproc: memory leak of carveouts on prepare() failure
--

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

remoteproc: amd_mbv_bram: Add RPMsg support

This commit adds RPMsg support to the AMD MicroBlaze/V BRAM remoteproc driver. It registers named reserved-memory carveouts and maps them for virtqueues. It also introduces mailbox support to send and receive virtqueue notification IDs.

Quoted 4 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +0 -0
index da621f62f7df5..65d2c3946325e 100644

[ ... ]

Quoted 16 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +16 -0
+static int amd_bram_rproc_add_reserved_mem(struct rproc *rproc)
+{
+	struct amd_bram_rproc *priv = rproc->priv;
+	struct device_node *np = priv->dev->of_node;
+	struct rproc_mem_entry *mem;
+	int count;
+	int ret;
+	int i;
+
+	if (!of_property_present(np, "memory-region"))
+		return 0;
+
+	count = of_reserved_mem_region_count(np);
+	if (count < 0)
+		return count;
+

drivers/remoteproc/amd_mbv_bram_rproc.c line 212

Quoted 10 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +10 -0
+	for (i = 0; i < count; i++) {
+		struct resource res;
+		const char *name;
+
+		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);

[Severity: Medium]
In amd_bram_rproc_prepare(), resources are added to rproc->carveouts and rproc->dump_segments before returning a call to this function.

If an error occurs in this loop, the function returns the error early.

The remoteproc core's rproc_fw_boot() handles a failure from ops->prepare by explicitly bypassing the clean_up_resources label, which means rproc_resource_cleanup() is never called.

Does this permanently leak any rproc_mem_entry and rproc_dump_segment objects added before the failure occurs? Retrying the boot might also append duplicate entries to the lists. Shouldn't the driver clean up its own carveouts on error, or rely on rproc_resource_cleanup() before returning?

[ ... ]

Quoted 17 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +5 -1
@@ -80,7 +279,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);
 }
 
 static int amd_bram_rproc_start(struct rproc *rproc)
@@ -111,10 +310,17 @@ static int amd_bram_rproc_start(struct rproc *rproc)
 	/* Hold reset asserted long enough to provide a clean reset pulse. */
 	usleep_range(10, 20);
 
+	ret = amd_bram_rproc_request_mboxes(priv);
+	if (ret) {
+		clk_disable_unprepare(priv->clk);
+		return ret;

drivers/remoteproc/amd_mbv_bram_rproc.c static int amd_bram_rproc_start(struct rproc *rproc) · line 326

Quoted 10 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +3 -0
+	}
+
 	/* Deassert reset and let the processor run. */
 	ret = gpiod_direction_output(priv->reset, 0);
 	if (ret) {
 		dev_err(priv->dev, "failed to deassert reset: %d\n", ret);
+		amd_bram_rproc_free_mboxes(priv);
 		clk_disable_unprepare(priv->clk);
 		return ret;
 	}

[Severity: High]
If gpiod_direction_output() fails here, amd_bram_rproc_free_mboxes() is called but cancel_work_sync(&priv->rx_work) is missing.

Could any work scheduled by a mailbox interrupt between request and free remain queued? If it executes later, could it access the freed priv pointer and cause a use-after-free?

[ ... ]

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

Quoted 4 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +0 -0
@@ -133,6 +339,10 @@ static int amd_bram_rproc_stop(struct rproc *rproc)
 		dev_err(priv->dev, "failed to assert reset: %d\n", ret);
 		return ret;
 	}

[Severity: High]
If gpiod_direction_output() fails, this returns early without cancelling the workqueue or freeing the mailbox channels.

Since the core rproc_del() ignores the stop error and frees the rproc and priv structs, wouldn't this leave active mailboxes and workqueues pointing to freed memory?

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

Quoted 7 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +4 -0
+	cancel_work_sync(&priv->rx_work);
+	bitmap_zero(priv->pending_notify_ids,
+		    ARRAY_SIZE(priv->notify_msgs));
+	amd_bram_rproc_free_mboxes(priv);
 
 	/* Disable clock after asserting reset */
 	clk_disable_unprepare(priv->clk);

[Severity: High]
Since cancel_work_sync() is called before freeing the mailboxes, the mailbox interrupt is still active.

Could an incoming notification trigger amd_bram_rproc_rx_callback() and reschedule the work right after it was cancelled, leading to a use-after-free on driver unbind?

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

Re: [PATCH 1/6] remoteproc: amd_mbv_bram: Bound device name formatting

In reply to Ben Levinsky
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] remoteproc: carveout memory leak on rproc_parse_fw() failure --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] remoteproc: carveout memory leak on rproc_parse_fw() failure
--

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

remoteproc: amd_mbv_bram: Bound device name formatting

Pass the device name through a constant format string to prevent percent conversions in the device name from consuming nonexistent variadic arguments, and bound it to 31 characters.

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

Quoted 13 lines
drivers/remoteproc/amd_mbv_bram_rproc.c +1 -1
index e4a103cf84558..6cf33c7b7e641 100644
@@ -72,7 +72,7 @@ static int amd_bram_rproc_prepare(struct rproc *rproc)
 				   resource_size(&res), da,
 				   rproc_mem_entry_ioremap_wc,
 				   rproc_mem_entry_iounmap,
-				   dev_name(priv->dev));
+				   "%.31s", dev_name(priv->dev));
 	if (!mem)
 		return -ENOMEM;
 

[Severity: Medium]
Could this introduce a regression where the carveout memory leaks?

If rproc_parse_fw() fails during boot (for instance, due to a memory allocation failure in rproc_elf_load_rsc_table()), the error path in rproc_fw_boot() bypasses rproc_resource_cleanup():

drivers/remoteproc/remoteproc_core.c:rproc_fw_boot() {
    ...
	ret = rproc_parse_fw(rproc, fw);
	if (ret)
		goto unprepare_rproc;
    ...
clean_up_resources:
	rproc_resource_cleanup(rproc);
    ...
unprepare_rproc:
	rproc_unprepare_device(rproc);
    ...
}

Because the driver adds the carveout to rproc->carveouts shortly after this allocation:

	mem = rproc_mem_entry_init(...);
	if (!mem)
		return -ENOMEM;

	rproc_add_carveout(rproc, mem);

And relies on the core's rproc_resource_cleanup() for cleanup, the carveout would remain on the list if parsing fails.

Subsequent rproc_boot() attempts would then call prepare() again, potentially adding duplicate carveouts and causing unbounded list growth.

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

Re: [PATCH 3/6] dt-bindings: mailbox: Add AMD PL Mailbox IP

In reply to Ben Levinsky
Quoted 7 lines · Ben Levinsky

Document the AMD programmable-logic Mailbox IP used for bidirectional FIFO communication between two processor-facing interfaces.

The same IP is used on ZynqMP, Versal, Versal NET and Versal Gen 2. Name each SoC in its compatible, and use amd,zynqmp-pl-mbox-2.1 as the fallback that drivers match.

Quoted 6 lines

Define the transmit and receive channel indices together with the register aperture, interrupt, and interface clock. Describe the FIFO depth chosen when the IP is configured, so that the driver can size received messages to it.

Assisted-by LLM sparse

How sparse assists here? It's something new. Since when does it parse yaml code?

Quoted 25 lines
---
 .../mailbox/amd,zynqmp-pl-mbox-2.1.yaml       | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +13 -0
new file mode 100644
index 000000000000..2cc0d106b888
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/amd,zynqmp-pl-mbox-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 provides bidirectional message passing

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml line 23

Quoted 10 lines
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +10 -0
+  between two processor-facing interfaces. Each interface writes messages to
+  a send FIFO and reads messages from a receive FIFO. The register aperture,
+  interrupt, and clock described by a node belong to one processor-facing
+  interface. Channel 0 represents transmit and channel 1 represents receive
+  for that interface.
+
+properties:
+  compatible:
+    oneOf:
+      - const: amd,zynqmp-pl-mbox-2.1

What is 2.1? Your SoC has different versions?

Quoted 15 lines
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +15 -0
+      - items:
+          - enum:
+              - amd,versal-pl-mbox-2.1
+              - amd,versal-net-pl-mbox-2.1
+              - amd,versal2-pl-mbox-2.1
+          - const: amd,zynqmp-pl-mbox-2.1
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml line 48

Quoted 10 lines
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +10 -0
+
+  amd,mbox-pl-fifo-len:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 16
+    maximum: 8192
+    default: 16
+    description:
+      Depth of the send and receive FIFOs in 32-bit words, as configured by
+      the C_MAILBOX_DEPTH parameter of the IP. Must match the configured
+      depth.

So you have multiple mailboxes per one soc different in this?

Best regards,
Krzysztof

#17 lore raw

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

In reply to Ben Levinsky
Quoted 57 lines · Ben Levinsky

Add a mailbox-framework controller for the AMD programmable-logic Mailbox soft IP. Expose separate transmit and receive FIFO channels.

Enable the interface clock only while a channel is started, before any register access, and disable it last when the channel shuts down. Keep provider probe free of register accesses and leave the IRQ disabled until a client starts the receive channel. Initialize each FIFO when its channel starts, use receive-threshold interrupts for incoming words, and poll the send-threshold status for transmit completion. Stop that polling from accessing registers once the transmit channel begins to shut down.

Carry mailbox payloads in struct zynqmp_ipi_message, limited to the FIFO depth given by the device tree. The FIFO transfers 32-bit words and the hardware conveys neither a byte count nor the FIFO occupancy, so a transmit length that is not a multiple of four is zero-padded to a whole word.

On a receive-threshold interrupt, read up to one FIFO depth of words and deliver them as one message, then acknowledge the interrupt. The event latches only when the FIFO goes from empty to nonempty, so a word that arrives between the drain and the acknowledge, or words left by the bounded drain, raise no new event. If the FIFO is nonempty after the acknowledge, toggle the threshold to latch a new event for them.

Assisted-by LLM sparse
---
 MAINTAINERS                      |   7 +
 drivers/mailbox/Kconfig          |  10 +
 drivers/mailbox/Makefile         |   1 +
 drivers/mailbox/amd-pl-mailbox.c | 369 +++++++++++++++++++++++++++++++
 4 files changed, 387 insertions(+)
 create mode 100644 drivers/mailbox/amd-pl-mailbox.c
MAINTAINERS +7 -0
index f53047aa8d3c..4e28e0c311c0 100644
@@ -1287,6 +1287,13 @@ 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,zynqmp-pl-mbox-2.1.yaml
+F:	drivers/mailbox/amd-pl-mailbox.c
+
 AMD PSTATE DRIVER
 M:	Huang Rui <[email protected]>
 M:	Mario Limonciello <[email protected]>
drivers/mailbox/Kconfig +0 -0
index ab869769e278..3c3f262c903c 100644

drivers/mailbox/Kconfig menuconfig MAILBOX · line 12

Quoted 5 lines
drivers/mailbox/Kconfig +2 -0
@@ -8,6 +8,16 @@ menuconfig MAILBOX
 
 if MAILBOX
 
+config AMD_PL_MAILBOX
+	tristate "AMD PL Mailbox soft IP controller"

Missing depends on Zynq/Xilinx.

Quoted 7 lines
drivers/mailbox/Kconfig +7 -0
+	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.

...

Quoted 12 lines
drivers/mailbox/Kconfig +12 -0
+	mb->controller.dev = dev;
+	mb->controller.ops = &amd_pl_mbox_ops;
+	mb->controller.chans = mb->chans;
+	mb->controller.num_chans = AMD_PL_MBOX_NUM_CHANS;
+	mb->controller.txdone_poll = true;
+	mb->controller.txpoll_period = 1;
+	mb->controller.of_xlate = amd_pl_mbox_xlate;
+
+	ret = devm_request_irq(dev, mb->irq, amd_pl_mbox_irq,
+			       IRQF_NO_AUTOEN,
+			       dev_name(dev), mb);
+	if (ret)

drivers/mailbox/Kconfig

Quoted 10 lines
drivers/mailbox/Kconfig +10 -0
+		return ret;
+
+	return devm_mbox_controller_register(dev, &mb->controller);
+}
+
+static const struct of_device_id amd_pl_mbox_of_match[] = {
+	{ .compatible = "amd,zynqmp-pl-mbox-2.1" },
+	{ .compatible = "amd,versal-pl-mbox-2.1" },
+	{ .compatible = "amd,versal-net-pl-mbox-2.1" },
+	{ .compatible = "amd,versal2-pl-mbox-2.1" },

So all of them are compatible? Then why do you need all this?

Best regards,
Krzysztof

#24 lore raw

Re: [PATCH 5/6] dt-bindings: remoteproc: Add RPMsg resources to AMD BRAM rproc

In reply to Ben Levinsky
Quoted 9 lines · Ben Levinsky

Describe the optional mailbox channels and named reserved-memory regions used for RPMsg communication with a BRAM-based MicroBlaze remote processor.

The three named memory regions provide the two virtio vrings and the shared RPMsg buffer pool. Firmware and its loaded resource table remain in the executable BRAM described by reg.

Assisted-by LLM sparse

How sparse can assist here?

Quoted 25 lines
---
 .../bindings/remoteproc/amd,bram-rproc.yaml   | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
Documentation/devicetree/bindings/remoteproc/amd,bram-rproc.yaml +12 -0
index c0359f447ea8..daff8e615ab6 100644
@@ -84,6 +84,33 @@ 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:

Documentation/devicetree/bindings/remoteproc/amd,bram-rproc.yaml properties: · line 108

Quoted 10 lines
Documentation/devicetree/bindings/remoteproc/amd,bram-rproc.yaml +10 -0
+    items:
+      - const: vdev0vring0
+      - const: vdev0vring1
+      - const: vdev0buffer
+
+dependentRequired:
+  mboxes:
+    - mbox-names
+  mbox-names:
+    - mboxes

Why do you add this? Please instruct your LLM to actually understand and learn dtschema.

Best regards,
Krzysztof

#29 lore raw

Re: [PATCH 6/6] remoteproc: amd_mbv_bram: Add RPMsg support

In reply to Ben Levinsky
Quoted 42 lines · Ben Levinsky

Register named reserved-memory carveouts and expose the firmware resource table after it has been loaded into BRAM. This lets remoteproc create virtqueues backed by reserved shared DDR without deriving carveout roles from DT node names. Map the shared-memory carveouts with the common rproc_mem_entry_ioremap_wc() and rproc_mem_entry_iounmap() callbacks.

Use the mailbox framework to send virtqueue notification IDs. Defer received notifications to process context before dispatching them to the remoteproc virtqueues. Keep mailbox payload storage valid until transmit completion and order write-combined vring updates before each kick.

For designs where the mailbox and remote processor share a clock, request the mailbox channels only after enabling that clock, while the processor is still held in reset. Release the channels before disabling the clock during stop.

The mailboxes are optional. Without them the driver keeps supporting load, start, and stop only.

Select the mailbox framework, the AMD PL Mailbox controller and the virtio RPMsg bus, which the driver uses for notifications and RPMsg channels. Selecting MAILBOX while depending on GPIOLIB creates a Kconfig recursive dependency, because GPIOLIB is selected by drivers that are reachable from MAILBOX, so select GPIOLIB as well instead of depending on it. The driver always needs GPIO for the reset line. Depend on HAS_IOMEM, which the selected mailbox controller and the write-combined carveout mappings require.

Assisted-by LLM sparse
---
 drivers/remoteproc/Kconfig              |   6 +-
 drivers/remoteproc/amd_mbv_bram_rproc.c | 231 +++++++++++++++++++++++-
 2 files changed, 235 insertions(+), 2 deletions(-)
drivers/remoteproc/Kconfig +0 -0
index 5b56b2dcc725..9ebbbf76289f 100644

drivers/remoteproc/Kconfig config REMOTEPROC_CDEV · line 31

Quoted 8 lines
drivers/remoteproc/Kconfig +4 -1
@@ -25,7 +25,11 @@ 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 OF && COMMON_CLK && HAS_IOMEM
+	select GPIOLIB
+	select MAILBOX
+	select AMD_PL_MAILBOX

You should not select user-visible symbols.

Best regards,
Krzysztof

#8 lore raw

Re: [PATCH 3/6] dt-bindings: mailbox: Add AMD PL Mailbox IP

In reply to a message not in the archive
Quoted 30 lines

*From: *Krzysztof Kozlowski <[email protected]>
*Date: *Thursday, October 15, 2026 at 2:46 AM
*To: *Levinsky, Ben <[email protected]>
*Cc: *[email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Simek, Michal <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; linux-arm- [email protected] <[email protected]>; linux- [email protected] <[email protected]>; Shah, Tanmay <[email protected]>
*Subject: *Re: [PATCH 3/6] dt-bindings: mailbox: Add AMD PL Mailbox IP

Quoted 12 lines · Ben Levinsky

Document the AMD programmable-logic Mailbox IP used for bidirectional FIFO communication between two processor-facing interfaces.

The same IP is used on ZynqMP, Versal, Versal NET and Versal Gen 2. Name each SoC in its compatible, and use amd,zynqmp-pl-mbox-2.1 as the fallback that drivers match.

Define the transmit and receive channel indices together with the register aperture, interrupt, and interface clock. Describe the FIFO depth chosen when the IP is configured, so that the driver can size received messages to it.

Quoted 4 lines
Quoted 1 line
Assisted-by LLM sparse

How sparse assists here? It's something new. Since when does it parse yaml code?

Hi Krzysztof,

Thank you for the review.

You are right, sparse was not used for this patch. It was only run on the C patches of the series, and I applied the same trailer to the whole series by mistake. In v2 the binding patches will name only the model, and the tool list will match what was actually used on each patch.

Quoted 35 lines
Quoted 6 lines
---
 .../mailbox/amd,zynqmp-pl-mbox-2.1.yaml       | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl- 

mbox-2.1.yaml

Review

Quoted 2 lines
(quoted diff) +0 -0

mbox-2.1.yaml b/Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl- mbox-2.1.yaml

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml line 4

Quoted 9 lines

new file mode 100644
index 000000000000..2cc0d106b888

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +4 -0
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/amd,zynqmp-pl-mbox-2.1.yaml# 

<http://devicetree.org/schemas/mailbox/amd,zynqmp-pl-mbox-2.1.yaml#>

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml line 5

Quoted 1 line
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +1 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml# <http:// 

devicetree.org/meta-schemas/core.yaml#>

Quoted 12 lines
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +12 -0
+
+title: AMD Programmable Logic Mailbox IP
+
+maintainers:
+  - Ben Levinsky <[email protected]>
+
+description: |
+  The AMD Programmable Logic Mailbox IP provides bidirectional message passing
+  between two processor-facing interfaces. Each interface writes messages to
+  a send FIFO and reads messages from a receive FIFO. The register aperture,
+  interrupt, and clock described by a node belong to one processor-facing
+  interface. Channel 0 represents transmit and channel 1 represents receive
Quoted 8 lines

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml line 23

Quoted 6 lines
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +6 -0
+  for that interface.
+
+properties:
+  compatible:
+    oneOf:
+      - const: amd,zynqmp-pl-mbox-2.1

What is 2.1? Your SoC has different versions?

2.1 is the version of the Mailbox IP core in the Xilinx IP catalog (Mailbox v2.1). It is not a SoC version. The IP is synthesized into the programmable logic, so the same core is used on every SoC, and the SoC names in the compatibles do not add information.

In v2 I will use a single IP-versioned compatible, "xlnx,mailbox-2.1", and drop the SoC-specific ones. This is also the compatible the Xilinx device tree generator already emits for this IP.

Quoted 20 lines
Quoted 20 lines
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +19 -0
+      - items:
+          - enum:
+              - amd,versal-pl-mbox-2.1
+              - amd,versal-net-pl-mbox-2.1
+              - amd,versal2-pl-mbox-2.1
+          - const: amd,zynqmp-pl-mbox-2.1
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  amd,mbox-pl-fifo-len:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 16
Quoted 8 lines

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml line 48

Quoted 6 lines
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +6 -0
+    maximum: 8192
+    default: 16
+    description:
+      Depth of the send and receive FIFOs in 32-bit words, as configured by
+      the C_MAILBOX_DEPTH parameter of the IP. Must match the configured
+      depth.

So you have multiple mailboxes per one soc different in this?

Yes. The FIFO depth is chosen per IP instance when the design is synthesized, so one design can contain several mailboxes with different depths. The depth cannot be read from the registers, so the driver needs it from the device tree to size its receive buffer and to limit transmit messages. In v2 I will rename the property to "xlnx,mailbox-depth", after the IP parameter, and state this in its description.

Thanks,
Ben

Quoted 4 lines

Best regards,
Krzysztof

#19 lore raw

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

In reply to a message not in the archive
Quoted 77 lines

*From: *Krzysztof Kozlowski <[email protected]>
*Date: *Thursday, October 15, 2026 at 2:48 AM
*To: *Levinsky, Ben <[email protected]>
*Cc: *[email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Simek, Michal <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; linux-arm- [email protected] <[email protected]>; linux- [email protected] <[email protected]>; Shah, Tanmay <[email protected]>
*Subject: *Re: [PATCH 4/6] mailbox: Add AMD PL Mailbox soft IP controller

Quoted 39 lines · Ben Levinsky

Add a mailbox-framework controller for the AMD programmable-logic Mailbox soft IP. Expose separate transmit and receive FIFO channels.

Enable the interface clock only while a channel is started, before any register access, and disable it last when the channel shuts down. Keep provider probe free of register accesses and leave the IRQ disabled until a client starts the receive channel. Initialize each FIFO when its channel starts, use receive-threshold interrupts for incoming words, and poll the send-threshold status for transmit completion. Stop that polling from accessing registers once the transmit channel begins to shut down.

Carry mailbox payloads in struct zynqmp_ipi_message, limited to the FIFO depth given by the device tree. The FIFO transfers 32-bit words and the hardware conveys neither a byte count nor the FIFO occupancy, so a transmit length that is not a multiple of four is zero-padded to a whole word.

On a receive-threshold interrupt, read up to one FIFO depth of words and deliver them as one message, then acknowledge the interrupt. The event latches only when the FIFO goes from empty to nonempty, so a word that arrives between the drain and the acknowledge, or words left by the bounded drain, raise no new event. If the FIFO is nonempty after the acknowledge, toggle the threshold to latch a new event for them.

Assisted-by LLM sparse
---
 MAINTAINERS                      |   7 +
 drivers/mailbox/Kconfig          |  10 +
 drivers/mailbox/Makefile         |   1 +
 drivers/mailbox/amd-pl-mailbox.c | 369 +++++++++++++++++++++++++++++++
 4 files changed, 387 insertions(+)
 create mode 100644 drivers/mailbox/amd-pl-mailbox.c
MAINTAINERS +0 -0
index f53047aa8d3c..4e28e0c311c0 100644

MAINTAINERS S: Supported · line 1287

Quoted 1 line
MAINTAINERS +0 -0
@@ -1287,6 +1287,13 @@ S:     Supported
 T:   git https://gitlab.freedesktop.org/agd5f/linux.git <https:// 

gitlab.freedesktop.org/agd5f/linux.git>

Quoted 18 lines
MAINTAINERS +7 -0
 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,zynqmp-pl-mbox-2.1.yaml
+F:   drivers/mailbox/amd-pl-mailbox.c
+
 AMD PSTATE DRIVER
 M:   Huang Rui <[email protected]>
 M:   Mario Limonciello <[email protected]>
drivers/mailbox/Kconfig +0 -0
index ab869769e278..3c3f262c903c 100644
@@ -8,6 +8,16 @@ menuconfig MAILBOX
 
Quoted 6 lines

drivers/mailbox/Kconfig menuconfig MAILBOX · line 12

Quoted 4 lines
drivers/mailbox/Kconfig +2 -0
 if MAILBOX
 
+config AMD_PL_MAILBOX
+     tristate "AMD PL Mailbox soft IP controller"

Missing depends on Zynq/Xilinx.

Hi Krzysztof,

Thanks, I will add "depends on ARCH_ZYNQMP || COMPILE_TEST" in v2. ARCH_ZYNQMP covers the ZynqMP, Versal, Versal NET and Versal Gen 2 families, which are the platforms this has been used and tested on.

Quoted 27 lines
Quoted 8 lines
drivers/mailbox/Kconfig +7 -0
+     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.

...

Quoted 16 lines
drivers/mailbox/Kconfig +16 -0
+     mb->controller.dev = dev;
+     mb->controller.ops = &amd_pl_mbox_ops;
+     mb->controller.chans = mb->chans;
+     mb->controller.num_chans = AMD_PL_MBOX_NUM_CHANS;
+     mb->controller.txdone_poll = true;
+     mb->controller.txpoll_period = 1;
+     mb->controller.of_xlate = amd_pl_mbox_xlate;
+
+     ret = devm_request_irq(dev, mb->irq, amd_pl_mbox_irq,
+                            IRQF_NO_AUTOEN,
+                            dev_name(dev), mb);
+     if (ret)
+             return ret;
+
+     return devm_mbox_controller_register(dev, &mb->controller);
+}
Quoted 8 lines

drivers/mailbox/Kconfig

Quoted 6 lines
drivers/mailbox/Kconfig +6 -0
+
+static const struct of_device_id amd_pl_mbox_of_match[] = {
+     { .compatible = "amd,zynqmp-pl-mbox-2.1" },
+     { .compatible = "amd,versal-pl-mbox-2.1" },
+     { .compatible = "amd,versal-net-pl-mbox-2.1" },
+     { .compatible = "amd,versal2-pl-mbox-2.1" },

So all of them are compatible? Then why do you need all this?

Yes, they are the same IP on every SoC, so there is no reason to list them separately. As described in my reply to patch 3, v2 uses the single compatible "xlnx,mailbox-2.1", and the match table will have just that one entry.

Thanks,
Ben

Quoted 4 lines

Best regards,
Krzysztof

#26 lore raw

Re: [PATCH 5/6] dt-bindings: remoteproc: Add RPMsg resources to AMD BRAM rproc

In reply to a message not in the archive
Quoted 23 lines

*From: *Krzysztof Kozlowski <[email protected]>
*Date: *Thursday, October 15, 2026 at 2:50 AM
*To: *Levinsky, Ben <[email protected]>
*Cc: *[email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Simek, Michal <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; linux-arm- [email protected] <[email protected]>; linux- [email protected] <[email protected]>; Shah, Tanmay <[email protected]>
*Subject: *Re: [PATCH 5/6] dt-bindings: remoteproc: Add RPMsg resources to AMD BRAM rproc

Quoted 4 lines · Ben Levinsky

Describe the optional mailbox channels and named reserved-memory regions used for RPMsg communication with a BRAM-based MicroBlaze remote processor.

Quoted 7 lines
Quoted 5 lines

The three named memory regions provide the two virtio vrings and the shared RPMsg buffer pool. Firmware and its loaded resource table remain in the executable BRAM described by reg.

Assisted-by LLM sparse

How sparse can assist here?

Hi Krzysztof,

It did not. As in patch 3, the trailer was applied to the whole series by mistake. I will correct it in v2.

Quoted 41 lines

Review

Quoted 7 lines
---
 .../bindings/remoteproc/amd,bram-rproc.yaml   | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/remoteproc/amd,bram-rproc.yaml

Quoted 19 lines

index c0359f447ea8..daff8e615ab6 100644

Documentation/devicetree/bindings/remoteproc/amd,bram-rproc.yaml +12 -0
@@ -84,6 +84,33 @@ 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:

Documentation/devicetree/bindings/remoteproc/amd,bram-rproc.yaml properties: · line 108

Quoted 10 lines
Documentation/devicetree/bindings/remoteproc/amd,bram-rproc.yaml +10 -0
+    items:
+      - const: vdev0vring0
+      - const: vdev0vring1
+      - const: vdev0buffer
+
+dependentRequired:
+  mboxes:
+    - mbox-names
+  mbox-names:
+    - mboxes

Why do you add this? Please instruct your LLM to actually understand and learn dtschema.

Quoted 3 lines

Best regards,
Krzysztof

You are right. The core mailbox consumer schema already requires mboxes when mbox-names is present, and this block is not something bindings normally add. I will remove the whole dependentRequired block in v2. Thank you for pointing it out.

Thanks,
Ben

#31 lore raw

Re: [PATCH 6/6] remoteproc: amd_mbv_bram: Add RPMsg support

In reply to a message not in the archive
Quoted 71 lines

*From: *Krzysztof Kozlowski <[email protected]>
*Date: *Thursday, October 15, 2026 at 2:51 AM
*To: *Levinsky, Ben <[email protected]>
*Cc: *[email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Simek, Michal <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; linux-arm- [email protected] <[email protected]>; linux- [email protected] <[email protected]>; Shah, Tanmay <[email protected]>
*Subject: *Re: [PATCH 6/6] remoteproc: amd_mbv_bram: Add RPMsg support

Quoted 42 lines · Ben Levinsky

Register named reserved-memory carveouts and expose the firmware resource table after it has been loaded into BRAM. This lets remoteproc create virtqueues backed by reserved shared DDR without deriving carveout roles from DT node names. Map the shared-memory carveouts with the common rproc_mem_entry_ioremap_wc() and rproc_mem_entry_iounmap() callbacks.

Use the mailbox framework to send virtqueue notification IDs. Defer received notifications to process context before dispatching them to the remoteproc virtqueues. Keep mailbox payload storage valid until transmit completion and order write-combined vring updates before each kick.

For designs where the mailbox and remote processor share a clock, request the mailbox channels only after enabling that clock, while the processor is still held in reset. Release the channels before disabling the clock during stop.

The mailboxes are optional. Without them the driver keeps supporting load, start, and stop only.

Select the mailbox framework, the AMD PL Mailbox controller and the virtio RPMsg bus, which the driver uses for notifications and RPMsg channels. Selecting MAILBOX while depending on GPIOLIB creates a Kconfig recursive dependency, because GPIOLIB is selected by drivers that are reachable from MAILBOX, so select GPIOLIB as well instead of depending on it. The driver always needs GPIO for the reset line. Depend on HAS_IOMEM, which the selected mailbox controller and the write-combined carveout mappings require.

Assisted-by LLM sparse
---
 drivers/remoteproc/Kconfig              |   6 +-
 drivers/remoteproc/amd_mbv_bram_rproc.c | 231 +++++++++++++++++++++++-
 2 files changed, 235 insertions(+), 2 deletions(-)
drivers/remoteproc/Kconfig +0 -0
index 5b56b2dcc725..9ebbbf76289f 100644

drivers/remoteproc/Kconfig config REMOTEPROC_CDEV · line 31

Quoted 8 lines
drivers/remoteproc/Kconfig +4 -1
@@ -25,7 +25,11 @@ 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 OF && COMMON_CLK && HAS_IOMEM
+     select GPIOLIB
+     select MAILBOX
+     select AMD_PL_MAILBOX

You should not select user-visible symbols.

Quoted 3 lines

Best regards,
Krzysztof

Hi Krzysztof,

Understood, thank you. In v2 I will keep the driver's existing dependencies and add "depends on MAILBOX", since the driver calls the mailbox client API, and drop all the selects. The PL mailbox controller and the virtio RPMsg bus are only needed at run time; I will mention them in the Kconfig help text rather than selecting them.

Thanks,
Ben

#9 lore raw

Re: [PATCH 3/6] dt-bindings: mailbox: Add AMD PL Mailbox IP

In reply to Ben Levinsky
Quoted 89 lines · Ben Levinsky
Quoted 30 lines

*From: *Krzysztof Kozlowski <[email protected]>
*Date: *Thursday, October 15, 2026 at 2:46 AM
*To: *Levinsky, Ben <[email protected]>
*Cc: *[email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Simek, Michal <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; linux-arm- [email protected] <[email protected]>; linux- [email protected] <[email protected]>; Shah, Tanmay <[email protected]>
*Subject: *Re: [PATCH 3/6] dt-bindings: mailbox: Add AMD PL Mailbox IP

Quoted 12 lines · Ben Levinsky

Document the AMD programmable-logic Mailbox IP used for bidirectional FIFO communication between two processor-facing interfaces.

The same IP is used on ZynqMP, Versal, Versal NET and Versal Gen 2. Name each SoC in its compatible, and use amd,zynqmp-pl-mbox-2.1 as the fallback that drivers match.

Define the transmit and receive channel indices together with the register aperture, interrupt, and interface clock. Describe the FIFO depth chosen when the IP is configured, so that the driver can size received messages to it.

Quoted 4 lines
Quoted 1 line
Assisted-by LLM sparse

How sparse assists here? It's something new. Since when does it parse yaml code?

Hi Krzysztof,

Thank you for the review.

You are right, sparse was not used for this patch. It was only run on the C patches of the series, and I applied the same trailer to the whole series by mistake. In v2 the binding patches will name only the model, and the tool list will match what was actually used on each patch.

Quoted 35 lines
Quoted 6 lines
---
 .../mailbox/amd,zynqmp-pl-mbox-2.1.yaml       | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl- 

mbox-2.1.yaml

Review

Quoted 2 lines
(quoted diff) +0 -0

mbox-2.1.yaml b/Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl- mbox-2.1.yaml

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml line 4

Quoted 9 lines

new file mode 100644
index 000000000000..2cc0d106b888

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +4 -0
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/amd,zynqmp-pl-mbox-2.1.yaml# 

<http://devicetree.org/schemas/mailbox/amd,zynqmp-pl-mbox-2.1.yaml#>

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml line 5

Quoted 1 line
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +1 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml# <http:// 

devicetree.org/meta-schemas/core.yaml#>

Quoted 12 lines
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +12 -0
+
+title: AMD Programmable Logic Mailbox IP
+
+maintainers:
+  - Ben Levinsky <[email protected]>
+
+description: |
+  The AMD Programmable Logic Mailbox IP provides bidirectional message passing
+  between two processor-facing interfaces. Each interface writes messages to
+  a send FIFO and reads messages from a receive FIFO. The register aperture,
+  interrupt, and clock described by a node belong to one processor-facing
+  interface. Channel 0 represents transmit and channel 1 represents receive
Quoted 8 lines

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml line 23

Quoted 6 lines
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +6 -0
+  for that interface.
+
+properties:
+  compatible:
+    oneOf:
+      - const: amd,zynqmp-pl-mbox-2.1

What is 2.1? Your SoC has different versions?

Quoted 9 lines

2.1 is the version of the Mailbox IP core in the Xilinx IP catalog (Mailbox v2.1). It is not a SoC version. The IP is synthesized into the programmable logic, so the same core is used on every SoC, and the SoC names in the compatibles do not add information.

In v2 I will use a single IP-versioned compatible, "xlnx,mailbox-2.1", and drop the SoC-specific ones. This is also the compatible the Xilinx device tree generator already emits for this IP.

Hi here is the reasoning behind the name:

We use 'amd' vendor prefix for all new drivers & bindings. Also, there is dedicated IPI hardware which can be used as mailbox too, and we should distinguish it with this PL mailbox. So I that is included in the compatible string. (pl-mbox).

If we are also to include SOC name as well (per compatible property guideline), then we should include one of the SOC name as well:

So, I think 'amd,zynqmp-pl-mbox-2.1' is good.

Krzysztof, are you okay with above name? The 2.1 is FPGA IP design version number and not the SOC version number. So in future let's say that FPGA IP design is improved then the name (pl-mbox) will remain same, but only version number will be updated i.e. (from 2.1 to 3.0). Is it okay if we explicitly mention this in the binding description?

Thank You.

Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +25 -0
+      - items:
+          - enum:
+              - amd,versal-pl-mbox-2.1
+              - amd,versal-net-pl-mbox-2.1
+              - amd,versal2-pl-mbox-2.1
+          - const: amd,zynqmp-pl-mbox-2.1
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  amd,mbox-pl-fifo-len:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 16
+    maximum: 8192
+    default: 16
+    description:
+      Depth of the send and receive FIFOs in 32-bit words, as configured by
+      the C_MAILBOX_DEPTH parameter of the IP. Must match the configured
+      depth.
Quoted 8 lines
Quoted 1 line

So you have multiple mailboxes per one soc different in this?

Yes. The FIFO depth is chosen per IP instance when the design is synthesized, so one design can contain several mailboxes with different depths. The depth cannot be read from the registers, so the driver needs it from the device tree to size its receive buffer and to limit transmit messages. In v2 I will rename the property to "xlnx,mailbox-depth", after the IP parameter, and state this in its

Please use 'amd' as vendor prefix, also keep pl in the property name:
i.e. 'amd,pl-mailbox-depth'.

Quoted 10 lines

description.

Thanks,
Ben

Quoted 4 lines

Best regards,
Krzysztof

#14 lore raw

Re: [PATCH 3/6] dt-bindings: mailbox: Add AMD PL Mailbox IP

In reply to Ben Levinsky
Quoted 87 lines · Ben Levinsky
Quoted 30 lines

*From: *Krzysztof Kozlowski <[email protected]>
*Date: *Thursday, October 15, 2026 at 2:46 AM
*To: *Levinsky, Ben <[email protected]>
*Cc: *[email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Simek, Michal <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; linux-arm- [email protected] <[email protected]>; linux- [email protected] <[email protected]>; Shah, Tanmay <[email protected]>
*Subject: *Re: [PATCH 3/6] dt-bindings: mailbox: Add AMD PL Mailbox IP

Quoted 12 lines · Ben Levinsky

Document the AMD programmable-logic Mailbox IP used for bidirectional FIFO communication between two processor-facing interfaces.

The same IP is used on ZynqMP, Versal, Versal NET and Versal Gen 2. Name each SoC in its compatible, and use amd,zynqmp-pl-mbox-2.1 as the fallback that drivers match.

Define the transmit and receive channel indices together with the register aperture, interrupt, and interface clock. Describe the FIFO depth chosen when the IP is configured, so that the driver can size received messages to it.

Quoted 4 lines
Quoted 1 line
Assisted-by LLM sparse

How sparse assists here? It's something new. Since when does it parse yaml code?

Hi Krzysztof,

Thank you for the review.

You are right, sparse was not used for this patch. It was only run on the C patches of the series, and I applied the same trailer to the whole series by mistake. In v2 the binding patches will name only the model, and the tool list will match what was actually used on each patch.

Quoted 42 lines
Quoted 6 lines
---
 .../mailbox/amd,zynqmp-pl-mbox-2.1.yaml       | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl- 

mbox-2.1.yaml

Review

Quoted 2 lines
(quoted diff) +0 -0

mbox-2.1.yaml b/Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl- mbox-2.1.yaml

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml line 4

Quoted 9 lines

new file mode 100644
index 000000000000..2cc0d106b888

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +4 -0
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/amd,zynqmp-pl-mbox-2.1.yaml# 

<http://devicetree.org/schemas/mailbox/amd,zynqmp-pl-mbox-2.1.yaml#>

Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml line 5

Quoted 1 line
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +1 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml# <http:// 

devicetree.org/meta-schemas/core.yaml#>

Quoted 18 lines
Documentation/devicetree/bindings/mailbox/amd,zynqmp-pl-mbox-2.1.yaml new file +18 -0
+
+title: AMD Programmable Logic Mailbox IP
+
+maintainers:
+  - Ben Levinsky <[email protected]>
+
+description: |
+  The AMD Programmable Logic Mailbox IP provides bidirectional message passing
+  between two processor-facing interfaces. Each interface writes messages to
+  a send FIFO and reads messages from a receive FIFO. The register aperture,
+  interrupt, and clock described by a node belong to one processor-facing
+  interface. Channel 0 represents transmit and channel 1 represents receive
+  for that interface.
+
+properties:
+  compatible:
+    oneOf:
+      - const: amd,zynqmp-pl-mbox-2.1
Quoted 6 lines
Quoted 1 line

What is 2.1? Your SoC has different versions?

2.1 is the version of the Mailbox IP core in the Xilinx IP catalog (Mailbox v2.1). It is not a SoC version. The IP is synthesized into the programmable logic, so the same core is used on every SoC, and the SoC names in the compatibles do not add information.

Heh? This is in contrast to writing bindings.

Quoted 4 lines

In v2 I will use a single IP-versioned compatible, "xlnx,mailbox-2.1", and drop the SoC-specific ones. This is also the compatible the Xilinx device tree generator already emits for this IP.

No, use SoC naming. Just like every other vendor. Remember: before doing something completely different, first find arguments why your vendor/patchset should be special.

Best regards,
Krzysztof

#10 lore raw

Re: [PATCH 3/6] dt-bindings: mailbox: Add AMD PL Mailbox IP

In reply to Shah, Tanmay
Quoted 8 lines · Tanmay

We use 'amd' vendor prefix for all new drivers & bindings. Also, there is dedicated IPI hardware which can be used as mailbox too, and we should distinguish it with this PL mailbox. So I that is included in the compatible string. (pl-mbox).

If we are also to include SOC name as well (per compatible property guideline), then we should include one of the SOC name as well:

Quoted 7 lines

So, I think 'amd,zynqmp-pl-mbox-2.1' is good.

Krzysztof, are you okay with above name? The 2.1 is FPGA IP design version number and not the SOC version number. So in future let's say that FPGA IP design is improved then the name (pl-mbox) will remain same, but only version number will be updated i.e. (from 2.1 to 3.0). Is it okay if we explicitly mention this in the binding description?

So you will release the same SoC with different versions of the block?

Best regards,
Krzysztof

#11 lore raw

Re: [PATCH 3/6] dt-bindings: mailbox: Add AMD PL Mailbox IP

Quoted 11 lines · Krzysztof Kozlowski
Quoted 10 lines · Tanmay

We use 'amd' vendor prefix for all new drivers & bindings. Also, there is dedicated IPI hardware which can be used as mailbox too, and we should distinguish it with this PL mailbox. So I that is included in the compatible string. (pl-mbox).

If we are also to include SOC name as well (per compatible property guideline), then we should include one of the SOC name as well:

So, I think 'amd,zynqmp-pl-mbox-2.1' is good.

Quoted 8 lines
Quoted 5 lines

Krzysztof, are you okay with above name? The 2.1 is FPGA IP design version number and not the SOC version number. So in future let's say that FPGA IP design is improved then the name (pl-mbox) will remain same, but only version number will be updated i.e. (from 2.1 to 3.0). Is it okay if we explicitly mention this in the binding description?

So you will release the same SoC with different versions of the block?

Yes correct.

Quoted 2 lines

Best regards,
Krzysztof

#20 lore raw

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

In reply to Krzysztof Kozlowski
Quoted 92 lines · Krzysztof Kozlowski
Quoted 57 lines · Ben Levinsky

Add a mailbox-framework controller for the AMD programmable-logic Mailbox soft IP. Expose separate transmit and receive FIFO channels.

Enable the interface clock only while a channel is started, before any register access, and disable it last when the channel shuts down. Keep provider probe free of register accesses and leave the IRQ disabled until a client starts the receive channel. Initialize each FIFO when its channel starts, use receive-threshold interrupts for incoming words, and poll the send-threshold status for transmit completion. Stop that polling from accessing registers once the transmit channel begins to shut down.

Carry mailbox payloads in struct zynqmp_ipi_message, limited to the FIFO depth given by the device tree. The FIFO transfers 32-bit words and the hardware conveys neither a byte count nor the FIFO occupancy, so a transmit length that is not a multiple of four is zero-padded to a whole word.

On a receive-threshold interrupt, read up to one FIFO depth of words and deliver them as one message, then acknowledge the interrupt. The event latches only when the FIFO goes from empty to nonempty, so a word that arrives between the drain and the acknowledge, or words left by the bounded drain, raise no new event. If the FIFO is nonempty after the acknowledge, toggle the threshold to latch a new event for them.

Assisted-by LLM sparse
---
 MAINTAINERS                      |   7 +
 drivers/mailbox/Kconfig          |  10 +
 drivers/mailbox/Makefile         |   1 +
 drivers/mailbox/amd-pl-mailbox.c | 369 +++++++++++++++++++++++++++++++
 4 files changed, 387 insertions(+)
 create mode 100644 drivers/mailbox/amd-pl-mailbox.c
MAINTAINERS +7 -0
index f53047aa8d3c..4e28e0c311c0 100644
@@ -1287,6 +1287,13 @@ 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,zynqmp-pl-mbox-2.1.yaml
+F:	drivers/mailbox/amd-pl-mailbox.c
+
 AMD PSTATE DRIVER
 M:	Huang Rui <[email protected]>
 M:	Mario Limonciello <[email protected]>
drivers/mailbox/Kconfig +0 -0
index ab869769e278..3c3f262c903c 100644

drivers/mailbox/Kconfig menuconfig MAILBOX · line 12

Quoted 5 lines
drivers/mailbox/Kconfig +2 -0
@@ -8,6 +8,16 @@ menuconfig MAILBOX
 
 if MAILBOX
 
+config AMD_PL_MAILBOX
+	tristate "AMD PL Mailbox soft IP controller"

Missing depends on Zynq/Xilinx.

Quoted 7 lines
drivers/mailbox/Kconfig +7 -0
+	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.

...

Quoted 16 lines
drivers/mailbox/Kconfig +16 -0
+	mb->controller.dev = dev;
+	mb->controller.ops = &amd_pl_mbox_ops;
+	mb->controller.chans = mb->chans;
+	mb->controller.num_chans = AMD_PL_MBOX_NUM_CHANS;
+	mb->controller.txdone_poll = true;
+	mb->controller.txpoll_period = 1;
+	mb->controller.of_xlate = amd_pl_mbox_xlate;
+
+	ret = devm_request_irq(dev, mb->irq, amd_pl_mbox_irq,
+			       IRQF_NO_AUTOEN,
+			       dev_name(dev), mb);
+	if (ret)
+		return ret;
+
+	return devm_mbox_controller_register(dev, &mb->controller);
+}
Quoted 9 lines

drivers/mailbox/Kconfig

Quoted 6 lines
drivers/mailbox/Kconfig +6 -0
+
+static const struct of_device_id amd_pl_mbox_of_match[] = {
+	{ .compatible = "amd,zynqmp-pl-mbox-2.1" },
+	{ .compatible = "amd,versal-pl-mbox-2.1" },
+	{ .compatible = "amd,versal-net-pl-mbox-2.1" },
+	{ .compatible = "amd,versal2-pl-mbox-2.1" },

So all of them are compatible? Then why do you need all this?

Hi Krzysztof,

This block will be used on 4 SoC - zynqmp, versal, versal-net & versal2. IIRC we should list each SoC where the device/hw block is available. That is why we listed all 4 of them. I am not sure if the compatible property in the YAML is presenting this correctly, but here I think it is good. Please suggest if there is a better way.

Thank You.

Quoted 2 lines

Best regards,
Krzysztof

#21 lore raw

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

Quoted 9 lines · Tanmay
Quoted 8 lines

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

Quoted 5 lines
drivers/mailbox/amd-pl-mailbox.c new file +5 -0
+static const struct of_device_id amd_pl_mbox_of_match[] = {
+	{ .compatible = "amd,zynqmp-pl-mbox-2.1" },
+	{ .compatible = "amd,versal-pl-mbox-2.1" },
+	{ .compatible = "amd,versal-net-pl-mbox-2.1" },
+	{ .compatible = "amd,versal2-pl-mbox-2.1" },

So all of them are compatible? Then why do you need all this?

Quoted 4 lines

Hi Krzysztof,

This block will be used on 4 SoC - zynqmp, versal, versal-net & versal2. IIRC we should list each SoC where the device/hw block is available.

No, you do not list here every compatible device. You only list fallbacks. Please open other drivers to see how this is done. Only hwmon is an exception here with its own reason.

Best regards,
Krzysztof

#22 lore raw

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

Quoted 15 lines · Krzysztof Kozlowski
Quoted 9 lines · Tanmay
Quoted 8 lines

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

Quoted 5 lines
drivers/mailbox/amd-pl-mailbox.c new file +5 -0
+static const struct of_device_id amd_pl_mbox_of_match[] = {
+	{ .compatible = "amd,zynqmp-pl-mbox-2.1" },
+	{ .compatible = "amd,versal-pl-mbox-2.1" },
+	{ .compatible = "amd,versal-net-pl-mbox-2.1" },
+	{ .compatible = "amd,versal2-pl-mbox-2.1" },

So all of them are compatible? Then why do you need all this?

Quoted 4 lines

Hi Krzysztof,

This block will be used on 4 SoC - zynqmp, versal, versal-net & versal2. IIRC we should list each SoC where the device/hw block is available.

Quoted 7 lines

No, you do not list here every compatible device. You only list fallbacks. Please open other drivers to see how this is done. Only hwmon is an exception here with its own reason.

Best regards,
Krzysztof

Hi Krzysztof,

Thanks, understood. In v2 the binding keeps the SoC-specific compatibles with amd,zynqmp-pl-mbox-2.1 as the fallback, and the driver matches only the fallback. I also withdraw the xlnx,mailbox-2.1 proposal from my earlier reply.

Thanks,
Ben

#12 lore raw

Re: [PATCH 3/6] dt-bindings: mailbox: Add AMD PL Mailbox IP

In reply to Shah, Tanmay
Quoted 20 lines · Tanmay
Quoted 17 lines · Krzysztof Kozlowski
Quoted 15 lines · Tanmay

We use 'amd' vendor prefix for all new drivers & bindings. Also, there is dedicated IPI hardware which can be used as mailbox too, and we should distinguish it with this PL mailbox. So I that is included in the compatible string. (pl-mbox).

If we are also to include SOC name as well (per compatible property guideline), then we should include one of the SOC name as well:

So, I think 'amd,zynqmp-pl-mbox-2.1' is good.

Krzysztof, are you okay with above name? The 2.1 is FPGA IP design version number and not the SOC version number. So in future let's say that FPGA IP design is improved then the name (pl-mbox) will remain same, but only version number will be updated i.e. (from 2.1 to 3.0). Is it okay if we explicitly mention this in the binding description?

Quoted 4 lines
Quoted 2 lines

So you will release the same SoC with different versions of the block?

Yes correct.

Well, then this does not look like SoC block at all.

Best regards,
Krzysztof

#13 lore raw

Re: [PATCH 3/6] dt-bindings: mailbox: Add AMD PL Mailbox IP

Quoted 21 lines · Krzysztof Kozlowski
Quoted 20 lines · Tanmay
Quoted 17 lines · Krzysztof Kozlowski
Quoted 15 lines · Tanmay

We use 'amd' vendor prefix for all new drivers & bindings. Also, there is dedicated IPI hardware which can be used as mailbox too, and we should distinguish it with this PL mailbox. So I that is included in the compatible string. (pl-mbox).

If we are also to include SOC name as well (per compatible property guideline), then we should include one of the SOC name as well:

So, I think 'amd,zynqmp-pl-mbox-2.1' is good.

Krzysztof, are you okay with above name? The 2.1 is FPGA IP design version number and not the SOC version number. So in future let's say that FPGA IP design is improved then the name (pl-mbox) will remain same, but only version number will be updated i.e. (from 2.1 to 3.0). Is it okay if we explicitly mention this in the binding description?

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

So you will release the same SoC with different versions of the block?

Yes correct.

Well, then this does not look like SoC block at all.

Hi Krzysztof,

Right, it is not a SoC block. The Mailbox is a soft IP core from the AMD IP catalog (Mailbox v2.1) that is instantiated in programmable logic ("PL" acronym), so the IP version, not the SoC, defines the programming model.

Following the other PL soft IP bindings, which use a single IP-versioned compatible without a SoC name (e.g. xlnx,tmr-manager-1.0, xlnx,axi-can-1.00.a), v2 would use:

    compatible = "amd,pl-mailbox-2.1";

with the driver matching only that compatible. The amd prefix follows what we use for new AMD bindings, and "pl" distinguishes it from the IPI mailbox hardware. Is that acceptable?

Thanks,
Ben

Quoted 2 lines

Best regards,
Krzysztof