Skip to contentSkip to conversation

Xilinx PCIe accelerator driver

RFC PATCH In review [email protected] 7 participants 20 messages Mar 19, 2019 – Apr 5, 2019

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

cover Xilinx PCIe accelerator driver

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise customers.

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two physical functions: management physical function and user physical function.

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different workloads.

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:

1.  ICAP programming (FPGA bitstream download with FPGA Mgr integration)
2.  Clock scaling
3.  Loading firmware container also called dsabin (embedded Microblaze
    firmware for ERT and XMC, optional clearing bitstream)
4.  In-band sensors: temp, voltage, power, etc.
5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical functions

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:

1.  Device memory topology discovery and memory management
2.  Buffer object abstraction and management for client process
3.  XDMA MM PCIe DMA engine programming
4.  Multi-process aware context management
5.  Compute unit execution management (optionally with help of ERT) for

client processes
6. Hardware mailbox for communication between two physical functions

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and export/import. xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects and provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at
https://github.com/Xilinx/XRT

Thanks,
-Sonal

Sonal Santan (6):
Add skeleton code: ioctl definitions and build hooks Global data structures shared between xocl and xmgmt drivers Add platform drivers for various IPs and frameworks Add core of XDMA driver
Add management driver
Add user physical function driver

 drivers/gpu/drm/Kconfig                    |    2 +
 drivers/gpu/drm/Makefile                   |    1 +
 drivers/gpu/drm/xocl/Kconfig               |   22 +
 drivers/gpu/drm/xocl/Makefile              |    3 +
 drivers/gpu/drm/xocl/devices.h             |  954 +++++
 drivers/gpu/drm/xocl/ert.h                 |  385 ++
 drivers/gpu/drm/xocl/lib/Makefile.in       |   16 +
 drivers/gpu/drm/xocl/lib/cdev_sgdma.h      |   63 +
 drivers/gpu/drm/xocl/lib/libxdma.c         | 4368 ++++++++++++++++++++
 drivers/gpu/drm/xocl/lib/libxdma.h         |  596 +++
 drivers/gpu/drm/xocl/lib/libxdma_api.h     |  127 +
 drivers/gpu/drm/xocl/mgmtpf/Makefile       |   29 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c    |  960 +++++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h    |  147 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c      |   30 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c   |  148 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h     |  244 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c   |  318 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c   |  399 ++
 drivers/gpu/drm/xocl/subdev/dna.c          |  356 ++
 drivers/gpu/drm/xocl/subdev/feature_rom.c  |  412 ++
 drivers/gpu/drm/xocl/subdev/firewall.c     |  389 ++
 drivers/gpu/drm/xocl/subdev/fmgr.c         |  198 +
 drivers/gpu/drm/xocl/subdev/icap.c         | 2859 +++++++++++++
 drivers/gpu/drm/xocl/subdev/mailbox.c      | 1868 +++++++++
 drivers/gpu/drm/xocl/subdev/mb_scheduler.c | 3059 ++++++++++++++
 drivers/gpu/drm/xocl/subdev/microblaze.c   |  722 ++++
 drivers/gpu/drm/xocl/subdev/mig.c          |  256 ++
 drivers/gpu/drm/xocl/subdev/sysmon.c       |  385 ++
 drivers/gpu/drm/xocl/subdev/xdma.c         |  510 +++
 drivers/gpu/drm/xocl/subdev/xmc.c          | 1480 +++++++
 drivers/gpu/drm/xocl/subdev/xvc.c          |  461 +++
 drivers/gpu/drm/xocl/userpf/Makefile       |   27 +
 drivers/gpu/drm/xocl/userpf/common.h       |  157 +
 drivers/gpu/drm/xocl/userpf/xocl_bo.c      | 1255 ++++++
 drivers/gpu/drm/xocl/userpf/xocl_bo.h      |  119 +
 drivers/gpu/drm/xocl/userpf/xocl_drm.c     |  640 +++
 drivers/gpu/drm/xocl/userpf/xocl_drv.c     |  743 ++++
 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c   |  396 ++
 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c   |  344 ++
 drivers/gpu/drm/xocl/version.h             |   22 +
 drivers/gpu/drm/xocl/xclbin.h              |  314 ++
 drivers/gpu/drm/xocl/xclfeatures.h         |  107 +
 drivers/gpu/drm/xocl/xocl_ctx.c            |  196 +
 drivers/gpu/drm/xocl/xocl_drm.h            |   91 +
 drivers/gpu/drm/xocl/xocl_drv.h            |  783 ++++
 drivers/gpu/drm/xocl/xocl_subdev.c         |  540 +++
 drivers/gpu/drm/xocl/xocl_thread.c         |   64 +
 include/uapi/drm/xmgmt_drm.h               |  204 +
 include/uapi/drm/xocl_drm.h                |  483 +++
 50 files changed, 28252 insertions(+)
 create mode 100644 drivers/gpu/drm/xocl/Kconfig
 create mode 100644 drivers/gpu/drm/xocl/Makefile
 create mode 100644 drivers/gpu/drm/xocl/devices.h
 create mode 100644 drivers/gpu/drm/xocl/ert.h
 create mode 100644 drivers/gpu/drm/xocl/lib/Makefile.in
 create mode 100644 drivers/gpu/drm/xocl/lib/cdev_sgdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.c
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma_api.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/dna.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/feature_rom.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/firewall.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/fmgr.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/icap.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mailbox.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mb_scheduler.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/microblaze.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mig.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/sysmon.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xdma.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xmc.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xvc.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/userpf/common.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drm.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drv.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/version.h
 create mode 100644 drivers/gpu/drm/xocl/xclbin.h
 create mode 100644 drivers/gpu/drm/xocl/xclfeatures.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_ctx.c
 create mode 100644 drivers/gpu/drm/xocl/xocl_drm.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_drv.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_subdev.c
 create mode 100644 drivers/gpu/drm/xocl/xocl_thread.c
 create mode 100644 include/uapi/drm/xmgmt_drm.h
 create mode 100644 include/uapi/drm/xocl_drm.h

--
2.17.0

#1 lore raw

RFC PATCH 1/6 Add skeleton code: ioctl definitions and build hooks

From: Sonal Santan <[email protected]>

---
 drivers/gpu/drm/Kconfig              |   2 +
 drivers/gpu/drm/Makefile             |   1 +
 drivers/gpu/drm/xocl/Kconfig         |  22 ++
 drivers/gpu/drm/xocl/Makefile        |   3 +
 drivers/gpu/drm/xocl/mgmtpf/Makefile |  29 ++
 drivers/gpu/drm/xocl/userpf/Makefile |  27 ++
 include/uapi/drm/xmgmt_drm.h         | 204 +++++++++++
 include/uapi/drm/xocl_drm.h          | 483 +++++++++++++++++++++++++++
 8 files changed, 771 insertions(+)
 create mode 100644 drivers/gpu/drm/xocl/Kconfig
 create mode 100644 drivers/gpu/drm/xocl/Makefile
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/userpf/Makefile
 create mode 100644 include/uapi/drm/xmgmt_drm.h
 create mode 100644 include/uapi/drm/xocl_drm.h
drivers/gpu/drm/Kconfig +2 -0
index bd943a71756c..cc3785b1ae3d 100644
@@ -329,6 +329,8 @@ source "drivers/gpu/drm/tve200/Kconfig"
 
 source "drivers/gpu/drm/xen/Kconfig"
 
+source "drivers/gpu/drm/xocl/Kconfig"
+
 # Keep legacy drivers last
 
 menuconfig DRM_LEGACY
drivers/gpu/drm/Makefile +1 -0
index 1ac55c65eac0..ebebaba2bf3d 100644
@@ -109,3 +109,4 @@ obj-$(CONFIG_DRM_TINYDRM) += tinydrm/
 obj-$(CONFIG_DRM_PL111) += pl111/
 obj-$(CONFIG_DRM_TVE200) += tve200/
 obj-$(CONFIG_DRM_XEN) += xen/
+obj-$(CONFIG_DRM_XOCL) += xocl/
drivers/gpu/drm/xocl/Kconfig new file +22 -0
new file mode 100644
index 000000000000..197d36250b7c
@@ -0,0 +1,22 @@
+#
+# Xilinx Alveo and FaaS platform drivers
+#
+
+config DRM_XOCL
+	tristate "DRM Support for Xilinx PCIe Accelerator Alveo and FaaS platforms (EXPERIMENTAL)"
+	depends on DRM
+	depends on PCI
+	default n
+	help
+	  Choose this option if you have a Xilinx PCIe Accelerator
+	  card like Alveo or FaaS environments like AWS F1
+
+
+config DRM_XMGMT
+	tristate "DRM Support for Xilinx PCIe Accelerator Alveo and FaaS platforms (EXPERIMENTAL)"
+	depends on PCI
+	depends on FPGA
+	default n
+	help
+	  Choose this option if you have a Xilinx PCIe Accelerator
+	  card like Alveo
drivers/gpu/drm/xocl/Makefile new file +3 -0
new file mode 100644
index 000000000000..605459ab7de6
@@ -0,0 +1,3 @@
+
+obj-$(CONFIG_DRM_XOCL) += userpf/
+obj-$(CONFIG_DRM_XMGMT) += mgmtpf/
drivers/gpu/drm/xocl/mgmtpf/Makefile new file +29 -0
new file mode 100644
index 000000000000..569b7dc01866
@@ -0,0 +1,29 @@
+obj-m	+= xmgmt.o
+
+xmgmt-y := \
+	../xocl_subdev.o \
+	../xocl_ctx.o \
+	../xocl_thread.o \
+	../subdev/sysmon.o \
+	../subdev/feature_rom.o \
+	../subdev/microblaze.o \
+	../subdev/firewall.o \
+	../subdev/xvc.o \
+	../subdev/mailbox.o \
+	../subdev/icap.o \
+	../subdev/mig.o \
+	../subdev/xmc.o \
+	../subdev/dna.o \
+	../subdev/fmgr.o \
+	mgmt-core.o \
+	mgmt-cw.o \
+	mgmt-utils.o \
+	mgmt-ioctl.o \
+	mgmt-sysfs.o
+
+
+
+ccflags-y += -DSUBDEV_SUFFIX=MGMT_SUFFIX
+ifeq ($(DEBUG),1)
+ccflags-y += -DDEBUG
+endif
drivers/gpu/drm/xocl/userpf/Makefile new file +27 -0
new file mode 100644
index 000000000000..ff895d2b2e68
@@ -0,0 +1,27 @@
+obj-$(CONFIG_DRM_XOCL)	+= xocl.o
+
+include $(src)/../lib/Makefile.in
+
+xocl-y := \
+	../xocl_subdev.o \
+	../xocl_ctx.o \
+	../xocl_thread.o \
+	../subdev/xdma.o \
+	../subdev/feature_rom.o \
+	../subdev/mb_scheduler.o \
+	../subdev/mailbox.o \
+	../subdev/xvc.o \
+	../subdev/icap.o \
+	../subdev/xmc.o \
+	$(xocl_lib-y)	\
+	xocl_drv.o	\
+	xocl_bo.o	\
+	xocl_drm.o	\
+	xocl_ioctl.o	\
+	xocl_sysfs.o
+
+
+ccflags-y += -DSUBDEV_SUFFIX=USER_SUFFIX
+ifeq ($(DEBUG),1)
+ccflags-y += -DDEBUG
+endif
include/uapi/drm/xmgmt_drm.h new file +204 -0

204 lines not on this page · raw message

include/uapi/drm/xocl_drm.h new file +483 -0

483 lines not on this page · raw message

Signature · 1 line
2.17.0
#2 lore raw

RFC PATCH 2/6 Global data structures shared between xocl and xmgmt drivers

In reply to [email protected]

From: Sonal Santan <[email protected]>

---
 drivers/gpu/drm/xocl/devices.h     | 954 +++++++++++++++++++++++++++++
 drivers/gpu/drm/xocl/ert.h         | 385 ++++++++++++
 drivers/gpu/drm/xocl/version.h     |  22 +
 drivers/gpu/drm/xocl/xclbin.h      | 314 ++++++++++
 drivers/gpu/drm/xocl/xclfeatures.h | 107 ++++
 drivers/gpu/drm/xocl/xocl_ctx.c    | 196 ++++++
 drivers/gpu/drm/xocl/xocl_drm.h    |  91 +++
 drivers/gpu/drm/xocl/xocl_drv.h    | 783 +++++++++++++++++++++++
 drivers/gpu/drm/xocl/xocl_subdev.c | 540 ++++++++++++++++
 drivers/gpu/drm/xocl/xocl_thread.c |  64 ++
 10 files changed, 3456 insertions(+)
 create mode 100644 drivers/gpu/drm/xocl/devices.h
 create mode 100644 drivers/gpu/drm/xocl/ert.h
 create mode 100644 drivers/gpu/drm/xocl/version.h
 create mode 100644 drivers/gpu/drm/xocl/xclbin.h
 create mode 100644 drivers/gpu/drm/xocl/xclfeatures.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_ctx.c
 create mode 100644 drivers/gpu/drm/xocl/xocl_drm.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_drv.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_subdev.c
 create mode 100644 drivers/gpu/drm/xocl/xocl_thread.c
drivers/gpu/drm/xocl/devices.h new file +954 -0
new file mode 100644
index 000000000000..3fc6f8ea6c9b
@@ -0,0 +1,954 @@
+/* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 */
+
+
+/*
+ *  Copyright (C) 2018-2019, Xilinx Inc
+ *
+ */
+
+
+#ifndef	_XCL_DEVICES_H_
+#define	_XCL_DEVICES_H_
+
+/* board flags */
+enum {
+	XOCL_DSAFLAG_PCI_RESET_OFF =		0x01,
+	XOCL_DSAFLAG_MB_SCHE_OFF =		0x02,
+	XOCL_DSAFLAG_AXILITE_FLUSH =		0x04,
+	XOCL_DSAFLAG_SET_DSA_VER =		0x08,
+	XOCL_DSAFLAG_SET_XPR =			0x10,
+	XOCL_DSAFLAG_MFG =			0x20,
+};
+
+#define	FLASH_TYPE_SPI	"spi"
+#define	FLASH_TYPE_QSPIPS	"qspi_ps"
+
+struct xocl_subdev_info {
+	uint32_t		id;
+	char			*name;
+	struct resource		*res;
+	int			num_res;
+	void			*priv_data;
+	int			data_len;
+};
+
+struct xocl_board_private {
+	uint64_t		flags;
+	struct xocl_subdev_info	*subdev_info;
+	uint32_t		subdev_num;
+	uint32_t		dsa_ver;
+	bool			xpr;
+	char			*flash_type; /* used by xbflash */
+	char			*board_name; /* used by xbflash */
+	bool			mpsoc;
+};
+
+#ifdef __KERNEL__
+#define XOCL_PCI_DEVID(ven, dev, subsysid, priv)		\
+	.vendor = ven, .device = dev, .subvendor = PCI_ANY_ID,	\
+	.subdevice = subsysid, .driver_data =			\
+	(kernel_ulong_t) &XOCL_BOARD_##priv
+
+struct xocl_dsa_vbnv_map {
+	uint16_t		vendor;
+	uint16_t		device;
+	uint16_t		subdevice;
+	char			*vbnv;
+	struct xocl_board_private	*priv_data;
+};
+
+#else
+struct xocl_board_info {
+	uint16_t		vendor;
+	uint16_t		device;
+	uint16_t		subdevice;
+	struct xocl_board_private	*priv_data;
+};
+
+#define XOCL_PCI_DEVID(ven, dev, subsysid, priv)        \
+	.vendor = ven, .device = dev,			\
+	.subdevice = subsysid, .priv_data = &XOCL_BOARD_##priv
+
+struct resource {
+	size_t		start;
+	size_t		end;
+	unsigned long	flags;
+};
+
+enum {
+	IORESOURCE_MEM,
+	IORESOURCE_IRQ,
+};
+
+#define	PCI_ANY_ID	-1
+#define SUBDEV_SUFFIX
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
+
+#endif
+
+#define	MGMT_SUFFIX		".m"
+#define	USER_SUFFIX		".u"
+
+#define	XOCL_FEATURE_ROM_USER	"rom" USER_SUFFIX
+#define XOCL_FEATURE_ROM	"rom" SUBDEV_SUFFIX
+#define XOCL_XDMA		"xdma" SUBDEV_SUFFIX
+#define XOCL_QDMA		"qdma" SUBDEV_SUFFIX
+#define XOCL_MB_SCHEDULER	"mb_scheduler" SUBDEV_SUFFIX
+#define XOCL_XVC_PUB		"xvc_pub" SUBDEV_SUFFIX
+#define XOCL_XVC_PRI		"xvc_pri" SUBDEV_SUFFIX
+#define XOCL_SYSMON		"sysmon" SUBDEV_SUFFIX
+#define XOCL_FIREWALL		"firewall" SUBDEV_SUFFIX
+#define	XOCL_MB			"microblaze" SUBDEV_SUFFIX
+#define	XOCL_XIIC		"xiic" SUBDEV_SUFFIX
+#define	XOCL_MAILBOX		"mailbox" SUBDEV_SUFFIX
+#define	XOCL_ICAP		"icap" SUBDEV_SUFFIX
+#define	XOCL_MIG		"mig" SUBDEV_SUFFIX
+#define	XOCL_XMC		"xmc" SUBDEV_SUFFIX
+#define	XOCL_DNA		"dna" SUBDEV_SUFFIX
+#define	XOCL_FMGR		"fmgr" SUBDEV_SUFFIX
+
+enum subdev_id {
+	XOCL_SUBDEV_FEATURE_ROM,
+	XOCL_SUBDEV_DMA,
+	XOCL_SUBDEV_MB_SCHEDULER,
+	XOCL_SUBDEV_XVC_PUB,
+	XOCL_SUBDEV_XVC_PRI,
+	XOCL_SUBDEV_SYSMON,
+	XOCL_SUBDEV_AF,
+	XOCL_SUBDEV_MIG,
+	XOCL_SUBDEV_MB,
+	XOCL_SUBDEV_XIIC,
+	XOCL_SUBDEV_MAILBOX,
+	XOCL_SUBDEV_ICAP,
+	XOCL_SUBDEV_XMC,
+	XOCL_SUBDEV_DNA,
+	XOCL_SUBDEV_FMGR,
+	XOCL_SUBDEV_NUM
+};
+
+#define	XOCL_RES_FEATURE_ROM				\
+		((struct resource []) {			\
+			{				\
+			.start	= 0xB0000,		\
+			.end	= 0xB0FFF,		\
+			.flags	= IORESOURCE_MEM,	\
+			}				\
+		})
+
+
+#define	XOCL_DEVINFO_FEATURE_ROM			\
+	{						\
+		XOCL_SUBDEV_FEATURE_ROM,		\
+		XOCL_FEATURE_ROM,			\
+		XOCL_RES_FEATURE_ROM,			\
+		ARRAY_SIZE(XOCL_RES_FEATURE_ROM),	\
+	}
+
+#define	XOCL_RES_SYSMON					\
+		((struct resource []) {			\
+			{				\
+			.start	= 0xA0000,		\
+			.end	= 0xAFFFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			}				\
+		})
+
+#define	XOCL_DEVINFO_SYSMON				\
+	{						\
+		XOCL_SUBDEV_SYSMON,			\
+		XOCL_SYSMON,				\
+		XOCL_RES_SYSMON,			\
+		ARRAY_SIZE(XOCL_RES_SYSMON),		\
+	}
+
+/* Will be populated dynamically */
+#define	XOCL_RES_MIG					\
+		((struct resource []) {			\
+			{				\
+			.start	= 0x0,			\
+			.end	= 0x3FF,		\
+			.flags  = IORESOURCE_MEM,	\
+			}				\
+		})
+
+#define	XOCL_DEVINFO_MIG				\
+	{						\
+		XOCL_SUBDEV_MIG,			\
+		XOCL_MIG,				\
+		XOCL_RES_MIG,				\
+		ARRAY_SIZE(XOCL_RES_MIG),		\
+	}
+
+
+#define	XOCL_RES_AF					\
+		((struct resource []) {			\
+			{				\
+			.start	= 0xD0000,		\
+			.end	= 0xDFFFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0xE0000,		\
+			.end	= 0xEFFFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0xF0000,		\
+			.end	= 0xFFFFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0x330000,		\
+			.end	= 0x330FFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+		})
+
+#define	XOCL_DEVINFO_AF					\
+	{						\
+		XOCL_SUBDEV_AF,				\
+		XOCL_FIREWALL,				\
+		XOCL_RES_AF,				\
+		ARRAY_SIZE(XOCL_RES_AF),		\
+	}
+
+#define	XOCL_RES_AF_DSA52				\
+		((struct resource []) {			\
+			{				\
+			.start	= 0xD0000,		\
+			.end	= 0xDFFFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0xE0000,		\
+			.end	= 0xE0FFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0xE1000,		\
+			.end	= 0xE1FFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0xF0000,		\
+			.end	= 0xFFFFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0x330000,		\
+			.end	= 0x330FFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+		})
+
+#define	XOCL_DEVINFO_AF_DSA52				\
+	{						\
+		XOCL_SUBDEV_AF,				\
+		XOCL_FIREWALL,				\
+		XOCL_RES_AF_DSA52,			\
+		ARRAY_SIZE(XOCL_RES_AF_DSA52),		\
+	}
+
+#define	XOCL_RES_XVC_PUB				\
+	((struct resource []) {				\
+		{					\
+			.start	= 0xC0000,		\
+			.end	= 0xCFFFF,		\
+			.flags	= IORESOURCE_MEM,	\
+		},					\
+	})
+
+#define	XOCL_DEVINFO_XVC_PUB				\
+	{						\
+		XOCL_SUBDEV_XVC_PUB,			\
+		XOCL_XVC_PUB,				\
+		XOCL_RES_XVC_PUB,			\
+		ARRAY_SIZE(XOCL_RES_XVC_PUB),		\
+	}
+
+#define	XOCL_RES_XVC_PRI				\
+	((struct resource []) {				\
+		{					\
+			.start	= 0x1C0000,		\
+			.end	= 0x1CFFFF,		\
+			.flags	= IORESOURCE_MEM,	\
+		},					\
+	})
+
+#define	XOCL_DEVINFO_XVC_PRI				\
+	{						\
+		XOCL_SUBDEV_XVC_PRI,			\
+		XOCL_XVC_PRI,				\
+		XOCL_RES_XVC_PRI,			\
+		ARRAY_SIZE(XOCL_RES_XVC_PRI),		\
+	}
+
+#define	XOCL_RES_XIIC					\
+	((struct resource []) {				\
+		{					\
+			.start	= 0x41000,		\
+			.end	= 0x41FFF,		\
+			.flags  = IORESOURCE_MEM,	\
+		},					\
+	})
+
+#define	XOCL_DEVINFO_XIIC				\
+	{						\
+		XOCL_SUBDEV_XIIC,			\
+		XOCL_XIIC,				\
+		XOCL_RES_XIIC,				\
+		ARRAY_SIZE(XOCL_RES_XIIC),		\
+	}
+
+
+/* Will be populated dynamically */
+#define	XOCL_RES_DNA					\
+	((struct resource []) {				\
+		{					\
+			.start	= 0x0,			\
+			.end	= 0xFFF,		\
+			.flags  = IORESOURCE_MEM,	\
+		}					\
+	})
+
+#define	XOCL_DEVINFO_DNA				\
+	{						\
+		XOCL_SUBDEV_DNA,			\
+		XOCL_DNA,				\
+		XOCL_RES_DNA,				\
+		ARRAY_SIZE(XOCL_RES_DNA),		\
+	}
+
+#define	XOCL_MAILBOX_OFFSET_MGMT	0x210000
+#define	XOCL_RES_MAILBOX_MGMT				\
+	((struct resource []) {				\
+		{					\
+			.start	= XOCL_MAILBOX_OFFSET_MGMT, \
+			.end	= 0x21002F,		\
+			.flags  = IORESOURCE_MEM,	\
+		},					\
+		{					\
+			.start	= 11,			\
+			.end	= 11,			\
+			.flags  = IORESOURCE_IRQ,	\
+		},					\
+	})
+
+#define	XOCL_DEVINFO_MAILBOX_MGMT			\
+	{						\
+		XOCL_SUBDEV_MAILBOX,			\
+		XOCL_MAILBOX,				\
+		XOCL_RES_MAILBOX_MGMT,			\
+		ARRAY_SIZE(XOCL_RES_MAILBOX_MGMT),	\
+	}
+
+#define	XOCL_MAILBOX_OFFSET_USER	0x200000
+#define	XOCL_RES_MAILBOX_USER				\
+	((struct resource []) {				\
+		{					\
+			.start	= XOCL_MAILBOX_OFFSET_USER, \
+			.end	= 0x20002F,		\
+			.flags  = IORESOURCE_MEM,	\
+		},					\
+		{					\
+			.start	= 4,			\
+			.end	= 4,			\
+			.flags  = IORESOURCE_IRQ,	\
+		},					\
+	})
+
+#define	XOCL_DEVINFO_MAILBOX_USER			\
+	{						\
+		XOCL_SUBDEV_MAILBOX,			\
+		XOCL_MAILBOX,				\
+		XOCL_RES_MAILBOX_USER,			\
+		ARRAY_SIZE(XOCL_RES_MAILBOX_USER),	\
+	}
+
+#define	XOCL_RES_ICAP_MGMT				\
+	((struct resource []) {				\
+		/* HWICAP registers */			\
+		{					\
+			.start	= 0x020000,		\
+			.end	= 0x020119,		\
+			.flags  = IORESOURCE_MEM,	\
+		},					\
+		/* GENERAL_STATUS_BASE */		\
+		{					\
+			.start	= 0x032000,		\
+			.end	= 0x032003,		\
+			.flags  = IORESOURCE_MEM,	\
+		},					\
+		/* AXI Gate registers */		\
+		{					\
+			.start	= 0x030000,		\
+			.end	= 0x03000b,		\
+			.flags  = IORESOURCE_MEM,	\
+		},					\
+		/* OCL_CLKWIZ0_BASE */			\
+		{					\
+			.start	= 0x050000,		\
+			.end	= 0x050fff,		\
+			.flags  = IORESOURCE_MEM,	\
+		},					\
+		/* OCL_CLKWIZ1_BASE */			\
+		{					\
+			.start	= 0x051000,		\
+			.end	= 0x051fff,		\
+			.flags  = IORESOURCE_MEM,	\
+		},					\
+		/* OCL_CLKFREQ_BASE */			\
+		{					\
+			.start	= 0x052000,		\
+			.end	= 0x052fff,		\
+			.flags  = IORESOURCE_MEM,	\
+		},					\
+	})
+
+#define	XOCL_DEVINFO_ICAP_MGMT				\
+	{						\
+		XOCL_SUBDEV_ICAP,			\
+		XOCL_ICAP,				\
+		XOCL_RES_ICAP_MGMT,			\
+		ARRAY_SIZE(XOCL_RES_ICAP_MGMT),		\
+	}
+
+#define	XOCL_DEVINFO_ICAP_USER				\
+	{						\
+		XOCL_SUBDEV_ICAP,			\
+		XOCL_ICAP,				\
+		NULL,					\
+		0,					\
+	}
+
+#define	XOCL_RES_XMC					\
+		((struct resource []) {			\
+			{				\
+			.start	= 0x120000,		\
+			.end	= 0x121FFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0x131000,		\
+			.end	= 0x131FFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0x140000,		\
+			.end	= 0x15FFFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0x160000,		\
+			.end	= 0x17FFFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0x190000,		\
+			.end	= 0x19FFFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+		})
+
+#define	XOCL_DEVINFO_XMC					\
+	{						\
+		XOCL_SUBDEV_XMC,				\
+		XOCL_XMC,				\
+		XOCL_RES_XMC,				\
+		ARRAY_SIZE(XOCL_RES_XMC),		\
+	}
+
+#define	XOCL_DEVINFO_XMC_USER			\
+	{						\
+		XOCL_SUBDEV_XMC,				\
+		XOCL_XMC,				\
+		NULL,					\
+		0,					\
+	}
+
+#define	XOCL_RES_MB					\
+		((struct resource []) {			\
+			{				\
+			.start	= 0x120000,		\
+			.end	= 0x121FFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0x131000,		\
+			.end	= 0x131FFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0x140000,		\
+			.end	= 0x15FFFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+			{				\
+			.start	= 0x160000,		\
+			.end	= 0x17FFFF,		\
+			.flags  = IORESOURCE_MEM,	\
+			},				\
+		})
+
+#define	XOCL_DEVINFO_MB					\
+	{						\
+		XOCL_SUBDEV_MB,				\
+		XOCL_MB,				\
+		XOCL_RES_MB,				\
+		ARRAY_SIZE(XOCL_RES_MB),		\
+	}
+
+#define	XOCL_DEVINFO_QDMA				\
+	{						\
+		XOCL_SUBDEV_DMA,			\
+		XOCL_QDMA,				\
+		NULL,					\
+		0,					\
+	}
+
+#define	XOCL_DEVINFO_XDMA				\
+	{						\
+		XOCL_SUBDEV_DMA,			\
+		XOCL_XDMA,				\
+		NULL,					\
+		0,					\
+	}
+
+#define XOCL_RES_SCHEDULER				\
+	((struct resource []) {				\
+		{					\
+			.start  = 0,			\
+			.end    = 3,			\
+			.flags  = IORESOURCE_IRQ,	\
+		}					\
+	})
+
+
+#define	XOCL_DEVINFO_SCHEDULER				\
+	{						\
+		XOCL_SUBDEV_MB_SCHEDULER,		\
+		XOCL_MB_SCHEDULER,			\
+		XOCL_RES_SCHEDULER,			\
+		ARRAY_SIZE(XOCL_RES_SCHEDULER),		\
+	}
+
+#define	XOCL_DEVINFO_FMGR				\
+	{						\
+		XOCL_SUBDEV_FMGR,			\
+		XOCL_FMGR,				\
+		NULL,					\
+		0,					\
+	}
+
+
+/* user pf defines */
+#define	USER_RES_QDMA							\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_QDMA,				\
+			XOCL_DEVINFO_SCHEDULER,				\
+			XOCL_DEVINFO_XVC_PUB,				\
+			XOCL_DEVINFO_ICAP_USER,				\
+		})
+
+#define	XOCL_BOARD_USER_QDMA						\
+	(struct xocl_board_private){					\
+		.flags		= XOCL_DSAFLAG_MB_SCHE_OFF,		\
+		.subdev_info	= USER_RES_QDMA,			\
+		.subdev_num = ARRAY_SIZE(USER_RES_QDMA),		\
+	}
+
+#define	USER_RES_XDMA_DSA50						\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_XDMA,				\
+			XOCL_DEVINFO_SCHEDULER,				\
+			XOCL_DEVINFO_ICAP_USER,				\
+		})
+
+#define	USER_RES_XDMA							\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_XDMA,				\
+			XOCL_DEVINFO_SCHEDULER,				\
+			XOCL_DEVINFO_MAILBOX_USER,			\
+			XOCL_DEVINFO_ICAP_USER,				\
+		})
+
+#define USER_RES_AWS							\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_XDMA,				\
+			XOCL_DEVINFO_SCHEDULER,				\
+			XOCL_DEVINFO_ICAP_USER,				\
+		})
+
+#define	USER_RES_DSA52							\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_XDMA,				\
+			XOCL_DEVINFO_SCHEDULER,				\
+			XOCL_DEVINFO_MAILBOX_USER,			\
+			XOCL_DEVINFO_XVC_PUB,				\
+			XOCL_DEVINFO_ICAP_USER,				\
+			XOCL_DEVINFO_XMC_USER,				\
+		})
+
+#define	XOCL_BOARD_USER_XDMA_DSA50					\
+	(struct xocl_board_private){					\
+		.flags		= XOCL_DSAFLAG_MB_SCHE_OFF,		\
+		.subdev_info	= USER_RES_XDMA_DSA50,			\
+		.subdev_num = ARRAY_SIZE(USER_RES_XDMA_DSA50),		\
+	}
+
+#define	XOCL_BOARD_USER_XDMA						\
+	(struct xocl_board_private){					\
+		.flags		= 0,					\
+		.subdev_info	= USER_RES_XDMA,			\
+		.subdev_num = ARRAY_SIZE(USER_RES_XDMA),		\
+	}
+
+#define	XOCL_BOARD_USER_XDMA_ERT_OFF					\
+	(struct xocl_board_private){					\
+		.flags		= XOCL_DSAFLAG_MB_SCHE_OFF,		\
+		.subdev_info	= USER_RES_XDMA,			\
+		.subdev_num = ARRAY_SIZE(USER_RES_XDMA),		\
+	}
+
+#define XOCL_BOARD_USER_AWS						\
+	(struct xocl_board_private){					\
+		.flags      = 0,					\
+		.subdev_info    = USER_RES_AWS,				\
+		.subdev_num = ARRAY_SIZE(USER_RES_AWS),			\
+	}
+
+#define	XOCL_BOARD_USER_DSA52						\
+	(struct xocl_board_private){					\
+		.flags		= 0,					\
+		.subdev_info	= USER_RES_DSA52,			\
+		.subdev_num = ARRAY_SIZE(USER_RES_DSA52),		\
+	}
+
+/* mgmt pf defines */
+#define	MGMT_RES_DEFAULT						\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_SYSMON,				\
+			XOCL_DEVINFO_AF,				\
+			XOCL_DEVINFO_MB,				\
+			XOCL_DEVINFO_XVC_PUB,				\
+			XOCL_DEVINFO_XIIC,				\
+			XOCL_DEVINFO_MAILBOX_MGMT,			\
+			XOCL_DEVINFO_ICAP_MGMT,				\
+			XOCL_DEVINFO_FMGR,				\
+		})
+
+#define	MGMT_RES_DSA50							\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_SYSMON,				\
+			XOCL_DEVINFO_AF,				\
+			XOCL_DEVINFO_MB,				\
+			XOCL_DEVINFO_XVC_PUB,				\
+			XOCL_DEVINFO_XIIC,				\
+			XOCL_DEVINFO_ICAP_MGMT,				\
+			XOCL_DEVINFO_FMGR,				\
+		})
+
+#define	XOCL_BOARD_MGMT_DEFAULT						\
+	(struct xocl_board_private){					\
+		.flags		= 0,					\
+		.subdev_info	= MGMT_RES_DEFAULT,			\
+		.subdev_num = ARRAY_SIZE(MGMT_RES_DEFAULT),		\
+	}
+
+#define	XOCL_BOARD_MGMT_DSA50						\
+	(struct xocl_board_private){					\
+		.flags		= XOCL_DSAFLAG_PCI_RESET_OFF |		\
+			XOCL_DSAFLAG_AXILITE_FLUSH |			\
+			XOCL_DSAFLAG_MB_SCHE_OFF,			\
+		.subdev_info	= MGMT_RES_DSA50,			\
+		.subdev_num = ARRAY_SIZE(MGMT_RES_DSA50),		\
+	}
+
+#define	MGMT_RES_6A8F							\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_SYSMON,				\
+			XOCL_DEVINFO_AF,				\
+			XOCL_DEVINFO_MB,				\
+			XOCL_DEVINFO_XVC_PUB,				\
+			XOCL_DEVINFO_MAILBOX_MGMT,			\
+			XOCL_DEVINFO_ICAP_MGMT,				\
+			XOCL_DEVINFO_FMGR,				\
+		})
+
+#define	MGMT_RES_6A8F_DSA50						\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_SYSMON,				\
+			XOCL_DEVINFO_AF,				\
+			XOCL_DEVINFO_MB,				\
+			XOCL_DEVINFO_XVC_PUB,				\
+			XOCL_DEVINFO_ICAP_MGMT,				\
+			XOCL_DEVINFO_FMGR,				\
+		})
+
+#define	MGMT_RES_XBB_DSA51						\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_SYSMON,				\
+			XOCL_DEVINFO_AF,				\
+			XOCL_DEVINFO_XMC,				\
+			XOCL_DEVINFO_XVC_PUB,				\
+			XOCL_DEVINFO_MAILBOX_MGMT,			\
+			XOCL_DEVINFO_ICAP_MGMT,				\
+			XOCL_DEVINFO_FMGR,				\
+		})
+
+#define	XOCL_BOARD_MGMT_6A8F						\
+	(struct xocl_board_private){					\
+		.flags		= 0,					\
+		.subdev_info	= MGMT_RES_6A8F,			\
+		.subdev_num = ARRAY_SIZE(MGMT_RES_6A8F),		\
+	}
+
+#define	XOCL_BOARD_MGMT_XBB_DSA51						\
+	(struct xocl_board_private){					\
+		.flags		= 0,					\
+		.subdev_info	= MGMT_RES_XBB_DSA51,			\
+		.subdev_num = ARRAY_SIZE(MGMT_RES_XBB_DSA51),		\
+		.flash_type = FLASH_TYPE_SPI,				\
+	}
+
+
+#define	XOCL_BOARD_MGMT_888F	XOCL_BOARD_MGMT_6A8F
+#define	XOCL_BOARD_MGMT_898F	XOCL_BOARD_MGMT_6A8F
+
+#define	XOCL_BOARD_MGMT_6A8F_DSA50					\
+	(struct xocl_board_private){					\
+		.flags		= 0,					\
+		.subdev_info	= MGMT_RES_6A8F_DSA50,			\
+		.subdev_num = ARRAY_SIZE(MGMT_RES_6A8F_DSA50),		\
+	}
+
+#define	MGMT_RES_QDMA							\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_SYSMON,				\
+			XOCL_DEVINFO_AF,				\
+			XOCL_DEVINFO_MB,				\
+			XOCL_DEVINFO_XVC_PRI,				\
+			XOCL_DEVINFO_ICAP_MGMT,				\
+			XOCL_DEVINFO_FMGR,				\
+		})
+
+
+#define	XOCL_BOARD_MGMT_QDMA					\
+	(struct xocl_board_private){					\
+		.flags		= 0,					\
+		.subdev_info	= MGMT_RES_QDMA,			\
+		.subdev_num = ARRAY_SIZE(MGMT_RES_QDMA),		\
+		.flash_type = FLASH_TYPE_SPI				\
+	}
+
+#define MGMT_RES_XBB_QDMA                                               \
+	((struct xocl_subdev_info []) {                         \
+		XOCL_DEVINFO_FEATURE_ROM,                       \
+		XOCL_DEVINFO_SYSMON,                            \
+		XOCL_DEVINFO_AF_DSA52,                          \
+		XOCL_DEVINFO_XMC,                               \
+		XOCL_DEVINFO_XVC_PRI,                           \
+		XOCL_DEVINFO_ICAP_MGMT,                         \
+	})
+
+#define XOCL_BOARD_MGMT_XBB_QDMA                                        \
+	(struct xocl_board_private){                                    \
+		.flags          = 0,                                    \
+		.subdev_info    = MGMT_RES_XBB_QDMA,                    \
+		.subdev_num = ARRAY_SIZE(MGMT_RES_XBB_QDMA),            \
+		.flash_type = FLASH_TYPE_SPI				\
+	}
+
+#define	XOCL_BOARD_MGMT_6B0F		XOCL_BOARD_MGMT_6A8F
+
+#define	MGMT_RES_6A8F_DSA52						\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_SYSMON,				\
+			XOCL_DEVINFO_AF_DSA52,				\
+			XOCL_DEVINFO_MB,				\
+			XOCL_DEVINFO_XVC_PRI,				\
+			XOCL_DEVINFO_MAILBOX_MGMT,			\
+			XOCL_DEVINFO_ICAP_MGMT,				\
+			XOCL_DEVINFO_FMGR,				\
+		})
+
+#define	XOCL_BOARD_MGMT_6A8F_DSA52					\
+	(struct xocl_board_private){					\
+		.flags		= 0,					\
+		.subdev_info	= MGMT_RES_6A8F_DSA52,			\
+		.subdev_num = ARRAY_SIZE(MGMT_RES_6A8F_DSA52),		\
+	}
+
+#define	MGMT_RES_XBB_DSA52						\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_SYSMON,				\
+			XOCL_DEVINFO_AF_DSA52,				\
+			XOCL_DEVINFO_XMC,				\
+			XOCL_DEVINFO_XVC_PRI,				\
+			XOCL_DEVINFO_MAILBOX_MGMT,			\
+			XOCL_DEVINFO_ICAP_MGMT,				\
+			XOCL_DEVINFO_FMGR,				\
+		})
+
+#define	XOCL_BOARD_MGMT_XBB_DSA52					\
+	(struct xocl_board_private){					\
+		.flags		= 0,					\
+		.subdev_info	= MGMT_RES_XBB_DSA52,			\
+		.subdev_num = ARRAY_SIZE(MGMT_RES_XBB_DSA52),		\
+		.flash_type = FLASH_TYPE_SPI,				\
+	}
+
+#define	MGMT_RES_6E8F_DSA52						\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_SYSMON,				\
+			XOCL_DEVINFO_AF,				\
+			XOCL_DEVINFO_MB,				\
+			XOCL_DEVINFO_XVC_PRI,				\
+			XOCL_DEVINFO_XIIC,				\
+			XOCL_DEVINFO_MAILBOX_MGMT,			\
+			XOCL_DEVINFO_ICAP_MGMT,				\
+			XOCL_DEVINFO_FMGR,				\
+		})
+
+#define	XOCL_BOARD_MGMT_6E8F_DSA52					\
+	(struct xocl_board_private){					\
+		.flags		= 0,					\
+		.subdev_info	= MGMT_RES_6E8F_DSA52,			\
+		.subdev_num = ARRAY_SIZE(MGMT_RES_6E8F_DSA52),		\
+	}
+
+#define MGMT_RES_MPSOC							\
+		((struct xocl_subdev_info []) {				\
+			XOCL_DEVINFO_FEATURE_ROM,			\
+			XOCL_DEVINFO_SYSMON,				\
+			XOCL_DEVINFO_XVC_PUB,				\
+			XOCL_DEVINFO_MAILBOX_MGMT,			\
+			XOCL_DEVINFO_ICAP_MGMT,				\
+			XOCL_DEVINFO_FMGR,				\
+		})
+
+#define	XOCL_BOARD_MGMT_MPSOC						\
+	(struct xocl_board_private){					\
+		.flags		= 0,					\
+		.subdev_info	= MGMT_RES_MPSOC,			\
+		.subdev_num = ARRAY_SIZE(MGMT_RES_MPSOC),		\
+		.mpsoc = true,						\
+		.board_name = "samsung",				\
+		.flash_type = FLASH_TYPE_QSPIPS,			\
+	}
+
+#define	XOCL_BOARD_USER_XDMA_MPSOC					\
+	(struct xocl_board_private){					\
+		.flags		= 0,					\
+		.subdev_info	= USER_RES_XDMA,			\
+		.subdev_num = ARRAY_SIZE(USER_RES_XDMA),		\
+		.mpsoc = true,						\
+	}
+
+
+#define	XOCL_BOARD_XBB_MFG(board)					\
+	(struct xocl_board_private){					\
+		.flags = XOCL_DSAFLAG_MFG,				\
+		.board_name = board,					\
+		.flash_type = FLASH_TYPE_SPI,				\
+	}
+
+#define	XOCL_MGMT_PCI_IDS	{					\
+	{ XOCL_PCI_DEVID(0x10EE, 0x4A47, PCI_ANY_ID, MGMT_DEFAULT) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x4A87, PCI_ANY_ID, MGMT_DEFAULT) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x4B47, PCI_ANY_ID, MGMT_DEFAULT) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x4B87, 0x4350, MGMT_DSA50) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x4B87, 0x4351, MGMT_DEFAULT) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x684F, PCI_ANY_ID, MGMT_DEFAULT) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0xA883, 0x1351, MGMT_MPSOC) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0xA983, 0x1351, MGMT_MPSOC) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x688F, PCI_ANY_ID, MGMT_DEFAULT) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x694F, PCI_ANY_ID, MGMT_DEFAULT) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x698F, PCI_ANY_ID, MGMT_DEFAULT) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6A4F, PCI_ANY_ID, MGMT_DEFAULT) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6A8F, 0x4350, MGMT_6A8F_DSA50) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6A8F, 0x4351, MGMT_6A8F) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6A8F, 0x4352, MGMT_6A8F_DSA52) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6A9F, 0x4360, MGMT_QDMA) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x5010, PCI_ANY_ID, MGMT_XBB_QDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6A9F, PCI_ANY_ID, MGMT_DEFAULT) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6E4F, PCI_ANY_ID, MGMT_DEFAULT) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6B0F, PCI_ANY_ID, MGMT_6B0F) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6E8F, 0x4352, MGMT_6E8F_DSA52) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x888F, PCI_ANY_ID, MGMT_888F) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x898F, PCI_ANY_ID, MGMT_898F) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x788F, 0x4351, MGMT_XBB_DSA51) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x788F, 0x4352, MGMT_XBB_DSA52) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x798F, 0x4352, MGMT_XBB_DSA52) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6A8F, 0x4353, MGMT_6A8F_DSA52) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x5000, PCI_ANY_ID, MGMT_XBB_DSA52) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x5004, PCI_ANY_ID, MGMT_XBB_DSA52) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x5008, PCI_ANY_ID, MGMT_XBB_DSA52) },	\
+	{ XOCL_PCI_DEVID(0x13FE, 0x006C, PCI_ANY_ID, MGMT_6A8F) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0xD000, PCI_ANY_ID, XBB_MFG("u200")) }, \
+	{ XOCL_PCI_DEVID(0x10EE, 0xD004, PCI_ANY_ID, XBB_MFG("u250")) }, \
+	{ XOCL_PCI_DEVID(0x10EE, 0xD008, PCI_ANY_ID, XBB_MFG("u280-es1")) }, \
+	{ XOCL_PCI_DEVID(0x10EE, 0xD00C, PCI_ANY_ID, XBB_MFG("u280")) }, \
+	{ XOCL_PCI_DEVID(0x10EE, 0xEB10, PCI_ANY_ID, XBB_MFG("twitch")) }, \
+	{ 0, }								\
+}
+
+#define	XOCL_USER_PCI_IDS	{					\
+	{ XOCL_PCI_DEVID(0x10EE, 0x4A48, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x4A88, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x4B48, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x4B88, 0x4350, USER_XDMA_DSA50) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x4B88, 0x4351, USER_XDMA) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6850, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6890, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6950, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0xA884, 0x1351, USER_XDMA_MPSOC) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0xA984, 0x1351, USER_XDMA_MPSOC) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6990, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6A50, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6A90, 0x4350, USER_XDMA_DSA50) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6A90, 0x4351, USER_XDMA) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6A90, 0x4352, USER_DSA52) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6A90, 0x4353, USER_DSA52) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6E50, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6B10, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6E90, 0x4352, USER_DSA52) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x8890, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x8990, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x7890, 0x4351, USER_XDMA) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x7890, 0x4352, USER_DSA52) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x7990, 0x4352, USER_DSA52) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x5001, PCI_ANY_ID, USER_DSA52) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x5005, PCI_ANY_ID, USER_DSA52) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x5009, PCI_ANY_ID, USER_DSA52) },	\
+	{ XOCL_PCI_DEVID(0x13FE, 0x0065, PCI_ANY_ID, USER_XDMA) },	\
+	{ XOCL_PCI_DEVID(0x1D0F, 0x1042, PCI_ANY_ID, USER_AWS) },	\
+	{ XOCL_PCI_DEVID(0x1D0F, 0xF000, PCI_ANY_ID, USER_AWS) },	\
+	{ XOCL_PCI_DEVID(0x1D0F, 0xF010, PCI_ANY_ID, USER_AWS) },	\
+	{ XOCL_PCI_DEVID(0x10EE, 0x6AA0, 0x4360, USER_QDMA) },		\
+	{ XOCL_PCI_DEVID(0x10EE, 0x5011, PCI_ANY_ID, USER_QDMA) },	\
+	{ 0, }								\
+}
+
+#define XOCL_DSA_VBNV_MAP	{					\
+	{ 0x10EE, 0x5001, PCI_ANY_ID, "xilinx_u200_xdma_201820_1",	\
+		&XOCL_BOARD_USER_XDMA },				\
+	{ 0x10EE, 0x5000, PCI_ANY_ID, "xilinx_u200_xdma_201820_1",	\
+		&XOCL_BOARD_MGMT_XBB_DSA51 }				\
+}
+
+#endif
drivers/gpu/drm/xocl/ert.h new file +385 -0

385 lines not on this page · raw message

drivers/gpu/drm/xocl/version.h new file +22 -0
new file mode 100644
index 000000000000..bdf3d2c6655a
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 */
+
+#ifndef _XRT_VERSION_H_
+#define _XRT_VERSION_H_
+
+static const char xrt_build_version[] = "2.2.0";
+
+static const char xrt_build_version_branch[] = "master";
+
+static const char xrt_build_version_hash[] = "2de0f3707ba3b3f1a853006bfd8f75a118907021";
+
+static const char xrt_build_version_hash_date[] = "Mon, 4 Mar 2019 13:26:04 -0800";
+
+static const char xrt_build_version_date_rfc[] = "Mon, 04 Mar 2019 19:33:17 -0800";
+
+static const char xrt_build_version_date[] = "2019-03-04 19:33:17";
+
+static const char xrt_modified_files[] = "";
+
+#define XRT_DRIVER_VERSION "2.2.0,2de0f3707ba3b3f1a853006bfd8f75a118907021"
+
+#endif
drivers/gpu/drm/xocl/xclbin.h new file +314 -0

314 lines not on this page · raw message

drivers/gpu/drm/xocl/xclfeatures.h new file +107 -0

107 lines not on this page · raw message

drivers/gpu/drm/xocl/xocl_ctx.c new file +196 -0

196 lines not on this page · raw message

drivers/gpu/drm/xocl/xocl_drm.h new file +91 -0

91 lines not on this page · raw message

drivers/gpu/drm/xocl/xocl_drv.h new file +783 -0

783 lines not on this page · raw message

drivers/gpu/drm/xocl/xocl_subdev.c new file +540 -0

148 lines not on this page · raw message

drivers/gpu/drm/xocl/xocl_thread.c new file +64 -0

64 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.0

Part of the diff is not shown here. View the raw message.

#3 lore raw

RFC PATCH 3/6 Add platform drivers for various IPs and frameworks

In reply to [email protected]

From: Sonal Santan <[email protected]>

---
 drivers/gpu/drm/xocl/subdev/dna.c          |  356 +++
 drivers/gpu/drm/xocl/subdev/feature_rom.c  |  412 +++
 drivers/gpu/drm/xocl/subdev/firewall.c     |  389 +++
 drivers/gpu/drm/xocl/subdev/fmgr.c         |  198 ++
 drivers/gpu/drm/xocl/subdev/icap.c         | 2859 ++++++++++++++++++
 drivers/gpu/drm/xocl/subdev/mailbox.c      | 1868 ++++++++++++
 drivers/gpu/drm/xocl/subdev/mb_scheduler.c | 3059 ++++++++++++++++++++
 drivers/gpu/drm/xocl/subdev/microblaze.c   |  722 +++++
 drivers/gpu/drm/xocl/subdev/mig.c          |  256 ++
 drivers/gpu/drm/xocl/subdev/sysmon.c       |  385 +++
 drivers/gpu/drm/xocl/subdev/xdma.c         |  510 ++++
 drivers/gpu/drm/xocl/subdev/xmc.c          | 1480 ++++++++++
 drivers/gpu/drm/xocl/subdev/xvc.c          |  461 +++
 13 files changed, 12955 insertions(+)
 create mode 100644 drivers/gpu/drm/xocl/subdev/dna.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/feature_rom.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/firewall.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/fmgr.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/icap.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mailbox.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mb_scheduler.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/microblaze.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mig.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/sysmon.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xdma.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xmc.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xvc.c
drivers/gpu/drm/xocl/subdev/dna.c new file +356 -0
new file mode 100644
index 000000000000..991d98e5b9aa
@@ -0,0 +1,356 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * A GEM style device manager for PCIe based OpenCL accelerators.
+ *
+ * Copyright (C) 2018 Xilinx, Inc. All rights reserved.
+ *
+ * Authors: Chien-Wei Lan <[email protected]>
+ *
+ */
+
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/vmalloc.h>
+#include "../xocl_drv.h"
+#include <drm/xmgmt_drm.h>
+
+/* Registers are defined in pg150-ultrascale-memory-ip.pdf:
+ * AXI4-Lite Slave Control/Status Register Map
+ */
+#define XLNX_DNA_MEMORY_MAP_MAGIC_IS_DEFINED                        (0x3E4D7732)
+#define XLNX_DNA_MAJOR_MINOR_VERSION_REGISTER_OFFSET                0x00          //  RO
+#define XLNX_DNA_REVISION_REGISTER_OFFSET                           0x04          //  RO
+#define XLNX_DNA_CAPABILITY_REGISTER_OFFSET                         0x08          //  RO
+//#define XLNX_DNA_SCRATCHPAD_REGISTER_OFFSET                         (0x0C)          //  RO (31-1) + RW (0)
+#define XLNX_DNA_STATUS_REGISTER_OFFSET                             0x10            //  RO
+#define XLNX_DNA_FSM_DNA_WORD_WRITE_COUNT_REGISTER_OFFSET           (0x14)          //  RO
+#define XLNX_DNA_FSM_CERTIFICATE_WORD_WRITE_COUNT_REGISTER_OFFSET   (0x18)          //  RO
+#define XLNX_DNA_MESSAGE_START_AXI_ONLY_REGISTER_OFFSET             (0x20)          //  RO (31-1) + RW (0)
+#define XLNX_DNA_READBACK_REGISTER_2_OFFSET                         0x40            //  RO XLNX_DNA_BOARD_DNA_95_64
+#define XLNX_DNA_READBACK_REGISTER_1_OFFSET                         0x44            //  RO XLNX_DNA_BOARD_DNA_63_32
+#define XLNX_DNA_READBACK_REGISTER_0_OFFSET                         0x48            //  RO XLNX_DNA_BOARD_DNA_31_0
+#define XLNX_DNA_DATA_AXI_ONLY_REGISTER_OFFSET                      (0x80)          //  WO
+#define XLNX_DNA_CERTIFICATE_DATA_AXI_ONLY_REGISTER_OFFSET          (0xC0)          //  WO - 512 bit aligned.
+#define XLNX_DNA_MAX_ADDRESS_WORDS                                  (0xC4)
+
+struct xocl_xlnx_dna {
+	void __iomem		*base;
+	struct device		*xlnx_dna_dev;
+	struct mutex		xlnx_dna_lock;
+};
+
+static ssize_t status_show(struct device *dev, struct device_attribute *attr,
+	char *buf)
+{
+	struct xocl_xlnx_dna *xlnx_dna = dev_get_drvdata(dev);
+	u32 status;
+
+	status = ioread32(xlnx_dna->base+XLNX_DNA_STATUS_REGISTER_OFFSET);
+
+	return sprintf(buf, "0x%x\n", status);
+}
+static DEVICE_ATTR_RO(status);
+
+static ssize_t dna_show(struct device *dev, struct device_attribute *attr,
+	char *buf)
+{
+	struct xocl_xlnx_dna *xlnx_dna = dev_get_drvdata(dev);
+	uint32_t dna96_64, dna63_32, dna31_0;
+
+	dna96_64 = ioread32(xlnx_dna->base+XLNX_DNA_READBACK_REGISTER_2_OFFSET);
+	dna63_32 = ioread32(xlnx_dna->base+XLNX_DNA_READBACK_REGISTER_1_OFFSET);
+	dna31_0  = ioread32(xlnx_dna->base+XLNX_DNA_READBACK_REGISTER_0_OFFSET);
+
+	return sprintf(buf, "%08x%08x%08x\n", dna96_64, dna63_32, dna31_0);
+}
+static DEVICE_ATTR_RO(dna);
+
+static ssize_t capability_show(struct device *dev, struct device_attribute *attr,
+	char *buf)
+{
+	struct xocl_xlnx_dna *xlnx_dna = dev_get_drvdata(dev);
+	u32 capability;
+
+	capability = ioread32(xlnx_dna->base+XLNX_DNA_CAPABILITY_REGISTER_OFFSET);
+
+	return sprintf(buf, "0x%x\n", capability);
+}
+static DEVICE_ATTR_RO(capability);
+
+
+static ssize_t dna_version_show(struct device *dev, struct device_attribute *attr,
+	char *buf)
+{
+	struct xocl_xlnx_dna *xlnx_dna = dev_get_drvdata(dev);
+	u32 version;
+
+	version = ioread32(xlnx_dna->base+XLNX_DNA_MAJOR_MINOR_VERSION_REGISTER_OFFSET);
+
+	return sprintf(buf, "%d.%d\n", version>>16, version & 0xffff);
+}
+static DEVICE_ATTR_RO(dna_version);
+
+static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
+	char *buf)
+{
+	struct xocl_xlnx_dna *xlnx_dna = dev_get_drvdata(dev);
+	u32 revision;
+
+	revision = ioread32(xlnx_dna->base+XLNX_DNA_REVISION_REGISTER_OFFSET);
+
+	return sprintf(buf, "%d\n", revision);
+}
+static DEVICE_ATTR_RO(revision);
+
+static struct attribute *xlnx_dna_attributes[] = {
+	&dev_attr_status.attr,
+	&dev_attr_dna.attr,
+	&dev_attr_capability.attr,
+	&dev_attr_dna_version.attr,
+	&dev_attr_revision.attr,
+	NULL
+};
+
+static const struct attribute_group xlnx_dna_attrgroup = {
+	.attrs = xlnx_dna_attributes,
+};
+
+static uint32_t dna_status(struct platform_device *pdev)
+{
+	struct xocl_xlnx_dna *xlnx_dna = platform_get_drvdata(pdev);
+	uint32_t status = 0;
+	uint8_t retries = 10;
+	bool rsa4096done = false;
+
+	if (!xlnx_dna)
+		return status;
+
+	while (!rsa4096done && retries) {
+		status = ioread32(xlnx_dna->base+XLNX_DNA_STATUS_REGISTER_OFFSET);
+		if (status>>8 & 0x1) {
+			rsa4096done = true;
+			break;
+		}
+		msleep(1);
+		retries--;
+	}
+
+	if (retries == 0)
+		return -EBUSY;
+
+	status = ioread32(xlnx_dna->base+XLNX_DNA_STATUS_REGISTER_OFFSET);
+
+	return status;
+}
+
+static uint32_t dna_capability(struct platform_device *pdev)
+{
+	struct xocl_xlnx_dna *xlnx_dna = platform_get_drvdata(pdev);
+	u32 capability = 0;
+
+	if (!xlnx_dna)
+		return capability;
+
+	capability = ioread32(xlnx_dna->base+XLNX_DNA_CAPABILITY_REGISTER_OFFSET);
+
+	return capability;
+}
+
+static void dna_write_cert(struct platform_device *pdev, const uint32_t *cert, uint32_t len)
+{
+	struct xocl_xlnx_dna *xlnx_dna = platform_get_drvdata(pdev);
+	int i, j, k;
+	u32 status = 0, words;
+	uint8_t retries = 100;
+	bool sha256done = false;
+	uint32_t convert;
+	uint32_t sign_start, message_words = (len-512)>>2;
+
+	sign_start = message_words;
+
+	if (!xlnx_dna)
+		return;
+
+	iowrite32(0x1, xlnx_dna->base+XLNX_DNA_MESSAGE_START_AXI_ONLY_REGISTER_OFFSET);
+	status = ioread32(xlnx_dna->base+XLNX_DNA_STATUS_REGISTER_OFFSET);
+	xocl_info(&pdev->dev, "Start: status %08x", status);
+
+	for (i = 0; i < message_words; i += 16) {
+
+		retries = 100;
+		sha256done = false;
+
+		while (!sha256done && retries) {
+			status = ioread32(xlnx_dna->base+XLNX_DNA_STATUS_REGISTER_OFFSET);
+			if (!(status >> 4 & 0x1)) {
+				sha256done = true;
+				break;
+			}
+			msleep(10);
+			retries--;
+		}
+		for (j = 0; j < 16; ++j) {
+			convert = (*(cert+i+j) >> 24 & 0xff) | (*(cert+i+j) >> 8 & 0xff00) |
+				(*(cert+i+j) << 8 & 0xff0000) | ((*(cert+i+j) & 0xff) << 24);
+			iowrite32(convert, xlnx_dna->base+XLNX_DNA_DATA_AXI_ONLY_REGISTER_OFFSET+j*4);
+		}
+	}
+	retries = 100;
+	sha256done = false;
+	while (!sha256done && retries) {
+		status = ioread32(xlnx_dna->base+XLNX_DNA_STATUS_REGISTER_OFFSET);
+		if (!(status >> 4 & 0x1)) {
+			sha256done = true;
+			break;
+		}
+		msleep(10);
+		retries--;
+	}
+
+	status = ioread32(xlnx_dna->base+XLNX_DNA_STATUS_REGISTER_OFFSET);
+	words  = ioread32(xlnx_dna->base+XLNX_DNA_FSM_DNA_WORD_WRITE_COUNT_REGISTER_OFFSET);
+	xocl_info(&pdev->dev, "Message: status %08x dna words %d", status, words);
+
+	for (k = 0; k < 128; k += 16) {
+		for (i = 0; i < 16; i++) {
+			j = k+i+sign_start;
+			convert = (*(cert + j) >> 24 & 0xff) | (*(cert + j) >> 8 & 0xff00) |
+				(*(cert + j) << 8 & 0xff0000) | ((*(cert + j) & 0xff) << 24);
+			iowrite32(convert, xlnx_dna->base+XLNX_DNA_CERTIFICATE_DATA_AXI_ONLY_REGISTER_OFFSET + i * 4);
+		}
+	}
+
+	status = ioread32(xlnx_dna->base+XLNX_DNA_STATUS_REGISTER_OFFSET);
+	words  = ioread32(xlnx_dna->base+XLNX_DNA_FSM_CERTIFICATE_WORD_WRITE_COUNT_REGISTER_OFFSET);
+	xocl_info(&pdev->dev, "Signature: status %08x certificate words %d", status, words);
+}
+
+static struct xocl_dna_funcs dna_ops = {
+	.status = dna_status,
+	.capability = dna_capability,
+	.write_cert = dna_write_cert,
+};
+
+
+static void mgmt_sysfs_destroy_xlnx_dna(struct platform_device *pdev)
+{
+	struct xocl_xlnx_dna *xlnx_dna;
+
+	xlnx_dna = platform_get_drvdata(pdev);
+
+	sysfs_remove_group(&pdev->dev.kobj, &xlnx_dna_attrgroup);
+
+}
+
+static int mgmt_sysfs_create_xlnx_dna(struct platform_device *pdev)
+{
+	struct xocl_xlnx_dna *xlnx_dna;
+	struct xocl_dev_core *core;
+	int err;
+
+	xlnx_dna = platform_get_drvdata(pdev);
+	core = XDEV(xocl_get_xdev(pdev));
+
+	err = sysfs_create_group(&pdev->dev.kobj, &xlnx_dna_attrgroup);
+	if (err) {
+		xocl_err(&pdev->dev, "create pw group failed: 0x%x", err);
+		goto create_grp_failed;
+	}
+
+	return 0;
+
+create_grp_failed:
+	return err;
+}
+
+static int xlnx_dna_probe(struct platform_device *pdev)
+{
+	struct xocl_xlnx_dna *xlnx_dna;
+	struct resource *res;
+	int err;
+
+	xlnx_dna = devm_kzalloc(&pdev->dev, sizeof(*xlnx_dna), GFP_KERNEL);
+	if (!xlnx_dna)
+		return -ENOMEM;
+
+	xlnx_dna->base = devm_kzalloc(&pdev->dev, sizeof(void __iomem *), GFP_KERNEL);
+	if (!xlnx_dna->base)
+		return -ENOMEM;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		xocl_err(&pdev->dev, "resource is NULL");
+		return -EINVAL;
+	}
+	xocl_info(&pdev->dev, "IO start: 0x%llx, end: 0x%llx",
+		res->start, res->end);
+
+	xlnx_dna->base = ioremap_nocache(res->start, res->end - res->start + 1);
+	if (!xlnx_dna->base) {
+		err = -EIO;
+		xocl_err(&pdev->dev, "Map iomem failed");
+		goto failed;
+	}
+
+	platform_set_drvdata(pdev, xlnx_dna);
+
+	err = mgmt_sysfs_create_xlnx_dna(pdev);
+	if (err)
+		goto create_xlnx_dna_failed;
+
+	xocl_subdev_register(pdev, XOCL_SUBDEV_DNA, &dna_ops);
+
+	return 0;
+
+create_xlnx_dna_failed:
+	platform_set_drvdata(pdev, NULL);
+failed:
+	return err;
+}
+
+
+static int xlnx_dna_remove(struct platform_device *pdev)
+{
+	struct xocl_xlnx_dna	*xlnx_dna;
+
+	xlnx_dna = platform_get_drvdata(pdev);
+	if (!xlnx_dna) {
+		xocl_err(&pdev->dev, "driver data is NULL");
+		return -EINVAL;
+	}
+
+	mgmt_sysfs_destroy_xlnx_dna(pdev);
+
+	if (xlnx_dna->base)
+		iounmap(xlnx_dna->base);
+
+	platform_set_drvdata(pdev, NULL);
+	devm_kfree(&pdev->dev, xlnx_dna);
+
+	return 0;
+}
+
+struct platform_device_id xlnx_dna_id_table[] = {
+	{ XOCL_DNA, 0 },
+	{ },
+};
+
+static struct platform_driver	xlnx_dna_driver = {
+	.probe		= xlnx_dna_probe,
+	.remove		= xlnx_dna_remove,
+	.driver		= {
+		.name = "xocl_dna",
+	},
+	.id_table = xlnx_dna_id_table,
+};
+
+int __init xocl_init_dna(void)
+{
+	return platform_driver_register(&xlnx_dna_driver);
+}
+
+void xocl_fini_dna(void)
+{
+	platform_driver_unregister(&xlnx_dna_driver);
+}
drivers/gpu/drm/xocl/subdev/feature_rom.c new file +412 -0

412 lines not on this page · raw message

drivers/gpu/drm/xocl/subdev/firewall.c new file +389 -0

389 lines not on this page · raw message

drivers/gpu/drm/xocl/subdev/fmgr.c new file +198 -0

198 lines not on this page · raw message

drivers/gpu/drm/xocl/subdev/icap.c new file +2859 -0

1,645 lines not on this page · raw message

drivers/gpu/drm/xocl/subdev/mailbox.c new file +1868 -0

1,868 lines not on this page · raw message

drivers/gpu/drm/xocl/subdev/mb_scheduler.c new file +3059 -0

3,059 lines not on this page · raw message

drivers/gpu/drm/xocl/subdev/microblaze.c new file +722 -0

722 lines not on this page · raw message

drivers/gpu/drm/xocl/subdev/mig.c new file +256 -0

256 lines not on this page · raw message

drivers/gpu/drm/xocl/subdev/sysmon.c new file +385 -0

385 lines not on this page · raw message

drivers/gpu/drm/xocl/subdev/xdma.c new file +510 -0

510 lines not on this page · raw message

drivers/gpu/drm/xocl/subdev/xmc.c new file +1480 -0

1,480 lines not on this page · raw message

drivers/gpu/drm/xocl/subdev/xvc.c new file +461 -0

461 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.0

Part of the diff is not shown here. View the raw message.

#4 lore raw

RFC PATCH 4/6 Add core of XDMA driver

In reply to [email protected]

From: Sonal Santan <[email protected]>

---
 drivers/gpu/drm/xocl/lib/Makefile.in   |   16 +
 drivers/gpu/drm/xocl/lib/cdev_sgdma.h  |   63 +
 drivers/gpu/drm/xocl/lib/libxdma.c     | 4368 ++++++++++++++++++++++++
 drivers/gpu/drm/xocl/lib/libxdma.h     |  596 ++++
 drivers/gpu/drm/xocl/lib/libxdma_api.h |  127 +
 5 files changed, 5170 insertions(+)
 create mode 100644 drivers/gpu/drm/xocl/lib/Makefile.in
 create mode 100644 drivers/gpu/drm/xocl/lib/cdev_sgdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.c
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma_api.h
drivers/gpu/drm/xocl/lib/Makefile.in new file +16 -0
new file mode 100644
index 000000000000..5e16aefd6aba
@@ -0,0 +1,16 @@
+#
+# Copyright (C) 2016-2018 Xilinx, Inc. All rights reserved.
+#
+# Authors:
+#
+# This software is licensed under the terms of the GNU General Public
+# License version 2, as published by the Free Software Foundation, and
+# may be copied, distributed, and modified under those terms.
+#
+# This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+
+xocl_lib-y	:= ../lib/libxdma.o
drivers/gpu/drm/xocl/lib/cdev_sgdma.h new file +63 -0

63 lines not on this page · raw message

drivers/gpu/drm/xocl/lib/libxdma.c new file +4368 -0

2,921 lines not on this page · raw message

drivers/gpu/drm/xocl/lib/libxdma.h new file +596 -0

596 lines not on this page · raw message

drivers/gpu/drm/xocl/lib/libxdma_api.h new file +127 -0

127 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.0

Part of the diff is not shown here. View the raw message.

#5 lore raw

RFC PATCH 5/6 Add management driver

In reply to [email protected]

From: Sonal Santan <[email protected]>

---
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c  | 960 +++++++++++++++++++++++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h  | 147 ++++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c    |  30 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c | 148 ++++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h   | 244 ++++++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c | 318 ++++++++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c | 399 ++++++++++
 7 files changed, 2246 insertions(+)
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c
drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c new file +960 -0
new file mode 100644
index 000000000000..2eb0267fc2b2
@@ -0,0 +1,960 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Simple Driver for Management PF
+ *
+ * Copyright (C) 2017 Xilinx, Inc.
+ *
+ * Code borrowed from Xilinx SDAccel XDMA driver
+ *
+ * Author(s):
+ * Sonal Santan <[email protected]>
+ */
+#include "mgmt-core.h"
+#include <linux/ioctl.h>
+#include <linux/module.h>
+#include <linux/vmalloc.h>
+#include <linux/version.h>
+#include <linux/fs.h>
+#include <linux/platform_device.h>
+#include <linux/i2c.h>
+#include <linux/crc32c.h>
+#include "../xocl_drv.h"
+#include "../version.h"
+
+//#define USE_FEATURE_ROM
+
+static const struct pci_device_id pci_ids[] = XOCL_MGMT_PCI_IDS;
+
+MODULE_DEVICE_TABLE(pci, pci_ids);
+
+int health_interval = 5;
+module_param(health_interval, int, (S_IRUGO|S_IWUSR));
+MODULE_PARM_DESC(health_interval,
+	"Interval (in sec) after which the health thread is run. (1 = Minimum, 5 = default)");
+
+int health_check = 1;
+module_param(health_check, int, (S_IRUGO|S_IWUSR));
+MODULE_PARM_DESC(health_check,
+	"Enable health thread that checks the status of AXI Firewall and SYSMON. (0 = disable, 1 = enable)");
+
+int minimum_initialization;
+module_param(minimum_initialization, int, (S_IRUGO|S_IWUSR));
+MODULE_PARM_DESC(minimum_initialization,
+	"Enable minimum_initialization to force driver to load without vailid firmware or DSA. Thus xbsak flash is able to upgrade firmware. (0 = normal initialization, 1 = minimum initialization)");
+
+#define	LOW_TEMP		0
+#define	HI_TEMP			85000
+#define	LOW_MILLVOLT		500
+#define	HI_MILLVOLT		2500
+
+
+static dev_t xclmgmt_devnode;
+struct class *xrt_class;
+
+/*
+ * Called when the device goes from unused to used.
+ */
+static int char_open(struct inode *inode, struct file *file)
+{
+	struct xclmgmt_dev *lro;
+
+	/* pointer to containing data structure of the character device inode */
+	lro = xocl_drvinst_open(inode->i_cdev);
+	if (!lro)
+		return -ENXIO;
+
+	/* create a reference to our char device in the opened file */
+	file->private_data = lro;
+	BUG_ON(!lro);
+
+	mgmt_info(lro, "opened file %p by pid: %d\n",
+		file, pid_nr(task_tgid(current)));
+
+	return 0;
+}
+
+/*
+ * Called when the device goes from used to unused.
+ */
+static int char_close(struct inode *inode, struct file *file)
+{
+	struct xclmgmt_dev *lro;
+
+	lro = (struct xclmgmt_dev *)file->private_data;
+	BUG_ON(!lro);
+
+	mgmt_info(lro, "Closing file %p by pid: %d\n",
+		file, pid_nr(task_tgid(current)));
+
+	xocl_drvinst_close(lro);
+
+	return 0;
+}
+
+/*
+ * Unmap the BAR regions that had been mapped earlier using map_bars()
+ */
+static void unmap_bars(struct xclmgmt_dev *lro)
+{
+	if (lro->core.bar_addr) {
+		/* unmap BAR */
+		pci_iounmap(lro->core.pdev, lro->core.bar_addr);
+		/* mark as unmapped */
+		lro->core.bar_addr = NULL;
+	}
+	if (lro->core.intr_bar_addr) {
+		/* unmap BAR */
+		pci_iounmap(lro->core.pdev, lro->core.intr_bar_addr);
+		/* mark as unmapped */
+		lro->core.intr_bar_addr = NULL;
+	}
+}
+
+static int identify_bar(struct xocl_dev_core *core, int bar)
+{
+	void *__iomem bar_addr;
+	resource_size_t bar_len;
+
+	bar_len = pci_resource_len(core->pdev, bar);
+	bar_addr = pci_iomap(core->pdev, bar, bar_len);
+	if (!bar_addr) {
+		xocl_err(&core->pdev->dev, "Could not map BAR #%d",
+				core->bar_idx);
+		return -EIO;
+	}
+
+	/*
+	 * did not find a better way to identify BARS. Currently,
+	 * we have DSAs which rely VBNV name to differenciate them.
+	 * And reading VBNV name needs to bring up Feature ROM.
+	 * So we are not able to specify BARs in devices.h
+	 */
+	if (bar_len < 1024 * 1024 && bar > 0) {
+		core->intr_bar_idx = bar;
+		core->intr_bar_addr = bar_addr;
+		core->intr_bar_size = bar_len;
+	} else if (bar_len < 256 * 1024 * 1024) {
+		core->bar_idx = bar;
+		core->bar_size = bar_len;
+		core->bar_addr = bar_addr;
+	}
+
+	return 0;
+}
+
+/* map_bars() -- map device regions into kernel virtual address space
+ *
+ * Map the device memory regions into kernel virtual address space after
+ * verifying their sizes respect the minimum sizes needed, given by the
+ * bar_map_sizes[] array.
+ */
+static int map_bars(struct xclmgmt_dev *lro)
+{
+	struct pci_dev *pdev = lro->core.pdev;
+	resource_size_t bar_len;
+	int	i, ret = 0;
+
+	for (i = PCI_STD_RESOURCES; i <= PCI_STD_RESOURCE_END; i++) {
+		bar_len = pci_resource_len(pdev, i);
+		if (bar_len > 0) {
+			ret = identify_bar(&lro->core, i);
+			if (ret)
+				goto failed;
+		}
+	}
+
+	/* succesfully mapped all required BAR regions */
+	return 0;
+
+failed:
+	unmap_bars(lro);
+	return ret;
+}
+
+void get_pcie_link_info(struct xclmgmt_dev *lro,
+	unsigned short *link_width, unsigned short *link_speed, bool is_cap)
+{
+	u16 stat;
+	long result;
+	int pos = is_cap ? PCI_EXP_LNKCAP : PCI_EXP_LNKSTA;
+
+	result = pcie_capability_read_word(lro->core.pdev, pos, &stat);
+	if (result) {
+		*link_width = *link_speed = 0;
+		mgmt_err(lro, "Read pcie capability failed");
+		return;
+	}
+	*link_width = (stat & PCI_EXP_LNKSTA_NLW) >> PCI_EXP_LNKSTA_NLW_SHIFT;
+	*link_speed = stat & PCI_EXP_LNKSTA_CLS;
+}
+
+void device_info(struct xclmgmt_dev *lro, struct xclmgmt_ioc_info *obj)
+{
+	u32 val, major, minor, patch;
+	struct FeatureRomHeader rom;
+
+	memset(obj, 0, sizeof(struct xclmgmt_ioc_info));
+	if (sscanf(XRT_DRIVER_VERSION, "%d.%d.%d", &major, &minor, &patch) != 3)
+		return;
+
+	obj->vendor = lro->core.pdev->vendor;
+	obj->device = lro->core.pdev->device;
+	obj->subsystem_vendor = lro->core.pdev->subsystem_vendor;
+	obj->subsystem_device = lro->core.pdev->subsystem_device;
+	obj->driver_version = XOCL_DRV_VER_NUM(major, minor, patch);
+	obj->pci_slot = PCI_SLOT(lro->core.pdev->devfn);
+
+	val = MGMT_READ_REG32(lro, GENERAL_STATUS_BASE);
+	mgmt_info(lro, "MIG Calibration: %d\n", val);
+
+	obj->mig_calibration[0] = (val & BIT(0)) ? true : false;
+	obj->mig_calibration[1] = obj->mig_calibration[0];
+	obj->mig_calibration[2] = obj->mig_calibration[0];
+	obj->mig_calibration[3] = obj->mig_calibration[0];
+
+	/*
+	 * Get feature rom info
+	 */
+	obj->ddr_channel_num = xocl_get_ddr_channel_count(lro);
+	obj->ddr_channel_size = xocl_get_ddr_channel_size(lro);
+	obj->time_stamp = xocl_get_timestamp(lro);
+	obj->isXPR = XOCL_DSA_XPR_ON(lro);
+	xocl_get_raw_header(lro, &rom);
+	memcpy(obj->vbnv, rom.VBNVName, 64);
+	memcpy(obj->fpga, rom.FPGAPartName, 64);
+
+	/* Get sysmon info */
+	xocl_sysmon_get_prop(lro, XOCL_SYSMON_PROP_TEMP, &val);
+	obj->onchip_temp = val / 1000;
+	xocl_sysmon_get_prop(lro, XOCL_SYSMON_PROP_VCC_INT, &val);
+	obj->vcc_int = val;
+	xocl_sysmon_get_prop(lro, XOCL_SYSMON_PROP_VCC_AUX, &val);
+	obj->vcc_aux = val;
+	xocl_sysmon_get_prop(lro, XOCL_SYSMON_PROP_VCC_BRAM, &val);
+	obj->vcc_bram = val;
+
+	fill_frequency_info(lro, obj);
+	get_pcie_link_info(lro, &obj->pcie_link_width, &obj->pcie_link_speed,
+		false);
+}
+
+/*
+ * Maps the PCIe BAR into user space for memory-like access using mmap().
+ * Callable even when lro->ready == false.
+ */
+static int bridge_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	int rc;
+	struct xclmgmt_dev *lro;
+	unsigned long off;
+	unsigned long phys;
+	unsigned long vsize;
+	unsigned long psize;
+
+	if (!capable(CAP_SYS_ADMIN))
+		return -EACCES;
+
+	lro = (struct xclmgmt_dev *)file->private_data;
+	BUG_ON(!lro);
+
+	off = vma->vm_pgoff << PAGE_SHIFT;
+	/* BAR physical address */
+	phys = pci_resource_start(lro->core.pdev, lro->core.bar_idx) + off;
+	vsize = vma->vm_end - vma->vm_start;
+	/* complete resource */
+	psize = pci_resource_end(lro->core.pdev, lro->core.bar_idx) -
+		pci_resource_start(lro->core.pdev, lro->core.bar_idx) + 1 - off;
+
+	mgmt_info(lro, "mmap(): bar %d, phys:0x%lx, vsize:%ld, psize:%ld",
+		lro->core.bar_idx, phys, vsize, psize);
+
+	if (vsize > psize)
+		return -EINVAL;
+
+	/*
+	 * pages must not be cached as this would result in cache line sized
+	 * accesses to the end point
+	 */
+	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+	/*
+	 * prevent touching the pages (byte access) for swap-in,
+	 * and prevent the pages from being swapped out
+	 */
+#ifndef VM_RESERVED
+	vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
+#else
+	vma->vm_flags |= VM_IO | VM_RESERVED;
+#endif
+
+	/* make MMIO accessible to user space */
+	rc = io_remap_pfn_range(vma, vma->vm_start, phys >> PAGE_SHIFT,
+				vsize, vma->vm_page_prot);
+	if (rc)
+		return -EAGAIN;
+
+	return rc;
+}
+
+/*
+ * character device file operations for control bus (through control bridge)
+ */
+static const struct file_operations ctrl_fops = {
+	.owner = THIS_MODULE,
+	.open = char_open,
+	.release = char_close,
+	.mmap = bridge_mmap,
+	.unlocked_ioctl = mgmt_ioctl,
+};
+
+/*
+ * create_char() -- create a character device interface to data or control bus
+ *
+ * If at least one SG DMA engine is specified, the character device interface
+ * is coupled to the SG DMA file operations which operate on the data bus. If
+ * no engines are specified, the interface is coupled with the control bus.
+ */
+static int create_char(struct xclmgmt_dev *lro)
+{
+	struct xclmgmt_char *lro_char;
+	int rc;
+
+	lro_char = &lro->user_char_dev;
+
+	/* couple the control device file operations to the character device */
+	lro_char->cdev = cdev_alloc();
+	if (!lro_char->cdev)
+		return -ENOMEM;
+
+	lro_char->cdev->ops = &ctrl_fops;
+	lro_char->cdev->owner = THIS_MODULE;
+	lro_char->cdev->dev = MKDEV(MAJOR(xclmgmt_devnode), lro->core.dev_minor);
+	rc = cdev_add(lro_char->cdev, lro_char->cdev->dev, 1);
+	if (rc < 0) {
+		memset(lro_char, 0, sizeof(*lro_char));
+		mgmt_info(lro, "cdev_add() = %d\n", rc);
+		goto fail_add;
+	}
+
+	lro_char->sys_device = device_create(xrt_class,
+				&lro->core.pdev->dev,
+				lro_char->cdev->dev, NULL,
+				DRV_NAME "%d", lro->instance);
+
+	if (IS_ERR(lro_char->sys_device)) {
+		rc = PTR_ERR(lro_char->sys_device);
+		goto fail_device;
+	}
+
+	return 0;
+
+fail_device:
+	cdev_del(lro_char->cdev);
+fail_add:
+	return rc;
+}
+
+static int destroy_sg_char(struct xclmgmt_char *lro_char)
+{
+	BUG_ON(!lro_char);
+	BUG_ON(!xrt_class);
+
+	if (lro_char->sys_device)
+		device_destroy(xrt_class, lro_char->cdev->dev);
+	cdev_del(lro_char->cdev);
+
+	return 0;
+}
+
+struct pci_dev *find_user_node(const struct pci_dev *pdev)
+{
+	struct xclmgmt_dev *lro;
+	unsigned int slot = PCI_SLOT(pdev->devfn);
+	unsigned int func = PCI_FUNC(pdev->devfn);
+	struct pci_dev *user_dev;
+
+	lro = (struct xclmgmt_dev *)dev_get_drvdata(&pdev->dev);
+
+	/*
+	 * if we are function one then the zero
+	 * function has the user pf node
+	 */
+	if (func == 0) {
+		mgmt_err(lro, "failed get user pf, expect user pf is func 0");
+		return NULL;
+	}
+
+	user_dev = pci_get_slot(pdev->bus, PCI_DEVFN(slot, 0));
+	if (!user_dev) {
+		mgmt_err(lro, "did not find user dev");
+		return NULL;
+	}
+
+	return user_dev;
+}
+
+inline void check_temp_within_range(struct xclmgmt_dev *lro, u32 temp)
+{
+	if (temp < LOW_TEMP || temp > HI_TEMP) {
+		mgmt_err(lro, "Temperature outside normal range (%d-%d) %d.",
+			LOW_TEMP, HI_TEMP, temp);
+	}
+}
+
+inline void check_volt_within_range(struct xclmgmt_dev *lro, u16 volt)
+{
+	if (volt < LOW_MILLVOLT || volt > HI_MILLVOLT) {
+		mgmt_err(lro, "Voltage outside normal range (%d-%d)mV %d.",
+			LOW_MILLVOLT, HI_MILLVOLT, volt);
+	}
+}
+
+static void check_sysmon(struct xclmgmt_dev *lro)
+{
+	u32 val;
+
+	xocl_sysmon_get_prop(lro, XOCL_SYSMON_PROP_TEMP, &val);
+	check_temp_within_range(lro, val);
+
+	xocl_sysmon_get_prop(lro, XOCL_SYSMON_PROP_VCC_INT, &val);
+	check_volt_within_range(lro, val);
+	xocl_sysmon_get_prop(lro, XOCL_SYSMON_PROP_VCC_AUX, &val);
+	check_volt_within_range(lro, val);
+	xocl_sysmon_get_prop(lro, XOCL_SYSMON_PROP_VCC_BRAM, &val);
+	check_volt_within_range(lro, val);
+}
+
+static int health_check_cb(void *data)
+{
+	struct xclmgmt_dev *lro = (struct xclmgmt_dev *)data;
+	struct mailbox_req mbreq = { MAILBOX_REQ_FIREWALL, };
+	bool tripped;
+
+	if (!health_check)
+		return 0;
+
+	mutex_lock(&lro->busy_mutex);
+	tripped = xocl_af_check(lro, NULL);
+	mutex_unlock(&lro->busy_mutex);
+
+	if (!tripped) {
+		check_sysmon(lro);
+	} else {
+		mgmt_info(lro, "firewall tripped, notify peer");
+		(void) xocl_peer_notify(lro, &mbreq, sizeof(struct mailbox_req));
+	}
+
+	return 0;
+}
+
+static inline bool xclmgmt_support_intr(struct xclmgmt_dev *lro)
+{
+	return lro->core.intr_bar_addr != NULL;
+}
+
+static int xclmgmt_setup_msix(struct xclmgmt_dev *lro)
+{
+	int total, rv, i;
+
+	if (!xclmgmt_support_intr(lro))
+		return -EOPNOTSUPP;
+
+	/*
+	 * Get start vector (index into msi-x table) of msi-x usr intr on this
+	 * device.
+	 *
+	 * The device has XCLMGMT_MAX_USER_INTR number of usr intrs, the last
+	 * half of them belongs to mgmt pf, and the first half to user pf. All
+	 * vectors are hard-wired.
+	 *
+	 * The device also has some number of DMA intrs whose vectors come
+	 * before usr ones.
+	 *
+	 * This means that mgmt pf needs to allocate msi-x table big enough to
+	 * cover its own usr vectors. So, only the last chunk of the table will
+	 * ever be used for mgmt pf.
+	 */
+	lro->msix_user_start_vector = XOCL_READ_REG32(lro->core.intr_bar_addr +
+		XCLMGMT_INTR_USER_VECTOR) & 0x0f;
+	total = lro->msix_user_start_vector + XCLMGMT_MAX_USER_INTR;
+
+	i = 0; // Suppress warning about unused variable
+	rv = pci_alloc_irq_vectors(lro->core.pdev, total, total, PCI_IRQ_MSIX);
+	if (rv == total)
+		rv = 0;
+	mgmt_info(lro, "setting up msix, total irqs: %d, rv=%d\n", total, rv);
+	return rv;
+}
+
+static void xclmgmt_teardown_msix(struct xclmgmt_dev *lro)
+{
+	if (xclmgmt_support_intr(lro))
+		pci_disable_msix(lro->core.pdev);
+}
+
+static int xclmgmt_intr_config(xdev_handle_t xdev_hdl, u32 intr, bool en)
+{
+	struct xclmgmt_dev *lro = (struct xclmgmt_dev *)xdev_hdl;
+
+	if (!xclmgmt_support_intr(lro))
+		return -EOPNOTSUPP;
+
+	XOCL_WRITE_REG32(1 << intr, lro->core.intr_bar_addr +
+		(en ? XCLMGMT_INTR_USER_ENABLE : XCLMGMT_INTR_USER_DISABLE));
+	return 0;
+}
+
+static int xclmgmt_intr_register(xdev_handle_t xdev_hdl, u32 intr,
+	irq_handler_t handler, void *arg)
+{
+	u32 vec;
+	struct xclmgmt_dev *lro = (struct xclmgmt_dev *)xdev_hdl;
+
+	if (!xclmgmt_support_intr(lro))
+		return -EOPNOTSUPP;
+
+	vec = pci_irq_vector(lro->core.pdev,
+		lro->msix_user_start_vector + intr);
+
+	if (handler)
+		return request_irq(vec, handler, 0, DRV_NAME, arg);
+
+	free_irq(vec, arg);
+	return 0;
+}
+
+static int xclmgmt_reset(xdev_handle_t xdev_hdl)
+{
+	struct xclmgmt_dev *lro = (struct xclmgmt_dev *)xdev_hdl;
+
+	return reset_hot_ioctl(lro);
+}
+
+struct xocl_pci_funcs xclmgmt_pci_ops = {
+	.intr_config = xclmgmt_intr_config,
+	.intr_register = xclmgmt_intr_register,
+	.reset = xclmgmt_reset,
+};
+
+static int xclmgmt_read_subdev_req(struct xclmgmt_dev *lro, char *data_ptr, void **resp, size_t *sz)
+{
+	uint64_t val = 0;
+	size_t resp_sz = 0;
+	void *ptr = NULL;
+	struct mailbox_subdev_peer *subdev_req = (struct mailbox_subdev_peer *)data_ptr;
+
+	switch (subdev_req->kind) {
+	case VOL_12V_PEX:
+		val = xocl_xmc_get_data(lro, subdev_req->kind);
+		resp_sz = sizeof(u32);
+		ptr = (void *)&val;
+		break;
+	case IDCODE:
+		val = xocl_icap_get_data(lro, subdev_req->kind);
+		resp_sz = sizeof(u32);
+		ptr = (void *)&val;
+		break;
+	case XCLBIN_UUID:
+		ptr = (void *)xocl_icap_get_data(lro, subdev_req->kind);
+		resp_sz = sizeof(uuid_t);
+		break;
+	default:
+		break;
+	}
+
+	if (!resp_sz)
+		return -EINVAL;
+
+	*resp = vmalloc(resp_sz);
+	if (*resp == NULL)
+		return -ENOMEM;
+
+	memcpy(*resp, ptr, resp_sz);
+	*sz = resp_sz;
+	return 0;
+}
+
+static void xclmgmt_mailbox_srv(void *arg, void *data, size_t len,
+	u64 msgid, int err)
+{
+	int ret = 0;
+	size_t sz = 0;
+	struct xclmgmt_dev *lro = (struct xclmgmt_dev *)arg;
+	struct mailbox_req *req = (struct mailbox_req *)data;
+	struct mailbox_req_bitstream_lock *bitstm_lock = NULL;
+	struct mailbox_bitstream_kaddr *mb_kaddr = NULL;
+	void *resp = NULL;
+
+	bitstm_lock =	(struct mailbox_req_bitstream_lock *)req->data;
+
+	if (err != 0)
+		return;
+
+	mgmt_info(lro, "%s received request (%d) from peer\n", __func__, req->req);
+
+	switch (req->req) {
+	case MAILBOX_REQ_LOCK_BITSTREAM:
+		ret = xocl_icap_lock_bitstream(lro, &bitstm_lock->uuid,
+			0);
+		(void) xocl_peer_response(lro, msgid, &ret, sizeof(ret));
+		break;
+	case MAILBOX_REQ_UNLOCK_BITSTREAM:
+		ret = xocl_icap_unlock_bitstream(lro, &bitstm_lock->uuid,
+			0);
+		break;
+	case MAILBOX_REQ_HOT_RESET:
+		ret = (int) reset_hot_ioctl(lro);
+		(void) xocl_peer_response(lro, msgid, &ret, sizeof(ret));
+		break;
+	case MAILBOX_REQ_LOAD_XCLBIN_KADDR:
+		mb_kaddr = (struct mailbox_bitstream_kaddr *)req->data;
+		ret = xocl_icap_download_axlf(lro, (void *)mb_kaddr->addr);
+		(void) xocl_peer_response(lro, msgid, &ret, sizeof(ret));
+		break;
+	case MAILBOX_REQ_LOAD_XCLBIN:
+		ret = xocl_icap_download_axlf(lro, req->data);
+		(void) xocl_peer_response(lro, msgid, &ret, sizeof(ret));
+		break;
+	case MAILBOX_REQ_RECLOCK:
+		ret = xocl_icap_ocl_update_clock_freq_topology(lro, (struct xclmgmt_ioc_freqscaling *)req->data);
+		(void) xocl_peer_response(lro, msgid, &ret, sizeof(ret));
+		break;
+	case MAILBOX_REQ_PEER_DATA:
+		ret = xclmgmt_read_subdev_req(lro, req->data, &resp, &sz);
+		if (ret) {
+			/* if can't get data, return 0 as response */
+			ret = 0;
+			(void) xocl_peer_response(lro, msgid, &ret, sizeof(ret));
+		} else
+			(void) xocl_peer_response(lro, msgid, resp, sz);
+		vfree(resp);
+		break;
+	default:
+		break;
+	}
+}
+
+/*
+ * Called after minimum initialization is done. Should not return failure.
+ * If something goes wrong, it should clean up and return back to minimum
+ * initialization stage.
+ */
+static void xclmgmt_extended_probe(struct xclmgmt_dev *lro)
+{
+	int ret;
+	struct xocl_board_private *dev_info = &lro->core.priv;
+	struct pci_dev *pdev = lro->pci_dev;
+
+	/* We can only support MSI-X. */
+	ret = xclmgmt_setup_msix(lro);
+	if (ret && (ret != -EOPNOTSUPP)) {
+		xocl_err(&pdev->dev, "set up MSI-X failed\n");
+		goto fail;
+	}
+	lro->core.pci_ops = &xclmgmt_pci_ops;
+	lro->core.pdev = pdev;
+
+	/*
+	 * Workaround needed on some platforms. Will clear out any stale
+	 * data after the platform has been reset
+	 */
+	ret = xocl_subdev_create_one(lro,
+		&(struct xocl_subdev_info)XOCL_DEVINFO_AF);
+	if (ret) {
+		xocl_err(&pdev->dev, "failed to register firewall\n");
+		goto fail_firewall;
+	}
+	if (dev_info->flags & XOCL_DSAFLAG_AXILITE_FLUSH)
+		platform_axilite_flush(lro);
+
+	ret = xocl_subdev_create_all(lro, dev_info->subdev_info,
+		dev_info->subdev_num);
+	if (ret) {
+		xocl_err(&pdev->dev, "failed to register subdevs\n");
+		goto fail_all_subdev;
+	}
+	xocl_err(&pdev->dev, "created all sub devices");
+
+	ret = xocl_icap_download_boot_firmware(lro);
+	if (ret)
+		goto fail_all_subdev;
+
+	lro->core.thread_arg.health_cb = health_check_cb;
+	lro->core.thread_arg.arg = lro;
+	lro->core.thread_arg.interval = health_interval * 1000;
+
+	health_thread_start(lro);
+
+	/* Launch the mailbox server. */
+	(void) xocl_peer_listen(lro, xclmgmt_mailbox_srv, (void *)lro);
+
+	lro->ready = true;
+	xocl_err(&pdev->dev, "device fully initialized\n");
+	return;
+
+fail_all_subdev:
+	xocl_subdev_destroy_all(lro);
+fail_firewall:
+	xclmgmt_teardown_msix(lro);
+fail:
+	xocl_err(&pdev->dev, "failed to fully probe device, err: %d\n", ret);
+}
+
+/*
+ * Device initialization is done in two phases:
+ * 1. Minimum initialization - init to the point where open/close/mmap entry
+ * points are working, sysfs entries work without register access, ioctl entry
+ * point is completely disabled.
+ * 2. Full initialization - driver is ready for use.
+ * Once we pass minimum initialization point, probe function shall not fail.
+ */
+static int xclmgmt_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+	int rc = 0;
+	struct xclmgmt_dev *lro = NULL;
+	struct xocl_board_private *dev_info;
+
+	xocl_info(&pdev->dev, "Driver: %s", XRT_DRIVER_VERSION);
+	xocl_info(&pdev->dev, "probe(pdev = 0x%p, pci_id = 0x%p)\n", pdev, id);
+
+	rc = pci_enable_device(pdev);
+	if (rc) {
+		xocl_err(&pdev->dev, "pci_enable_device() failed, rc = %d.\n",
+			rc);
+		return rc;
+	}
+
+	/* allocate zeroed device book keeping structure */
+	lro = xocl_drvinst_alloc(&pdev->dev, sizeof(struct xclmgmt_dev));
+	if (!lro) {
+		xocl_err(&pdev->dev, "Could not kzalloc(xclmgmt_dev).\n");
+		rc = -ENOMEM;
+		goto err_alloc;
+	}
+
+	/* create a device to driver reference */
+	dev_set_drvdata(&pdev->dev, lro);
+	/* create a driver to device reference */
+	lro->core.pdev = pdev;
+	lro->pci_dev = pdev;
+	lro->ready = false;
+
+	rc = pcie_get_readrq(pdev);
+	if (rc < 0) {
+		dev_err(&pdev->dev, "failed to read mrrs %d\n", rc);
+		goto err_alloc;
+	}
+	if (rc > 512) {
+		rc = pcie_set_readrq(pdev, 512);
+		if (rc) {
+			dev_err(&pdev->dev, "failed to force mrrs %d\n", rc);
+			goto err_alloc;
+		}
+	}
+
+	rc = xocl_alloc_dev_minor(lro);
+	if (rc)
+		goto err_alloc_minor;
+
+	dev_info = (struct xocl_board_private *)id->driver_data;
+	xocl_fill_dsa_priv(lro, dev_info);
+
+	/* map BARs */
+	rc = map_bars(lro);
+	if (rc)
+		goto err_map;
+
+	lro->instance = XOCL_DEV_ID(pdev);
+	rc = create_char(lro);
+	if (rc) {
+		xocl_err(&pdev->dev, "create_char(user_char_dev) failed\n");
+		goto err_cdev;
+	}
+
+	xocl_drvinst_set_filedev(lro, lro->user_char_dev.cdev);
+
+	mutex_init(&lro->busy_mutex);
+
+	mgmt_init_sysfs(&pdev->dev);
+
+	/* Probe will not fail from now on. */
+	xocl_err(&pdev->dev, "minimum initialization done\n");
+
+	/* No further initialization for MFG board. */
+	if (minimum_initialization ||
+		(dev_info->flags & XOCL_DSAFLAG_MFG) != 0) {
+		return 0;
+	}
+
+	xclmgmt_extended_probe(lro);
+
+	return 0;
+
+err_cdev:
+	unmap_bars(lro);
+err_map:
+	xocl_free_dev_minor(lro);
+err_alloc_minor:
+	dev_set_drvdata(&pdev->dev, NULL);
+	xocl_drvinst_free(lro);
+err_alloc:
+	pci_disable_device(pdev);
+
+	return rc;
+}
+
+static void xclmgmt_remove(struct pci_dev *pdev)
+{
+	struct xclmgmt_dev *lro;
+
+	if ((pdev == 0) || (dev_get_drvdata(&pdev->dev) == 0))
+		return;
+
+	lro = (struct xclmgmt_dev *)dev_get_drvdata(&pdev->dev);
+	mgmt_info(lro, "remove(0x%p) where pdev->dev.driver_data = 0x%p",
+	       pdev, lro);
+	BUG_ON(lro->core.pdev != pdev);
+
+	health_thread_stop(lro);
+
+	mgmt_fini_sysfs(&pdev->dev);
+
+	xocl_subdev_destroy_all(lro);
+
+	xclmgmt_teardown_msix(lro);
+	/* remove user character device */
+	destroy_sg_char(&lro->user_char_dev);
+
+	/* unmap the BARs */
+	unmap_bars(lro);
+	pci_disable_device(pdev);
+
+	xocl_free_dev_minor(lro);
+
+	dev_set_drvdata(&pdev->dev, NULL);
+
+	xocl_drvinst_free(lro);
+}
+
+static pci_ers_result_t mgmt_pci_error_detected(struct pci_dev *pdev,
+	pci_channel_state_t state)
+{
+	switch (state) {
+	case pci_channel_io_normal:
+		xocl_info(&pdev->dev, "PCI normal state error\n");
+		return PCI_ERS_RESULT_CAN_RECOVER;
+	case pci_channel_io_frozen:
+		xocl_info(&pdev->dev, "PCI frozen state error\n");
+		return PCI_ERS_RESULT_NEED_RESET;
+	case pci_channel_io_perm_failure:
+		xocl_info(&pdev->dev, "PCI failure state error\n");
+		return PCI_ERS_RESULT_DISCONNECT;
+	default:
+		xocl_info(&pdev->dev, "PCI unknown state %d error\n", state);
+		break;
+	}
+	return PCI_ERS_RESULT_NEED_RESET;
+}
+
+static const struct pci_error_handlers xclmgmt_err_handler = {
+	.error_detected = mgmt_pci_error_detected,
+};
+
+static struct pci_driver xclmgmt_driver = {
+	.name = DRV_NAME,
+	.id_table = pci_ids,
+	.probe = xclmgmt_probe,
+	.remove = xclmgmt_remove,
+	/* resume, suspend are optional */
+	.err_handler = &xclmgmt_err_handler,
+};
+
+static int (*drv_reg_funcs[])(void) __initdata = {
+	xocl_init_feature_rom,
+	xocl_init_sysmon,
+	xocl_init_mb,
+	xocl_init_xvc,
+	xocl_init_mailbox,
+	xocl_init_firewall,
+	xocl_init_icap,
+	xocl_init_mig,
+	xocl_init_xmc,
+	xocl_init_dna,
+	xocl_init_fmgr,
+};
+
+static void (*drv_unreg_funcs[])(void) = {
+	xocl_fini_feature_rom,
+	xocl_fini_sysmon,
+	xocl_fini_mb,
+	xocl_fini_xvc,
+	xocl_fini_mailbox,
+	xocl_fini_firewall,
+	xocl_fini_icap,
+	xocl_fini_mig,
+	xocl_fini_xmc,
+	xocl_fini_dna,
+	xocl_fini_fmgr,
+};
+
+static int __init xclmgmt_init(void)
+{
+	int res, i;
+
+	pr_info(DRV_NAME " init()\n");
+	xrt_class = class_create(THIS_MODULE, "xrt_mgmt");
+	if (IS_ERR(xrt_class))
+		return PTR_ERR(xrt_class);
+
+	res = alloc_chrdev_region(&xclmgmt_devnode, 0,
+				  XOCL_MAX_DEVICES, DRV_NAME);
+	if (res)
+		goto alloc_err;
+
+	/* Need to init sub device driver before pci driver register */
+	for (i = 0; i < ARRAY_SIZE(drv_reg_funcs); ++i) {
+		res = drv_reg_funcs[i]();
+		if (res)
+			goto drv_init_err;
+	}
+
+	res = pci_register_driver(&xclmgmt_driver);
+	if (res)
+		goto reg_err;
+
+	return 0;
+
+drv_init_err:
+reg_err:
+	for (i--; i >= 0; i--)
+		drv_unreg_funcs[i]();
+
+	unregister_chrdev_region(xclmgmt_devnode, XOCL_MAX_DEVICES);
+alloc_err:
+	pr_info(DRV_NAME " init() err\n");
+	class_destroy(xrt_class);
+	return res;
+}
+
+static void xclmgmt_exit(void)
+{
+	int i;
+
+	pr_info(DRV_NAME" exit()\n");
+	pci_unregister_driver(&xclmgmt_driver);
+
+	for (i = ARRAY_SIZE(drv_unreg_funcs) - 1; i >= 0; i--)
+		drv_unreg_funcs[i]();
+
+	/* unregister this driver from the PCI bus driver */
+	unregister_chrdev_region(xclmgmt_devnode, XOCL_MAX_DEVICES);
+	class_destroy(xrt_class);
+}
+
+module_init(xclmgmt_init);
+module_exit(xclmgmt_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Lizhi Hou <[email protected]>");
+MODULE_VERSION(XRT_DRIVER_VERSION);
+MODULE_DESCRIPTION("Xilinx SDx management function driver");
drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h new file +147 -0

147 lines not on this page · raw message

drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c new file +30 -0
new file mode 100644
index 000000000000..5e60db260b37
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/**
+ *  Copyright (C) 2017-2019 Xilinx, Inc. All rights reserved.
+ *
+ *  Code borrowed from Xilinx SDAccel XDMA driver
+ *  Author: Umang Parekh
+ *
+ */
+
+#include "mgmt-core.h"
+
+int ocl_freqscaling_ioctl(struct xclmgmt_dev *lro, const void __user *arg)
+{
+	struct xclmgmt_ioc_freqscaling freq_obj;
+
+	mgmt_info(lro, "%s  called", __func__);
+
+	if (copy_from_user((void *)&freq_obj, arg,
+		sizeof(struct xclmgmt_ioc_freqscaling)))
+		return -EFAULT;
+
+	return xocl_icap_ocl_update_clock_freq_topology(lro, &freq_obj);
+}
+
+void fill_frequency_info(struct xclmgmt_dev *lro, struct xclmgmt_ioc_info *obj)
+{
+	(void) xocl_icap_ocl_get_freq(lro, 0, obj->ocl_frequency,
+		ARRAY_SIZE(obj->ocl_frequency));
+}
drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c new file +148 -0

148 lines not on this page · raw message

drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h new file +244 -0

244 lines not on this page · raw message

drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c new file +318 -0

318 lines not on this page · raw message

drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c new file +399 -0

399 lines not on this page · raw message

Signature · 1 line
2.17.0
#6 lore raw

RFC PATCH 6/6 Add user physical function driver

In reply to [email protected]

From: Sonal Santan <[email protected]>

---
 drivers/gpu/drm/xocl/userpf/common.h     |  157 +++
 drivers/gpu/drm/xocl/userpf/xocl_bo.c    | 1255 ++++++++++++++++++++++
 drivers/gpu/drm/xocl/userpf/xocl_bo.h    |  119 ++
 drivers/gpu/drm/xocl/userpf/xocl_drm.c   |  640 +++++++++++
 drivers/gpu/drm/xocl/userpf/xocl_drv.c   |  743 +++++++++++++
 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c |  396 +++++++
 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c |  344 ++++++
 7 files changed, 3654 insertions(+)
 create mode 100644 drivers/gpu/drm/xocl/userpf/common.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drm.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drv.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c
drivers/gpu/drm/xocl/userpf/common.h new file +157 -0
new file mode 100644
index 000000000000..c7dd4a68441c
@@ -0,0 +1,157 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+/*
+ * Copyright (C) 2016-2019 Xilinx, Inc. All rights reserved.
+ *
+ * Authors:
+ * Lizhi Hou <[email protected]>
+ *
+ */
+
+#ifndef _USERPF_COMMON_H
+#define	_USERPF_COMMON_H
+
+#include "../xocl_drv.h"
+#include "xocl_bo.h"
+#include "../xocl_drm.h"
+#include <drm/xocl_drm.h>
+#include <linux/hashtable.h>
+
+#define XOCL_DRIVER_DESC        "Xilinx PCIe Accelerator Device Manager"
+#define XOCL_DRIVER_DATE        "20180612"
+#define XOCL_DRIVER_MAJOR       2018
+#define XOCL_DRIVER_MINOR       2
+#define XOCL_DRIVER_PATCHLEVEL  8
+
+#define XOCL_MAX_CONCURRENT_CLIENTS 32
+
+#define XOCL_DRIVER_VERSION                             \
+	__stringify(XOCL_DRIVER_MAJOR) "."              \
+	__stringify(XOCL_DRIVER_MINOR) "."              \
+	__stringify(XOCL_DRIVER_PATCHLEVEL)
+
+#define XOCL_DRIVER_VERSION_NUMBER                              \
+	((XOCL_DRIVER_MAJOR)*1000 + (XOCL_DRIVER_MINOR)*100 +   \
+	XOCL_DRIVER_PATCHLEVEL)
+
+#define userpf_err(d, args...)                     \
+	xocl_err(&XDEV(d)->pdev->dev, ##args)
+#define userpf_info(d, args...)                    \
+	xocl_info(&XDEV(d)->pdev->dev, ##args)
+#define userpf_dbg(d, args...)                     \
+	xocl_dbg(&XDEV(d)->pdev->dev, ##args)
+
+#define xocl_get_root_dev(dev, root)		\
+	for (root = dev; root->bus && root->bus->self; root = root->bus->self)
+
+#define	XOCL_USER_PROC_HASH_SZ		256
+
+#define XOCL_U32_MASK 0xFFFFFFFF
+
+#define	MAX_SLOTS	128
+#define MAX_CUS		128
+#define MAX_U32_SLOT_MASKS (((MAX_SLOTS-1)>>5) + 1)
+#define MAX_U32_CU_MASKS (((MAX_CUS-1)>>5) + 1)
+#define MAX_DEPS        8
+
+#define XOCL_DRM_FREE_MALLOC
+
+#define XOCL_PA_SECTION_SHIFT		28
+
+struct xocl_dev	{
+	struct xocl_dev_core	core;
+
+	bool			offline;
+
+	/* health thread */
+	struct task_struct	       *health_thread;
+	struct xocl_health_thread_arg	thread_arg;
+
+	u32			p2p_bar_idx;
+	resource_size_t		p2p_bar_len;
+	void			* __iomem p2p_bar_addr;
+
+	/*should be removed after mailbox is supported */
+	struct percpu_ref ref;
+	struct completion cmp;
+
+	struct dev_pagemap pgmap;
+	struct list_head                ctx_list;
+	struct mutex			ctx_list_lock;
+	unsigned int                    needs_reset; /* bool aligned */
+	atomic_t                        outstanding_execs;
+	atomic64_t                      total_execs;
+	void				*p2p_res_grp;
+};
+
+/**
+ * struct client_ctx: Manage user space client attached to device
+ *
+ * @link: Client context is added to list in device
+ * @xclbin_id: UUID for xclbin loaded by client, or nullid if no xclbin loaded
+ * @xclbin_locked: Flag to denote that this context locked the xclbin
+ * @trigger: Poll wait counter for number of completed exec buffers
+ * @outstanding_execs: Counter for number outstanding exec buffers
+ * @abort: Flag to indicate that this context has detached from user space (ctrl-c)
+ * @num_cus: Number of resources (CUs) explcitly aquired
+ * @lock: Mutex lock for exclusive access
+ * @cu_bitmap: CUs reserved by this context, may contain implicit resources
+ */
+struct client_ctx {
+	struct list_head	link;
+	uuid_t                  xclbin_id;
+	unsigned int            xclbin_locked;
+	unsigned int            abort;
+	unsigned int		num_cus; /* number of resource locked explicitly by client */
+	atomic_t		trigger;     /* count of poll notification to acknowledge */
+	atomic_t                outstanding_execs;
+	struct mutex		lock;
+	struct xocl_dev        *xdev;
+	DECLARE_BITMAP(cu_bitmap, MAX_CUS);  /* may contain implicitly aquired resources such as CDMA */
+	struct pid             *pid;
+};
+
+struct xocl_mm_wrapper {
+	struct drm_mm *mm;
+	struct drm_xocl_mm_stat *mm_usage_stat;
+	uint64_t start_addr;
+	uint64_t size;
+	uint32_t ddr;
+	struct hlist_node node;
+};
+
+/* ioctl functions */
+int xocl_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);
+int xocl_execbuf_ioctl(struct drm_device *dev, void *data,
+	struct drm_file *filp);
+int xocl_ctx_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);
+int xocl_user_intr_ioctl(struct drm_device *dev, void *data,
+	struct drm_file *filp);
+int xocl_read_axlf_ioctl(struct drm_device *dev, void *data,
+	struct drm_file *filp);
+int xocl_hot_reset_ioctl(struct drm_device *dev, void *data,
+	struct drm_file *filp);
+int xocl_reclock_ioctl(struct drm_device *dev, void *data,
+	struct drm_file *filp);
+
+/* sysfs functions */
+int xocl_init_sysfs(struct device *dev);
+void xocl_fini_sysfs(struct device *dev);
+
+/* helper functions */
+int64_t xocl_hot_reset(struct xocl_dev *xdev, bool force);
+void xocl_p2p_mem_release(struct xocl_dev *xdev, bool recov_bar_sz);
+int xocl_p2p_mem_reserve(struct xocl_dev *xdev);
+int xocl_get_p2p_bar(struct xocl_dev *xdev, u64 *bar_size);
+int xocl_pci_resize_resource(struct pci_dev *dev, int resno, int size);
+void xocl_reset_notify(struct pci_dev *pdev, bool prepare);
+void user_pci_reset_prepare(struct pci_dev *pdev);
+void user_pci_reset_done(struct pci_dev *pdev);
+
+uint get_live_client_size(struct xocl_dev *xdev);
+void reset_notify_client_ctx(struct xocl_dev *xdev);
+
+void get_pcie_link_info(struct xocl_dev	*xdev,
+	unsigned short *link_width, unsigned short *link_speed, bool is_cap);
+int xocl_reclock(struct xocl_dev *xdev, void *data);
+#endif
drivers/gpu/drm/xocl/userpf/xocl_bo.c new file +1255 -0

1,255 lines not on this page · raw message

drivers/gpu/drm/xocl/userpf/xocl_bo.h new file +119 -0

119 lines not on this page · raw message

drivers/gpu/drm/xocl/userpf/xocl_drm.c new file +640 -0

640 lines not on this page · raw message

drivers/gpu/drm/xocl/userpf/xocl_drv.c new file +743 -0

743 lines not on this page · raw message

drivers/gpu/drm/xocl/userpf/xocl_ioctl.c new file +396 -0

86 lines not on this page · raw message

drivers/gpu/drm/xocl/userpf/xocl_sysfs.c new file +344 -0

344 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.0

Part of the diff is not shown here. View the raw message.

#7 lore raw
In reply to [email protected]
Quoted 7 lines · On Tue, Mar 19, 2019 at 02:53:55PM -0700, [email protected] wrote:

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 50 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two physical functions: management physical function and user physical function.

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different workloads.

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:

1.  ICAP programming (FPGA bitstream download with FPGA Mgr integration)
2.  Clock scaling
3.  Loading firmware container also called dsabin (embedded Microblaze
    firmware for ERT and XMC, optional clearing bitstream)
4.  In-band sensors: temp, voltage, power, etc.
5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical functions

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:

1.  Device memory topology discovery and memory management
2.  Buffer object abstraction and management for client process
3.  XDMA MM PCIe DMA engine programming
4.  Multi-process aware context management
5.  Compute unit execution management (optionally with help of ERT) for

client processes
6. Hardware mailbox for communication between two physical functions

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and export/import. xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects and provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

Quoted 6 lines

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at
https://github.com/Xilinx/XRT

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really something applications would use.

From the pretty picture on github it looks like there's some opencl/ml/other fancy stuff sitting on top that applications would use. Is that also available?

Thanks, Daniel

Quoted 118 lines

Thanks,
-Sonal

Sonal Santan (6):
Add skeleton code: ioctl definitions and build hooks Global data structures shared between xocl and xmgmt drivers Add platform drivers for various IPs and frameworks Add core of XDMA driver
Add management driver
Add user physical function driver

 drivers/gpu/drm/Kconfig                    |    2 +
 drivers/gpu/drm/Makefile                   |    1 +
 drivers/gpu/drm/xocl/Kconfig               |   22 +
 drivers/gpu/drm/xocl/Makefile              |    3 +
 drivers/gpu/drm/xocl/devices.h             |  954 +++++
 drivers/gpu/drm/xocl/ert.h                 |  385 ++
 drivers/gpu/drm/xocl/lib/Makefile.in       |   16 +
 drivers/gpu/drm/xocl/lib/cdev_sgdma.h      |   63 +
 drivers/gpu/drm/xocl/lib/libxdma.c         | 4368 ++++++++++++++++++++
 drivers/gpu/drm/xocl/lib/libxdma.h         |  596 +++
 drivers/gpu/drm/xocl/lib/libxdma_api.h     |  127 +
 drivers/gpu/drm/xocl/mgmtpf/Makefile       |   29 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c    |  960 +++++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h    |  147 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c      |   30 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c   |  148 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h     |  244 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c   |  318 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c   |  399 ++
 drivers/gpu/drm/xocl/subdev/dna.c          |  356 ++
 drivers/gpu/drm/xocl/subdev/feature_rom.c  |  412 ++
 drivers/gpu/drm/xocl/subdev/firewall.c     |  389 ++
 drivers/gpu/drm/xocl/subdev/fmgr.c         |  198 +
 drivers/gpu/drm/xocl/subdev/icap.c         | 2859 +++++++++++++
 drivers/gpu/drm/xocl/subdev/mailbox.c      | 1868 +++++++++
 drivers/gpu/drm/xocl/subdev/mb_scheduler.c | 3059 ++++++++++++++
 drivers/gpu/drm/xocl/subdev/microblaze.c   |  722 ++++
 drivers/gpu/drm/xocl/subdev/mig.c          |  256 ++
 drivers/gpu/drm/xocl/subdev/sysmon.c       |  385 ++
 drivers/gpu/drm/xocl/subdev/xdma.c         |  510 +++
 drivers/gpu/drm/xocl/subdev/xmc.c          | 1480 +++++++
 drivers/gpu/drm/xocl/subdev/xvc.c          |  461 +++
 drivers/gpu/drm/xocl/userpf/Makefile       |   27 +
 drivers/gpu/drm/xocl/userpf/common.h       |  157 +
 drivers/gpu/drm/xocl/userpf/xocl_bo.c      | 1255 ++++++
 drivers/gpu/drm/xocl/userpf/xocl_bo.h      |  119 +
 drivers/gpu/drm/xocl/userpf/xocl_drm.c     |  640 +++
 drivers/gpu/drm/xocl/userpf/xocl_drv.c     |  743 ++++
 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c   |  396 ++
 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c   |  344 ++
 drivers/gpu/drm/xocl/version.h             |   22 +
 drivers/gpu/drm/xocl/xclbin.h              |  314 ++
 drivers/gpu/drm/xocl/xclfeatures.h         |  107 +
 drivers/gpu/drm/xocl/xocl_ctx.c            |  196 +
 drivers/gpu/drm/xocl/xocl_drm.h            |   91 +
 drivers/gpu/drm/xocl/xocl_drv.h            |  783 ++++
 drivers/gpu/drm/xocl/xocl_subdev.c         |  540 +++
 drivers/gpu/drm/xocl/xocl_thread.c         |   64 +
 include/uapi/drm/xmgmt_drm.h               |  204 +
 include/uapi/drm/xocl_drm.h                |  483 +++
 50 files changed, 28252 insertions(+)
 create mode 100644 drivers/gpu/drm/xocl/Kconfig
 create mode 100644 drivers/gpu/drm/xocl/Makefile
 create mode 100644 drivers/gpu/drm/xocl/devices.h
 create mode 100644 drivers/gpu/drm/xocl/ert.h
 create mode 100644 drivers/gpu/drm/xocl/lib/Makefile.in
 create mode 100644 drivers/gpu/drm/xocl/lib/cdev_sgdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.c
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma_api.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/dna.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/feature_rom.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/firewall.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/fmgr.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/icap.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mailbox.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mb_scheduler.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/microblaze.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mig.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/sysmon.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xdma.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xmc.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xvc.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/userpf/common.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drm.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drv.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/version.h
 create mode 100644 drivers/gpu/drm/xocl/xclbin.h
 create mode 100644 drivers/gpu/drm/xocl/xclfeatures.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_ctx.c
 create mode 100644 drivers/gpu/drm/xocl/xocl_drm.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_drv.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_subdev.c
 create mode 100644 drivers/gpu/drm/xocl/xocl_thread.c
 create mode 100644 include/uapi/drm/xmgmt_drm.h
 create mode 100644 include/uapi/drm/xocl_drm.h

--
2.17.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw
Quoted 82 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 25, 2019 1:28 PM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

Quoted 7 lines · On Tue, Mar 19, 2019 at 02:53:55PM -0700, [email protected] wrote:

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise

customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 8 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two physical functions:
management physical function and user physical function.

Quoted 5 lines

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different

workloads.

Quoted 25 lines

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:
1. ICAP programming (FPGA bitstream download with FPGA Mgr integration) 2. Clock scaling 3. Loading firmware container also called dsabin (embedded Microblaze
firmware for ERT and XMC, optional clearing bitstream) 4. In-band
sensors: temp, voltage, power, etc.

5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical functions

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:
1. Device memory topology discovery and memory management 2. Buffer object abstraction and management for client process 3. XDMA MM PCIe DMA engine programming 4. Multi-process aware context management 5. Compute unit execution management (optionally with help of ERT) for client processes
6. Hardware mailbox for communication between two physical functions

Quoted 6 lines

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and export/import. xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects

and

Quoted 11 lines

provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at
https://github.com/Xilinx/XRT

Quoted 4 lines

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really something applications would use.

Sonal Santan <[email protected]>

4:20 PM (1 minute ago)

to me

Quoted 80 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 25, 2019 1:28 PM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

Quoted 7 lines · On Tue, Mar 19, 2019 at 02:53:55PM -0700, [email protected] wrote:

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise

customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 8 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two physical functions:
management physical function and user physical function.

Quoted 5 lines

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different

workloads.

Quoted 25 lines

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:
1. ICAP programming (FPGA bitstream download with FPGA Mgr integration) 2. Clock scaling 3. Loading firmware container also called dsabin (embedded Microblaze
firmware for ERT and XMC, optional clearing bitstream) 4. In-band
sensors: temp, voltage, power, etc.

5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical functions

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:
1. Device memory topology discovery and memory management 2. Buffer object abstraction and management for client process 3. XDMA MM PCIe DMA engine programming 4. Multi-process aware context management 5. Compute unit execution management (optionally with help of ERT) for client processes
6. Hardware mailbox for communication between two physical functions

Quoted 6 lines

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and export/import. xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects

and

Quoted 11 lines

provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at
https://github.com/Xilinx/XRT

Quoted 5 lines

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really something applications would use.

Appreciate your feedback.

The userspace libraries define a common abstraction but have different implementations for Zynq Ultrascale+ embedded platform, PCIe based Alveo (and Faas) and emulation flows. The latter lets you run your application without physical hardware.

Quoted 3 lines

From the pretty picture on github it looks like there's some opencl/ml/other fancy stuff sitting on top that applications would use. Is that also available?

The full OpenCL runtime is available in the same repository. Xilinx ML Suite is also based on XRT and its source can be found at https://github.com/Xilinx/ml-suite.

Typically end users use OpenCL APIs which are part of XRT stack. One can write an application to directly call XRT APIs defined at
https://xilinx.github.io/XRT/2018.3/html/xclhal2.main.html

Thanks,
-Sonal

Quoted 126 lines

Thanks, Daniel

Quoted 110 lines

Thanks,
-Sonal

Sonal Santan (6):
Add skeleton code: ioctl definitions and build hooks Global data structures shared between xocl and xmgmt drivers Add platform drivers for various IPs and frameworks Add core of XDMA driver
Add management driver
Add user physical function driver

 drivers/gpu/drm/Kconfig                    |    2 +
 drivers/gpu/drm/Makefile                   |    1 +
 drivers/gpu/drm/xocl/Kconfig               |   22 +
 drivers/gpu/drm/xocl/Makefile              |    3 +
 drivers/gpu/drm/xocl/devices.h             |  954 +++++
 drivers/gpu/drm/xocl/ert.h                 |  385 ++
 drivers/gpu/drm/xocl/lib/Makefile.in       |   16 +
 drivers/gpu/drm/xocl/lib/cdev_sgdma.h      |   63 +
 drivers/gpu/drm/xocl/lib/libxdma.c         | 4368 ++++++++++++++++++++
 drivers/gpu/drm/xocl/lib/libxdma.h         |  596 +++
 drivers/gpu/drm/xocl/lib/libxdma_api.h     |  127 +
 drivers/gpu/drm/xocl/mgmtpf/Makefile       |   29 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c    |  960 +++++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h    |  147 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c      |   30 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c   |  148 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h     |  244 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c   |  318 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c   |  399 ++
 drivers/gpu/drm/xocl/subdev/dna.c          |  356 ++
 drivers/gpu/drm/xocl/subdev/feature_rom.c  |  412 ++
 drivers/gpu/drm/xocl/subdev/firewall.c     |  389 ++
 drivers/gpu/drm/xocl/subdev/fmgr.c         |  198 +
 drivers/gpu/drm/xocl/subdev/icap.c         | 2859 +++++++++++++
 drivers/gpu/drm/xocl/subdev/mailbox.c      | 1868 +++++++++
 drivers/gpu/drm/xocl/subdev/mb_scheduler.c | 3059 ++++++++++++++
 drivers/gpu/drm/xocl/subdev/microblaze.c   |  722 ++++
 drivers/gpu/drm/xocl/subdev/mig.c          |  256 ++
 drivers/gpu/drm/xocl/subdev/sysmon.c       |  385 ++
 drivers/gpu/drm/xocl/subdev/xdma.c         |  510 +++
 drivers/gpu/drm/xocl/subdev/xmc.c          | 1480 +++++++
 drivers/gpu/drm/xocl/subdev/xvc.c          |  461 +++
 drivers/gpu/drm/xocl/userpf/Makefile       |   27 +
 drivers/gpu/drm/xocl/userpf/common.h       |  157 +
 drivers/gpu/drm/xocl/userpf/xocl_bo.c      | 1255 ++++++
 drivers/gpu/drm/xocl/userpf/xocl_bo.h      |  119 +
 drivers/gpu/drm/xocl/userpf/xocl_drm.c     |  640 +++
 drivers/gpu/drm/xocl/userpf/xocl_drv.c     |  743 ++++
 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c   |  396 ++
 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c   |  344 ++
 drivers/gpu/drm/xocl/version.h             |   22 +
 drivers/gpu/drm/xocl/xclbin.h              |  314 ++
 drivers/gpu/drm/xocl/xclfeatures.h         |  107 +
 drivers/gpu/drm/xocl/xocl_ctx.c            |  196 +
 drivers/gpu/drm/xocl/xocl_drm.h            |   91 +
 drivers/gpu/drm/xocl/xocl_drv.h            |  783 ++++
 drivers/gpu/drm/xocl/xocl_subdev.c         |  540 +++
 drivers/gpu/drm/xocl/xocl_thread.c         |   64 +
 include/uapi/drm/xmgmt_drm.h               |  204 +
 include/uapi/drm/xocl_drm.h                |  483 +++
 50 files changed, 28252 insertions(+)  create mode 100644

drivers/gpu/drm/xocl/Kconfig create mode 100644 drivers/gpu/drm/xocl/Makefile create mode 100644 drivers/gpu/drm/xocl/devices.h create mode 100644 drivers/gpu/drm/xocl/ert.h create mode 100644 drivers/gpu/drm/xocl/lib/Makefile.in

 create mode 100644 drivers/gpu/drm/xocl/lib/cdev_sgdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.c
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma_api.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/dna.c  create mode
100644 drivers/gpu/drm/xocl/subdev/feature_rom.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/firewall.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/fmgr.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/icap.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mailbox.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mb_scheduler.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/microblaze.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mig.c  create mode
100644 drivers/gpu/drm/xocl/subdev/sysmon.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xdma.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xmc.c  create mode
100644 drivers/gpu/drm/xocl/subdev/xvc.c  create mode 100644
drivers/gpu/drm/xocl/userpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/userpf/common.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drm.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drv.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/version.h  create mode 100644
drivers/gpu/drm/xocl/xclbin.h  create mode 100644
drivers/gpu/drm/xocl/xclfeatures.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_ctx.c  create mode
100644 drivers/gpu/drm/xocl/xocl_drm.h  create mode 100644
drivers/gpu/drm/xocl/xocl_drv.h  create mode 100644
drivers/gpu/drm/xocl/xocl_subdev.c
 create mode 100644 drivers/gpu/drm/xocl/xocl_thread.c
 create mode 100644 include/uapi/drm/xmgmt_drm.h  create mode 100644
Quoted 8 lines

include/uapi/drm/xocl_drm.h

--
2.17.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

#9 lore raw
Quoted 187 lines · Sonal Santan
Quoted 83 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 25, 2019 1:28 PM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

Quoted 7 lines · On Tue, Mar 19, 2019 at 02:53:55PM -0700, [email protected] wrote:

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise

customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 8 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two physical functions:
management physical function and user physical function.

Quoted 5 lines

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different

workloads.

Quoted 25 lines

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:
1. ICAP programming (FPGA bitstream download with FPGA Mgr integration) 2. Clock scaling 3. Loading firmware container also called dsabin (embedded Microblaze
firmware for ERT and XMC, optional clearing bitstream) 4. In-band
sensors: temp, voltage, power, etc.

5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical functions

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:
1. Device memory topology discovery and memory management 2. Buffer object abstraction and management for client process 3. XDMA MM PCIe DMA engine programming 4. Multi-process aware context management 5. Compute unit execution management (optionally with help of ERT) for client processes
6. Hardware mailbox for communication between two physical functions

Quoted 6 lines

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and export/import. xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects

and

Quoted 11 lines

provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at
https://github.com/Xilinx/XRT

Quoted 4 lines

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really something applications would use.

Sonal Santan <[email protected]>

4:20 PM (1 minute ago)

to me

Quoted 80 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 25, 2019 1:28 PM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

Quoted 7 lines · On Tue, Mar 19, 2019 at 02:53:55PM -0700, [email protected] wrote:

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise

customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 8 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two physical functions:
management physical function and user physical function.

Quoted 5 lines

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different

workloads.

Quoted 25 lines

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:
1. ICAP programming (FPGA bitstream download with FPGA Mgr integration) 2. Clock scaling 3. Loading firmware container also called dsabin (embedded Microblaze
firmware for ERT and XMC, optional clearing bitstream) 4. In-band
sensors: temp, voltage, power, etc.

5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical functions

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:
1. Device memory topology discovery and memory management 2. Buffer object abstraction and management for client process 3. XDMA MM PCIe DMA engine programming 4. Multi-process aware context management 5. Compute unit execution management (optionally with help of ERT) for client processes
6. Hardware mailbox for communication between two physical functions

Quoted 6 lines

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and export/import. xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects

and

Quoted 11 lines

provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at
https://github.com/Xilinx/XRT

Quoted 5 lines

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really something applications would use.

Appreciate your feedback.

The userspace libraries define a common abstraction but have different implementations for Zynq Ultrascale+ embedded platform, PCIe based Alveo (and Faas) and emulation flows. The latter lets you run your application without physical hardware.

Quoted 1 line
Quoted 5 lines
Quoted 2 lines

From the pretty picture on github it looks like there's some opencl/ml/other fancy stuff sitting on top that applications would use. Is that also available?

The full OpenCL runtime is available in the same repository. Xilinx ML Suite is also based on XRT and its source can be found at https://github.com/Xilinx/ml-suite.

Hm, I did a few git grep for the usual opencl entry points, but didn't find anything. Do I need to run some build scripts first (which downloads additional sourcecode)? Or is there some symbol mangling going on and that's why I don't find anything? Pointers very much appreciated.

Quoted 3 lines

Typically end users use OpenCL APIs which are part of XRT stack. One can write an application to directly call XRT APIs defined at
https://xilinx.github.io/XRT/2018.3/html/xclhal2.main.html

I have no clue about DNN/ML unfortunately, I think I'll try to look into the ocl side a bit more first.

Thanks, Daniel

Quoted 129 lines

Thanks,
-Sonal

Quoted 126 lines

Thanks, Daniel

Quoted 110 lines

Thanks,
-Sonal

Sonal Santan (6):
Add skeleton code: ioctl definitions and build hooks Global data structures shared between xocl and xmgmt drivers Add platform drivers for various IPs and frameworks Add core of XDMA driver
Add management driver
Add user physical function driver

 drivers/gpu/drm/Kconfig                    |    2 +
 drivers/gpu/drm/Makefile                   |    1 +
 drivers/gpu/drm/xocl/Kconfig               |   22 +
 drivers/gpu/drm/xocl/Makefile              |    3 +
 drivers/gpu/drm/xocl/devices.h             |  954 +++++
 drivers/gpu/drm/xocl/ert.h                 |  385 ++
 drivers/gpu/drm/xocl/lib/Makefile.in       |   16 +
 drivers/gpu/drm/xocl/lib/cdev_sgdma.h      |   63 +
 drivers/gpu/drm/xocl/lib/libxdma.c         | 4368 ++++++++++++++++++++
 drivers/gpu/drm/xocl/lib/libxdma.h         |  596 +++
 drivers/gpu/drm/xocl/lib/libxdma_api.h     |  127 +
 drivers/gpu/drm/xocl/mgmtpf/Makefile       |   29 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c    |  960 +++++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h    |  147 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c      |   30 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c   |  148 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h     |  244 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c   |  318 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c   |  399 ++
 drivers/gpu/drm/xocl/subdev/dna.c          |  356 ++
 drivers/gpu/drm/xocl/subdev/feature_rom.c  |  412 ++
 drivers/gpu/drm/xocl/subdev/firewall.c     |  389 ++
 drivers/gpu/drm/xocl/subdev/fmgr.c         |  198 +
 drivers/gpu/drm/xocl/subdev/icap.c         | 2859 +++++++++++++
 drivers/gpu/drm/xocl/subdev/mailbox.c      | 1868 +++++++++
 drivers/gpu/drm/xocl/subdev/mb_scheduler.c | 3059 ++++++++++++++
 drivers/gpu/drm/xocl/subdev/microblaze.c   |  722 ++++
 drivers/gpu/drm/xocl/subdev/mig.c          |  256 ++
 drivers/gpu/drm/xocl/subdev/sysmon.c       |  385 ++
 drivers/gpu/drm/xocl/subdev/xdma.c         |  510 +++
 drivers/gpu/drm/xocl/subdev/xmc.c          | 1480 +++++++
 drivers/gpu/drm/xocl/subdev/xvc.c          |  461 +++
 drivers/gpu/drm/xocl/userpf/Makefile       |   27 +
 drivers/gpu/drm/xocl/userpf/common.h       |  157 +
 drivers/gpu/drm/xocl/userpf/xocl_bo.c      | 1255 ++++++
 drivers/gpu/drm/xocl/userpf/xocl_bo.h      |  119 +
 drivers/gpu/drm/xocl/userpf/xocl_drm.c     |  640 +++
 drivers/gpu/drm/xocl/userpf/xocl_drv.c     |  743 ++++
 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c   |  396 ++
 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c   |  344 ++
 drivers/gpu/drm/xocl/version.h             |   22 +
 drivers/gpu/drm/xocl/xclbin.h              |  314 ++
 drivers/gpu/drm/xocl/xclfeatures.h         |  107 +
 drivers/gpu/drm/xocl/xocl_ctx.c            |  196 +
 drivers/gpu/drm/xocl/xocl_drm.h            |   91 +
 drivers/gpu/drm/xocl/xocl_drv.h            |  783 ++++
 drivers/gpu/drm/xocl/xocl_subdev.c         |  540 +++
 drivers/gpu/drm/xocl/xocl_thread.c         |   64 +
 include/uapi/drm/xmgmt_drm.h               |  204 +
 include/uapi/drm/xocl_drm.h                |  483 +++
 50 files changed, 28252 insertions(+)  create mode 100644

drivers/gpu/drm/xocl/Kconfig create mode 100644 drivers/gpu/drm/xocl/Makefile create mode 100644 drivers/gpu/drm/xocl/devices.h create mode 100644 drivers/gpu/drm/xocl/ert.h create mode 100644 drivers/gpu/drm/xocl/lib/Makefile.in

 create mode 100644 drivers/gpu/drm/xocl/lib/cdev_sgdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.c
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma_api.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/dna.c  create mode
100644 drivers/gpu/drm/xocl/subdev/feature_rom.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/firewall.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/fmgr.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/icap.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mailbox.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mb_scheduler.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/microblaze.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mig.c  create mode
100644 drivers/gpu/drm/xocl/subdev/sysmon.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xdma.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xmc.c  create mode
100644 drivers/gpu/drm/xocl/subdev/xvc.c  create mode 100644
drivers/gpu/drm/xocl/userpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/userpf/common.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drm.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drv.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/version.h  create mode 100644
drivers/gpu/drm/xocl/xclbin.h  create mode 100644
drivers/gpu/drm/xocl/xclfeatures.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_ctx.c  create mode
100644 drivers/gpu/drm/xocl/xocl_drm.h  create mode 100644
drivers/gpu/drm/xocl/xocl_drv.h  create mode 100644
drivers/gpu/drm/xocl/xocl_subdev.c
 create mode 100644 drivers/gpu/drm/xocl/xocl_thread.c
 create mode 100644 include/uapi/drm/xmgmt_drm.h  create mode 100644
Quoted 8 lines

include/uapi/drm/xocl_drm.h

--
2.17.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#10 lore raw
Quoted 226 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]]
Sent: Wednesday, March 27, 2019 1:23 AM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

Quoted 16 lines · Sonal Santan
Quoted 16 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 25, 2019 1:28 PM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

On Tue, Mar 19, 2019 at 02:53:55PM -0700, [email protected]

Quoted 44 lines · wrote:
Quoted 44 lines
Quoted 7 lines

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise

customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 8 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two physical functions:
management physical function and user physical function.

Quoted 6 lines

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different

workloads.

Quoted 17 lines

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:
1. ICAP programming (FPGA bitstream download with FPGA Mgr integration) 2. Clock scaling 3. Loading firmware container also called dsabin (embedded Microblaze
firmware for ERT and XMC, optional clearing bitstream) 4.
In-band
sensors: temp, voltage, power, etc.

5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical

functions

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:
1. Device memory topology discovery and memory management 2. Buffer object abstraction and management for client process 3. XDMA MM PCIe DMA engine programming 4. Multi-process aware

context management 5.

Quoted 25 lines
Quoted 25 lines
Quoted 5 lines

Compute unit execution management (optionally with help of ERT) for
client processes
6. Hardware mailbox for communication between two physical functions

Quoted 7 lines

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and export/import. xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects

and

Quoted 11 lines

provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at https://github.com/Xilinx/XRT

Quoted 4 lines
Quoted 4 lines

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really

something applications would use.

Quoted 20 lines

Sonal Santan <[email protected]>

4:20 PM (1 minute ago)

to me

Quoted 13 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 25, 2019 1:28 PM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

On Tue, Mar 19, 2019 at 02:53:55PM -0700, [email protected]

Quoted 44 lines · wrote:
Quoted 44 lines
Quoted 7 lines

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise

customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 8 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two physical functions:
management physical function and user physical function.

Quoted 6 lines

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different

workloads.

Quoted 17 lines

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:
1. ICAP programming (FPGA bitstream download with FPGA Mgr integration) 2. Clock scaling 3. Loading firmware container also called dsabin (embedded Microblaze
firmware for ERT and XMC, optional clearing bitstream) 4.
In-band
sensors: temp, voltage, power, etc.

5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical

functions

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:
1. Device memory topology discovery and memory management 2. Buffer object abstraction and management for client process 3. XDMA MM PCIe DMA engine programming 4. Multi-process aware

context management 5.

Quoted 25 lines
Quoted 25 lines
Quoted 5 lines

Compute unit execution management (optionally with help of ERT) for
client processes
6. Hardware mailbox for communication between two physical functions

Quoted 7 lines

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and export/import. xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects

and

Quoted 11 lines

provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at https://github.com/Xilinx/XRT

Quoted 4 lines
Quoted 4 lines

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really

something applications would use.

Quoted 7 lines
Quoted 1 line

Appreciate your feedback.

The userspace libraries define a common abstraction but have different implementations for Zynq Ultrascale+ embedded platform, PCIe based Alveo (and Faas) and emulation flows. The latter lets you run your

application without physical hardware.

Quoted 4 lines
Quoted 4 lines

From the pretty picture on github it looks like there's some opencl/ml/other fancy stuff sitting on top that applications would use. Is

that also available?

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

The full OpenCL runtime is available in the same repository. Xilinx ML Suite is also based on XRT and its source can be found at

https://github.com/Xilinx/ml-suite.

Hm, I did a few git grep for the usual opencl entry points, but didn't find anything. Do I need to run some build scripts first (which downloads additional sourcecode)? Or is there some symbol mangling going on and that's why I don't find anything? Pointers very much appreciated.

The bulk of the OCL runtime code can be found inside
https://github.com/Xilinx/XRT/tree/master/src/runtime_src/xocl.
The OCL runtime also includes https://github.com/Xilinx/XRT/tree/master/src/runtime_src/xrt.
The OCL runtime library called libxilinxopencl.so in turn then uses XRT APIs to talk to the drivers. For PCIe these XRT APIs are implemented in the library libxrt_core.so the source for which is
https://github.com/Xilinx/XRT/tree/master/src/runtime_src/driver/xclng/xrt.

You can build a fully functioning runtime stack by following very simple build instructions--
https://xilinx.github.io/XRT/master/html/build.html

We do have a few dependencies on standard Linux packages including a few OpenCL packages bundled by Linux distros: ocl-icd, ocl-icd-devel and opencl-headers

Thanks,
-Sonal

Quoted 145 lines
Quoted 4 lines

Typically end users use OpenCL APIs which are part of XRT stack. One can write an application to directly call XRT APIs defined at
https://xilinx.github.io/XRT/2018.3/html/xclhal2.main.html

I have no clue about DNN/ML unfortunately, I think I'll try to look into the ocl side a bit more first.

Thanks, Daniel

Quoted 128 lines

Thanks,
-Sonal

Quoted 125 lines

Thanks, Daniel

Quoted 110 lines

Thanks,
-Sonal

Sonal Santan (6):
Add skeleton code: ioctl definitions and build hooks Global data structures shared between xocl and xmgmt drivers Add platform drivers for various IPs and frameworks Add core of XDMA driver
Add management driver
Add user physical function driver

 drivers/gpu/drm/Kconfig                    |    2 +
 drivers/gpu/drm/Makefile                   |    1 +
 drivers/gpu/drm/xocl/Kconfig               |   22 +
 drivers/gpu/drm/xocl/Makefile              |    3 +
 drivers/gpu/drm/xocl/devices.h             |  954 +++++
 drivers/gpu/drm/xocl/ert.h                 |  385 ++
 drivers/gpu/drm/xocl/lib/Makefile.in       |   16 +
 drivers/gpu/drm/xocl/lib/cdev_sgdma.h      |   63 +
 drivers/gpu/drm/xocl/lib/libxdma.c         | 4368 ++++++++++++++++++++
 drivers/gpu/drm/xocl/lib/libxdma.h         |  596 +++
 drivers/gpu/drm/xocl/lib/libxdma_api.h     |  127 +
 drivers/gpu/drm/xocl/mgmtpf/Makefile       |   29 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c    |  960 +++++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h    |  147 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c      |   30 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c   |  148 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h     |  244 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c   |  318 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c   |  399 ++
 drivers/gpu/drm/xocl/subdev/dna.c          |  356 ++
 drivers/gpu/drm/xocl/subdev/feature_rom.c  |  412 ++
 drivers/gpu/drm/xocl/subdev/firewall.c     |  389 ++
 drivers/gpu/drm/xocl/subdev/fmgr.c         |  198 +
 drivers/gpu/drm/xocl/subdev/icap.c         | 2859 +++++++++++++
 drivers/gpu/drm/xocl/subdev/mailbox.c      | 1868 +++++++++
 drivers/gpu/drm/xocl/subdev/mb_scheduler.c | 3059 ++++++++++++++
 drivers/gpu/drm/xocl/subdev/microblaze.c   |  722 ++++
 drivers/gpu/drm/xocl/subdev/mig.c          |  256 ++
 drivers/gpu/drm/xocl/subdev/sysmon.c       |  385 ++
 drivers/gpu/drm/xocl/subdev/xdma.c         |  510 +++
 drivers/gpu/drm/xocl/subdev/xmc.c          | 1480 +++++++
 drivers/gpu/drm/xocl/subdev/xvc.c          |  461 +++
 drivers/gpu/drm/xocl/userpf/Makefile       |   27 +
 drivers/gpu/drm/xocl/userpf/common.h       |  157 +
 drivers/gpu/drm/xocl/userpf/xocl_bo.c      | 1255 ++++++
 drivers/gpu/drm/xocl/userpf/xocl_bo.h      |  119 +
 drivers/gpu/drm/xocl/userpf/xocl_drm.c     |  640 +++
 drivers/gpu/drm/xocl/userpf/xocl_drv.c     |  743 ++++
 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c   |  396 ++
 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c   |  344 ++
 drivers/gpu/drm/xocl/version.h             |   22 +
 drivers/gpu/drm/xocl/xclbin.h              |  314 ++
 drivers/gpu/drm/xocl/xclfeatures.h         |  107 +
 drivers/gpu/drm/xocl/xocl_ctx.c            |  196 +
 drivers/gpu/drm/xocl/xocl_drm.h            |   91 +
 drivers/gpu/drm/xocl/xocl_drv.h            |  783 ++++
 drivers/gpu/drm/xocl/xocl_subdev.c         |  540 +++
 drivers/gpu/drm/xocl/xocl_thread.c         |   64 +
 include/uapi/drm/xmgmt_drm.h               |  204 +
 include/uapi/drm/xocl_drm.h                |  483 +++
 50 files changed, 28252 insertions(+)  create mode 100644

drivers/gpu/drm/xocl/Kconfig create mode 100644 drivers/gpu/drm/xocl/Makefile create mode 100644 drivers/gpu/drm/xocl/devices.h create mode 100644 drivers/gpu/drm/xocl/ert.h create mode 100644 drivers/gpu/drm/xocl/lib/Makefile.in

 create mode 100644 drivers/gpu/drm/xocl/lib/cdev_sgdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.c
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma_api.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/dna.c  create mode
100644 drivers/gpu/drm/xocl/subdev/feature_rom.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/firewall.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/fmgr.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/icap.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mailbox.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mb_scheduler.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/microblaze.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mig.c  create mode
100644 drivers/gpu/drm/xocl/subdev/sysmon.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xdma.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xmc.c  create mode
100644 drivers/gpu/drm/xocl/subdev/xvc.c  create mode 100644
drivers/gpu/drm/xocl/userpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/userpf/common.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drm.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drv.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/version.h  create mode
100644 drivers/gpu/drm/xocl/xclbin.h  create mode 100644
drivers/gpu/drm/xocl/xclfeatures.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_ctx.c  create mode
100644 drivers/gpu/drm/xocl/xocl_drm.h  create mode 100644
drivers/gpu/drm/xocl/xocl_drv.h  create mode 100644
drivers/gpu/drm/xocl/xocl_subdev.c
 create mode 100644 drivers/gpu/drm/xocl/xocl_thread.c
 create mode 100644 include/uapi/drm/xmgmt_drm.h  create mode
Quoted 8 lines

100644 include/uapi/drm/xocl_drm.h

--
2.17.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation http://blog.ffwll.ch

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

#11 lore raw
Quoted 242 lines · Sonal Santan
Quoted 226 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]]
Sent: Wednesday, March 27, 2019 1:23 AM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

Quoted 16 lines · Sonal Santan
Quoted 16 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 25, 2019 1:28 PM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

On Tue, Mar 19, 2019 at 02:53:55PM -0700, [email protected]

Quoted 44 lines · wrote:
Quoted 44 lines
Quoted 7 lines

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise

customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 8 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two physical functions:
management physical function and user physical function.

Quoted 6 lines

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different

workloads.

Quoted 17 lines

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:
1. ICAP programming (FPGA bitstream download with FPGA Mgr integration) 2. Clock scaling 3. Loading firmware container also called dsabin (embedded Microblaze
firmware for ERT and XMC, optional clearing bitstream) 4.
In-band
sensors: temp, voltage, power, etc.

5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical

functions

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:
1. Device memory topology discovery and memory management 2. Buffer object abstraction and management for client process 3. XDMA MM PCIe DMA engine programming 4. Multi-process aware

context management 5.

Quoted 25 lines
Quoted 25 lines
Quoted 5 lines

Compute unit execution management (optionally with help of ERT) for
client processes
6. Hardware mailbox for communication between two physical functions

Quoted 7 lines

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and export/import. xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects

and

Quoted 11 lines

provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at https://github.com/Xilinx/XRT

Quoted 4 lines
Quoted 4 lines

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really

something applications would use.

Quoted 20 lines

Sonal Santan <[email protected]>

4:20 PM (1 minute ago)

to me

Quoted 13 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 25, 2019 1:28 PM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

On Tue, Mar 19, 2019 at 02:53:55PM -0700, [email protected]

Quoted 44 lines · wrote:
Quoted 44 lines
Quoted 7 lines

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise

customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 8 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two physical functions:
management physical function and user physical function.

Quoted 6 lines

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different

workloads.

Quoted 17 lines

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:
1. ICAP programming (FPGA bitstream download with FPGA Mgr integration) 2. Clock scaling 3. Loading firmware container also called dsabin (embedded Microblaze
firmware for ERT and XMC, optional clearing bitstream) 4.
In-band
sensors: temp, voltage, power, etc.

5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical

functions

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:
1. Device memory topology discovery and memory management 2. Buffer object abstraction and management for client process 3. XDMA MM PCIe DMA engine programming 4. Multi-process aware

context management 5.

Quoted 25 lines
Quoted 25 lines
Quoted 5 lines

Compute unit execution management (optionally with help of ERT) for
client processes
6. Hardware mailbox for communication between two physical functions

Quoted 7 lines

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and export/import. xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects

and

Quoted 11 lines

provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at https://github.com/Xilinx/XRT

Quoted 4 lines
Quoted 4 lines

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really

something applications would use.

Quoted 7 lines
Quoted 1 line

Appreciate your feedback.

The userspace libraries define a common abstraction but have different implementations for Zynq Ultrascale+ embedded platform, PCIe based Alveo (and Faas) and emulation flows. The latter lets you run your

application without physical hardware.

Quoted 4 lines
Quoted 4 lines

From the pretty picture on github it looks like there's some opencl/ml/other fancy stuff sitting on top that applications would use. Is

that also available?

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

The full OpenCL runtime is available in the same repository. Xilinx ML Suite is also based on XRT and its source can be found at

https://github.com/Xilinx/ml-suite.

Hm, I did a few git grep for the usual opencl entry points, but didn't find anything. Do I need to run some build scripts first (which downloads additional sourcecode)? Or is there some symbol mangling going on and that's why I don't find anything? Pointers very much appreciated.

The bulk of the OCL runtime code can be found inside
https://github.com/Xilinx/XRT/tree/master/src/runtime_src/xocl.
The OCL runtime also includes https://github.com/Xilinx/XRT/tree/master/src/runtime_src/xrt.
The OCL runtime library called libxilinxopencl.so in turn then uses XRT APIs to talk to the drivers. For PCIe these XRT APIs are implemented in the library libxrt_core.so the source for which is
https://github.com/Xilinx/XRT/tree/master/src/runtime_src/driver/xclng/xrt.

Quoted 5 lines

You can build a fully functioning runtime stack by following very simple build instructions--
https://xilinx.github.io/XRT/master/html/build.html

We do have a few dependencies on standard Linux packages including a few OpenCL packages bundled by Linux distros: ocl-icd, ocl-icd-devel and opencl-headers

Thanks a lot for pointers. No idea why I didn't find this stuff, I guess I was blind.

The thing I'm really interested in is the compiler, since at least the experience from gpus says that very much is part of the overall uapi, and definitely needed to be able to make any chances to the implementation. Looking at clCreateProgramWithSource there's only a lookup up cached compiles (it looks for xclbin), and src/runtime_src/xclbin doesn't look like that provides a compiler either. It seems like apps need to precompile everything first. Am I again missing something, or is this how it's supposed to work?

Note: There's no expectation for the fully optimizing compiler, and we're totally ok if there's an optimizing proprietary compiler and a basic open one (amd, and bunch of other companies all have such dual stacks running on top of drm kernel drivers). But a basic compiler that can convert basic kernels into machine code is expected.

Thanks, Daniel

Quoted 149 lines

Thanks,
-Sonal

Quoted 145 lines
Quoted 4 lines

Typically end users use OpenCL APIs which are part of XRT stack. One can write an application to directly call XRT APIs defined at
https://xilinx.github.io/XRT/2018.3/html/xclhal2.main.html

I have no clue about DNN/ML unfortunately, I think I'll try to look into the ocl side a bit more first.

Thanks, Daniel

Quoted 128 lines

Thanks,
-Sonal

Quoted 125 lines

Thanks, Daniel

Quoted 110 lines

Thanks,
-Sonal

Sonal Santan (6):
Add skeleton code: ioctl definitions and build hooks Global data structures shared between xocl and xmgmt drivers Add platform drivers for various IPs and frameworks Add core of XDMA driver
Add management driver
Add user physical function driver

 drivers/gpu/drm/Kconfig                    |    2 +
 drivers/gpu/drm/Makefile                   |    1 +
 drivers/gpu/drm/xocl/Kconfig               |   22 +
 drivers/gpu/drm/xocl/Makefile              |    3 +
 drivers/gpu/drm/xocl/devices.h             |  954 +++++
 drivers/gpu/drm/xocl/ert.h                 |  385 ++
 drivers/gpu/drm/xocl/lib/Makefile.in       |   16 +
 drivers/gpu/drm/xocl/lib/cdev_sgdma.h      |   63 +
 drivers/gpu/drm/xocl/lib/libxdma.c         | 4368 ++++++++++++++++++++
 drivers/gpu/drm/xocl/lib/libxdma.h         |  596 +++
 drivers/gpu/drm/xocl/lib/libxdma_api.h     |  127 +
 drivers/gpu/drm/xocl/mgmtpf/Makefile       |   29 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c    |  960 +++++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h    |  147 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c      |   30 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c   |  148 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h     |  244 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c   |  318 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c   |  399 ++
 drivers/gpu/drm/xocl/subdev/dna.c          |  356 ++
 drivers/gpu/drm/xocl/subdev/feature_rom.c  |  412 ++
 drivers/gpu/drm/xocl/subdev/firewall.c     |  389 ++
 drivers/gpu/drm/xocl/subdev/fmgr.c         |  198 +
 drivers/gpu/drm/xocl/subdev/icap.c         | 2859 +++++++++++++
 drivers/gpu/drm/xocl/subdev/mailbox.c      | 1868 +++++++++
 drivers/gpu/drm/xocl/subdev/mb_scheduler.c | 3059 ++++++++++++++
 drivers/gpu/drm/xocl/subdev/microblaze.c   |  722 ++++
 drivers/gpu/drm/xocl/subdev/mig.c          |  256 ++
 drivers/gpu/drm/xocl/subdev/sysmon.c       |  385 ++
 drivers/gpu/drm/xocl/subdev/xdma.c         |  510 +++
 drivers/gpu/drm/xocl/subdev/xmc.c          | 1480 +++++++
 drivers/gpu/drm/xocl/subdev/xvc.c          |  461 +++
 drivers/gpu/drm/xocl/userpf/Makefile       |   27 +
 drivers/gpu/drm/xocl/userpf/common.h       |  157 +
 drivers/gpu/drm/xocl/userpf/xocl_bo.c      | 1255 ++++++
 drivers/gpu/drm/xocl/userpf/xocl_bo.h      |  119 +
 drivers/gpu/drm/xocl/userpf/xocl_drm.c     |  640 +++
 drivers/gpu/drm/xocl/userpf/xocl_drv.c     |  743 ++++
 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c   |  396 ++
 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c   |  344 ++
 drivers/gpu/drm/xocl/version.h             |   22 +
 drivers/gpu/drm/xocl/xclbin.h              |  314 ++
 drivers/gpu/drm/xocl/xclfeatures.h         |  107 +
 drivers/gpu/drm/xocl/xocl_ctx.c            |  196 +
 drivers/gpu/drm/xocl/xocl_drm.h            |   91 +
 drivers/gpu/drm/xocl/xocl_drv.h            |  783 ++++
 drivers/gpu/drm/xocl/xocl_subdev.c         |  540 +++
 drivers/gpu/drm/xocl/xocl_thread.c         |   64 +
 include/uapi/drm/xmgmt_drm.h               |  204 +
 include/uapi/drm/xocl_drm.h                |  483 +++
 50 files changed, 28252 insertions(+)  create mode 100644

drivers/gpu/drm/xocl/Kconfig create mode 100644 drivers/gpu/drm/xocl/Makefile create mode 100644 drivers/gpu/drm/xocl/devices.h create mode 100644 drivers/gpu/drm/xocl/ert.h create mode 100644 drivers/gpu/drm/xocl/lib/Makefile.in

 create mode 100644 drivers/gpu/drm/xocl/lib/cdev_sgdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.c
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma_api.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/dna.c  create mode
100644 drivers/gpu/drm/xocl/subdev/feature_rom.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/firewall.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/fmgr.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/icap.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mailbox.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mb_scheduler.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/microblaze.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mig.c  create mode
100644 drivers/gpu/drm/xocl/subdev/sysmon.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xdma.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xmc.c  create mode
100644 drivers/gpu/drm/xocl/subdev/xvc.c  create mode 100644
drivers/gpu/drm/xocl/userpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/userpf/common.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drm.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drv.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/version.h  create mode
100644 drivers/gpu/drm/xocl/xclbin.h  create mode 100644
drivers/gpu/drm/xocl/xclfeatures.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_ctx.c  create mode
100644 drivers/gpu/drm/xocl/xocl_drm.h  create mode 100644
drivers/gpu/drm/xocl/xocl_drv.h  create mode 100644
drivers/gpu/drm/xocl/xocl_subdev.c
 create mode 100644 drivers/gpu/drm/xocl/xocl_thread.c
 create mode 100644 include/uapi/drm/xmgmt_drm.h  create mode
Quoted 8 lines

100644 include/uapi/drm/xocl_drm.h

--
2.17.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation http://blog.ffwll.ch

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw
Quoted 290 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, March 27, 2019 7:12 AM
To: Sonal Santan <[email protected]>
Cc: Daniel Vetter <[email protected]>; [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; linux- [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

Quoted 14 lines · Sonal Santan
Quoted 14 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]]
Sent: Wednesday, March 27, 2019 1:23 AM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

On Wed, Mar 27, 2019 at 12:30 AM Sonal Santan <[email protected]>

Quoted 31 lines · wrote:
Quoted 31 lines
Quoted 17 lines
Quoted 17 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 25, 2019 1:28 PM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

On Tue, Mar 19, 2019 at 02:53:55PM -0700,
[email protected]

Quoted 13 lines · wrote:
Quoted 13 lines
Quoted 8 lines

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise

customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two

physical functions:

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 8 lines

management physical function and user physical function.

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different

workloads.

Quoted 17 lines

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:
1. ICAP programming (FPGA bitstream download with FPGA Mgr integration) 2. Clock scaling 3. Loading firmware container also called dsabin (embedded Microblaze
firmware for ERT and XMC, optional clearing bitstream) 4.
In-band
sensors: temp, voltage, power, etc.

5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical

functions

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:
1. Device memory topology discovery and memory management 2. Buffer object abstraction and management for client process 3. XDMA MM PCIe DMA engine programming 4. Multi-process aware

context management 5.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Compute unit execution management (optionally with help of ERT)

for

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

client processes
6. Hardware mailbox for communication between two physical functions

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and

export/import.

Quoted 59 lines
Quoted 59 lines
Quoted 18 lines
Quoted 18 lines
Quoted 4 lines

xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects

and

Quoted 12 lines

provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at https://github.com/Xilinx/XRT

Quoted 5 lines
Quoted 5 lines

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really

something applications would use.

Quoted 21 lines

Sonal Santan <[email protected]>

4:20 PM (1 minute ago)

to me

Quoted 14 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 25, 2019 1:28 PM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

On Tue, Mar 19, 2019 at 02:53:55PM -0700,
[email protected]

Quoted 13 lines · wrote:
Quoted 13 lines
Quoted 8 lines

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise

customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two

physical functions:

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 8 lines

management physical function and user physical function.

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different

workloads.

Quoted 17 lines

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:
1. ICAP programming (FPGA bitstream download with FPGA Mgr integration) 2. Clock scaling 3. Loading firmware container also called dsabin (embedded Microblaze
firmware for ERT and XMC, optional clearing bitstream) 4.
In-band
sensors: temp, voltage, power, etc.

5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical

functions

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:
1. Device memory topology discovery and memory management 2. Buffer object abstraction and management for client process 3. XDMA MM PCIe DMA engine programming 4. Multi-process aware

context management 5.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Compute unit execution management (optionally with help of ERT)

for

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

client processes
6. Hardware mailbox for communication between two physical functions

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and

export/import.

Quoted 43 lines
Quoted 43 lines
Quoted 18 lines
Quoted 18 lines
Quoted 4 lines

xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects

and

Quoted 12 lines

provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at https://github.com/Xilinx/XRT

Quoted 5 lines
Quoted 5 lines

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really

something applications would use.

Quoted 8 lines
Quoted 1 line

Appreciate your feedback.

The userspace libraries define a common abstraction but have different implementations for Zynq Ultrascale+ embedded platform, PCIe based Alveo (and Faas) and emulation flows. The latter lets you run your

application without physical hardware.

Quoted 5 lines
Quoted 5 lines

From the pretty picture on github it looks like there's some opencl/ml/other fancy stuff sitting on top that applications would use. Is

that also available?

Quoted 4 lines

The full OpenCL runtime is available in the same repository. Xilinx ML Suite is also based on XRT and its source can be found at

Quoted 6 lines
Quoted 6 lines

https://github.com/Xilinx/ml-suite.

Hm, I did a few git grep for the usual opencl entry points, but didn't find anything. Do I need to run some build scripts first (which downloads additional sourcecode)? Or is there some symbol mangling going on and that's why I don't find anything? Pointers very

much appreciated.

Quoted 4 lines

The bulk of the OCL runtime code can be found inside
https://github.com/Xilinx/XRT/tree/master/src/runtime_src/xocl.
The OCL runtime also includes

https://github.com/Xilinx/XRT/tree/master/src/runtime_src/xrt.

Quoted 1 line

The OCL runtime library called libxilinxopencl.so in turn then uses XRT APIs

to talk to the drivers.

Quoted 2 lines

For PCIe these XRT APIs are implemented in the library libxrt_core.so the source for which is

https://github.com/Xilinx/XRT/tree/master/src/runtime_src/driver/xclng/xrt.

Quoted 8 lines

You can build a fully functioning runtime stack by following very simple build instructions--
https://xilinx.github.io/XRT/master/html/build.html

We do have a few dependencies on standard Linux packages including a few OpenCL packages bundled by Linux distros: ocl-icd, ocl-icd-devel and opencl-headers

Thanks a lot for pointers. No idea why I didn't find this stuff, I guess I was blind.

Quoted 8 lines

The thing I'm really interested in is the compiler, since at least the experience from gpus says that very much is part of the overall uapi, and definitely needed to be able to make any chances to the implementation.
Looking at clCreateProgramWithSource there's only a lookup up cached compiles (it looks for xclbin), and src/runtime_src/xclbin doesn't look like that provides a compiler either. It seems like apps need to precompile everything first. Am I again missing something, or is this how it's supposed to work?

XRT works with precompiled binaries which are compiled by Xilinx SDx compiler called xocc. The binary (xclbin) is loaded by clCreateProgramWithBinary().

Quoted 6 lines

Note: There's no expectation for the fully optimizing compiler, and we're totally ok if there's an optimizing proprietary compiler and a basic open one (amd, and bunch of other companies all have such dual stacks running on top of drm kernel drivers). But a basic compiler that can convert basic kernels into machine code is expected.

Although the compiler is not open source the compilation flow lets users examine output from various stages. For example if you write your kernel in OpenCL/C/C++ you can view the RTL (Verilog/VHDL) output produced by first stage of compilation. Note that the compiler is really generating a custom circuit given a high level input which in the last phase gets synthesized into bitstream. Expert hardware designers can handcraft a circuit in RTL and feed it to the compiler. Our FPGA tools let you view the generated hardware design, the register map, etc. You can get more information about a compiled design by running XRT tool like xclbinutil on the generated file.

In essence compiling for FPGAs is quite different than compiling for GPU/CPU/DSP. Interestingly FPGA compilers can run anywhere from 30 mins to a few hours to compile a testcase.

Thanks,
-Sonal

Quoted 163 lines

Thanks, Daniel

Quoted 41 lines

Thanks,
-Sonal

Quoted 37 lines
Quoted 4 lines

Typically end users use OpenCL APIs which are part of XRT stack. One can write an application to directly call XRT APIs defined at
https://xilinx.github.io/XRT/2018.3/html/xclhal2.main.html

I have no clue about DNN/ML unfortunately, I think I'll try to look into the ocl side a bit more first.

Thanks, Daniel

Quoted 27 lines

Thanks,
-Sonal

Quoted 24 lines

Thanks, Daniel

Quoted 21 lines

Thanks,
-Sonal

Sonal Santan (6):
Add skeleton code: ioctl definitions and build hooks Global data structures shared between xocl and xmgmt drivers Add platform drivers for various IPs and frameworks Add core of XDMA driver
Add management driver
Add user physical function driver

 drivers/gpu/drm/Kconfig                    |    2 +
 drivers/gpu/drm/Makefile                   |    1 +
 drivers/gpu/drm/xocl/Kconfig               |   22 +
 drivers/gpu/drm/xocl/Makefile              |    3 +
 drivers/gpu/drm/xocl/devices.h             |  954 +++++
 drivers/gpu/drm/xocl/ert.h                 |  385 ++
 drivers/gpu/drm/xocl/lib/Makefile.in       |   16 +
 drivers/gpu/drm/xocl/lib/cdev_sgdma.h      |   63 +
 drivers/gpu/drm/xocl/lib/libxdma.c         | 4368

++++++++++++++++++++

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
 drivers/gpu/drm/xocl/lib/libxdma.h         |  596 +++
 drivers/gpu/drm/xocl/lib/libxdma_api.h     |  127 +
 drivers/gpu/drm/xocl/mgmtpf/Makefile       |   29 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c    |  960 +++++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h    |  147 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c      |   30 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c   |  148 +
 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h     |  244 ++
 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c   |  318 ++
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c   |  399 ++
 drivers/gpu/drm/xocl/subdev/dna.c          |  356 ++
 drivers/gpu/drm/xocl/subdev/feature_rom.c  |  412 ++
 drivers/gpu/drm/xocl/subdev/firewall.c     |  389 ++
 drivers/gpu/drm/xocl/subdev/fmgr.c         |  198 +
 drivers/gpu/drm/xocl/subdev/icap.c         | 2859 +++++++++++++
 drivers/gpu/drm/xocl/subdev/mailbox.c      | 1868 +++++++++
 drivers/gpu/drm/xocl/subdev/mb_scheduler.c | 3059

++++++++++++++

Quoted 92 lines
Quoted 92 lines
Quoted 89 lines
Quoted 89 lines
Quoted 77 lines
 drivers/gpu/drm/xocl/subdev/microblaze.c   |  722 ++++
 drivers/gpu/drm/xocl/subdev/mig.c          |  256 ++
 drivers/gpu/drm/xocl/subdev/sysmon.c       |  385 ++
 drivers/gpu/drm/xocl/subdev/xdma.c         |  510 +++
 drivers/gpu/drm/xocl/subdev/xmc.c          | 1480 +++++++
 drivers/gpu/drm/xocl/subdev/xvc.c          |  461 +++
 drivers/gpu/drm/xocl/userpf/Makefile       |   27 +
 drivers/gpu/drm/xocl/userpf/common.h       |  157 +
 drivers/gpu/drm/xocl/userpf/xocl_bo.c      | 1255 ++++++
 drivers/gpu/drm/xocl/userpf/xocl_bo.h      |  119 +
 drivers/gpu/drm/xocl/userpf/xocl_drm.c     |  640 +++
 drivers/gpu/drm/xocl/userpf/xocl_drv.c     |  743 ++++
 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c   |  396 ++
 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c   |  344 ++
 drivers/gpu/drm/xocl/version.h             |   22 +
 drivers/gpu/drm/xocl/xclbin.h              |  314 ++
 drivers/gpu/drm/xocl/xclfeatures.h         |  107 +
 drivers/gpu/drm/xocl/xocl_ctx.c            |  196 +
 drivers/gpu/drm/xocl/xocl_drm.h            |   91 +
 drivers/gpu/drm/xocl/xocl_drv.h            |  783 ++++
 drivers/gpu/drm/xocl/xocl_subdev.c         |  540 +++
 drivers/gpu/drm/xocl/xocl_thread.c         |   64 +
 include/uapi/drm/xmgmt_drm.h               |  204 +
 include/uapi/drm/xocl_drm.h                |  483 +++
 50 files changed, 28252 insertions(+)  create mode 100644

drivers/gpu/drm/xocl/Kconfig create mode 100644 drivers/gpu/drm/xocl/Makefile create mode 100644 drivers/gpu/drm/xocl/devices.h create mode 100644 drivers/gpu/drm/xocl/ert.h create mode 100644 drivers/gpu/drm/xocl/lib/Makefile.in

 create mode 100644 drivers/gpu/drm/xocl/lib/cdev_sgdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.c
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma.h
 create mode 100644 drivers/gpu/drm/xocl/lib/libxdma_api.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-core.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-cw.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-reg.h
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/mgmtpf/mgmt-utils.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/dna.c  create
mode
100644 drivers/gpu/drm/xocl/subdev/feature_rom.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/firewall.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/fmgr.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/icap.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mailbox.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mb_scheduler.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/microblaze.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/mig.c  create
mode
100644 drivers/gpu/drm/xocl/subdev/sysmon.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xdma.c
 create mode 100644 drivers/gpu/drm/xocl/subdev/xmc.c  create
mode
100644 drivers/gpu/drm/xocl/subdev/xvc.c  create mode 100644
drivers/gpu/drm/xocl/userpf/Makefile
 create mode 100644 drivers/gpu/drm/xocl/userpf/common.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_bo.h
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drm.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_drv.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_ioctl.c
 create mode 100644 drivers/gpu/drm/xocl/userpf/xocl_sysfs.c
 create mode 100644 drivers/gpu/drm/xocl/version.h  create
mode
100644 drivers/gpu/drm/xocl/xclbin.h  create mode 100644
drivers/gpu/drm/xocl/xclfeatures.h
 create mode 100644 drivers/gpu/drm/xocl/xocl_ctx.c  create

mode
100644 drivers/gpu/drm/xocl/xocl_drm.h create mode 100644 drivers/gpu/drm/xocl/xocl_drv.h create mode 100644 drivers/gpu/drm/xocl/xocl_subdev.c

 create mode 100644 drivers/gpu/drm/xocl/xocl_thread.c
 create mode 100644 include/uapi/drm/xmgmt_drm.h  create mode
Quoted 8 lines

100644 include/uapi/drm/xocl_drm.h

--
2.17.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation http://blog.ffwll.ch

Quoted 4 lines
Quoted 4 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

maintainer
#13 lore raw
Quoted 318 lines · Sonal Santan
Quoted 291 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, March 27, 2019 7:12 AM
To: Sonal Santan <[email protected]>
Cc: Daniel Vetter <[email protected]>; [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; linux- [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

Quoted 14 lines · Sonal Santan
Quoted 14 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]]
Sent: Wednesday, March 27, 2019 1:23 AM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

On Wed, Mar 27, 2019 at 12:30 AM Sonal Santan <[email protected]>

Quoted 31 lines · wrote:
Quoted 31 lines
Quoted 17 lines
Quoted 17 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 25, 2019 1:28 PM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

On Tue, Mar 19, 2019 at 02:53:55PM -0700,
[email protected]

Quoted 13 lines · wrote:
Quoted 13 lines
Quoted 8 lines

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise

customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two

physical functions:

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 8 lines

management physical function and user physical function.

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different

workloads.

Quoted 17 lines

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:
1. ICAP programming (FPGA bitstream download with FPGA Mgr integration) 2. Clock scaling 3. Loading firmware container also called dsabin (embedded Microblaze
firmware for ERT and XMC, optional clearing bitstream) 4.
In-band
sensors: temp, voltage, power, etc.

5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical

functions

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:
1. Device memory topology discovery and memory management 2. Buffer object abstraction and management for client process 3. XDMA MM PCIe DMA engine programming 4. Multi-process aware

context management 5.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Compute unit execution management (optionally with help of ERT)

for

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

client processes
6. Hardware mailbox for communication between two physical functions

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and

export/import.

Quoted 59 lines
Quoted 59 lines
Quoted 18 lines
Quoted 18 lines
Quoted 4 lines

xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects

and

Quoted 12 lines

provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at https://github.com/Xilinx/XRT

Quoted 5 lines
Quoted 5 lines

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really

something applications would use.

Quoted 21 lines

Sonal Santan <[email protected]>

4:20 PM (1 minute ago)

to me

Quoted 14 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 25, 2019 1:28 PM
To: Sonal Santan <[email protected]>
Cc: [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

On Tue, Mar 19, 2019 at 02:53:55PM -0700,
[email protected]

Quoted 13 lines · wrote:
Quoted 13 lines
Quoted 8 lines

From: Sonal Santan <[email protected]>

Hello,

This patch series adds drivers for Xilinx Alveo PCIe accelerator cards. These drivers are part of Xilinx Runtime (XRT) open source stack and have been deployed by leading FaaS vendors and many enterprise

customers.

Cool, first fpga driver submitted to drm! And from a high level I think this makes a lot of sense.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

PLATFORM ARCHITECTURE

Alveo PCIe platforms have a static shell and a reconfigurable (dynamic) region. The shell is automatically loaded from PROM when host is booted and PCIe is enumerated by BIOS. Shell cannot be changed till next cold reboot. The shell exposes two

physical functions:

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 8 lines

management physical function and user physical function.

Users compile their high level design in C/C++/OpenCL or RTL into FPGA image using SDx compiler. The FPGA image packaged as xclbin file can be loaded onto reconfigurable region. The image may contain one or more compute unit. Users can dynamically swap the full image running on the reconfigurable region in order to switch between different

workloads.

Quoted 17 lines

XRT DRIVERS

XRT Linux kernel driver xmgmt binds to mgmt pf. The driver is modular and organized into several platform drivers which primarily handle the following functionality:
1. ICAP programming (FPGA bitstream download with FPGA Mgr integration) 2. Clock scaling 3. Loading firmware container also called dsabin (embedded Microblaze
firmware for ERT and XMC, optional clearing bitstream) 4.
In-band
sensors: temp, voltage, power, etc.

5.  AXI Firewall management
6.  Device reset and rescan
7.  Hardware mailbox for communication between two physical

functions

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

XRT Linux kernel driver xocl binds to user pf. Like its peer, this driver is also modular and organized into several platform drivers which handle the following functionality:
1. Device memory topology discovery and memory management 2. Buffer object abstraction and management for client process 3. XDMA MM PCIe DMA engine programming 4. Multi-process aware

context management 5.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Compute unit execution management (optionally with help of ERT)

for

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

client processes
6. Hardware mailbox for communication between two physical functions

The drivers export ioctls and sysfs nodes for various services. xocl driver makes heavy use of DRM GEM features for device memory management, reference counting, mmap support and

export/import.

Quoted 43 lines
Quoted 43 lines
Quoted 18 lines
Quoted 18 lines
Quoted 4 lines

xocl also includes a simple scheduler called KDS which schedules compute units and interacts with hardware scheduler running ERT firmware. The scheduler understands custom opcodes packaged into command objects

and

Quoted 12 lines

provides an asynchronous command done notification via POSIX poll.

More details on architecture, software APIs, ioctl definitions, execution model, etc. is available as Sphinx documentation--

https://xilinx.github.io/XRT/2018.3/html/index.html

The complete runtime software stack (XRT) which includes out of tree kernel drivers, user space libraries, board utilities and firmware for the hardware scheduler is open source and available at https://github.com/Xilinx/XRT

Quoted 5 lines
Quoted 5 lines

Before digging into the implementation side more I looked into the userspace here. I admit I got lost a bit, since there's lots of indirections and abstractions going on, but it seems like this is just a fancy ioctl wrapper/driver backend abstractions. Not really

something applications would use.

Quoted 8 lines
Quoted 1 line

Appreciate your feedback.

The userspace libraries define a common abstraction but have different implementations for Zynq Ultrascale+ embedded platform, PCIe based Alveo (and Faas) and emulation flows. The latter lets you run your

application without physical hardware.

Quoted 5 lines
Quoted 5 lines

From the pretty picture on github it looks like there's some opencl/ml/other fancy stuff sitting on top that applications would use. Is

that also available?

Quoted 4 lines

The full OpenCL runtime is available in the same repository. Xilinx ML Suite is also based on XRT and its source can be found at

Quoted 6 lines
Quoted 6 lines

https://github.com/Xilinx/ml-suite.

Hm, I did a few git grep for the usual opencl entry points, but didn't find anything. Do I need to run some build scripts first (which downloads additional sourcecode)? Or is there some symbol mangling going on and that's why I don't find anything? Pointers very

much appreciated.

Quoted 4 lines

The bulk of the OCL runtime code can be found inside
https://github.com/Xilinx/XRT/tree/master/src/runtime_src/xocl.
The OCL runtime also includes

https://github.com/Xilinx/XRT/tree/master/src/runtime_src/xrt.

Quoted 1 line

The OCL runtime library called libxilinxopencl.so in turn then uses XRT APIs

to talk to the drivers.

Quoted 2 lines

For PCIe these XRT APIs are implemented in the library libxrt_core.so the source for which is

https://github.com/Xilinx/XRT/tree/master/src/runtime_src/driver/xclng/xrt.

Quoted 8 lines

You can build a fully functioning runtime stack by following very simple build instructions--
https://xilinx.github.io/XRT/master/html/build.html

We do have a few dependencies on standard Linux packages including a few OpenCL packages bundled by Linux distros: ocl-icd, ocl-icd-devel and opencl-headers

Thanks a lot for pointers. No idea why I didn't find this stuff, I guess I was blind.

Quoted 8 lines

The thing I'm really interested in is the compiler, since at least the experience from gpus says that very much is part of the overall uapi, and definitely needed to be able to make any chances to the implementation.
Looking at clCreateProgramWithSource there's only a lookup up cached compiles (it looks for xclbin), and src/runtime_src/xclbin doesn't look like that provides a compiler either. It seems like apps need to precompile everything first. Am I again missing something, or is this how it's supposed to work?

XRT works with precompiled binaries which are compiled by Xilinx SDx compiler called xocc. The binary (xclbin) is loaded by clCreateProgramWithBinary().

Quoted 6 lines

Note: There's no expectation for the fully optimizing compiler, and we're totally ok if there's an optimizing proprietary compiler and a basic open one (amd, and bunch of other companies all have such dual stacks running on top of drm kernel drivers). But a basic compiler that can convert basic kernels into machine code is expected.

Although the compiler is not open source the compilation flow lets users examine output from various stages. For example if you write your kernel in OpenCL/C/C++ you can view the RTL (Verilog/VHDL) output produced by first stage of compilation. Note that the compiler is really generating a custom circuit given a high level input which in the last phase gets synthesized into bitstream. Expert hardware designers can handcraft a circuit in RTL and feed it to the compiler. Our FPGA tools let you view the generated hardware design, the register map, etc. You can get more information about a compiled design by running XRT tool like xclbinutil on the generated file.

Quoted 3 lines

In essence compiling for FPGAs is quite different than compiling for GPU/CPU/DSP. Interestingly FPGA compilers can run anywhere from 30 mins to a few hours to compile a testcase.

So is there any open source userspace generator for what this interface provides? Is the bitstream format that gets fed into the FPGA proprietary and is it signed?

Dave.

#14 lore raw

I am adding [email protected], since this is why I missed this thread in the first place...

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Dave Airlie

Hi Dave!

Dave> On Thu, 28 Mar 2019 at 10:14, Sonal Santan <[email protected]> wrote:

>>> From: Daniel Vetter [mailto:[email protected]]

[...]

Quoted 19 lines
Quoted 18 lines
Quoted 6 lines

Note: There's no expectation for the fully optimizing compiler, and we're totally ok if there's an optimizing proprietary compiler and a basic open one (amd, and bunch of other companies all have such dual stacks running on top of drm kernel drivers). But a basic compiler that can convert basic kernels into machine code is expected.

Although the compiler is not open source the compilation flow lets users examine output from various stages. For example if you write your kernel in OpenCL/C/C++ you can view the RTL (Verilog/VHDL) output produced by first stage of compilation. Note that the compiler is really generating a custom circuit given a high level input which in the last phase gets synthesized into bitstream. Expert hardware designers can handcraft a circuit in RTL and feed it to the compiler. Our FPGA tools let you view the generated hardware design, the register map, etc. You can get more information about a compiled design by running XRT tool like xclbinutil on the generated file.

Quoted 3 lines
Quoted 3 lines

In essence compiling for FPGAs is quite different than compiling for GPU/CPU/DSP. Interestingly FPGA compilers can run anywhere from 30 mins to a few hours to compile a testcase.

Dave> So is there any open source userspace generator for what this Dave> interface provides? Is the bitstream format that gets fed into Dave> the FPGA proprietary and is it signed?

Short answer:

- a bitstream is an opaque content similar to various firmware handled by Linux, EFI capsules, x86 microcode, WiFi modems, etc.

- there is no open-source generator for what the interface consume;

- I do not know if it is signed;

- it is probably similar to what Intel FPGA (not GPU) drivers provide already inside the Linux kernel and I guess there is no pure open-source way to generate their bit-stream either.

Long answer:

- processors, GPU and other digital circuits are designed from a lot of elementary transistors, wires, capacitors, resistors... using some very complex (and expensive) tools from some EDA companies but at the end, after months of work, they come often with a "simple" public interface, the... instruction set! So it is rather "easy" at the end to generate some instructions with a compiler such as LLVM from a description of this ISA or some reverse engineering. Note that even if the ISA is public, it is very difficult to make another efficient processor from scratch just from this ISA, so there is often no concern about making this ISA public to develop the ecosystem ;

- FPGA are field-programmable gate arrays, made also from a lot of elementary transistors, wires, capacitors, resistors... but organized in billions of very low-level elementary gates, memory elements, DSP blocks, I/O blocks, clock generators, specific accelerators... directly exposed to the user and that can be programmed according to a configuration memory (the bitstream) that details how to connect each part, routing element, configuring each elemental piece of hardware. So instead of just writing instructions like on a CPU or a GPU, you need to configure each bit of the architecture in such a way it does something interesting for you. Concretely, you write some programs in RTL languages (Verilog, VHDL) or higher-level (C/C++, OpenCL, SYCL...) and you use some very complex (and expensive) tools from some EDA companies to generate the bitstream implementing an equivalent circuit with the same semantics. Since the architecture is so low level, there is a direct mapping between the configuration memory (bitstream) and the hardware architecture itself, so if it is public then it is easy to duplicate the FPGA itself and to start a new FPGA company. That is unfortunately something the existing FPGA companies do not want... ;-)

To summarize:

- on a CPU & GPU, the vendor used the expensive EDA tools once already for you and provide the simpler ISA interface;

- on an FPGA, you have access to a pile of low-level hardware and it is up to you to use the lengthy process of building your own computing architecture using the heavy expensive very subtle EDA tools that will run for hours or days to generate some good-enough placement for your pleasure.

There is some public documentation on-line:
https://www.xilinx.com/products/silicon-devices/fpga/virtex-ultrascale-plus.html#documentation

To have an idea of the elementary architecture:
https://www.xilinx.com/support/documentation/user_guides/ug574-ultrascale-clb.pdf
https://www.xilinx.com/support/documentation/user_guides/ug579-ultrascale-dsp.pdf
https://www.xilinx.com/support/documentation/user_guides/ug573-ultrascale-memory-resources.pdf

Even on the configuration and the file format, but without any detailed semantics:
https://www.xilinx.com/support/documentation/user_guides/ug570-ultrascale-configuration.pdf

The Xilinx compiler xocc taking for example some LLVM IR and generating some bitstream is not open-source and will probably never be for the reasons above... :-(

Xilinx is open-sourcing all what can reasonably be open-sourced:

- the user-level and system run-time, including the OpenCL runtime:
https://github.com/Xilinx/XRT to handle the bitstreams generated by some close-source tools

- the kernel device drivers which are already in
https://github.com/Xilinx/XRT but we want to upstream into the Linux kernel to make life easier (this is the matter of this e-mail thread);

- to generate some real code in the most (modern and) open-source way, there is an open-source framework to compile some SYCL C++ including some Xilinx FPGA-specific extensions down to SPIR LLVM IR using Clang/LLVM and to feed the close-source xocc tool with it
https://github.com/triSYCL/triSYCL

You can see starting from
https://github.com/triSYCL/triSYCL/blob/master/tests/Makefile#L322 how to start from C++ code, generate some SPIR LLVM IR and to feed xocc and build a fat binary that will use the XRT runtime.

Some documentation in
https://github.com/triSYCL/triSYCL/blob/master/doc/architecture.rst

There are other more official ways to generate bitstream (they are called products instead of research projects like triSYCL :-) ).

We are also working on an other open-source SYCL compiler with Intel to have a better common implementation
https://github.com/intel/llvm/wiki and to upstream this into Clang/LLVM.

So for Xilinx FPGA, you can see the LLVM IR as the equivalent of PTX for nVidia. But xocc is close-source for some more fundamental reasons: it would expose all the details of the FPGA. I guess this is exactly the same for Xilinx FPGA.

Note that probably most of the tool chains used to generate the low-level firmware for the various CPU (microcode), GPU, etc. are also close-source.

See you,

Signature · 1 line
Ronan KERYELL, Xilinx Research Labs / San José, California.
#15 lore raw
Quoted 45 lines · Ronan KERYELL

I am adding [email protected], since this is why I missed this thread in the first place...

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Dave Airlie

Hi Dave!

Dave> On Thu, 28 Mar 2019 at 10:14, Sonal Santan <[email protected]> wrote:

>>> From: Daniel Vetter [mailto:[email protected]]

[...]

Quoted 19 lines
Quoted 18 lines
Quoted 6 lines

Note: There's no expectation for the fully optimizing compiler, and we're totally ok if there's an optimizing proprietary compiler and a basic open one (amd, and bunch of other companies all have such dual stacks running on top of drm kernel drivers). But a basic compiler that can convert basic kernels into machine code is expected.

Although the compiler is not open source the compilation flow lets users examine output from various stages. For example if you write your kernel in OpenCL/C/C++ you can view the RTL (Verilog/VHDL) output produced by first stage of compilation. Note that the compiler is really generating a custom circuit given a high level input which in the last phase gets synthesized into bitstream. Expert hardware designers can handcraft a circuit in RTL and feed it to the compiler. Our FPGA tools let you view the generated hardware design, the register map, etc. You can get more information about a compiled design by running XRT tool like xclbinutil on the generated file.

Quoted 3 lines
Quoted 3 lines

In essence compiling for FPGAs is quite different than compiling for GPU/CPU/DSP. Interestingly FPGA compilers can run anywhere from 30 mins to a few hours to compile a testcase.

Dave> So is there any open source userspace generator for what this Dave> interface provides? Is the bitstream format that gets fed into Dave> the FPGA proprietary and is it signed?

Short answer:

- a bitstream is an opaque content similar to various firmware handled by Linux, EFI capsules, x86 microcode, WiFi modems, etc.

Quoted 7 lines

- there is no open-source generator for what the interface consume;

- I do not know if it is signed;

- it is probably similar to what Intel FPGA (not GPU) drivers provide already inside the Linux kernel and I guess there is no pure open-source way to generate their bit-stream either.

Yeah, drivers/gpu folks wouldn't ever have merged drivers/fpga, and I think there's pretty strong consensus over here that merging fpga stuff without having clear specs (in the form of an executable open source compiler/synthesizer/whatever) was a mistake.

We just had a similar huge discussions around the recently merged habanalabs driver in drivers/misc, for neural network accel. There was a proposed drivers/accel for these. gpu folks objected, Greg and Olof were happy with merging.

And the exact same arguments has come up tons of times for gpus too, with lots proposals to merge a kernel driver with just the kernel driver being open source, or just the state tracker/runtime, but most definitely not anything looking like the compiler. Because $reasons.

Conclusion was that drivers/gpu people will continue to reject these, everyone else will continue to take whatever, but just don't complain to us if it all comes crashing down :-)

Quoted 24 lines

Long answer:

- processors, GPU and other digital circuits are designed from a lot of elementary transistors, wires, capacitors, resistors... using some very complex (and expensive) tools from some EDA companies but at the end, after months of work, they come often with a "simple" public interface, the... instruction set! So it is rather "easy" at the end to generate some instructions with a compiler such as LLVM from a description of this ISA or some reverse engineering. Note that even if the ISA is public, it is very difficult to make another efficient processor from scratch just from this ISA, so there is often no concern about making this ISA public to develop the ecosystem ;

- FPGA are field-programmable gate arrays, made also from a lot of elementary transistors, wires, capacitors, resistors... but organized in billions of very low-level elementary gates, memory elements, DSP blocks, I/O blocks, clock generators, specific accelerators... directly exposed to the user and that can be programmed according to a configuration memory (the bitstream) that details how to connect each part, routing element, configuring each elemental piece of hardware. So instead of just writing instructions like on a CPU or a GPU, you need to configure each bit of the architecture in such a way it does something interesting for you. Concretely, you write some programs in RTL languages (Verilog,

Quoted 8 lines

VHDL) or higher-level (C/C++, OpenCL, SYCL...) and you use some very complex (and expensive) tools from some EDA companies to generate the bitstream implementing an equivalent circuit with the same semantics. Since the architecture is so low level, there is a direct mapping between the configuration memory (bitstream) and the hardware architecture itself, so if it is public then it is easy to duplicate the FPGA itself and to start a new FPGA company. That is unfortunately something the existing FPGA companies do not want... ;-)

i.e. you have a use case where you absolutely need an offline compiler. Like with gpus (in some use cases), the only difference is that for gpus the latency requirement that's too high is measured in milliseconds, cause that would cause dropped frames, and worst case compiling takes seconds for some big shaders. With FPGAs it's just 1000x higher limits, same problem.

Quoted 51 lines

To summarize:

- on a CPU & GPU, the vendor used the expensive EDA tools once already for you and provide the simpler ISA interface;

- on an FPGA, you have access to a pile of low-level hardware and it is up to you to use the lengthy process of building your own computing architecture using the heavy expensive very subtle EDA tools that will run for hours or days to generate some good-enough placement for your pleasure.

There is some public documentation on-line:
https://www.xilinx.com/products/silicon-devices/fpga/virtex-ultrascale-plus.html#documentation

To have an idea of the elementary architecture:
https://www.xilinx.com/support/documentation/user_guides/ug574-ultrascale-clb.pdf
https://www.xilinx.com/support/documentation/user_guides/ug579-ultrascale-dsp.pdf
https://www.xilinx.com/support/documentation/user_guides/ug573-ultrascale-memory-resources.pdf

Even on the configuration and the file format, but without any detailed semantics:
https://www.xilinx.com/support/documentation/user_guides/ug570-ultrascale-configuration.pdf

The Xilinx compiler xocc taking for example some LLVM IR and generating some bitstream is not open-source and will probably never be for the reasons above... :-(

Xilinx is open-sourcing all what can reasonably be open-sourced:

- the user-level and system run-time, including the OpenCL runtime:
https://github.com/Xilinx/XRT to handle the bitstreams generated by some close-source tools

- the kernel device drivers which are already in
https://github.com/Xilinx/XRT but we want to upstream into the Linux kernel to make life easier (this is the matter of this e-mail thread);

- to generate some real code in the most (modern and) open-source way, there is an open-source framework to compile some SYCL C++ including some Xilinx FPGA-specific extensions down to SPIR LLVM IR using Clang/LLVM and to feed the close-source xocc tool with it
https://github.com/triSYCL/triSYCL

You can see starting from
https://github.com/triSYCL/triSYCL/blob/master/tests/Makefile#L322 how to start from C++ code, generate some SPIR LLVM IR and to feed xocc and build a fat binary that will use the XRT runtime.

Some documentation in
https://github.com/triSYCL/triSYCL/blob/master/doc/architecture.rst

Quoted 6 lines

There are other more official ways to generate bitstream (they are called products instead of research projects like triSYCL :-) ).

We are also working on an other open-source SYCL compiler with Intel to have a better common implementation
https://github.com/intel/llvm/wiki and to upstream this into Clang/LLVM.

Yeah, there's been plenty of gpu stacks with "everything open sourced that can be open sourced", except the compiler, for gpus. We didn't take those drivers either.

And I looked at the entire stack already to see what's there and what's missing.

Quoted 4 lines

So for Xilinx FPGA, you can see the LLVM IR as the equivalent of PTX for nVidia. But xocc is close-source for some more fundamental reasons: it would expose all the details of the FPGA. I guess this is exactly the same for Xilinx FPGA.

Yeah, neither did we merge a driver with just some IR as the "compiler", and most definitely not PTX (since that's just nv lock-in, spirv is the cross vendor solution that at least seems to have a fighting chance). We want the low level stuff (and if the high level compiler is the dumbest, least optimizing thing ever that can't run any real world workload yet, that's fine, it can be fixed). The low level stuff is what matters from an uapi perspective.

Quoted 3 lines

Note that probably most of the tool chains used to generate the low-level firmware for the various CPU (microcode), GPU, etc. are also close-source.

Yup. None have been successfully used to merge stuff into drivers/gpu.

Note that we're perfectly fine with closed source stacks running on top of drivers/gpu, with lots of additional secret sauce/value add/customer lock in/whatever compared to the basic open source stack. There's plenty of vendors doing that. But for the uapi review, and making sure we can at least keep the basic stack working, it needs to be the full open stack. End to end.

I guess I need to actually type that article on my blog about why exactly we're so much insisting on this, seems to become a bit an FAQ.

Cheers, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer
#16 lore raw

Hi Daniel,

Quoted 50 lines · Daniel Vetter
Quoted 49 lines · Ronan KERYELL

I am adding [email protected], since this is why I missed this thread in the first place...

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Dave Airlie

Hi Dave!

Dave> On Thu, 28 Mar 2019 at 10:14, Sonal Santan <[email protected]> wrote:

>>> From: Daniel Vetter [mailto:[email protected]]

[...]

Quoted 19 lines
Quoted 18 lines
Quoted 6 lines

Note: There's no expectation for the fully optimizing compiler, and we're totally ok if there's an optimizing proprietary compiler and a basic open one (amd, and bunch of other companies all have such dual stacks running on top of drm kernel drivers). But a basic compiler that can convert basic kernels into machine code is expected.

Although the compiler is not open source the compilation flow lets users examine output from various stages. For example if you write your kernel in OpenCL/C/C++ you can view the RTL (Verilog/VHDL) output produced by first stage of compilation. Note that the compiler is really generating a custom circuit given a high level input which in the last phase gets synthesized into bitstream. Expert hardware designers can handcraft a circuit in RTL and feed it to the compiler. Our FPGA tools let you view the generated hardware design, the register map, etc. You can get more information about a compiled design by running XRT tool like xclbinutil on the generated file.

Quoted 3 lines
Quoted 3 lines

In essence compiling for FPGAs is quite different than compiling for GPU/CPU/DSP. Interestingly FPGA compilers can run anywhere from 30 mins to a few hours to compile a testcase.

Dave> So is there any open source userspace generator for what this Dave> interface provides? Is the bitstream format that gets fed into Dave> the FPGA proprietary and is it signed?

Short answer:

- a bitstream is an opaque content similar to various firmware handled by Linux, EFI capsules, x86 microcode, WiFi modems, etc.

- there is no open-source generator for what the interface consume;

- I do not know if it is signed;

Quoted 8 lines
Quoted 3 lines

- it is probably similar to what Intel FPGA (not GPU) drivers provide already inside the Linux kernel and I guess there is no pure open-source way to generate their bit-stream either.

Yeah, drivers/gpu folks wouldn't ever have merged drivers/fpga, and I think there's pretty strong consensus over here that merging fpga stuff without having clear specs (in the form of an executable open source compiler/synthesizer/whatever) was a mistake.

I don't totally understand this statement. You don't go out and ask people to open source their EDA tools that are used to create the ASICs on any piece of HW (NIC, GPU, USB controller,...) out there.

FPGAs are no different.

I think you need to distinguish between the general FPGA as a means to implement a HW solution and *FPGA based devices* that implement flows such as OpenCL etc. For the latter I'm more inclined to buy the equivalence to GPUs argument.

Quoted 47 lines

We just had a similar huge discussions around the recently merged habanalabs driver in drivers/misc, for neural network accel. There was a proposed drivers/accel for these. gpu folks objected, Greg and Olof were happy with merging.

And the exact same arguments has come up tons of times for gpus too, with lots proposals to merge a kernel driver with just the kernel driver being open source, or just the state tracker/runtime, but most definitely not anything looking like the compiler. Because $reasons.

Conclusion was that drivers/gpu people will continue to reject these, everyone else will continue to take whatever, but just don't complain to us if it all comes crashing down :-)

Quoted 24 lines

Long answer:

- processors, GPU and other digital circuits are designed from a lot of elementary transistors, wires, capacitors, resistors... using some very complex (and expensive) tools from some EDA companies but at the end, after months of work, they come often with a "simple" public interface, the... instruction set! So it is rather "easy" at the end to generate some instructions with a compiler such as LLVM from a description of this ISA or some reverse engineering. Note that even if the ISA is public, it is very difficult to make another efficient processor from scratch just from this ISA, so there is often no concern about making this ISA public to develop the ecosystem ;

- FPGA are field-programmable gate arrays, made also from a lot of elementary transistors, wires, capacitors, resistors... but organized in billions of very low-level elementary gates, memory elements, DSP blocks, I/O blocks, clock generators, specific accelerators... directly exposed to the user and that can be programmed according to a configuration memory (the bitstream) that details how to connect each part, routing element, configuring each elemental piece of hardware. So instead of just writing instructions like on a CPU or a GPU, you need to configure each bit of the architecture in such a way it does something interesting for you. Concretely, you write some programs in RTL languages (Verilog,

Quoted 8 lines

VHDL) or higher-level (C/C++, OpenCL, SYCL...) and you use some very complex (and expensive) tools from some EDA companies to generate the bitstream implementing an equivalent circuit with the same semantics. Since the architecture is so low level, there is a direct mapping between the configuration memory (bitstream) and the hardware architecture itself, so if it is public then it is easy to duplicate the FPGA itself and to start a new FPGA company. That is unfortunately something the existing FPGA companies do not want... ;-)

Quoted 5 lines

i.e. you have a use case where you absolutely need an offline compiler. Like with gpus (in some use cases), the only difference is that for gpus the latency requirement that's too high is measured in milliseconds, cause that would cause dropped frames, and worst case compiling takes seconds for some big shaders. With FPGAs it's just 1000x higher limits, same problem.

As I said above, you'd do the same thing when you design any other piece of hardware out there, except for with FPGAs you'd be able to change stuff, whereas with an ASIC your netlist gets fixed at tape-out date.

Quoted 92 lines
Quoted 52 lines

To summarize:

- on a CPU & GPU, the vendor used the expensive EDA tools once already for you and provide the simpler ISA interface;

- on an FPGA, you have access to a pile of low-level hardware and it is up to you to use the lengthy process of building your own computing architecture using the heavy expensive very subtle EDA tools that will run for hours or days to generate some good-enough placement for your pleasure.

There is some public documentation on-line:
https://www.xilinx.com/products/silicon-devices/fpga/virtex-ultrascale-plus.html#documentation

To have an idea of the elementary architecture:
https://www.xilinx.com/support/documentation/user_guides/ug574-ultrascale-clb.pdf
https://www.xilinx.com/support/documentation/user_guides/ug579-ultrascale-dsp.pdf
https://www.xilinx.com/support/documentation/user_guides/ug573-ultrascale-memory-resources.pdf

Even on the configuration and the file format, but without any detailed semantics:
https://www.xilinx.com/support/documentation/user_guides/ug570-ultrascale-configuration.pdf

The Xilinx compiler xocc taking for example some LLVM IR and generating some bitstream is not open-source and will probably never be for the reasons above... :-(

Xilinx is open-sourcing all what can reasonably be open-sourced:

- the user-level and system run-time, including the OpenCL runtime:
https://github.com/Xilinx/XRT to handle the bitstreams generated by some close-source tools

- the kernel device drivers which are already in
https://github.com/Xilinx/XRT but we want to upstream into the Linux kernel to make life easier (this is the matter of this e-mail thread);

- to generate some real code in the most (modern and) open-source way, there is an open-source framework to compile some SYCL C++ including some Xilinx FPGA-specific extensions down to SPIR LLVM IR using Clang/LLVM and to feed the close-source xocc tool with it
https://github.com/triSYCL/triSYCL

You can see starting from
https://github.com/triSYCL/triSYCL/blob/master/tests/Makefile#L322 how to start from C++ code, generate some SPIR LLVM IR and to feed xocc and build a fat binary that will use the XRT runtime.

Some documentation in
https://github.com/triSYCL/triSYCL/blob/master/doc/architecture.rst

Quoted 6 lines

There are other more official ways to generate bitstream (they are called products instead of research projects like triSYCL :-) ).

We are also working on an other open-source SYCL compiler with Intel to have a better common implementation
https://github.com/intel/llvm/wiki and to upstream this into Clang/LLVM.

Yeah, there's been plenty of gpu stacks with "everything open sourced that can be open sourced", except the compiler, for gpus. We didn't take those drivers either.

And I looked at the entire stack already to see what's there and what's missing.

Quoted 4 lines

So for Xilinx FPGA, you can see the LLVM IR as the equivalent of PTX for nVidia. But xocc is close-source for some more fundamental reasons: it would expose all the details of the FPGA. I guess this is exactly the same for Xilinx FPGA.

Yeah, neither did we merge a driver with just some IR as the "compiler", and most definitely not PTX (since that's just nv lock-in, spirv is the cross vendor solution that at least seems to have a fighting chance). We want the low level stuff (and if the high level compiler is the dumbest, least optimizing thing ever that can't run any real world workload yet, that's fine, it can be fixed). The low level stuff is what matters from an uapi perspective.

Quoted 3 lines

Note that probably most of the tool chains used to generate the low-level firmware for the various CPU (microcode), GPU, etc. are also close-source.

Yup. None have been successfully used to merge stuff into drivers/gpu.

Note that we're perfectly fine with closed source stacks running on top of drivers/gpu, with lots of additional secret sauce/value add/customer lock in/whatever compared to the basic open source stack. There's plenty of vendors doing that. But for the uapi review, and making sure we can at least keep the basic stack working, it needs to be the full open stack. End to end.

Quoted 8 lines

I guess I need to actually type that article on my blog about why exactly we're so much insisting on this, seems to become a bit an FAQ.

Cheers, Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Cheers,
Moritz

#17 lore raw
Quoted 67 lines · Moritz Fischer

Hi Daniel,

Quoted 50 lines · Daniel Vetter
Quoted 49 lines · Ronan KERYELL

I am adding [email protected], since this is why I missed this thread in the first place...

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Dave Airlie

Hi Dave!

Dave> On Thu, 28 Mar 2019 at 10:14, Sonal Santan <[email protected]> wrote:

>>> From: Daniel Vetter [mailto:[email protected]]

[...]

Quoted 19 lines
Quoted 18 lines
Quoted 6 lines

Note: There's no expectation for the fully optimizing compiler, and we're totally ok if there's an optimizing proprietary compiler and a basic open one (amd, and bunch of other companies all have such dual stacks running on top of drm kernel drivers). But a basic compiler that can convert basic kernels into machine code is expected.

Although the compiler is not open source the compilation flow lets users examine output from various stages. For example if you write your kernel in OpenCL/C/C++ you can view the RTL (Verilog/VHDL) output produced by first stage of compilation. Note that the compiler is really generating a custom circuit given a high level input which in the last phase gets synthesized into bitstream. Expert hardware designers can handcraft a circuit in RTL and feed it to the compiler. Our FPGA tools let you view the generated hardware design, the register map, etc. You can get more information about a compiled design by running XRT tool like xclbinutil on the generated file.

Quoted 3 lines
Quoted 3 lines

In essence compiling for FPGAs is quite different than compiling for GPU/CPU/DSP. Interestingly FPGA compilers can run anywhere from 30 mins to a few hours to compile a testcase.

Dave> So is there any open source userspace generator for what this Dave> interface provides? Is the bitstream format that gets fed into Dave> the FPGA proprietary and is it signed?

Short answer:

- a bitstream is an opaque content similar to various firmware handled by Linux, EFI capsules, x86 microcode, WiFi modems, etc.

- there is no open-source generator for what the interface consume;

- I do not know if it is signed;

Quoted 8 lines
Quoted 3 lines

- it is probably similar to what Intel FPGA (not GPU) drivers provide already inside the Linux kernel and I guess there is no pure open-source way to generate their bit-stream either.

Yeah, drivers/gpu folks wouldn't ever have merged drivers/fpga, and I think there's pretty strong consensus over here that merging fpga stuff without having clear specs (in the form of an executable open source compiler/synthesizer/whatever) was a mistake.

I don't totally understand this statement. You don't go out and ask people to open source their EDA tools that are used to create the ASICs on any piece of HW (NIC, GPU, USB controller,...) out there.

Quoted 6 lines

FPGAs are no different.

I think you need to distinguish between the general FPGA as a means to implement a HW solution and *FPGA based devices* that implement flows such as OpenCL etc. For the latter I'm more inclined to buy the equivalence to GPUs argument.

Yeah maybe there's a misunderstanding, my comments where in the context of the submitted xilinx driver, and similar drivers that mean to expose fpgas to userspace for doing stuff. If all you use your FGPA for is to load a bitstream as a firmware blob, to then instantiate a device which doesn't really change anymore, then then bistream is just like firmware indeed. But we're talking about kernel/userspace api, where (possible multiple) unpriviledged clients can do whatever they feel like, and where we have pretty hard requirements about not breaking userspace. To be able to fully review and more or less indefinitely support such driver stacks, we need to understand what they're doing and what's possible. It's the "unpriviledge userspace submits touring complete (ok sometimes not quite touring complete, but really powerful i/o is usually on the menu) blobs to be run on questionable hardware by the kernel" which is the part that distinguishes a firmware blob from the compute kernels we're talking about here. It's not gpu vs fpga vs something else. From a kernel driver pov those are all the same: You take a shader/bitstream/whatever blob + a bit of state/configuration from userspace, and need to make sure there's no DOS or other exploit in there.

And we're not going to take "there's no problem here" on blind faith, because we know how well designed&validated hw is. This isn't new with smeltdown, because gpus have been very fragile/broken/insecure pieces since forever (it's slowly getting better though, and we rely ever less on sw to guarantee isolation).

Wrt drivers/fpga: My understanding is that's very much meant to allow unpriviledge userspace to use them, at least they wouldn't need an ioctl interface otherwise.
-Daniel

Quoted 163 lines
Quoted 47 lines

We just had a similar huge discussions around the recently merged habanalabs driver in drivers/misc, for neural network accel. There was a proposed drivers/accel for these. gpu folks objected, Greg and Olof were happy with merging.

And the exact same arguments has come up tons of times for gpus too, with lots proposals to merge a kernel driver with just the kernel driver being open source, or just the state tracker/runtime, but most definitely not anything looking like the compiler. Because $reasons.

Conclusion was that drivers/gpu people will continue to reject these, everyone else will continue to take whatever, but just don't complain to us if it all comes crashing down :-)

Quoted 24 lines

Long answer:

- processors, GPU and other digital circuits are designed from a lot of elementary transistors, wires, capacitors, resistors... using some very complex (and expensive) tools from some EDA companies but at the end, after months of work, they come often with a "simple" public interface, the... instruction set! So it is rather "easy" at the end to generate some instructions with a compiler such as LLVM from a description of this ISA or some reverse engineering. Note that even if the ISA is public, it is very difficult to make another efficient processor from scratch just from this ISA, so there is often no concern about making this ISA public to develop the ecosystem ;

- FPGA are field-programmable gate arrays, made also from a lot of elementary transistors, wires, capacitors, resistors... but organized in billions of very low-level elementary gates, memory elements, DSP blocks, I/O blocks, clock generators, specific accelerators... directly exposed to the user and that can be programmed according to a configuration memory (the bitstream) that details how to connect each part, routing element, configuring each elemental piece of hardware. So instead of just writing instructions like on a CPU or a GPU, you need to configure each bit of the architecture in such a way it does something interesting for you. Concretely, you write some programs in RTL languages (Verilog,

Quoted 8 lines

VHDL) or higher-level (C/C++, OpenCL, SYCL...) and you use some very complex (and expensive) tools from some EDA companies to generate the bitstream implementing an equivalent circuit with the same semantics. Since the architecture is so low level, there is a direct mapping between the configuration memory (bitstream) and the hardware architecture itself, so if it is public then it is easy to duplicate the FPGA itself and to start a new FPGA company. That is unfortunately something the existing FPGA companies do not want... ;-)

Quoted 5 lines

i.e. you have a use case where you absolutely need an offline compiler. Like with gpus (in some use cases), the only difference is that for gpus the latency requirement that's too high is measured in milliseconds, cause that would cause dropped frames, and worst case compiling takes seconds for some big shaders. With FPGAs it's just 1000x higher limits, same problem.

As I said above, you'd do the same thing when you design any other piece of hardware out there, except for with FPGAs you'd be able to change stuff, whereas with an ASIC your netlist gets fixed at tape-out date.

Quoted 92 lines
Quoted 52 lines

To summarize:

- on a CPU & GPU, the vendor used the expensive EDA tools once already for you and provide the simpler ISA interface;

- on an FPGA, you have access to a pile of low-level hardware and it is up to you to use the lengthy process of building your own computing architecture using the heavy expensive very subtle EDA tools that will run for hours or days to generate some good-enough placement for your pleasure.

There is some public documentation on-line:
https://www.xilinx.com/products/silicon-devices/fpga/virtex-ultrascale-plus.html#documentation

To have an idea of the elementary architecture:
https://www.xilinx.com/support/documentation/user_guides/ug574-ultrascale-clb.pdf
https://www.xilinx.com/support/documentation/user_guides/ug579-ultrascale-dsp.pdf
https://www.xilinx.com/support/documentation/user_guides/ug573-ultrascale-memory-resources.pdf

Even on the configuration and the file format, but without any detailed semantics:
https://www.xilinx.com/support/documentation/user_guides/ug570-ultrascale-configuration.pdf

The Xilinx compiler xocc taking for example some LLVM IR and generating some bitstream is not open-source and will probably never be for the reasons above... :-(

Xilinx is open-sourcing all what can reasonably be open-sourced:

- the user-level and system run-time, including the OpenCL runtime:
https://github.com/Xilinx/XRT to handle the bitstreams generated by some close-source tools

- the kernel device drivers which are already in
https://github.com/Xilinx/XRT but we want to upstream into the Linux kernel to make life easier (this is the matter of this e-mail thread);

- to generate some real code in the most (modern and) open-source way, there is an open-source framework to compile some SYCL C++ including some Xilinx FPGA-specific extensions down to SPIR LLVM IR using Clang/LLVM and to feed the close-source xocc tool with it
https://github.com/triSYCL/triSYCL

You can see starting from
https://github.com/triSYCL/triSYCL/blob/master/tests/Makefile#L322 how to start from C++ code, generate some SPIR LLVM IR and to feed xocc and build a fat binary that will use the XRT runtime.

Some documentation in
https://github.com/triSYCL/triSYCL/blob/master/doc/architecture.rst

Quoted 6 lines

There are other more official ways to generate bitstream (they are called products instead of research projects like triSYCL :-) ).

We are also working on an other open-source SYCL compiler with Intel to have a better common implementation
https://github.com/intel/llvm/wiki and to upstream this into Clang/LLVM.

Yeah, there's been plenty of gpu stacks with "everything open sourced that can be open sourced", except the compiler, for gpus. We didn't take those drivers either.

And I looked at the entire stack already to see what's there and what's missing.

Quoted 4 lines

So for Xilinx FPGA, you can see the LLVM IR as the equivalent of PTX for nVidia. But xocc is close-source for some more fundamental reasons: it would expose all the details of the FPGA. I guess this is exactly the same for Xilinx FPGA.

Yeah, neither did we merge a driver with just some IR as the "compiler", and most definitely not PTX (since that's just nv lock-in, spirv is the cross vendor solution that at least seems to have a fighting chance). We want the low level stuff (and if the high level compiler is the dumbest, least optimizing thing ever that can't run any real world workload yet, that's fine, it can be fixed). The low level stuff is what matters from an uapi perspective.

Quoted 3 lines

Note that probably most of the tool chains used to generate the low-level firmware for the various CPU (microcode), GPU, etc. are also close-source.

Yup. None have been successfully used to merge stuff into drivers/gpu.

Note that we're perfectly fine with closed source stacks running on top of drivers/gpu, with lots of additional secret sauce/value add/customer lock in/whatever compared to the basic open source stack. There's plenty of vendors doing that. But for the uapi review, and making sure we can at least keep the basic stack working, it needs to be the full open stack. End to end.

Quoted 8 lines

I guess I need to actually type that article on my blog about why exactly we're so much insisting on this, seems to become a bit an FAQ.

Cheers, Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Cheers,
Moritz
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#18 lore raw
In reply to Ronan KERYELL
Quoted 5 lines · Ronan KERYELL

I am adding [email protected], since this is why I missed this thread in the first place...

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Dave Airlie

Dave> On Thu, 28 Mar 2019 at 10:14, Sonal Santan <[email protected]> wrote:
>>> From: Daniel Vetter [mailto:[email protected]]

[...]

Quoted 24 lines

Long answer:

- processors, GPU and other digital circuits are designed from a lot of elementary transistors, wires, capacitors, resistors... using some very complex (and expensive) tools from some EDA companies but at the end, after months of work, they come often with a "simple" public interface, the... instruction set! So it is rather "easy" at the end to generate some instructions with a compiler such as LLVM from a description of this ISA or some reverse engineering. Note that even if the ISA is public, it is very difficult to make another efficient processor from scratch just from this ISA, so there is often no concern about making this ISA public to develop the ecosystem ;

- FPGA are field-programmable gate arrays, made also from a lot of elementary transistors, wires, capacitors, resistors... but organized in billions of very low-level elementary gates, memory elements, DSP blocks, I/O blocks, clock generators, specific accelerators... directly exposed to the user and that can be programmed according to a configuration memory (the bitstream) that details how to connect each part, routing element, configuring each elemental piece of hardware. So instead of just writing instructions like on a CPU or a GPU, you need to configure each bit of the architecture in such a way it does something interesting for you. Concretely, you write some programs in RTL languages (Verilog,

Quoted 8 lines

VHDL) or higher-level (C/C++, OpenCL, SYCL...) and you use some very complex (and expensive) tools from some EDA companies to generate the bitstream implementing an equivalent circuit with the same semantics. Since the architecture is so low level, there is a direct mapping between the configuration memory (bitstream) and the hardware architecture itself, so if it is public then it is easy to duplicate the FPGA itself and to start a new FPGA company. That is unfortunately something the existing FPGA companies do not want... ;-)

This is completely bogus argument, all FPGA documentation i have seen so far _extensively_ describe _each_ basic blocks within the FGPA, this does include the excelent documentation Xilinx provide on the inner working and layout of Xilinx FPGA. Same apply to Altera, Atmel, Latice, ...

The extensive public documentation is enough for anyone with the money and with half decent engineers to produce an FPGA.

The real know how of FPGA vendor is how to produce big chips on small process capable to sustain high clock with the best power consumption possible. This is the part where the years of experiences of each company pay off. The cost for anyone to come to the market is in the hundred of millions just in setup cost and to catch with established vendor on the hardware side. This without any garanty of revenue at the end.

The bitstream is only giving away which bits correspond to which wire where the LUT boolean table is store ... Bitstream that have been reverse engineer never revealed anything of value that was not already publicly documented.

So no the bitstream has _no_ value, please prove me wrong with Latice bitstream for instance. If anything the fact that Latice has a reverse engineer bitstream has made that FPGA popular with the maker community as it allows people to do experiment for which the closed source tools are an impediment. So i would argue that open bitstream is actualy beneficial.

The only valid reason i have ever seen for hidding the bitstream is to protect the IP of the customer ie those customer that can pour quite a lot of money on designing something with an FPGA and then wants to keep the VHDL/Verilog protected and "safe" from reverse engineering.

But this is security by obscurity and FPGA company would be better off providing strong bitstream encryption (and most already do but i have seen some paper on how to break them).

I rather not see any bogus argument to try to justify something that is not justifiable.

Daniel already stressed that we need to know what the bitstream can do and it is even more important with FPGA where on some FPGA AFAICT the bitstream can have total control over the PCIE BUS and thus can be use to attack either main memory or other PCIE devices.

For instance with ATS/PASID you can have the device send pre-translated request to the IOMMU and access any memory despite the IOMMU.

So without total confidence of what the bitstream can and can not do, and thus without knowledge of the bitstream format and how it maps to LUT, switch, cross- bar, clock, fix block (PCIE, DSP, DAC, ADC, ...) there is no way for someone independant to check anything.

Cheers,
Jérôme Glisse

#19 lore raw
Quoted 104 lines

-----Original Message-----
From: Jerome Glisse [mailto:[email protected]]
Sent: Wednesday, April 03, 2019 8:48 AM
To: Ronan KERYELL <[email protected]>
Cc: Dave Airlie <[email protected]>; Sonal Santan <[email protected]>; Daniel Vetter <[email protected]>; [email protected]; [email protected]; Cyril Chemparathy <[email protected]>; linux- [email protected]; Lizhi Hou <[email protected]>; Michal Simek <[email protected]>; [email protected]; [email protected]; Ralph Wittig <[email protected]>; Ronan Keryell <[email protected]>
Subject: Re: [RFC PATCH Xilinx Alveo 0/6] Xilinx PCIe accelerator driver

Quoted 3 lines · Ronan KERYELL

I am adding [email protected], since this is why I missed this thread in the first place...

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Fri, 29 Mar 2019 14:56:17 +1000, Dave Airlie <[email protected]>

Quoted 1 line · said:
    Dave> On Thu, 28 Mar 2019 at 10:14, Sonal Santan <[email protected]>
Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line

From: Daniel Vetter [mailto:[email protected]]

[...]

Quoted 24 lines

Long answer:

- processors, GPU and other digital circuits are designed from a lot of elementary transistors, wires, capacitors, resistors... using some very complex (and expensive) tools from some EDA companies but at the end, after months of work, they come often with a "simple" public interface, the... instruction set! So it is rather "easy" at the end to generate some instructions with a compiler such as LLVM from a description of this ISA or some reverse engineering. Note that even if the ISA is public, it is very difficult to make another efficient processor from scratch just from this ISA, so there is often no concern about making this ISA public to develop the ecosystem ;

- FPGA are field-programmable gate arrays, made also from a lot of elementary transistors, wires, capacitors, resistors... but organized in billions of very low-level elementary gates, memory elements, DSP blocks, I/O blocks, clock generators, specific accelerators... directly exposed to the user and that can be programmed according to a configuration memory (the bitstream) that details how to connect each part, routing element, configuring each elemental piece of hardware. So instead of just writing instructions like on a CPU or a GPU, you need to configure each bit of the architecture in such a way it does something interesting for you. Concretely, you write some programs in RTL languages (Verilog,

Quoted 8 lines

VHDL) or higher-level (C/C++, OpenCL, SYCL...) and you use some very complex (and expensive) tools from some EDA companies to generate the bitstream implementing an equivalent circuit with the same semantics. Since the architecture is so low level, there is a direct mapping between the configuration memory (bitstream) and the hardware architecture itself, so if it is public then it is easy to duplicate the FPGA itself and to start a new FPGA company. That is unfortunately something the existing FPGA companies do not want... ;-)

This is completely bogus argument, all FPGA documentation i have seen so far _extensively_ describe _each_ basic blocks within the FGPA, this does include the excelent documentation Xilinx provide on the inner working and layout of Xilinx FPGA. Same apply to Altera, Atmel, Latice, ...

The extensive public documentation is enough for anyone with the money and with half decent engineers to produce an FPGA.

The real know how of FPGA vendor is how to produce big chips on small process capable to sustain high clock with the best power consumption possible. This is the part where the years of experiences of each company pay off. The cost for anyone to come to the market is in the hundred of millions just in setup cost and to catch with established vendor on the hardware side. This without any garanty of revenue at the end.

The bitstream is only giving away which bits correspond to which wire where the LUT boolean table is store ... Bitstream that have been reverse engineer never revealed anything of value that was not already publicly documented.

So no the bitstream has _no_ value, please prove me wrong with Latice bitstream for instance. If anything the fact that Latice has a reverse engineer bitstream has made that FPGA popular with the maker community as it allows people to do experiment for which the closed source tools are an impediment. So i would argue that open bitstream is actualy beneficial.

The only valid reason i have ever seen for hidding the bitstream is to protect the IP of the customer ie those customer that can pour quite a lot of money on designing something with an FPGA and then wants to keep the VHDL/Verilog protected and "safe" from reverse engineering.

But this is security by obscurity and FPGA company would be better off providing strong bitstream encryption (and most already do but i have seen some paper on how to break them).

I rather not see any bogus argument to try to justify something that is not justifiable.

Daniel already stressed that we need to know what the bitstream can do and it is even more important with FPGA where on some FPGA AFAICT the bitstream can have total control over the PCIE BUS and thus can be use to attack either main memory or other PCIE devices.

Quoted 9 lines

For instance with ATS/PASID you can have the device send pre-translated request to the IOMMU and access any memory despite the IOMMU.

So without total confidence of what the bitstream can and can not do, and thus without knowledge of the bitstream format and how it maps to LUT, switch, cross- bar, clock, fix block (PCIE, DSP, DAC, ADC, ...) there is no way for someone independant to check anything.

Thank you for your time and valuable feedback. I will work on addressing these and get back.

-Sonal

Quoted 2 lines

Cheers,
Jérôme Glisse