Skip to contentSkip to conversation

xilinx XDMA driver

PATCH Superseded Lizhi Hou 2 participants 8 messages Oct 4, 2022 – Oct 12, 2022

Subsystems (5)

v6 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Lizhi Hou

author maintainer
#0 lore raw

v6 cover xilinx XDMA driver

Hello,

This V6 of patch series is to provide the platform driver to support the Xilinx XDMA subsystem. The XDMA subsystem is used in conjunction with the PCI Express IP block to provide high performance data transfer between host memory and the card's DMA subsystem. It also provides up to 16 user interrupt wires to user logic that generate interrupts to the host.

            +-------+       +-------+       +-----------+
   PCIe     |       |       |       |       |           |
   Tx/Rx    |       |       |       |  AXI  |           |
 <=======>  | PCIE  | <===> | XDMA  | <====>| User Logic|
            |       |       |       |       |           |
            +-------+       +-------+       +-----------+

The XDMA has been used for Xilinx Alveo PCIe devices.
And it is also integrated into Versal ACAP DMA and Bridge Subsystem.
https://www.xilinx.com/products/boards-and-kits/alveo.html
https://docs.xilinx.com/r/en-US/pg344-pcie-dma-versal/Introduction-to-the-DMA-and-Bridge-Subsystems

The device driver for any FPGA based PCIe device which leverages XDMA can call the standard dmaengine APIs to discover and use the XDMA subsystem without duplicating the XDMA driver code in its own driver.

Changes since v5:
- Modified user logic interrupt APIs to handle user logic IP which does not have its own register to enable/disable interrupt.
- Clean up code based on review comments.

Changes since v4:
- Modified user logic interrupt APIs.

Changes since v3:
- Added one patch to support user logic interrupt.

Changes since v2:
- Removed tasklet.
- Fixed regression bug introduced to V2.
- Test Robot warning.

Changes since v1:
- Moved filling hardware descriptor to xdma_prep_device_sg().
- Changed hardware descriptor enum to "struct xdma_hw_desc".
- Minor changes from code review comments.

Lizhi Hou (2):
dmaengine: xilinx: xdma: Add xilinx xdma driver
dmaengine: xilinx: xdma: Add user logic interrupt support

 MAINTAINERS                            |   11 +
 drivers/dma/Kconfig                    |   13 +
 drivers/dma/xilinx/Makefile            |    1 +
 drivers/dma/xilinx/xdma-regs.h         |  171 ++++
 drivers/dma/xilinx/xdma.c              | 1034 ++++++++++++++++++++++++
 include/linux/dma/amd_xdma.h           |   16 +
 include/linux/platform_data/amd_xdma.h |   34 +
 7 files changed, 1280 insertions(+)
 create mode 100644 drivers/dma/xilinx/xdma-regs.h
 create mode 100644 drivers/dma/xilinx/xdma.c
 create mode 100644 include/linux/dma/amd_xdma.h
 create mode 100644 include/linux/platform_data/amd_xdma.h
Signature · 1 line
2.27.0
author maintainer
#1 lore raw

PATCH v6 1/2 dmaengine: xilinx: xdma: Add xilinx xdma driver

Add driver to enable PCIe board which uses XDMA (the DMA/Bridge Subsystem for PCI Express). For example, Xilinx Alveo PCIe devices.
https://www.xilinx.com/products/boards-and-kits/alveo.html

The XDMA engine support up to 4 Host to Card (H2C) and 4 Card to Host (C2H) channels. Memory transfers are specified on a per-channel basis in descriptor linked lists, which the DMA fetches from host memory and processes. Events such as descriptor completion and errors are signaled using interrupts. The hardware detail is provided by

    https://docs.xilinx.com/r/en-US/pg195-pcie-dma/Introduction

This driver implements dmaengine APIs.
- probe the available DMA channels
- use dma_slave_map for channel lookup
- use virtual channel to manage dmaengine tx descriptors
- implement device_prep_slave_sg callback to handle host scatter gather list
- implement device_config to config device address for DMA transfer

---
 MAINTAINERS                            |  10 +
 drivers/dma/Kconfig                    |  13 +
 drivers/dma/xilinx/Makefile            |   1 +
 drivers/dma/xilinx/xdma-regs.h         | 171 +++++
 drivers/dma/xilinx/xdma.c              | 947 +++++++++++++++++++++++++
 include/linux/platform_data/amd_xdma.h |  34 +
 6 files changed, 1176 insertions(+)
 create mode 100644 drivers/dma/xilinx/xdma-regs.h
 create mode 100644 drivers/dma/xilinx/xdma.c
 create mode 100644 include/linux/platform_data/amd_xdma.h
MAINTAINERS +10 -0
index e8c52d0192a6..c1be0b2e378a 100644
@@ -21683,6 +21683,16 @@ F:	Documentation/devicetree/bindings/media/xilinx/
 F:	drivers/media/platform/xilinx/
 F:	include/uapi/linux/xilinx-v4l2-controls.h
 
+XILINX XDMA DRIVER
+M:	Lizhi Hou <[email protected]>
+M:	Brian Xu <[email protected]>
+M:	Raj Kumar Rampelli <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/dma/xilinx/xdma-regs.h
+F:	drivers/dma/xilinx/xdma.c
+F:	include/linux/platform_data/amd_xdma.h
+
 XILINX ZYNQMP DPDMA DRIVER
 M:	Hyun Kwon <[email protected]>
 M:	Laurent Pinchart <[email protected]>
drivers/dma/Kconfig +13 -0
index d5de3f77d3aa..4d90f2f51655 100644
@@ -733,6 +733,19 @@ config XILINX_ZYNQMP_DPDMA
 	  driver provides the dmaengine required by the DisplayPort subsystem
 	  display driver.
 
+config XILINX_XDMA
+	tristate "Xilinx DMA/Bridge Subsystem DMA Engine"
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+	select REGMAP_MMIO
+	help
+	  Enable support for Xilinx DMA/Bridge Subsystem DMA engine. The DMA
+	  provides high performance block data movement between Host memory
+	  and the DMA subsystem. These direct memory transfers can be both in
+	  the Host to Card (H2C) and Card to Host (C2H) transfers.
+	  The core also provides up to 16 user interrupt wires that generate
+	  interrupts to the host.
+
 # driver files
 source "drivers/dma/bestcomm/Kconfig"
 
drivers/dma/xilinx/Makefile +1 -0
index 767bb45f641f..c7a538a56643 100644
@@ -2,3 +2,4 @@
 obj-$(CONFIG_XILINX_DMA) += xilinx_dma.o
 obj-$(CONFIG_XILINX_ZYNQMP_DMA) += zynqmp_dma.o
 obj-$(CONFIG_XILINX_ZYNQMP_DPDMA) += xilinx_dpdma.o
+obj-$(CONFIG_XILINX_XDMA) += xdma.o
drivers/dma/xilinx/xdma-regs.h new file +171 -0

171 lines not on this page · raw message

drivers/dma/xilinx/xdma.c new file +947 -0

947 lines not on this page · raw message

include/linux/platform_data/amd_xdma.h new file +34 -0
new file mode 100644
index 000000000000..b5e23e14bac8
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2022, Advanced Micro Devices, Inc.
+ */
+
+#ifndef _PLATDATA_AMD_XDMA_H
+#define _PLATDATA_AMD_XDMA_H
+
+#include <linux/dmaengine.h>
+
+/**
+ * struct xdma_chan_info - DMA channel information
+ *	This information is used to match channel when request dma channel
+ * @dir: Channel transfer direction
+ */
+struct xdma_chan_info {
+	enum dma_transfer_direction dir;
+};
+
+#define XDMA_FILTER_PARAM(chan_info)	((void *)(chan_info))
+
+struct dma_slave_map;
+
+/**
+ * struct xdma_platdata - platform specific data for XDMA engine
+ * @max_dma_channels: Maximum dma channels in each direction
+ */
+struct xdma_platdata {
+	u32 max_dma_channels;
+	u32 device_map_cnt;
+	struct dma_slave_map *device_map;
+};
+
+#endif /* _PLATDATA_AMD_XDMA_H */
Signature · 1 line
2.27.0
author maintainer
#2 lore raw

PATCH v6 2/2 dmaengine: xilinx: xdma: Add user logic interrupt support

In reply to Lizhi Hou

The Xilinx DMA/Bridge Subsystem for PCIe (XDMA) provides up to 16 user interrupt wires to user logic that generate interrupts to the host. This patch adds APIs to enable/disable user logic interrupt for a given interrupt wire index.

---
 MAINTAINERS                  |  1 +
 drivers/dma/xilinx/xdma.c    | 87 ++++++++++++++++++++++++++++++++++++
 include/linux/dma/amd_xdma.h | 16 +++++++
 3 files changed, 104 insertions(+)
 create mode 100644 include/linux/dma/amd_xdma.h
MAINTAINERS +1 -0
index c1be0b2e378a..019d84b2b086 100644
@@ -21691,6 +21691,7 @@ L:	[email protected]
 S:	Supported
 F:	drivers/dma/xilinx/xdma-regs.h
 F:	drivers/dma/xilinx/xdma.c
+F:	include/linux/dma/amd_xdma.h
 F:	include/linux/platform_data/amd_xdma.h
 
 XILINX ZYNQMP DPDMA DRIVER
drivers/dma/xilinx/xdma.c +87 -0

111 lines not on this page · raw message

include/linux/dma/amd_xdma.h new file +16 -0
new file mode 100644
index 000000000000..ceba69ed7cb4
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2022, Advanced Micro Devices, Inc.
+ */
+
+#ifndef _DMAENGINE_AMD_XDMA_H
+#define _DMAENGINE_AMD_XDMA_H
+
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+
+int xdma_enable_user_irq(struct platform_device *pdev, u32 irq_num);
+void xdma_disable_user_irq(struct platform_device *pdev, u32 irq_num);
+int xdma_get_user_irq(struct platform_device *pdev, u32 user_irq_index);
+
+#endif /* _DMAENGINE_AMD_XDMA_H */
Signature · 1 line
2.27.0
#3 lore raw
In reply to Lizhi Hou
Quoted 57 lines · Lizhi Hou

Hello,

This V6 of patch series is to provide the platform driver to support the Xilinx XDMA subsystem. The XDMA subsystem is used in conjunction with the PCI Express IP block to provide high performance data transfer between host memory and the card's DMA subsystem. It also provides up to 16 user interrupt wires to user logic that generate interrupts to the host.

             +-------+       +-------+       +-----------+
    PCIe     |       |       |       |       |           |
    Tx/Rx    |       |       |       |  AXI  |           |
  <=======>  | PCIE  | <===> | XDMA  | <====>| User Logic|
             |       |       |       |       |           |
             +-------+       +-------+       +-----------+

The XDMA has been used for Xilinx Alveo PCIe devices.
And it is also integrated into Versal ACAP DMA and Bridge Subsystem.
https://www.xilinx.com/products/boards-and-kits/alveo.html
https://docs.xilinx.com/r/en-US/pg344-pcie-dma-versal/Introduction-to-the-DMA-and-Bridge-Subsystems

The device driver for any FPGA based PCIe device which leverages XDMA can call the standard dmaengine APIs to discover and use the XDMA subsystem without duplicating the XDMA driver code in its own driver.

Changes since v5:
- Modified user logic interrupt APIs to handle user logic IP which does not have its own register to enable/disable interrupt.
- Clean up code based on review comments.

Changes since v4:
- Modified user logic interrupt APIs.

Changes since v3:
- Added one patch to support user logic interrupt.

Changes since v2:
- Removed tasklet.
- Fixed regression bug introduced to V2.
- Test Robot warning.

Changes since v1:
- Moved filling hardware descriptor to xdma_prep_device_sg().
- Changed hardware descriptor enum to "struct xdma_hw_desc".
- Minor changes from code review comments.

Lizhi Hou (2):
dmaengine: xilinx: xdma: Add xilinx xdma driver
dmaengine: xilinx: xdma: Add user logic interrupt support

  MAINTAINERS                            |   11 +
  drivers/dma/Kconfig                    |   13 +
  drivers/dma/xilinx/Makefile            |    1 +
  drivers/dma/xilinx/xdma-regs.h         |  171 ++++
  drivers/dma/xilinx/xdma.c              | 1034 ++++++++++++++++++++++++
  include/linux/dma/amd_xdma.h           |   16 +
  include/linux/platform_data/amd_xdma.h |   34 +
  7 files changed, 1280 insertions(+)
Quoted 5 lines

create mode 100644 drivers/dma/xilinx/xdma-regs.h create mode 100644 drivers/dma/xilinx/xdma.c create mode 100644 include/linux/dma/amd_xdma.h create mode 100644 include/linux/platform_data/amd_xdma.h

Hi,
I have rewritten our V4L2 driver to use this new XDMA driver, but it does not work on our HW (where the previous Xilinx XDMA driver derived from the Xilinx sample code worked fine). The driver is sucessfully loaded and 4(2+2) DMA channels are successfully created. But when a DMA transfer is initiated, I get an error from my PC's DMA chip:

AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x000a address=0x36a00000 flags=0x0000]

and no error from XDMA.

Does the driver expect some special FPGA IP core configuration? Or is there something else I'm missing? My code is quiet similar to what you use in your XRT repo on GitHub (there is btw. a bug in the XRT code - you do not clear the dma_slave_config struct before using) but in my case the DMA transfer triggers the AMD-Vi error and timeouts.

The code of our driver is attached, the relevant parts are in mgb4_dma.c and mgb4_core.c.

M.

drivers/media/pci/Kconfig +1 -0
index 1224d908713a..e3f9d0d4e4cc 100644
@@ -13,6 +13,7 @@ if MEDIA_PCI_SUPPORT
 if MEDIA_CAMERA_SUPPORT
 	comment "Media capture support"
 
+source "drivers/media/pci/mgb4/Kconfig"
 source "drivers/media/pci/meye/Kconfig"
 source "drivers/media/pci/solo6x10/Kconfig"
 source "drivers/media/pci/sta2x11/Kconfig"
drivers/media/pci/Makefile +1 -0
index 551169a3e434..8ca819cf3cc1 100644
@@ -33,6 +33,7 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
 obj-$(CONFIG_VIDEO_DT3155) += dt3155/
 obj-$(CONFIG_VIDEO_IVTV) += ivtv/
 obj-$(CONFIG_VIDEO_MEYE) += meye/
+obj-$(CONFIG_VIDEO_MGB4) += mgb4/
 obj-$(CONFIG_VIDEO_SAA7134) += saa7134/
 obj-$(CONFIG_VIDEO_SAA7164) += saa7164/
 obj-$(CONFIG_VIDEO_SOLO6X10) += solo6x10/
drivers/media/pci/mgb4/Kconfig new file +17 -0
new file mode 100644
index 000000000000..13fad15a434c
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config VIDEO_MGB4
+	tristate "Digiteq Automotive MGB4 support"
+	depends on VIDEO_DEV && PCI && I2C && DMADEVICES && SPI && MTD && IIO
+	select VIDEOBUF2_DMA_SG
+	select IIO_BUFFER
+	select IIO_TRIGGERED_BUFFER
+	select I2C_XILINX
+	select SPI_XILINX
+	select MTD_SPI_NOR
+	select XILINX_XDMA
+	help
+	  This is a video4linux driver for Digiteq Automotive MGB4 grabber
+	  cards.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called mgb4.
drivers/media/pci/mgb4/Makefile new file +6 -0
new file mode 100644
index 000000000000..e92ead18bed0
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+mgb4-objs	:= mgb4_regs.o mgb4_core.o mgb4_vin.o mgb4_vout.o \
+               mgb4_sysfs_pci.o mgb4_sysfs_in.o mgb4_sysfs_out.o \
+               mgb4_i2c.o mgb4_cmt.o mgb4_trigger.o mgb4_dma.o
+
+obj-$(CONFIG_VIDEO_MGB4) += mgb4.o
drivers/media/pci/mgb4/mgb4_cmt.c new file +243 -0

243 lines not on this page · raw message

drivers/media/pci/mgb4/mgb4_cmt.h new file +16 -0
new file mode 100644
index 000000000000..353966654c95
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2021-2022 Digiteq Automotive
+ *     author: Martin Tuma <[email protected]>
+ */
+
+#ifndef __MGB4_CMT_H__
+#define __MGB4_CMT_H__
+
+#include "mgb4_vout.h"
+#include "mgb4_vin.h"
+
+u32 mgb4_cmt_set_vout(struct mgb4_vout_dev *voutdev, unsigned int freq);
+void mgb4_cmt_set_vin(struct mgb4_vin_dev *vindev, unsigned int freq_range);
+
+#endif
drivers/media/pci/mgb4/mgb4_core.c new file +656 -0

656 lines not on this page · raw message

drivers/media/pci/mgb4/mgb4_core.h new file +65 -0

65 lines not on this page · raw message

drivers/media/pci/mgb4/mgb4_dma.c new file +117 -0

117 lines not on this page · raw message

drivers/media/pci/mgb4/mgb4_dma.h new file +18 -0
new file mode 100644
index 000000000000..443e2a11b055
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2021-2022 Digiteq Automotive
+ *     author: Martin Tuma <[email protected]>
+ */
+
+#ifndef __MGB4_DMA_H__
+#define __MGB4_DMA_H__
+
+#include "mgb4_core.h"
+
+extern int mgb4_dma_channel_init(struct mgb4_dev *mgbdev);
+extern void mgb4_dma_channel_free(struct mgb4_dev *mgbdev);
+
+extern int mgb4_dma_transfer(struct mgb4_dev *mgbdev, u32 channel, bool write,
+			     u64 paddr, struct sg_table *sgt);
+
+#endif
drivers/media/pci/mgb4/mgb4_i2c.c new file +139 -0

139 lines not on this page · raw message

drivers/media/pci/mgb4/mgb4_i2c.h new file +35 -0
new file mode 100644
index 000000000000..e5003927509f
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2021-2022 Digiteq Automotive
+ *     author: Martin Tuma <[email protected]>
+ */
+
+#ifndef __MGB4_I2C_H__
+#define __MGB4_I2C_H__
+
+#include <linux/i2c.h>
+
+struct mgb4_i2c_client {
+	struct i2c_client *client;
+	int addr_size;
+};
+
+struct mgb4_i2c_kv {
+	u16 reg;
+	u8 mask;
+	u8 val;
+};
+
+extern int mgb4_i2c_init(struct mgb4_i2c_client *client, struct i2c_adapter *adap,
+			 struct i2c_board_info const *info, int addr_size);
+extern void mgb4_i2c_free(struct mgb4_i2c_client *client);
+
+extern s32 mgb4_i2c_read_byte(struct mgb4_i2c_client *client, u16 reg);
+extern s32 mgb4_i2c_write_byte(struct mgb4_i2c_client *client, u16 reg, u8 val);
+extern s32 mgb4_i2c_mask_byte(struct mgb4_i2c_client *client, u16 reg, u8 mask,
+			      u8 val);
+
+extern int mgb4_i2c_configure(struct mgb4_i2c_client *client,
+			      const struct mgb4_i2c_kv *values, size_t count);
+
+#endif
drivers/media/pci/mgb4/mgb4_io.h new file +36 -0
new file mode 100644
index 000000000000..dff92065f2c0
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2021-2022 Digiteq Automotive
+ *     author: Martin Tuma <[email protected]>
+ */
+
+#ifndef __MGB4_IO_H__
+#define __MGB4_IO_H__
+
+#include <media/v4l2-dev.h>
+
+#ifndef VFL_TYPE_GRABBER
+#define VFL_TYPE_GRABBER VFL_TYPE_VIDEO
+#endif
+
+#define ERR_NO_REG        0xFFFFFFFE
+#define ERR_QUEUE_TIMEOUT 0xFFFFFFFD
+#define ERR_QUEUE_EMPTY   0xFFFFFFFC
+#define ERR_QUEUE_FULL    0xFFFFFFFB
+
+#define BYTESPERLINE(width, alignment) \
+	(((((width) * 4) - 1) | ((alignment) - 1)) + 1)
+#define PADDING(width, alignment) \
+	((BYTESPERLINE((width), (alignment)) - ((width) * 4)) / 4)
+
+struct frame_buffer {
+	struct vb2_v4l2_buffer vb;
+	struct list_head list;
+};
+
+extern inline struct frame_buffer *to_frame_buffer(struct vb2_v4l2_buffer *vbuf)
+{
+	return container_of(vbuf, struct frame_buffer, vb);
+}
+
+#endif
drivers/media/pci/mgb4/mgb4_regs.c new file +30 -0
new file mode 100644
index 000000000000..53d4e4503a74
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2021-2022 Digiteq Automotive
+ *     author: Martin Tuma <[email protected]>
+ */
+
+#include <linux/ioport.h>
+#include "mgb4_regs.h"
+
+int mgb4_regs_map(struct resource *res, struct mgb4_regs *regs)
+{
+	regs->mapbase = res->start;
+	regs->mapsize = res->end - res->start;
+
+	if (!request_mem_region(regs->mapbase, regs->mapsize, res->name))
+		return -EINVAL;
+	regs->membase = ioremap(regs->mapbase, regs->mapsize);
+	if (!regs->membase) {
+		release_mem_region(regs->mapbase, regs->mapsize);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+void mgb4_regs_free(struct mgb4_regs *regs)
+{
+	iounmap(regs->membase);
+	release_mem_region(regs->mapbase, regs->mapsize);
+}
drivers/media/pci/mgb4/mgb4_regs.h new file +35 -0
new file mode 100644
index 000000000000..1cc16941ea45
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2021-2022 Digiteq Automotive
+ *     author: Martin Tuma <[email protected]>
+ */
+
+#ifndef __MGB4_REGS_H__
+#define __MGB4_REGS_H__
+
+#include <linux/io.h>
+
+struct mgb4_regs {
+	resource_size_t mapbase;
+	resource_size_t mapsize;
+	void __iomem *membase;
+};
+
+#define mgb4_write_reg(regs, offset, val) \
+	iowrite32(val, (regs)->membase + (offset))
+#define  mgb4_read_reg(regs, offset) \
+	ioread32((regs)->membase + (offset))
+
+static inline void mgb4_mask_reg(struct mgb4_regs *regs, u32 reg, u32 mask,
+				 u32 val)
+{
+	u32 ret = mgb4_read_reg(regs, reg);
+
+	val |= ret & ~mask;
+	mgb4_write_reg(regs, reg, val);
+}
+
+extern int mgb4_regs_map(struct resource *res, struct mgb4_regs *regs);
+extern void mgb4_regs_free(struct mgb4_regs *regs);
+
+#endif
drivers/media/pci/mgb4/mgb4_sysfs.h new file +18 -0
new file mode 100644
index 000000000000..2b42a8ba37f7
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2021-2022 Digiteq Automotive
+ *     author: Martin Tuma <[email protected]>
+ */
+
+#ifndef __MGB4_SYSFS_H__
+#define __MGB4_SYSFS_H__
+
+#include <linux/sysfs.h>
+
+extern struct device_attribute *mgb4_pci_attrs[];
+extern struct device_attribute *mgb4_fpdl3_in_attrs[];
+extern struct device_attribute *mgb4_gmsl_in_attrs[];
+extern struct device_attribute *mgb4_fpdl3_out_attrs[];
+extern struct device_attribute *mgb4_gmsl_out_attrs[];
+
+#endif
drivers/media/pci/mgb4/mgb4_sysfs_in.c new file +750 -0

750 lines not on this page · raw message

drivers/media/pci/mgb4/mgb4_sysfs_out.c new file +734 -0

734 lines not on this page · raw message

drivers/media/pci/mgb4/mgb4_sysfs_pci.c new file +83 -0

71 lines not on this page · raw message

drivers/media/pci/mgb4/mgb4_trigger.c new file +203 -0

203 lines not on this page · raw message

drivers/media/pci/mgb4/mgb4_trigger.h new file +8 -0
new file mode 100644
index 000000000000..9e6a651817d5

Lines of this file are not shown. View the raw message.

drivers/media/pci/mgb4/mgb4_vin.c new file +663 -0

663 lines not on this page · raw message

drivers/media/pci/mgb4/mgb4_vin.h new file +64 -0

64 lines not on this page · raw message

drivers/media/pci/mgb4/mgb4_vout.c new file +505 -0

505 lines not on this page · raw message

drivers/media/pci/mgb4/mgb4_vout.h new file +58 -0

58 lines not on this page · raw message

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

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

author maintainer
#4 lore raw
Quoted 70 lines · Martin Tůma
Quoted 57 lines · Lizhi Hou

Hello,

This V6 of patch series is to provide the platform driver to support the Xilinx XDMA subsystem. The XDMA subsystem is used in conjunction with the PCI Express IP block to provide high performance data transfer between host memory and the card's DMA subsystem. It also provides up to 16 user interrupt wires to user logic that generate interrupts to the host.

             +-------+       +-------+       +-----------+
    PCIe     |       |       |       |       |           |
    Tx/Rx    |       |       |       |  AXI  |           |
  <=======>  | PCIE  | <===> | XDMA  | <====>| User Logic|
             |       |       |       |       |           |
             +-------+       +-------+       +-----------+

The XDMA has been used for Xilinx Alveo PCIe devices.
And it is also integrated into Versal ACAP DMA and Bridge Subsystem.
     https://www.xilinx.com/products/boards-and-kits/alveo.html
https://docs.xilinx.com/r/en-US/pg344-pcie-dma-versal/Introduction-to-the-DMA-and-Bridge-Subsystems

The device driver for any FPGA based PCIe device which leverages XDMA can call the standard dmaengine APIs to discover and use the XDMA subsystem without duplicating the XDMA driver code in its own driver.

Changes since v5:
- Modified user logic interrupt APIs to handle user logic IP which does not
   have its own register to enable/disable interrupt.
- Clean up code based on review comments.

Changes since v4:
- Modified user logic interrupt APIs.

Changes since v3:
- Added one patch to support user logic interrupt.

Changes since v2:
- Removed tasklet.
- Fixed regression bug introduced to V2.
- Test Robot warning.

Changes since v1:
- Moved filling hardware descriptor to xdma_prep_device_sg().
- Changed hardware descriptor enum to "struct xdma_hw_desc".
- Minor changes from code review comments.

Lizhi Hou (2):
   dmaengine: xilinx: xdma: Add xilinx xdma driver
   dmaengine: xilinx: xdma: Add user logic interrupt support

  MAINTAINERS                            |   11 + drivers/dma/Kconfig                    |   13 + drivers/dma/xilinx/Makefile            |    1 + drivers/dma/xilinx/xdma-regs.h         |  171 ++++ drivers/dma/xilinx/xdma.c              | 1034 ++++++++++++++++++++++++ include/linux/dma/amd_xdma.h           |   16 + include/linux/platform_data/amd_xdma.h |   34 +

Quoted 6 lines
  7 files changed, 1280 insertions(+)

  create mode 100644 drivers/dma/xilinx/xdma-regs.h create mode 100644 drivers/dma/xilinx/xdma.c create mode 100644 include/linux/dma/amd_xdma.h create mode 100644 include/linux/platform_data/amd_xdma.h

Hi,
I have rewritten our V4L2 driver to use this new XDMA driver, but it does not work on our HW (where the previous Xilinx XDMA driver derived from the Xilinx sample code worked fine). The driver is sucessfully loaded and 4(2+2) DMA channels are successfully created. But when a DMA transfer is initiated, I get an error from my PC's DMA chip:

AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x000a address=0x36a00000 flags=0x0000]

Quoted 8 lines

and no error from XDMA.

Does the driver expect some special FPGA IP core configuration? Or is there something else I'm missing? My code is quiet similar to what you use in your XRT repo on GitHub (there is btw. a bug in the XRT code - you do not clear the dma_slave_config struct before using) but in my case the DMA transfer triggers the AMD-Vi error and timeouts.

The code of our driver is attached, the relevant parts are in mgb4_dma.c and mgb4_core.c.

M.

Hi Martin,

Thanks for trying this and got a lot thing works. I have read your driver. Could you call pci_map_sg() before calling prep_sg()? (and pci_unmap_sg()) after transfer complete?

example: https://github.com/houlz0507/XRT-1/blob/xdma_v4_usage/src/runtime_src/core/pcie/driver/linux/xocl/subdev/xdma.c#L103

Thanks,

Lizhi

#5 lore raw
Quoted 83 lines · Lizhi Hou
Quoted 70 lines · Martin Tůma
Quoted 57 lines · Lizhi Hou

Hello,

This V6 of patch series is to provide the platform driver to support the Xilinx XDMA subsystem. The XDMA subsystem is used in conjunction with the PCI Express IP block to provide high performance data transfer between host memory and the card's DMA subsystem. It also provides up to 16 user interrupt wires to user logic that generate interrupts to the host.

             +-------+       +-------+       +-----------+
    PCIe     |       |       |       |       |           |
    Tx/Rx    |       |       |       |  AXI  |           |
  <=======>  | PCIE  | <===> | XDMA  | <====>| User Logic|
             |       |       |       |       |           |
             +-------+       +-------+       +-----------+

The XDMA has been used for Xilinx Alveo PCIe devices.
And it is also integrated into Versal ACAP DMA and Bridge Subsystem.
     https://www.xilinx.com/products/boards-and-kits/alveo.html
https://docs.xilinx.com/r/en-US/pg344-pcie-dma-versal/Introduction-to-the-DMA-and-Bridge-Subsystems

The device driver for any FPGA based PCIe device which leverages XDMA can call the standard dmaengine APIs to discover and use the XDMA subsystem without duplicating the XDMA driver code in its own driver.

Changes since v5:
- Modified user logic interrupt APIs to handle user logic IP which does not
   have its own register to enable/disable interrupt.
- Clean up code based on review comments.

Changes since v4:
- Modified user logic interrupt APIs.

Changes since v3:
- Added one patch to support user logic interrupt.

Changes since v2:
- Removed tasklet.
- Fixed regression bug introduced to V2.
- Test Robot warning.

Changes since v1:
- Moved filling hardware descriptor to xdma_prep_device_sg().
- Changed hardware descriptor enum to "struct xdma_hw_desc".
- Minor changes from code review comments.

Lizhi Hou (2):
   dmaengine: xilinx: xdma: Add xilinx xdma driver
   dmaengine: xilinx: xdma: Add user logic interrupt support

  MAINTAINERS                            |   11 + drivers/dma/Kconfig                    |   13 + drivers/dma/xilinx/Makefile            |    1 + drivers/dma/xilinx/xdma-regs.h         |  171 ++++ drivers/dma/xilinx/xdma.c              | 1034 ++++++++++++++++++++++++ include/linux/dma/amd_xdma.h           |   16 + include/linux/platform_data/amd_xdma.h |   34 +

Quoted 6 lines
  7 files changed, 1280 insertions(+)

  create mode 100644 drivers/dma/xilinx/xdma-regs.h create mode 100644 drivers/dma/xilinx/xdma.c create mode 100644 include/linux/dma/amd_xdma.h create mode 100644 include/linux/platform_data/amd_xdma.h

Hi,
I have rewritten our V4L2 driver to use this new XDMA driver, but it does not work on our HW (where the previous Xilinx XDMA driver derived from the Xilinx sample code worked fine). The driver is sucessfully loaded and 4(2+2) DMA channels are successfully created. But when a DMA transfer is initiated, I get an error from my PC's DMA chip:

AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x000a address=0x36a00000 flags=0x0000]

Quoted 8 lines

and no error from XDMA.

Does the driver expect some special FPGA IP core configuration? Or is there something else I'm missing? My code is quiet similar to what you use in your XRT repo on GitHub (there is btw. a bug in the XRT code - you do not clear the dma_slave_config struct before using) but in my case the DMA transfer triggers the AMD-Vi error and timeouts.

The code of our driver is attached, the relevant parts are in mgb4_dma.c and mgb4_core.c.

M.

Hi Martin,

Quoted 9 lines

Thanks for trying this and got a lot thing works. I have read your driver. Could you call pci_map_sg() before calling prep_sg()? (and pci_unmap_sg()) after transfer complete?

example: https://github.com/houlz0507/XRT-1/blob/xdma_v4_usage/src/runtime_src/core/pcie/driver/linux/xocl/subdev/xdma.c#L103

Thanks,

Lizhi

Hi,
That's not the problem, the sg is already mapped by V4L2 videobuf-dma-sg
(https://elixir.bootlin.com/linux/v6.0/source/drivers/media/v4l2-core/videobuf-dma-sg.c#L285). With the original XDMA driver I was also not mapping the sg and it worked fine. And yes, I have tried it anyway and it didn't help ;-)

So there must be some other problem in your XDMA driver.

M.

author maintainer
#6 lore raw
Quoted 96 lines · Martin Tůma
Quoted 85 lines · Lizhi Hou
Quoted 72 lines · Martin Tůma
Quoted 59 lines · Lizhi Hou

Hello,

This V6 of patch series is to provide the platform driver to support the Xilinx XDMA subsystem. The XDMA subsystem is used in conjunction with the PCI Express IP block to provide high performance data transfer between host memory and the card's DMA subsystem. It also provides up to 16 user interrupt wires to user logic that generate interrupts to the host.

             +-------+       +-------+       +-----------+
    PCIe     |       |       |       |       |           |
    Tx/Rx    |       |       |       |  AXI  |           |
  <=======>  | PCIE  | <===> | XDMA  | <====>| User Logic|
             |       |       |       |       |           |
             +-------+       +-------+       +-----------+

The XDMA has been used for Xilinx Alveo PCIe devices.
And it is also integrated into Versal ACAP DMA and Bridge Subsystem.
https://www.xilinx.com/products/boards-and-kits/alveo.html
https://docs.xilinx.com/r/en-US/pg344-pcie-dma-versal/Introduction-to-the-DMA-and-Bridge-Subsystems

The device driver for any FPGA based PCIe device which leverages XDMA can call the standard dmaengine APIs to discover and use the XDMA subsystem without duplicating the XDMA driver code in its own driver.

Changes since v5:
- Modified user logic interrupt APIs to handle user logic IP which does not
   have its own register to enable/disable interrupt.
- Clean up code based on review comments.

Changes since v4:
- Modified user logic interrupt APIs.

Changes since v3:
- Added one patch to support user logic interrupt.

Changes since v2:
- Removed tasklet.
- Fixed regression bug introduced to V2.
- Test Robot warning.

Changes since v1:
- Moved filling hardware descriptor to xdma_prep_device_sg().
- Changed hardware descriptor enum to "struct xdma_hw_desc".
- Minor changes from code review comments.

Lizhi Hou (2):
   dmaengine: xilinx: xdma: Add xilinx xdma driver
   dmaengine: xilinx: xdma: Add user logic interrupt support

  MAINTAINERS                            |   11 + drivers/dma/Kconfig                    |   13 + drivers/dma/xilinx/Makefile            |    1 + drivers/dma/xilinx/xdma-regs.h         |  171 ++++ drivers/dma/xilinx/xdma.c              | 1034
++++++++++++++++++++++++
  include/linux/dma/amd_xdma.h           |   16 + include/linux/platform_data/amd_xdma.h |   34 +

Quoted 6 lines
  7 files changed, 1280 insertions(+)

  create mode 100644 drivers/dma/xilinx/xdma-regs.h create mode 100644 drivers/dma/xilinx/xdma.c create mode 100644 include/linux/dma/amd_xdma.h create mode 100644 include/linux/platform_data/amd_xdma.h

Hi,
I have rewritten our V4L2 driver to use this new XDMA driver, but it does not work on our HW (where the previous Xilinx XDMA driver derived from the Xilinx sample code worked fine). The driver is sucessfully loaded and 4(2+2) DMA channels are successfully created. But when a DMA transfer is initiated, I get an error from my PC's DMA chip:

AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x000a address=0x36a00000 flags=0x0000]

Quoted 8 lines

and no error from XDMA.

Does the driver expect some special FPGA IP core configuration? Or is there something else I'm missing? My code is quiet similar to what you use in your XRT repo on GitHub (there is btw. a bug in the XRT code - you do not clear the dma_slave_config struct before using) but in my case the DMA transfer triggers the AMD-Vi error and timeouts.

The code of our driver is attached, the relevant parts are in mgb4_dma.c and mgb4_core.c.

M.

Hi Martin,

Quoted 9 lines

Thanks for trying this and got a lot thing works. I have read your driver. Could you call pci_map_sg() before calling prep_sg()? (and pci_unmap_sg()) after transfer complete?

example: https://github.com/houlz0507/XRT-1/blob/xdma_v4_usage/src/runtime_src/core/pcie/driver/linux/xocl/subdev/xdma.c#L103

Thanks,

Lizhi

Quoted 7 lines

Hi,
That's not the problem, the sg is already mapped by V4L2 videobuf-dma-sg
(https://elixir.bootlin.com/linux/v6.0/source/drivers/media/v4l2-core/videobuf-dma-sg.c#L285). With the original XDMA driver I was also not mapping the sg and it worked fine. And yes, I have tried it anyway and it didn't help ;-)

So there must be some other problem in your XDMA driver.

M.

Hi Martin,

I got a AMD server and debug this issue. And there is indeed a XDMA driver issue. My DMA test passed on this server after fixing the issue. I will post v7 patches and hopefully that fixes the issue you have seen as well.

Thanks for trying the driver.

Lizhi

#7 lore raw
Quoted 105 lines · Lizhi Hou
Quoted 95 lines · Martin Tůma
Quoted 84 lines · Lizhi Hou
Quoted 71 lines · Martin Tůma
Quoted 58 lines · Lizhi Hou

Hello,

This V6 of patch series is to provide the platform driver to support the Xilinx XDMA subsystem. The XDMA subsystem is used in conjunction with the PCI Express IP block to provide high performance data transfer between host memory and the card's DMA subsystem. It also provides up to 16 user interrupt wires to user logic that generate interrupts to the host.

             +-------+       +-------+       +-----------+
    PCIe     |       |       |       |       |           |
    Tx/Rx    |       |       |       |  AXI  |           |
  <=======>  | PCIE  | <===> | XDMA  | <====>| User Logic|
             |       |       |       |       |           |
             +-------+       +-------+       +-----------+

The XDMA has been used for Xilinx Alveo PCIe devices.
And it is also integrated into Versal ACAP DMA and Bridge Subsystem.
https://www.xilinx.com/products/boards-and-kits/alveo.html
https://docs.xilinx.com/r/en-US/pg344-pcie-dma-versal/Introduction-to-the-DMA-and-Bridge-Subsystems

The device driver for any FPGA based PCIe device which leverages XDMA can call the standard dmaengine APIs to discover and use the XDMA subsystem without duplicating the XDMA driver code in its own driver.

Changes since v5:
- Modified user logic interrupt APIs to handle user logic IP which does not
   have its own register to enable/disable interrupt.
- Clean up code based on review comments.

Changes since v4:
- Modified user logic interrupt APIs.

Changes since v3:
- Added one patch to support user logic interrupt.

Changes since v2:
- Removed tasklet.
- Fixed regression bug introduced to V2.
- Test Robot warning.

Changes since v1:
- Moved filling hardware descriptor to xdma_prep_device_sg().
- Changed hardware descriptor enum to "struct xdma_hw_desc".
- Minor changes from code review comments.

Lizhi Hou (2):
   dmaengine: xilinx: xdma: Add xilinx xdma driver
   dmaengine: xilinx: xdma: Add user logic interrupt support

  MAINTAINERS                            |   11 + drivers/dma/Kconfig                    |   13 + drivers/dma/xilinx/Makefile            |    1 + drivers/dma/xilinx/xdma-regs.h         |  171 ++++ drivers/dma/xilinx/xdma.c              | 1034
++++++++++++++++++++++++
  include/linux/dma/amd_xdma.h           |   16 + include/linux/platform_data/amd_xdma.h |   34 +

Quoted 6 lines
  7 files changed, 1280 insertions(+)

  create mode 100644 drivers/dma/xilinx/xdma-regs.h create mode 100644 drivers/dma/xilinx/xdma.c create mode 100644 include/linux/dma/amd_xdma.h create mode 100644 include/linux/platform_data/amd_xdma.h

Hi,
I have rewritten our V4L2 driver to use this new XDMA driver, but it does not work on our HW (where the previous Xilinx XDMA driver derived from the Xilinx sample code worked fine). The driver is sucessfully loaded and 4(2+2) DMA channels are successfully created. But when a DMA transfer is initiated, I get an error from my PC's DMA chip:

AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x000a address=0x36a00000 flags=0x0000]

Quoted 8 lines

and no error from XDMA.

Does the driver expect some special FPGA IP core configuration? Or is there something else I'm missing? My code is quiet similar to what you use in your XRT repo on GitHub (there is btw. a bug in the XRT code - you do not clear the dma_slave_config struct before using) but in my case the DMA transfer triggers the AMD-Vi error and timeouts.

The code of our driver is attached, the relevant parts are in mgb4_dma.c and mgb4_core.c.

M.

Hi Martin,

Quoted 9 lines

Thanks for trying this and got a lot thing works. I have read your driver. Could you call pci_map_sg() before calling prep_sg()? (and pci_unmap_sg()) after transfer complete?

example: https://github.com/houlz0507/XRT-1/blob/xdma_v4_usage/src/runtime_src/core/pcie/driver/linux/xocl/subdev/xdma.c#L103

Thanks,

Lizhi

Quoted 7 lines

Hi,
That's not the problem, the sg is already mapped by V4L2 videobuf-dma-sg
(https://elixir.bootlin.com/linux/v6.0/source/drivers/media/v4l2-core/videobuf-dma-sg.c#L285). With the original XDMA driver I was also not mapping the sg and it worked fine. And yes, I have tried it anyway and it didn't help ;-)

So there must be some other problem in your XDMA driver.

M.

Quoted 8 lines

Hi Martin,

I got a AMD server and debug this issue. And there is indeed a XDMA driver issue. My DMA test passed on this server after fixing the issue. I will post v7 patches and hopefully that fixes the issue you have seen as well.

Thanks for trying the driver.

Lizhi

Hi,
Even the newest version (v7) still does not work with our card. The error is the same.

M.