Skip to contentSkip to conversation

Add versal-pci driver

PATCH In review Yidong Zhang 2 participants 6 messages Mar 3, 2025 – Apr 17, 2025 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

cover Add versal-pci driver

This patchset introduces a new Linux Kernel Driver, versal-pci for AMD Alevo Versal based PCIe Card.

The AMD Alevo Versal based PCIe Card, including V70 and RAVE, is the first Alevo production card leveraging AMD XDNA architecture with AI Engines. It is designed for AI inference efficiency and is tuned for video analytics and natural language processing applications [1].

This versal-pci driver provides services, including:
- leveraging linux firmware and configfs framework to download management firmware
- communicate with firmware running on the PCIe Card
- monitor device health

The driver is licensed under GPL-2.0.

The firmwares are distributed as a closed binary, delivered by AMD. Please see [1] for more information.

[1] https://www.amd.com/en/products/accelerators/alveo/v70.html

Yidong Zhang (3):
drivers/misc/amd: Add new driver amd versal-pci
drivers/misc/amd: Add remote queue service
drivers/misc/amd: Add load base shell firmware

 MAINTAINERS                              |   5 +
 drivers/misc/Kconfig                     |   1 +
 drivers/misc/Makefile                    |   1 +
 drivers/misc/amd/Kconfig                 |  15 +
 drivers/misc/amd/Makefile                |   7 +
 drivers/misc/amd/versal-pci-main.c       | 313 ++++++++++++++
 drivers/misc/amd/versal-pci-rm-queue.c   | 314 ++++++++++++++
 drivers/misc/amd/versal-pci-rm-queue.h   |  21 +
 drivers/misc/amd/versal-pci-rm-service.c | 497 +++++++++++++++++++++++
 drivers/misc/amd/versal-pci-rm-service.h | 229 +++++++++++
 drivers/misc/amd/versal-pci.h            |  64 +++
 11 files changed, 1467 insertions(+)
 create mode 100644 drivers/misc/amd/Kconfig
 create mode 100644 drivers/misc/amd/Makefile
 create mode 100644 drivers/misc/amd/versal-pci-main.c
 create mode 100644 drivers/misc/amd/versal-pci-rm-queue.c
 create mode 100644 drivers/misc/amd/versal-pci-rm-queue.h
 create mode 100644 drivers/misc/amd/versal-pci-rm-service.c
 create mode 100644 drivers/misc/amd/versal-pci-rm-service.h
 create mode 100644 drivers/misc/amd/versal-pci.h
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/3 drivers/misc/amd: Add new driver amd versal-pci

AMD Versal based PCIe card, including V70 and RAVE, is designed for AI inference efficiency and is tuned for video analytics and natural language processing applications.

The driver architecture:

  +---------+----+  Remote   +-----+------+
  |         |PCIe|  Queue    | Embedded   |
  | Mgmt PF |Bar | <=======> |   SoC      |
  |         |    |           +------------+
  +---------+----+           | base FW    |
                             +-----+------+

This driver provides the following functionalities:

- module and PCI device initialization
the driver will initialize itself based on bar resources for a hardware queue based ring buffer between PCIe bar and RTOS services VMR [1] running on Embedded SoC hardware firmware for flashing firmware and checking card healthy status.

- programming FW
The base FW is downloaded onto the flash of the card.

[1] https://github.com/Xilinx/VMR.git

---
 MAINTAINERS                        |   5 +
 drivers/misc/Kconfig               |   1 +
 drivers/misc/Makefile              |   1 +
 drivers/misc/amd/Kconfig           |  15 ++
 drivers/misc/amd/Makefile          |   5 +
 drivers/misc/amd/versal-pci-main.c | 272 +++++++++++++++++++++++++++++
 drivers/misc/amd/versal-pci.h      |  62 +++++++
 7 files changed, 361 insertions(+)
 create mode 100644 drivers/misc/amd/Kconfig
 create mode 100644 drivers/misc/amd/Makefile
 create mode 100644 drivers/misc/amd/versal-pci-main.c
 create mode 100644 drivers/misc/amd/versal-pci.h
MAINTAINERS +5 -0
index 8e0736dc2ee0..8d79e8b7e963 100644
@@ -1215,6 +1215,11 @@ L:	[email protected]
 S:	Supported
 F:	drivers/spi/spi-amd.c
 
+AMD VERSAL PCI DRIVER
+M:	Yidong Zhang <[email protected]>
+S:	Supported
+F:	drivers/misc/amd/
+
 AMD XDNA DRIVER
 M:	Min Ma <[email protected]>
 M:	Lizhi Hou <[email protected]>
drivers/misc/Kconfig +1 -0
index 56bc72c7ce4a..d1616f0fb12f 100644
@@ -649,4 +649,5 @@ source "drivers/misc/uacce/Kconfig"
 source "drivers/misc/pvpanic/Kconfig"
 source "drivers/misc/mchp_pci1xxxx/Kconfig"
 source "drivers/misc/keba/Kconfig"
+source "drivers/misc/amd/Kconfig"
 endmenu
drivers/misc/Makefile +1 -0
index 545aad06d088..230a8d6bafaf 100644
@@ -75,3 +75,4 @@ lan966x-pci-objs		:= lan966x_pci.o
 lan966x-pci-objs		+= lan966x_pci.dtbo.o
 obj-$(CONFIG_MCHP_LAN966X_PCI)	+= lan966x-pci.o
 obj-y				+= keba/
+obj-$(CONFIG_AMD_VERSAL_PCI)	+= amd/
drivers/misc/amd/Kconfig new file +15 -0
new file mode 100644
index 000000000000..8b1a9bd0d150
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config AMD_VERSAL_PCI
+	tristate "AMD Versal PCIe Management Driver"
+	select FW_LOADER
+	select CONFIGFS_FS
+	depends on HAS_IOMEM
+	depends on PCI
+	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/misc/amd/Makefile new file +5 -0
new file mode 100644
index 000000000000..e3868cb39563
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_AMD_VERSAL_PCI)		+= versal-pci.o
+
+versal-pci-$(CONFIG_AMD_VERSAL_PCI)	:= versal-pci-main.o
drivers/misc/amd/versal-pci-main.c new file +272 -0

272 lines not on this page · raw message

drivers/misc/amd/versal-pci.h new file +62 -0

62 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/3 drivers/misc/amd: Add remote queue service

In reply to Yidong Zhang

The remote queue is a hardware queue based ring buffer service between mgmt PF and firmware for data and message transfer.

---
 drivers/misc/amd/Makefile                |   3 +-
 drivers/misc/amd/versal-pci-rm-queue.c   | 316 +++++++++++++++++++++++
 drivers/misc/amd/versal-pci-rm-queue.h   |  21 ++
 drivers/misc/amd/versal-pci-rm-service.h | 209 +++++++++++++++
 drivers/misc/amd/versal-pci.h            |   1 +
 5 files changed, 549 insertions(+), 1 deletion(-)
 create mode 100644 drivers/misc/amd/versal-pci-rm-queue.c
 create mode 100644 drivers/misc/amd/versal-pci-rm-queue.h
 create mode 100644 drivers/misc/amd/versal-pci-rm-service.h
drivers/misc/amd/Makefile +2 -1
index e3868cb39563..63879800a3e5 100644
@@ -2,4 +2,5 @@
 
 obj-$(CONFIG_AMD_VERSAL_PCI)		+= versal-pci.o
 
-versal-pci-$(CONFIG_AMD_VERSAL_PCI)	:= versal-pci-main.o
+versal-pci-$(CONFIG_AMD_VERSAL_PCI)	:= versal-pci-main.o \
+					   versal-pci-rm-queue.o
drivers/misc/amd/versal-pci-rm-queue.c new file +316 -0

316 lines not on this page · raw message

drivers/misc/amd/versal-pci-rm-queue.h new file +21 -0
new file mode 100644
index 000000000000..d5d991704d5c
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Driver for Versal PCIe device
+ *
+ * Copyright (C) 2025 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/misc/amd/versal-pci-rm-service.h new file +209 -0

209 lines not on this page · raw message

drivers/misc/amd/versal-pci.h +1 -0
index ca309aee87ad..33f0ef881a33 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
#3 lore raw

PATCH 3/3 drivers/misc/amd: Add load base shell firmware

In reply to Yidong Zhang

- programming FW
- The base FW is downloaded onto the flash of the card.
- The APU FW is downloaded once after a POR (power on reset).
- Reloading the driver will not change any existing hardware.

---
 drivers/misc/amd/Makefile                |   3 +-
 drivers/misc/amd/versal-pci-main.c       |  45 +-
 drivers/misc/amd/versal-pci-rm-queue.c   |  14 +-
 drivers/misc/amd/versal-pci-rm-service.c | 497 +++++++++++++++++++++++
 drivers/misc/amd/versal-pci-rm-service.h |  20 +
 drivers/misc/amd/versal-pci.h            |   1 +
 6 files changed, 569 insertions(+), 11 deletions(-)
 create mode 100644 drivers/misc/amd/versal-pci-rm-service.c
drivers/misc/amd/Makefile +2 -1
index 63879800a3e5..03394b06fd33 100644
@@ -3,4 +3,5 @@
 obj-$(CONFIG_AMD_VERSAL_PCI)		+= versal-pci.o
 
 versal-pci-$(CONFIG_AMD_VERSAL_PCI)	:= versal-pci-main.o \
-					   versal-pci-rm-queue.o
+					   versal-pci-rm-queue.o \
+					   versal-pci-rm-service.o
drivers/misc/amd/versal-pci-main.c +43 -2

87 lines not on this page · raw message

drivers/misc/amd/versal-pci-rm-queue.c +6 -8
index 8c1aca442253..7afc5a1e238c 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/misc/amd/versal-pci-rm-service.c new file +497 -0

497 lines not on this page · raw message

drivers/misc/amd/versal-pci-rm-service.h +20 -0
index d2397a1a672c..57333bb1443c 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/misc/amd/versal-pci.h +1 -0
index 33f0ef881a33..89f3590137ce 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
maintainer
#4 lore raw
In reply to Yidong Zhang
Quoted 7 lines · Yidong Zhang

This patchset introduces a new Linux Kernel Driver, versal-pci for AMD Alevo Versal based PCIe Card.

The AMD Alevo Versal based PCIe Card, including V70 and RAVE, is the first Alevo production card leveraging AMD XDNA architecture with AI Engines. It is designed for AI inference efficiency and is tuned for video analytics and natural language processing applications [1].

accelerator drivers should be under drivers/accel/, please work with the maintainers there to get it reviewed properly in that location.

thanks,

greg k-h

#5 lore raw
Quoted 7 lines · Greg KH

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 3 lines · Yidong Zhang

This patchset introduces a new Linux Kernel Driver, versal-pci for AMD Alevo Versal based PCIe Card.

Quoted 7 lines
Quoted 4 lines

The AMD Alevo Versal based PCIe Card, including V70 and RAVE, is the first Alevo production card leveraging AMD XDNA architecture with AI Engines. It is designed for AI inference efficiency and is tuned for video analytics and natural language processing applications [1].

accelerator drivers should be under drivers/accel/, please work with the maintainers there to get it reviewed properly in that location.

Hi Greg,

We will work with drivers/accel community and send updated patches to them for further review.

Thank you so much for taking your time guiding us the right direction.

Thanks,
David

Quoted 4 lines

thanks,

greg k-h