Skip to contentSkip to conversation

accel/amd_vpci: Add new driver for AMD Versal PCI

PATCH In review David Zhang 2 participants 8 messages Jan 26 – Feb 2

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

v2 cover accel/amd_vpci: Add new driver for AMD Versal PCI

This patchset introduces a new Linux Kernel Driver, *versal-pci*, for AMD Embedded+ platform.

The AMD Embedded+ platform integrates AMD Ryzen Embedded processors with AMD Versal AI Edge adaptive SoCs on a single PCB [1]. The AMD Ryzen Embedded processor is connected to the Versal AI Edge adaptive SoC via PCIe enabling a tightly coupled heterogeneous compute platform. AMD Embedded+ platform is used for sensor fusion, AI inferencing, industrial networking, control, and visualization.

AMD Versal PCI driver, versal-pci, is a host-side PCIe driver for AMD Embedded+ platform running on AMD Ryzen Embedded processor.

The versal-pci driver is responsible for the management-plane operations for the AMD Versal AI Edge adaptive SoC, including:

- Loading accelerator firmware images
- Reset and recovery
- Health monitoring

The driver is licensed under GPL-2.0.

The firmwares are distributed as closed binaries. Please see [1] for more information. Please see [2] for software architecture.

[1] https://www.amd.com/en/products/embedded/embedded-plus.html
[2] https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/3011838141/AMD+Embedded+Platforms

David Zhang (5):
accel/amd_vpci: Add documentation for AMD Versal PCI accelerator
management
accel/amd_vpci: Add new driver for AMD Versal PCI accelerator accel/amd_vpci: Add Remote Management(RM) queue infrastructure accel/amd_vpci: Add Remote Management (RM) queue service APIs accel/amd_vpci: Add communication channel service

 Documentation/accel/amd_vpci/amd_vpci.rst     | 122 +++++
 Documentation/accel/amd_vpci/index.rst        |  11 +
 Documentation/accel/index.rst                 |   1 +
 MAINTAINERS                                   |   5 +
 drivers/accel/Kconfig                         |   1 +
 drivers/accel/Makefile                        |   3 +-
 drivers/accel/amd_vpci/Kconfig                |  15 +
 drivers/accel/amd_vpci/Makefile               |   9 +
 drivers/accel/amd_vpci/versal-pci-comm-chan.c | 295 +++++++++++
 drivers/accel/amd_vpci/versal-pci-comm-chan.h |  14 +
 drivers/accel/amd_vpci/versal-pci-main.c      | 395 ++++++++++++++
 drivers/accel/amd_vpci/versal-pci-rm-queue.c  | 314 +++++++++++
 drivers/accel/amd_vpci/versal-pci-rm-queue.h  |  21 +
 .../accel/amd_vpci/versal-pci-rm-service.c    | 497 ++++++++++++++++++
 .../accel/amd_vpci/versal-pci-rm-service.h    | 229 ++++++++
 drivers/accel/amd_vpci/versal-pci.h           |  70 +++
 16 files changed, 2001 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/accel/amd_vpci/amd_vpci.rst
 create mode 100644 Documentation/accel/amd_vpci/index.rst
 create mode 100644 drivers/accel/amd_vpci/Kconfig
 create mode 100644 drivers/accel/amd_vpci/Makefile
 create mode 100644 drivers/accel/amd_vpci/versal-pci-comm-chan.c
 create mode 100644 drivers/accel/amd_vpci/versal-pci-comm-chan.h
 create mode 100644 drivers/accel/amd_vpci/versal-pci-main.c
 create mode 100644 drivers/accel/amd_vpci/versal-pci-rm-queue.c
 create mode 100644 drivers/accel/amd_vpci/versal-pci-rm-queue.h
 create mode 100644 drivers/accel/amd_vpci/versal-pci-rm-service.c
 create mode 100644 drivers/accel/amd_vpci/versal-pci-rm-service.h
 create mode 100644 drivers/accel/amd_vpci/versal-pci.h
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/5 accel/amd_vpci: Add documentation for AMD Versal PCI accelerator management

This patch introduces documentation for the AMD Versal PCI accelerator management driver. The driver runs on the host and manages the AMD Versal AI Edge SoC on the AMD Embedded+ platform. It handles management-plane operations including firmware image loading, reset, and health monitoring. This documentation also describes the firmware interface (VMR) and overall platform architecture.

---
 Documentation/accel/amd_vpci/amd_vpci.rst | 122 ++++++++++++++++++++++
 Documentation/accel/amd_vpci/index.rst    |  11 ++
 Documentation/accel/index.rst             |   1 +
 3 files changed, 134 insertions(+)
 create mode 100644 Documentation/accel/amd_vpci/amd_vpci.rst
 create mode 100644 Documentation/accel/amd_vpci/index.rst
Documentation/accel/amd_vpci/amd_vpci.rst new file +122 -0
new file mode 100644
index 000000000000..7638e9107ff6
@@ -0,0 +1,122 @@
+.. SPDX-License-Identifier: GPL-2.0-only
+
+.. include:: <isonum.txt>
+
+===============
+ AMD Versal PCI
+===============
+
+:Copyright: |copy| 2026 Advanced Micro Devices, Inc.
+:Authors: - Sonal Santan <[email protected]>
+	  - Yidong (David) Zhang <[email protected]>
+
+Overview
+========
+
+The AMD Embedded+ platform integrates AMD Ryzen Embedded processors with
+AMD Versal AI Edge adaptive System-on-Chip (SoC) on a single PCB. The AMD
+Ryzen Embedded processor is connected to the Versal AI Edge adaptive SoC
+via PCIe enabling a tightly coupled heterogeneous compute platform. AMD
+Embedded+ platform is commonly used for sensor fusion, AI inferencing,
+industrial networking, control, and visualization.
+
+AMD Versal PCI driver, versal-pci, is a host-side PCIe driver for AMD
+Embedded+ platform running on AMD Ryzen Embedded processor. The versal-pci
+driver is responsible for the **management-plane** operations for the AMD
+Versal AI Edge adaptive SoC, including:
+
+* Loading accelerator firmware images
+* Reset and recovery
+* Health monitoring
+
+Please note that the versal-pci driver does *not* participate in workload
+execution.
+
+Hardware Description
+====================
+
+AMD Versal AI SoCs boot from a dedicated flash device and presents two
+PCIe physical functions to the AMD Ryzen Embedded processor which acts as
+PCIe host.
+
+* Physical function 0 (PF0) is used for the management-plane to interact
+  with versal-pci driver.
+* Physical function 1 (PF1) is used for the execution-plane. In some cases
+  PF1 can be attached to a VM.
+
+Versal Management Runtime (VMR) Firmware
+----------------------------------------
+
+AMD Versal AI SoC runs Versal Management Runtime (VMR) firmware on a
+microcontroller. VMR is responsible for:
+
+* Low-level management of the AMD Versal AI SoC.
+* Loading accelerator images into a dedicated partition on the AMD Versal
+  AI SoC.
+
+The VMR communicates with the versal-pci driver via:
+
+* A command queue mapped to PCIe PF0 BAR.
+* A shared memory region in the PCIe PF0 BAR.
+
+Accelerator Image
+-----------------
+
+An AMD Embedded+ platform may store multiple *accelerator images*, each
+identified by a UUID in a secure location on the AMD Ryzen host file
+system. Each image enables a specific application like sensor fusion, AI
+inferencing, etc. A chosen accelerator image is sent to the VMR by the
+versal-pci driver. Once loaded, the accelerator image running in the
+dedicated partition of AMD Versal AI SoC interfaces with the AMD Ryzen host
+via PCIe PF1.
+
+Accelerator Image Loading Workflow
+----------------------------------
+
+1. A user application requests an image load by sending the UUID of the
+   desired image to the user driver attached to PF1.
+2. The user driver forwards the UUID to the versal-pci driver via a mailbox
+   channel which connects PF1 to PF0.
+3. The versal-pci driver on PF0 receives the UUID via the mailbox channel.
+4. The versal-pci driver on PF0 then requests the accelerator image change
+   by sending a message to the VMR.
+5. The versal-pci driver copies the accelerator image to the shared memory
+   region on the PF0 PCIe BAR. It then sends a message to the VMR via the
+   command queue.
+6. Upon receiving the request from versal-pci, the VMR programs dedicated
+   hardware in the AMD Versal AI SoC to perform image loading.
+7. The image is loaded over the dedicated partition which then starts
+   running.  The VMR sends success response to the versal-pci driver.
+8. The versal-pci driver then responds to the user PF driver over the
+   communication channel.
+9. The versal-pci driver begins monitoring the health of the AMD Versal
+   SoC.
+
+
+The Driver Architecture
+=======================
+
+.. code-block:: bash
+
+                          +------------+
+                          |            |
+                          |     VM     |
+       +------------+     |            |
+       | versal-pci |     |            |
+   +---+----o-------+-----+-----o------+-----+
+   |        |       Linux       |            |  AMD Ryzen Host
+   +--------|-------------------|------------+
+           PF0                 PF1
+            |                   |
+   +--------v--------+----------v------------+
+   |                 .                       |
+   |       VMR       .   Accelerator Image   | AMD Versal AI SoC
+   |                 .                       |
+   +-----------------+-----------------------+
+
+
+References
+==========
+
+* `AMD Embedded Plus <https://www.amd.com/en/products/embedded/embedded-plus.html>`_
+* `AMD Embedded Platform Architecture <https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/3011838141/AMD+Embedded+Platforms>`_
Documentation/accel/amd_vpci/index.rst new file +11 -0
new file mode 100644
index 000000000000..3ed4ab9e1332
@@ -0,0 +1,11 @@
+.. SPDX-License-Identifier: GPL-2.0-only
+
+===========================================
+ accel/amd_vpci Versal Embedded Plus driver
+===========================================
+
+The accel/amd_vpci driver supports the AMD Versal Embedded Plus accelerator
+
+.. toctree::
+
+   amd_vpci
Documentation/accel/index.rst +1 -0
index d8fa332d60a8..30fed42e1686 100644
@@ -9,6 +9,7 @@ Compute Accelerators
 
    introduction
    amdxdna/index
+   amd_vpci/index
    qaic/index
    rocket/index
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/5 accel/amd_vpci: Add new driver for AMD Versal PCI accelerator

In reply to David Zhang

This patch introduces a new PCI driver for AMD Versal-based accelerator cards.

The driver provides basic module and PCI device initialization, based on BAR resources used to establish a hardware queue-based ring buffer between the PCIe host and the Versal Management Runtime (VMR) service running on the embedded SoC. This interface enables firmware management and board health monitoring.

Key features:
- PCI probe and BAR resource initialization.
- Integration with configfs for firmware management
- Compatibility check using firmware-reported UUIDs

The base firmware image is expected under /lib/firmware/xilinx/<fw_name> and can be programmed to the device through the configfs interface. Firmware transfer is handled via a remote queue service (added in a later patch).

---
 MAINTAINERS                              |   5 +
 drivers/accel/Kconfig                    |   1 +
 drivers/accel/Makefile                   |   3 +-
 drivers/accel/amd_vpci/Kconfig           |  15 ++
 drivers/accel/amd_vpci/Makefile          |   6 +
 drivers/accel/amd_vpci/versal-pci-main.c | 280 +++++++++++++++++++++++
 drivers/accel/amd_vpci/versal-pci.h      |  62 +++++
 7 files changed, 371 insertions(+), 1 deletion(-)
 create mode 100644 drivers/accel/amd_vpci/Kconfig
 create mode 100644 drivers/accel/amd_vpci/Makefile
 create mode 100644 drivers/accel/amd_vpci/versal-pci-main.c
 create mode 100644 drivers/accel/amd_vpci/versal-pci.h
MAINTAINERS +5 -0
index 6863d5fa07a1..8fb7276eb7c1 100644
@@ -1271,6 +1271,11 @@ F:	drivers/spi/spi-amd-pci.c
 F:	drivers/spi/spi-amd.c
 F:	drivers/spi/spi-amd.h
 
+AMD VERSAL PCI DRIVER
+M:	Yidong Zhang <[email protected]>
+S:	Supported
+F:	drivers/accel/amd_vpci/
+
 AMD XDNA DRIVER
 M:	Min Ma <[email protected]>
 M:	Lizhi Hou <[email protected]>
drivers/accel/Kconfig +1 -0
index bdf48ccafcf2..f80998fdb3fc 100644
@@ -25,6 +25,7 @@ menuconfig DRM_ACCEL
 	  and debugfs).
 
 source "drivers/accel/amdxdna/Kconfig"
+source "drivers/accel/amd_vpci/Kconfig"
 source "drivers/accel/ethosu/Kconfig"
 source "drivers/accel/habanalabs/Kconfig"
 source "drivers/accel/ivpu/Kconfig"
drivers/accel/Makefile +2 -1
index 1d3a7251b950..be62e08bbef1 100644
@@ -1,8 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 obj-$(CONFIG_DRM_ACCEL_AMDXDNA)		+= amdxdna/
+obj-$(CONFIG_DRM_ACCEL_AMD_VPCI)	+= amd_vpci/
 obj-$(CONFIG_DRM_ACCEL_ARM_ETHOSU)	+= ethosu/
 obj-$(CONFIG_DRM_ACCEL_HABANALABS)	+= habanalabs/
 obj-$(CONFIG_DRM_ACCEL_IVPU)		+= ivpu/
 obj-$(CONFIG_DRM_ACCEL_QAIC)		+= qaic/
-obj-$(CONFIG_DRM_ACCEL_ROCKET)		+= rocket/
\ No newline at end of file
+obj-$(CONFIG_DRM_ACCEL_ROCKET)		+= rocket/
drivers/accel/amd_vpci/Kconfig new file +15 -0
new file mode 100644
index 000000000000..dcf83bf3d8e6
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config DRM_ACCEL_AMD_VPCI
+	tristate "AMD Versal PCIe Management Driver"
+	depends on DRM_ACCEL
+	depends on PCI && HAS_IOMEM
+	select FW_LOADER
+	select CONFIGFS_FS
+	default m
+	help
+	  AMD Versal PCIe Management Driver provides management services,
+	  including download firmware, program bitstream, and communicate with
+	  the User function.
+
+	  If "M" is selected, the driver module will be versal-pci
drivers/accel/amd_vpci/Makefile new file +6 -0
new file mode 100644
index 000000000000..03849875ad0b
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_DRM_ACCEL_AMD_VPCI) := versal-pci.o
+
+versal-pci-y := \
+	versal-pci-main.o
drivers/accel/amd_vpci/versal-pci-main.c new file +280 -0

280 lines not on this page · raw message

drivers/accel/amd_vpci/versal-pci.h new file +62 -0

62 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH V2 2/5] accel/amd_vpci: Add new driver for AMD Versal PCI accelerator

Quoted 293 lines · David Zhang

This patch introduces a new PCI driver for AMD Versal-based accelerator cards.

The driver provides basic module and PCI device initialization, based on BAR resources used to establish a hardware queue-based ring buffer between the PCIe host and the Versal Management Runtime (VMR) service running on the embedded SoC. This interface enables firmware management and board health monitoring.

Key features:
- PCI probe and BAR resource initialization.
- Integration with configfs for firmware management
- Compatibility check using firmware-reported UUIDs

The base firmware image is expected under /lib/firmware/xilinx/<fw_name> and can be programmed to the device through the configfs interface. Firmware transfer is handled via a remote queue service (added in a later patch).

---
  MAINTAINERS                              |   5 +
  drivers/accel/Kconfig                    |   1 +
  drivers/accel/Makefile                   |   3 +-
  drivers/accel/amd_vpci/Kconfig           |  15 ++
  drivers/accel/amd_vpci/Makefile          |   6 +
  drivers/accel/amd_vpci/versal-pci-main.c | 280 +++++++++++++++++++++++
  drivers/accel/amd_vpci/versal-pci.h      |  62 +++++
  7 files changed, 371 insertions(+), 1 deletion(-)

create mode 100644 drivers/accel/amd_vpci/Kconfig create mode 100644 drivers/accel/amd_vpci/Makefile create mode 100644 drivers/accel/amd_vpci/versal-pci-main.c create mode 100644 drivers/accel/amd_vpci/versal-pci.h

MAINTAINERS +5 -0
index 6863d5fa07a1..8fb7276eb7c1 100644
@@ -1271,6 +1271,11 @@ F:	drivers/spi/spi-amd-pci.c
  F:	drivers/spi/spi-amd.c
  F:	drivers/spi/spi-amd.h
 
+AMD VERSAL PCI DRIVER
+M:	Yidong Zhang <[email protected]>
+S:	Supported
+F:	drivers/accel/amd_vpci/
+
  AMD XDNA DRIVER
  M:	Min Ma <[email protected]>
  M:	Lizhi Hou <[email protected]>
drivers/accel/Kconfig +1 -0
index bdf48ccafcf2..f80998fdb3fc 100644
@@ -25,6 +25,7 @@ menuconfig DRM_ACCEL
  	  and debugfs).
 
  source "drivers/accel/amdxdna/Kconfig"
+source "drivers/accel/amd_vpci/Kconfig"
  source "drivers/accel/ethosu/Kconfig"
  source "drivers/accel/habanalabs/Kconfig"
  source "drivers/accel/ivpu/Kconfig"
drivers/accel/Makefile +2 -1
index 1d3a7251b950..be62e08bbef1 100644
@@ -1,8 +1,9 @@
  # SPDX-License-Identifier: GPL-2.0-only
 
  obj-$(CONFIG_DRM_ACCEL_AMDXDNA)		+= amdxdna/
+obj-$(CONFIG_DRM_ACCEL_AMD_VPCI)	+= amd_vpci/
  obj-$(CONFIG_DRM_ACCEL_ARM_ETHOSU)	+= ethosu/
  obj-$(CONFIG_DRM_ACCEL_HABANALABS)	+= habanalabs/
  obj-$(CONFIG_DRM_ACCEL_IVPU)		+= ivpu/
  obj-$(CONFIG_DRM_ACCEL_QAIC)		+= qaic/
-obj-$(CONFIG_DRM_ACCEL_ROCKET)		+= rocket/
\ No newline at end of file
+obj-$(CONFIG_DRM_ACCEL_ROCKET)		+= rocket/
drivers/accel/amd_vpci/Kconfig new file +15 -0
new file mode 100644
index 000000000000..dcf83bf3d8e6
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config DRM_ACCEL_AMD_VPCI
+	tristate "AMD Versal PCIe Management Driver"
+	depends on DRM_ACCEL
+	depends on PCI && HAS_IOMEM
+	select FW_LOADER
+	select CONFIGFS_FS
+	default m
+	help
+	  AMD Versal PCIe Management Driver provides management services,
+	  including download firmware, program bitstream, and communicate with
+	  the User function.
+
+	  If "M" is selected, the driver module will be versal-pci
drivers/accel/amd_vpci/Makefile new file +6 -0
new file mode 100644
index 000000000000..03849875ad0b
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_DRM_ACCEL_AMD_VPCI) := versal-pci.o
+
+versal-pci-y := \
+	versal-pci-main.o
drivers/accel/amd_vpci/versal-pci-main.c new file +172 -0
new file mode 100644
index 000000000000..36f88d5aee95
@@ -0,0 +1,280 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Driver for Versal PCIe device
+ *
+ * Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#include <linux/pci.h>
+
+#include "versal-pci.h"
+
+#define DRV_NAME			"amd-versal-pci"
+
+#define PCI_DEVICE_ID_V70PQ2		0x50B0
+#define PCI_DEVICE_ID_RAVE		0x5700
+#define VERSAL_XCLBIN_MAGIC_ID		"xclbin2"
+
+static inline u32 versal_pci_devid(struct versal_pci_device *vdev)
+{
+	return ((pci_domain_nr(vdev->pdev->bus) << 16) |
+		PCI_DEVID(vdev->pdev->bus->number, vdev->pdev->devfn));
+}
+
+static int versal_pci_load_shell(struct versal_pci_device *vdev, char *fw_name)
+{
+	const struct firmware *fw;
+	struct axlf *xsabin;
+	int ret;
+
+	strim(fw_name);
+
+	ret = request_firmware(&fw, fw_name, &vdev->pdev->dev);
+	if (ret) {
+		vdev_warn(vdev, "request xsabin fw %s failed %d", fw_name, ret);
+		return ret;
+	}
+
+	xsabin = (struct axlf *)fw->data;
+	if (memcmp(xsabin->magic, VERSAL_XCLBIN_MAGIC_ID, strlen(VERSAL_XCLBIN_MAGIC_ID))) {
+		vdev_err(vdev, "Invalid device firmware");
+		ret = -EINVAL;
+		goto release_firmware;
+	}
+
+	if (!fw->size ||
+	    fw->size != xsabin->header.length ||
+	    fw->size < sizeof(*xsabin) ||
+	    fw->size > SZ_1G) {
+		vdev_err(vdev, "Invalid device firmware size %zu", fw->size);
+		ret = -EINVAL;
+		goto release_firmware;
+	}
+
+	if (!uuid_equal(&vdev->intf_uuid, &xsabin->header.rom_uuid)) {
+		vdev_err(vdev, "base shell doesn't match uuid %pUb", &xsabin->header.rom_uuid);
+		ret = -EINVAL;
+		goto release_firmware;
+	}
+
+	/* TODO upload fw to card */
+	if (ret) {
+		vdev_err(vdev, "failed to load xsabin %s : %d", fw_name, ret);
+		goto release_firmware;
+	}
+
+	vdev_info(vdev, "Downloaded xsabin %pUb of size %lld Bytes",
+		  &xsabin->header.uuid, xsabin->header.length);
+
+release_firmware:
+	release_firmware(fw);
+
+	return ret;
+}
+
+static inline struct versal_pci_device *item_to_vdev(struct config_item *item)
+{
+	return container_of(to_configfs_subsystem(to_config_group(item)),
+			    struct versal_pci_device, cfs_subsys);
+}
+
+static ssize_t versal_pci_cfs_config_store(struct config_item *item,
+					   const char *page, size_t count)
+{
+	struct versal_pci_device *vdev = item_to_vdev(item);
+	u32 config;
+	int ret;
+
+	ret = kstrtou32(page, 0, &config);
+	if (ret)
+		return -EINVAL;
+
+	if (config)
+		ret = versal_pci_load_shell(vdev, vdev->fw.name);
+
+	if (ret)
+		return -EFAULT;
+
+	return count;
+}
+CONFIGFS_ATTR_WO(versal_pci_cfs_, config);
+
+static ssize_t versal_pci_cfs_image_show(struct config_item *item, char *page)
+{
+	struct versal_pci_device *vdev = item_to_vdev(item);
+
+	vdev_info(vdev, "fw name: %s", vdev->fw.name);
+
+	return 0;
+}
+
+static ssize_t versal_pci_cfs_image_store(struct config_item *item,
+					  const char *page, size_t count)
+{
+	struct versal_pci_device *vdev = item_to_vdev(item);
+
+	count = snprintf(vdev->fw.name, sizeof(vdev->fw.name), "%s", page);
+
+	vdev_info(vdev, "fw name: %s", vdev->fw.name);
+	return count;
+}
+CONFIGFS_ATTR(versal_pci_cfs_, image);
+
+static struct configfs_attribute *versal_pci_cfs_attrs[] = {
+	&versal_pci_cfs_attr_config,
+	&versal_pci_cfs_attr_image,
+	NULL,
+};
+
+static const struct config_item_type versal_pci_cfs_table = {
+	.ct_owner = THIS_MODULE,
+	.ct_attrs = versal_pci_cfs_attrs,
+};
+
+static int versal_pci_cfs_init(struct versal_pci_device *vdev)
+{
+	struct configfs_subsystem *subsys = &vdev->cfs_subsys;
+
+	snprintf(subsys->su_group.cg_item.ci_namebuf,
+		 sizeof(subsys->su_group.cg_item.ci_namebuf),
+		 "%s%x", DRV_NAME, versal_pci_devid(vdev));
+
+	subsys->su_group.cg_item.ci_type = &versal_pci_cfs_table;
+
+	config_group_init(&subsys->su_group);
+	return configfs_register_subsystem(subsys);
+}
+
+static void versal_pci_fw_fini(struct versal_pci_device *vdev)
+{
+	uuid_copy(&vdev->intf_uuid, &uuid_null);
+}
+
+static void versal_pci_cfs_fini(struct configfs_subsystem *subsys)
+{
+	configfs_unregister_subsystem(subsys);
+}
+
+static void versal_pci_device_teardown(struct versal_pci_device *vdev)
+{
+	versal_pci_cfs_fini(&vdev->cfs_subsys);
+	versal_pci_fw_fini(vdev);
+}
+
+static int versal_pci_uuid_parse(struct versal_pci_device *vdev, uuid_t *uuid)
+{
+	char str[UUID_STRING_LEN];
+	u8 i, j;
+	int len = strlen(vdev->fw_id);
+
+	/* parse uuid into a valid uuid string format */
+	for (i = 0, j = 0; i < len && i < sizeof(str); i++) {
+		str[j++] = vdev->fw_id[i];

drivers/accel/amd_vpci/versal-pci-main.c line 182

Quoted 10 lines
drivers/accel/amd_vpci/versal-pci-main.c new file +10 -0
+		if (j == 8 || j == 13 || j == 18 || j == 23)
+			str[j++] = '-';
+	}
+
+	if (uuid_parse(str, uuid)) {
+		vdev_warn(vdev, "Invalid fw_id format");
+		return -EINVAL;
+	}
+
+	vdev_info(vdev, "Interface uuid %pU", uuid);

Is the UUID from the ROM not considered sensitive? The system UUID is.

❮ cat /sys/class/dmi/id/product_uuid
cat: /sys/class/dmi/id/product_uuid: Permission denied

Besides this comment some errors are showing it too AFAICT.

Quoted 166 lines
drivers/accel/amd_vpci/versal-pci-main.c new file +98 -0
+	return 0;
+}
+
+static int versal_pci_fw_init(struct versal_pci_device *vdev)
+{
+	int ret;
+
+	/* TODO request compatible fw_id from card */
+
+	ret = versal_pci_uuid_parse(vdev, &vdev->intf_uuid);
+
+	return ret;
+}
+
+static int versal_pci_device_setup(struct versal_pci_device *vdev)
+{
+	int ret;
+
+	ret = versal_pci_fw_init(vdev);
+	if (ret) {
+		vdev_err(vdev, "Failed to init fw, err %d", ret);
+		goto comm_chan_fini;
+	}
+
+	ret = versal_pci_cfs_init(vdev);
+	if (ret) {
+		vdev_err(vdev, "Failed to init configfs subsys, err %d", ret);
+		goto comm_chan_fini;
+	}
+
+	return 0;
+
+comm_chan_fini:
+	versal_pci_fw_fini(vdev);
+
+	return ret;
+}
+
+static void versal_pci_remove(struct pci_dev *pdev)
+{
+	struct versal_pci_device *vdev = pci_get_drvdata(pdev);
+
+	versal_pci_device_teardown(vdev);
+}
+
+static int versal_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id)
+{
+	struct versal_pci_device *vdev;
+	int ret;
+
+	vdev = devm_kzalloc(&pdev->dev, sizeof(*vdev), GFP_KERNEL);
+	if (!vdev)
+		return -ENOMEM;
+
+	pci_set_drvdata(pdev, vdev);
+	vdev->pdev = pdev;
+
+	ret = pcim_enable_device(pdev);
+	if (ret) {
+		vdev_err(vdev, "Failed to enable device %d", ret);
+		return ret;
+	}
+
+	vdev->io_regs = pcim_iomap_region(vdev->pdev, MGMT_BAR, DRV_NAME);
+	if (IS_ERR(vdev->io_regs)) {
+		vdev_err(vdev, "Failed to map RM shared memory BAR%d", MGMT_BAR);
+		return PTR_ERR(vdev->io_regs);
+	}
+
+	ret = versal_pci_device_setup(vdev);
+	if (ret) {
+		vdev_err(vdev, "Failed to setup Versal device %d", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static const struct pci_device_id versal_pci_ids[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_V70PQ2), },
+	{ PCI_DEVICE(PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RAVE), },
+	{ 0 }
+};
+
+MODULE_DEVICE_TABLE(pci, versal_pci_ids);
+
+static struct pci_driver versal_pci_driver = {
+	.name = DRV_NAME,
+	.id_table = versal_pci_ids,
+	.probe = versal_pci_probe,
+	.remove = versal_pci_remove,
+};
+
+module_pci_driver(versal_pci_driver);
+
+MODULE_DESCRIPTION("AMD Versal PCIe Management Driver");
+MODULE_AUTHOR("XRT Team <[email protected]>");
+MODULE_LICENSE("GPL");
drivers/accel/amd_vpci/versal-pci.h new file +62 -0
new file mode 100644
index 000000000000..890da1d6bcc9
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Driver for Versal PCIe device
+ *
+ * Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#ifndef __VERSAL_PCI_H
+#define __VERSAL_PCI_H
+
+#include <linux/configfs.h>
+#include <linux/firmware.h>
+
+#define MGMT_BAR		0
+
+#define vdev_info(vdev, fmt, args...)					\
+	dev_info(&(vdev)->pdev->dev, "%s: "fmt, __func__, ##args)
+
+#define vdev_warn(vdev, fmt, args...)					\
+	dev_warn(&(vdev)->pdev->dev, "%s: "fmt, __func__, ##args)
+
+#define vdev_err(vdev, fmt, args...)					\
+	dev_err(&(vdev)->pdev->dev, "%s: "fmt, __func__, ##args)
+
+#define vdev_dbg(vdev, fmt, args...)					\
+	dev_dbg(&(vdev)->pdev->dev, fmt, ##args)
+
+struct versal_pci_device;
+
+struct axlf_header {
+	__u64				length;
+	__u8				reserved1[24];
+	uuid_t				rom_uuid;
+	__u8				reserved2[64];
+	uuid_t				uuid;
+	__u8				reserved3[24];
+} __packed;
+
+struct axlf {
+	__u8				magic[8];
+	__u8				reserved[296];
+	struct axlf_header		header;
+} __packed;
+
+struct fw_info {
+	__u32				opcode;
+	char				name[128];
+};
+
+struct versal_pci_device {
+	struct pci_dev			*pdev;
+
+	struct fw_info			fw;
+
+	void __iomem			*io_regs;
+	uuid_t				intf_uuid;
+	__u8				fw_id[UUID_STRING_LEN + 1];
+
+	struct configfs_subsystem	cfs_subsys;
+};
+
+#endif	/* __VERSAL_PCI_H */
#4 lore raw

Re: [PATCH V2 2/5] accel/amd_vpci: Add new driver for AMD Versal PCI accelerator

Hi Mario,

Quoted 313 lines · Mario Limonciello
Quoted 297 lines · David Zhang

This patch introduces a new PCI driver for AMD Versal-based accelerator cards.

The driver provides basic module and PCI device initialization, based on BAR resources used to establish a hardware queue-based ring buffer between the PCIe host and the Versal Management Runtime (VMR) service running on the embedded SoC. This interface enables firmware management and board health monitoring.

Key features:
    - PCI probe and BAR resource initialization.
    - Integration with configfs for firmware management
    - Compatibility check using firmware-reported UUIDs

The base firmware image is expected under /lib/firmware/xilinx/<fw_name> and can be programmed to the device through the configfs interface. Firmware transfer is handled via a remote queue service (added in a later patch).

---
  MAINTAINERS                              |   5 + drivers/accel/Kconfig                    |   1 + drivers/accel/Makefile                   |   3 +- drivers/accel/amd_vpci/Kconfig           |  15 ++ drivers/accel/amd_vpci/Makefile          |   6 + drivers/accel/amd_vpci/versal-pci-main.c | 280 +++++++++++++++++++++++ drivers/accel/amd_vpci/versal-pci.h      |  62 +++++

  7 files changed, 371 insertions(+), 1 deletion(-)

  create mode 100644 drivers/accel/amd_vpci/Kconfig create mode 100644 drivers/accel/amd_vpci/Makefile create mode 100644 drivers/accel/amd_vpci/versal-pci-main.c create mode 100644 drivers/accel/amd_vpci/versal-pci.h

MAINTAINERS +0 -0
index 6863d5fa07a1..8fb7276eb7c1 100644
@@ -1271,6 +1271,11 @@ F:    drivers/spi/spi-amd-pci.c

  F:    drivers/spi/spi-amd.c
  F:    drivers/spi/spi-amd.h

MAINTAINERS +5 -0
+AMD VERSAL PCI DRIVER
+M:    Yidong Zhang <[email protected]>
+S:    Supported
+F:    drivers/accel/amd_vpci/
+

  AMD XDNA DRIVER
  M:    Min Ma <[email protected]>
  M:    Lizhi Hou <[email protected]>

drivers/accel/Kconfig +0 -0
index bdf48ccafcf2..f80998fdb3fc 100644
@@ -25,6 +25,7 @@ menuconfig DRM_ACCEL

        and debugfs).
  source "drivers/accel/amdxdna/Kconfig"
+source "drivers/accel/amd_vpci/Kconfig"
  source "drivers/accel/ethosu/Kconfig"
  source "drivers/accel/habanalabs/Kconfig"
  source "drivers/accel/ivpu/Kconfig"

drivers/accel/Makefile +0 -0
index 1d3a7251b950..be62e08bbef1 100644
@@ -1,8 +1,9 @@
   # SPDX-License-Identifier: GPL-2.0-only

  obj-$(CONFIG_DRM_ACCEL_AMDXDNA)        += amdxdna/ +obj-$(CONFIG_DRM_ACCEL_AMD_VPCI)    += amd_vpci/ obj-$(CONFIG_DRM_ACCEL_ARM_ETHOSU)    += ethosu/ obj-$(CONFIG_DRM_ACCEL_HABANALABS)    += habanalabs/ obj-$(CONFIG_DRM_ACCEL_IVPU)        += ivpu/ obj-$(CONFIG_DRM_ACCEL_QAIC)        += qaic/

drivers/accel/Makefile +1 -1
-obj-$(CONFIG_DRM_ACCEL_ROCKET)        += rocket/
\ No newline at end of file
+obj-$(CONFIG_DRM_ACCEL_ROCKET)        += rocket/
drivers/accel/amd_vpci/Kconfig new file +12 -0
new file mode 100644
index 000000000000..dcf83bf3d8e6
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config DRM_ACCEL_AMD_VPCI
+    tristate "AMD Versal PCIe Management Driver"
+    depends on DRM_ACCEL
+    depends on PCI && HAS_IOMEM
+    select FW_LOADER
+    select CONFIGFS_FS
+    default m
+    help
+      AMD Versal PCIe Management Driver provides management services,
+      including download firmware, program bitstream, and communicate 

with
+      the User function.

drivers/accel/amd_vpci/Kconfig new file +2 -0
+
+      If "M" is selected, the driver module will be versal-pci
drivers/accel/amd_vpci/Makefile new file +6 -0
new file mode 100644
index 000000000000..03849875ad0b
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_DRM_ACCEL_AMD_VPCI) := versal-pci.o
+
+versal-pci-y := \
+    versal-pci-main.o
drivers/accel/amd_vpci/versal-pci-main.c new file +24 -0
new file mode 100644
index 000000000000..36f88d5aee95
@@ -0,0 +1,280 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Driver for Versal PCIe device
+ *
+ * Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#include <linux/pci.h>
+
+#include "versal-pci.h"
+
+#define DRV_NAME            "amd-versal-pci"
+
+#define PCI_DEVICE_ID_V70PQ2        0x50B0
+#define PCI_DEVICE_ID_RAVE        0x5700
+#define VERSAL_XCLBIN_MAGIC_ID        "xclbin2"
+
+static inline u32 versal_pci_devid(struct versal_pci_device *vdev)
+{
+    return ((pci_domain_nr(vdev->pdev->bus) << 16) |
+        PCI_DEVID(vdev->pdev->bus->number, vdev->pdev->devfn));
+}
+
+static int versal_pci_load_shell(struct versal_pci_device *vdev, char 

*fw_name)

drivers/accel/amd_vpci/versal-pci-main.c new file +15 -0
+{
+    const struct firmware *fw;
+    struct axlf *xsabin;
+    int ret;
+
+    strim(fw_name);
+
+    ret = request_firmware(&fw, fw_name, &vdev->pdev->dev);
+    if (ret) {
+        vdev_warn(vdev, "request xsabin fw %s failed %d", fw_name, ret);
+        return ret;
+    }
+
+    xsabin = (struct axlf *)fw->data;
+    if (memcmp(xsabin->magic, VERSAL_XCLBIN_MAGIC_ID, 

strlen(VERSAL_XCLBIN_MAGIC_ID))) {
+        vdev_err(vdev, "Invalid device firmware"); +        ret = -EINVAL;
+        goto release_firmware;
+    }

drivers/accel/amd_vpci/versal-pci-main.c new file +12 -0
+
+    if (!fw->size ||
+        fw->size != xsabin->header.length ||
+        fw->size < sizeof(*xsabin) ||
+        fw->size > SZ_1G) {
+        vdev_err(vdev, "Invalid device firmware size %zu", fw->size);
+        ret = -EINVAL;
+        goto release_firmware;
+    }
+
+    if (!uuid_equal(&vdev->intf_uuid, &xsabin->header.rom_uuid)) {
+        vdev_err(vdev, "base shell doesn't match uuid %pUb", 

&xsabin->header.rom_uuid);
+        ret = -EINVAL;
+        goto release_firmware;
+    }

drivers/accel/amd_vpci/versal-pci-main.c new file +17 -0
+
+    /* TODO upload fw to card */
+    if (ret) {
+        vdev_err(vdev, "failed to load xsabin %s : %d", fw_name, ret);
+        goto release_firmware;
+    }
+
+    vdev_info(vdev, "Downloaded xsabin %pUb of size %lld Bytes",
+          &xsabin->header.uuid, xsabin->header.length);
+
+release_firmware:
+    release_firmware(fw);
+
+    return ret;
+}
+
+static inline struct versal_pci_device *item_to_vdev(struct 

config_item *item)

drivers/accel/amd_vpci/versal-pci-main.c new file +27 -0
+{
+    return container_of(to_configfs_subsystem(to_config_group(item)),
+                struct versal_pci_device, cfs_subsys);
+}
+
+static ssize_t versal_pci_cfs_config_store(struct config_item *item,
+                       const char *page, size_t count)
+{
+    struct versal_pci_device *vdev = item_to_vdev(item);
+    u32 config;
+    int ret;
+
+    ret = kstrtou32(page, 0, &config);
+    if (ret)
+        return -EINVAL;
+
+    if (config)
+        ret = versal_pci_load_shell(vdev, vdev->fw.name);
+
+    if (ret)
+        return -EFAULT;
+
+    return count;
+}
+CONFIGFS_ATTR_WO(versal_pci_cfs_, config);
+
+static ssize_t versal_pci_cfs_image_show(struct config_item *item, 

char *page)

drivers/accel/amd_vpci/versal-pci-main.c new file +62 -0
+{
+    struct versal_pci_device *vdev = item_to_vdev(item);
+
+    vdev_info(vdev, "fw name: %s", vdev->fw.name);
+
+    return 0;
+}
+
+static ssize_t versal_pci_cfs_image_store(struct config_item *item,
+                      const char *page, size_t count)
+{
+    struct versal_pci_device *vdev = item_to_vdev(item);
+
+    count = snprintf(vdev->fw.name, sizeof(vdev->fw.name), "%s", page);
+
+    vdev_info(vdev, "fw name: %s", vdev->fw.name);
+    return count;
+}
+CONFIGFS_ATTR(versal_pci_cfs_, image);
+
+static struct configfs_attribute *versal_pci_cfs_attrs[] = {
+    &versal_pci_cfs_attr_config,
+    &versal_pci_cfs_attr_image,
+    NULL,
+};
+
+static const struct config_item_type versal_pci_cfs_table = {
+    .ct_owner = THIS_MODULE,
+    .ct_attrs = versal_pci_cfs_attrs,
+};
+
+static int versal_pci_cfs_init(struct versal_pci_device *vdev)
+{
+    struct configfs_subsystem *subsys = &vdev->cfs_subsys;
+
+    snprintf(subsys->su_group.cg_item.ci_namebuf,
+         sizeof(subsys->su_group.cg_item.ci_namebuf),
+         "%s%x", DRV_NAME, versal_pci_devid(vdev));
+
+    subsys->su_group.cg_item.ci_type = &versal_pci_cfs_table;
+
+    config_group_init(&subsys->su_group);
+    return configfs_register_subsystem(subsys);
+}
+
+static void versal_pci_fw_fini(struct versal_pci_device *vdev)
+{
+    uuid_copy(&vdev->intf_uuid, &uuid_null);
+}
+
+static void versal_pci_cfs_fini(struct configfs_subsystem *subsys)
+{
+    configfs_unregister_subsystem(subsys);
+}
+
+static void versal_pci_device_teardown(struct versal_pci_device *vdev)
+{
+    versal_pci_cfs_fini(&vdev->cfs_subsys);
+    versal_pci_fw_fini(vdev);
+}
+
+static int versal_pci_uuid_parse(struct versal_pci_device *vdev, 

uuid_t *uuid)

drivers/accel/amd_vpci/versal-pci-main.c new file +8 -0
+{
+    char str[UUID_STRING_LEN];
+    u8 i, j;
+    int len = strlen(vdev->fw_id);
+
+    /* parse uuid into a valid uuid string format */
+    for (i = 0, j = 0; i < len && i < sizeof(str); i++) {
+        str[j++] = vdev->fw_id[i];

drivers/accel/amd_vpci/versal-pci-main.c line 182

Quoted 10 lines
drivers/accel/amd_vpci/versal-pci-main.c new file +10 -0
+        if (j == 8 || j == 13 || j == 18 || j == 23)
+            str[j++] = '-';
+    }
+
+    if (uuid_parse(str, uuid)) {
+        vdev_warn(vdev, "Invalid fw_id format");
+        return -EINVAL;
+    }
+
+    vdev_info(vdev, "Interface uuid %pU", uuid);

Is the UUID from the ROM not considered sensitive?  The system UUID is.

Quoted 4 lines

❮ cat /sys/class/dmi/id/product_uuid
cat: /sys/class/dmi/id/product_uuid: Permission denied

Besides this comment some errors are showing it too AFAICT.

Thanks for catching this out. I will remove all UUID messages from the debug message.

Thanks,
David

Quoted 170 lines
Quoted 169 lines

+    return 0;

drivers/accel/amd_vpci/versal-pci-main.c new file +45 -0
+}
+
+static int versal_pci_fw_init(struct versal_pci_device *vdev)
+{
+    int ret;
+
+    /* TODO request compatible fw_id from card */
+
+    ret = versal_pci_uuid_parse(vdev, &vdev->intf_uuid);
+
+    return ret;
+}
+
+static int versal_pci_device_setup(struct versal_pci_device *vdev)
+{
+    int ret;
+
+    ret = versal_pci_fw_init(vdev);
+    if (ret) {
+        vdev_err(vdev, "Failed to init fw, err %d", ret);
+        goto comm_chan_fini;
+    }
+
+    ret = versal_pci_cfs_init(vdev);
+    if (ret) {
+        vdev_err(vdev, "Failed to init configfs subsys, err %d", ret);
+        goto comm_chan_fini;
+    }
+
+    return 0;
+
+comm_chan_fini:
+    versal_pci_fw_fini(vdev);
+
+    return ret;
+}
+
+static void versal_pci_remove(struct pci_dev *pdev)
+{
+    struct versal_pci_device *vdev = pci_get_drvdata(pdev);
+
+    versal_pci_device_teardown(vdev);
+}
+
+static int versal_pci_probe(struct pci_dev *pdev, const struct 

pci_device_id *pdev_id)

drivers/accel/amd_vpci/versal-pci-main.c new file +20 -0
+{
+    struct versal_pci_device *vdev;
+    int ret;
+
+    vdev = devm_kzalloc(&pdev->dev, sizeof(*vdev), GFP_KERNEL);
+    if (!vdev)
+        return -ENOMEM;
+
+    pci_set_drvdata(pdev, vdev);
+    vdev->pdev = pdev;
+
+    ret = pcim_enable_device(pdev);
+    if (ret) {
+        vdev_err(vdev, "Failed to enable device %d", ret);
+        return ret;
+    }
+
+    vdev->io_regs = pcim_iomap_region(vdev->pdev, MGMT_BAR, DRV_NAME);
+    if (IS_ERR(vdev->io_regs)) {
+        vdev_err(vdev, "Failed to map RM shared memory BAR%d", 

MGMT_BAR);
+        return PTR_ERR(vdev->io_regs);
+    }

drivers/accel/amd_vpci/versal-pci-main.c new file +30 -0
+
+    ret = versal_pci_device_setup(vdev);
+    if (ret) {
+        vdev_err(vdev, "Failed to setup Versal device %d", ret);
+        return ret;
+    }
+
+    return 0;
+}
+
+static const struct pci_device_id versal_pci_ids[] = {
+    { PCI_DEVICE(PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_V70PQ2), },
+    { PCI_DEVICE(PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RAVE), },
+    { 0 }
+};
+
+MODULE_DEVICE_TABLE(pci, versal_pci_ids);
+
+static struct pci_driver versal_pci_driver = {
+    .name = DRV_NAME,
+    .id_table = versal_pci_ids,
+    .probe = versal_pci_probe,
+    .remove = versal_pci_remove,
+};
+
+module_pci_driver(versal_pci_driver);
+
+MODULE_DESCRIPTION("AMD Versal PCIe Management Driver");
+MODULE_AUTHOR("XRT Team <[email protected]>");
+MODULE_LICENSE("GPL");
drivers/accel/amd_vpci/versal-pci.h new file +62 -0
new file mode 100644
index 000000000000..890da1d6bcc9
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Driver for Versal PCIe device
+ *
+ * Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#ifndef __VERSAL_PCI_H
+#define __VERSAL_PCI_H
+
+#include <linux/configfs.h>
+#include <linux/firmware.h>
+
+#define MGMT_BAR        0
+
+#define vdev_info(vdev, fmt, args...)                    \
+    dev_info(&(vdev)->pdev->dev, "%s: "fmt, __func__, ##args)
+
+#define vdev_warn(vdev, fmt, args...)                    \
+    dev_warn(&(vdev)->pdev->dev, "%s: "fmt, __func__, ##args)
+
+#define vdev_err(vdev, fmt, args...)                    \
+    dev_err(&(vdev)->pdev->dev, "%s: "fmt, __func__, ##args)
+
+#define vdev_dbg(vdev, fmt, args...)                    \
+    dev_dbg(&(vdev)->pdev->dev, fmt, ##args)
+
+struct versal_pci_device;
+
+struct axlf_header {
+    __u64                length;
+    __u8                reserved1[24];
+    uuid_t                rom_uuid;
+    __u8                reserved2[64];
+    uuid_t                uuid;
+    __u8                reserved3[24];
+} __packed;
+
+struct axlf {
+    __u8                magic[8];
+    __u8                reserved[296];
+    struct axlf_header        header;
+} __packed;
+
+struct fw_info {
+    __u32                opcode;
+    char                name[128];
+};
+
+struct versal_pci_device {
+    struct pci_dev            *pdev;
+
+    struct fw_info            fw;
+
+    void __iomem            *io_regs;
+    uuid_t                intf_uuid;
+    __u8                fw_id[UUID_STRING_LEN + 1];
+
+    struct configfs_subsystem    cfs_subsys;
+};
+
+#endif    /* __VERSAL_PCI_H */
#5 lore raw

PATCH v2 3/5 accel/amd_vpci: Add Remote Management(RM) queue infrastructure

In reply to David Zhang

This patch introduces a Remote Management (RM) queue service, which provides a way to communicate between the management PCIe function (PF0) and the embedded firmware running on AMD Versal SoCs.

The RM service implements a hardware-based ring buffer for bidirectional command and response exchange between the host driver and the firmware.

This patch adds the core infrastructure for:
- Initializing and managing the RM queue
- Submitting commands to the embedded firmware
- Polling for command completion

Subsequent patches will integrate the infrastructure with the firmware management logic to enable firmware download, status query, and other control operations.

---
 drivers/accel/amd_vpci/Makefile               |   3 +-
 drivers/accel/amd_vpci/versal-pci-rm-queue.c  | 316 ++++++++++++++++++
 drivers/accel/amd_vpci/versal-pci-rm-queue.h  |  21 ++
 .../accel/amd_vpci/versal-pci-rm-service.h    | 209 ++++++++++++
 drivers/accel/amd_vpci/versal-pci.h           |   1 +
 5 files changed, 549 insertions(+), 1 deletion(-)
 create mode 100644 drivers/accel/amd_vpci/versal-pci-rm-queue.c
 create mode 100644 drivers/accel/amd_vpci/versal-pci-rm-queue.h
 create mode 100644 drivers/accel/amd_vpci/versal-pci-rm-service.h
drivers/accel/amd_vpci/Makefile +2 -1
index 03849875ad0b..9e4e56ac2dee 100644
@@ -3,4 +3,5 @@
 obj-$(CONFIG_DRM_ACCEL_AMD_VPCI) := versal-pci.o
 
 versal-pci-y := \
-	versal-pci-main.o
+	versal-pci-main.o \
+	versal-pci-rm-queue.o
drivers/accel/amd_vpci/versal-pci-rm-queue.c new file +316 -0

316 lines not on this page · raw message

drivers/accel/amd_vpci/versal-pci-rm-queue.h new file +21 -0
new file mode 100644
index 000000000000..80e587b5a12a
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Driver for Versal PCIe device
+ *
+ * Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#ifndef __RM_QUEUE_H
+#define __RM_QUEUE_H
+
+struct rm_device;
+
+/* rm queue hardware setup */
+int rm_queue_init(struct rm_device *rdev);
+void rm_queue_fini(struct rm_device *rdev);
+
+/* rm queue common API */
+int rm_queue_send_cmd(struct rm_cmd *cmd, unsigned long timeout);
+void rm_queue_withdraw_cmd(struct rm_cmd *cmd);
+
+#endif	/* __RM_QUEUE_H */
drivers/accel/amd_vpci/versal-pci-rm-service.h new file +209 -0

209 lines not on this page · raw message

drivers/accel/amd_vpci/versal-pci.h +1 -0
index 890da1d6bcc9..be69dda8da73 100644
@@ -26,6 +26,7 @@
 	dev_dbg(&(vdev)->pdev->dev, fmt, ##args)
 
 struct versal_pci_device;
+struct rm_cmd;
 
 struct axlf_header {
 	__u64				length;
Signature · 1 line
2.34.1
#6 lore raw

PATCH v2 4/5 accel/amd_vpci: Add Remote Management (RM) queue service APIs

In reply to David Zhang

This patch introduces a set of APIs for allowing the PCIe driver submit commands, transfer binary payloads and retrieve firmware metadata.

Key features:
- RM queue command APIs:
- create and destroy RM queue commands
- Initialized command data payloads
- Send and poll for command completion
- Service-level operations:
- Retrieve firmware ID
- Program accelerator and APU firmware images
- Periodic health monitoring

---
 drivers/accel/amd_vpci/Makefile               |   3 +-
 drivers/accel/amd_vpci/versal-pci-main.c      |  43 +-
 drivers/accel/amd_vpci/versal-pci-rm-queue.c  |  14 +-
 .../accel/amd_vpci/versal-pci-rm-service.c    | 497 ++++++++++++++++++
 .../accel/amd_vpci/versal-pci-rm-service.h    |  20 +
 drivers/accel/amd_vpci/versal-pci.h           |   1 +
 6 files changed, 567 insertions(+), 11 deletions(-)
 create mode 100644 drivers/accel/amd_vpci/versal-pci-rm-service.c
drivers/accel/amd_vpci/Makefile +2 -1
index 9e4e56ac2dee..bacd305783dd 100644
@@ -4,4 +4,5 @@ obj-$(CONFIG_DRM_ACCEL_AMD_VPCI) := versal-pci.o
 
 versal-pci-y := \
 	versal-pci-main.o \
-	versal-pci-rm-queue.o
+	versal-pci-rm-queue.o \
+	versal-pci-rm-service.o
drivers/accel/amd_vpci/versal-pci-main.c +41 -2

85 lines not on this page · raw message

drivers/accel/amd_vpci/versal-pci-rm-queue.c +6 -8
index eeda07065487..97e5911f18ed 100644
@@ -23,37 +23,35 @@ static inline struct rm_device *to_rdev_msg_timer(struct timer_list *t)
 
 static inline u32 rm_io_read(struct rm_device *rdev, u32 offset)
 {
-	/* TODO */
-	return 0;
+	return rm_reg_read(rdev, RM_PCI_IO_BAR_OFF + offset);
 }
 
 static inline int rm_io_write(struct rm_device *rdev, u32 offset, u32 value)
 {
-	/* TODO */
+	rm_reg_write(rdev, RM_PCI_IO_BAR_OFF + offset, value);
 	return 0;
 }
 
 static inline u32 rm_queue_read(struct rm_device *rdev, u32 offset)
 {
-	/* TODO */
-	return 0;
+	return rm_reg_read(rdev, RM_PCI_SHMEM_BAR_OFF + rdev->queue_base + offset);
 }
 
 static inline void rm_queue_write(struct rm_device *rdev, u32 offset, u32 value)
 {
-	/* TODO */
+	rm_reg_write(rdev, RM_PCI_SHMEM_BAR_OFF + rdev->queue_base + offset, value);
 }
 
 static inline void rm_queue_bulk_read(struct rm_device *rdev, u32 offset,
 				      u32 *value, u32 size)
 {
-	/* TODO */
+	rm_bulk_reg_read(rdev, RM_PCI_SHMEM_BAR_OFF + rdev->queue_base + offset, value, size);
 }
 
 static inline void rm_queue_bulk_write(struct rm_device *rdev, u32 offset,
 				       u32 *value, u32 size)
 {
-	/* TODO */
+	rm_bulk_reg_write(rdev, RM_PCI_SHMEM_BAR_OFF + rdev->queue_base + offset, value, size);
 }
 
 static inline u32 rm_queue_get_cidx(struct rm_device *rdev, enum rm_queue_type type)
drivers/accel/amd_vpci/versal-pci-rm-service.c new file +497 -0

497 lines not on this page · raw message

drivers/accel/amd_vpci/versal-pci-rm-service.h +20 -0
index a16198944e17..487c7ae2a4bc 100644
@@ -206,4 +206,24 @@ struct rm_device {
 	__u32			firewall_tripped;
 };
 
+/* rm service init api */
+struct rm_device *versal_pci_rm_init(struct versal_pci_device *vdev);
+void versal_pci_rm_fini(struct rm_device *rdev);
+
+/* rm services APIs */
+int rm_queue_create_cmd(struct rm_device *rdev, enum rm_queue_opcode opcode,
+			struct rm_cmd **cmd_ptr);
+void rm_queue_destroy_cmd(struct rm_cmd *cmd);
+
+int rm_queue_data_init(struct rm_cmd *cmd, const char *buffer, ssize_t size);
+void rm_queue_data_fini(struct rm_cmd *cmd);
+int rm_queue_get_fw_id(struct rm_device *rdev);
+int rm_queue_boot_apu(struct rm_device *rdev);
+
+/* rm bar register operation APIs */
+u32 rm_reg_read(struct rm_device *rdev, u32 offset);
+void rm_reg_write(struct rm_device *rdev, u32 offset, const u32 value);
+void rm_bulk_reg_read(struct rm_device *rdev, u32 offset, u32 *value, size_t size);
+void rm_bulk_reg_write(struct rm_device *rdev, u32 offset, const void *value, size_t size);
+
 #endif	/* __RM_SERVICE_H */
drivers/accel/amd_vpci/versal-pci.h +1 -0
index be69dda8da73..092cac6afa26 100644
@@ -51,6 +51,7 @@ struct fw_info {
 struct versal_pci_device {
 	struct pci_dev			*pdev;
 
+	struct rm_device		*rdev;
 	struct fw_info			fw;
 
 	void __iomem			*io_regs;
Signature · 1 line
2.34.1
#7 lore raw

PATCH v2 5/5 accel/amd_vpci: Add communication channel service

In reply to David Zhang

This patch introduces the communication channel (comm_chan) service, which enables communication between the management PF driver and the user PF driver.

The comm_chan service provides a shared-memory-based command channel located in a BAR-mapped region. The user PF driver issues requests by writing command messages into this region. The management PF driver periodically polls the region and process any pending requests.

Supported operations include firmware (xclbin) reloads, where the management PF invokes 'versal_pci_load_xclbin' to reprogram the embedded firmware through the remote management queue service.

This service provides the foundation for dynamic firmware updates and other management requests from the user PFs.

---
 drivers/accel/amd_vpci/Makefile               |   3 +-
 drivers/accel/amd_vpci/versal-pci-comm-chan.c | 295 ++++++++++++++++++
 drivers/accel/amd_vpci/versal-pci-comm-chan.h |  14 +
 drivers/accel/amd_vpci/versal-pci-main.c      |  82 ++++-
 drivers/accel/amd_vpci/versal-pci.h           |   6 +
 5 files changed, 396 insertions(+), 4 deletions(-)
 create mode 100644 drivers/accel/amd_vpci/versal-pci-comm-chan.c
 create mode 100644 drivers/accel/amd_vpci/versal-pci-comm-chan.h
drivers/accel/amd_vpci/Makefile +2 -1
index bacd305783dd..8adfde3490fd 100644
@@ -5,4 +5,5 @@ obj-$(CONFIG_DRM_ACCEL_AMD_VPCI) := versal-pci.o
 versal-pci-y := \
 	versal-pci-main.o \
 	versal-pci-rm-queue.o \
-	versal-pci-rm-service.o
+	versal-pci-rm-service.o \
+	versal-pci-comm-chan.o
drivers/accel/amd_vpci/versal-pci-comm-chan.c new file +295 -0

295 lines not on this page · raw message

drivers/accel/amd_vpci/versal-pci-comm-chan.h new file +14 -0
new file mode 100644
index 000000000000..a6ad3228c3ff
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Driver for Versal PCIe device
+ *
+ * Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#ifndef __VERSAL_PCI_COMM_CHAN_H
+#define __VERSAL_PCI_COMM_CHAN_H
+
+struct comm_chan_device *versal_pci_comm_chan_init(struct versal_pci_device *vdev);
+void versal_pci_comm_chan_fini(struct comm_chan_device *ccdev);
+
+#endif	/* __VERSAL_PCI_COMM_CHAN_H */
drivers/accel/amd_vpci/versal-pci-main.c +79 -3

119 lines not on this page · raw message

drivers/accel/amd_vpci/versal-pci.h +6 -0
index 092cac6afa26..ef02cefd8f48 100644
@@ -26,6 +26,7 @@
 	dev_dbg(&(vdev)->pdev->dev, fmt, ##args)
 
 struct versal_pci_device;
+struct comm_chan_device;
 struct rm_cmd;
 
 struct axlf_header {
@@ -52,13 +53,18 @@ struct versal_pci_device {
 	struct pci_dev			*pdev;
 
 	struct rm_device		*rdev;
+	struct comm_chan_device         *ccdev;
 	struct fw_info			fw;
 
 	void __iomem			*io_regs;
+	uuid_t				xclbin_uuid;
 	uuid_t				intf_uuid;
 	__u8				fw_id[UUID_STRING_LEN + 1];
 
 	struct configfs_subsystem	cfs_subsys;
 };
 
+/* versal pci driver APIs */
+int versal_pci_load_xclbin(struct versal_pci_device *vdev, uuid_t *xclbin_uuid);
+
 #endif	/* __VERSAL_PCI_H */
Signature · 1 line
2.34.1