Skip to contentSkip to conversation

xilinx XDMA driver

PATCH Superseded Lizhi Hou 2 participants 9 messages Sep 22, 2022 – Sep 27, 2022

Subsystems (3)

v4 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Lizhi Hou

author maintainer
#0 lore raw

v4 cover xilinx XDMA driver

Hello,

This V4 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 v3:
- Add 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              | 1035 ++++++++++++++++++++++++
 include/linux/dma/amd_xdma.h           |   17 +
 include/linux/platform_data/amd_xdma.h |   34 +
 7 files changed, 1282 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 v4 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              | 955 +++++++++++++++++++++++++
 include/linux/platform_data/amd_xdma.h |  34 +
 6 files changed, 1184 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 +955 -0

955 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 v4 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 register/unregister interrupt handler for a given interrupt wire index.

---
 MAINTAINERS                  |  1 +
 drivers/dma/xilinx/xdma.c    | 80 ++++++++++++++++++++++++++++++++++++
 include/linux/dma/amd_xdma.h | 17 ++++++++
 3 files changed, 98 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 +80 -0

104 lines not on this page · raw message

include/linux/dma/amd_xdma.h new file +17 -0
new file mode 100644
index 000000000000..b70486121ca6
@@ -0,0 +1,17 @@
+/* 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_request_user_irq(struct platform_device *pdev, u32 user_irq_index,
+			  irq_handler_t handler, void *arg, ulong flags);
+void xdma_free_user_irq(struct platform_device *pdev, u32 user_irq_index,
+			void *arg);
+
+#endif /* _DMAENGINE_AMD_XDMA_H */
Signature · 1 line
2.27.0
#3 lore raw

Re: [PATCH V4 XDMA 2/2] dmaengine: xilinx: xdma: Add user logic interrupt support

Quoted 153 lines · 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 register/unregister interrupt handler for a given interrupt wire index.

---
  MAINTAINERS                  |  1 +
  drivers/dma/xilinx/xdma.c    | 80 ++++++++++++++++++++++++++++++++++++
  include/linux/dma/amd_xdma.h | 17 ++++++++
  3 files changed, 98 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 +80 -0
index 58a57e03bef5..884942cd2a37 100644
@@ -25,6 +25,7 @@
  #include <linux/dmapool.h>
  #include <linux/regmap.h>
  #include <linux/dmaengine.h>
+#include <linux/dma/amd_xdma.h>
  #include <linux/platform_device.h>
  #include <linux/platform_data/amd_xdma.h>
  #include <linux/dma-mapping.h>
@@ -736,6 +737,7 @@ static int xdma_set_vector_reg(struct xdma_device *xdev, u32 vec_tbl_start,
  static int xdma_irq_init(struct xdma_device *xdev)
  {
  	u32 irq = xdev->irq_start;
+	u32 user_irq_start;
  	int i, j, ret;
 
  	/* return failure if there are not enough IRQs */
@@ -786,6 +788,18 @@ static int xdma_irq_init(struct xdma_device *xdev)
  		goto failed;
  	}
 
+	/* config user IRQ registers if needed */
+	user_irq_start = xdev->h2c_chan_num + xdev->c2h_chan_num;
+	if (xdev->irq_num > user_irq_start) {
+		ret = xdma_set_vector_reg(xdev, XDMA_IRQ_USER_VEC_NUM,
+					  user_irq_start,
+					  xdev->irq_num - user_irq_start);
+		if (ret) {
+			xdma_err(xdev, "failed to set user vectors: %d", ret);
+			goto failed;
+		}
+	}
+
  	/* enable interrupt */
  	ret = xdma_enable_intr(xdev);
  	if (ret) {
@@ -816,6 +830,72 @@ static bool xdma_filter_fn(struct dma_chan *chan, void *param)
  	return true;
  }
 
+/**
+ * xdma_free_user_irq - Free user interrupt
+ * @pdev: Pointer to the platform_device structure
+ * @user_irq_index: User IRQ index
+ * @arg: User interrupt cookie
+ */
+void xdma_free_user_irq(struct platform_device *pdev, u32 user_irq_index,
+			void *arg)
+{
+	struct xdma_device *xdev = platform_get_drvdata(pdev);
+	u32 user_irq;
+
+	user_irq = xdev->h2c_chan_num + xdev->c2h_chan_num + user_irq_index;
+	if (user_irq >= xdev->irq_num) {
+		xdma_err(xdev, "invalid user irq index");
+		return;
+	}
+	user_irq += xdev->irq_start;
+
+	xdma_write_reg(xdev, XDMA_IRQ_BASE, XDMA_IRQ_USER_INT_EN_W1C,
+		       (1 << user_irq_index));
+
+	free_irq(user_irq, arg);
+}
+EXPORT_SYMBOL(xdma_free_user_irq);
+
+/**
+ * xdma_request_user_irq - Register user interrupt
+ * @pdev: Pointer to the platform_device structure
+ * @user_irq_index: User IRQ index
+ * @flags: Handling flags
+ * @handler: User interrupt handler
+ * @arg: User interrupt cookie
+ */
+int xdma_request_user_irq(struct platform_device *pdev, u32 user_irq_index,
+			  irq_handler_t handler, void *arg, ulong flags)
+{
+	struct xdma_device *xdev = platform_get_drvdata(pdev);
+	u32 user_irq;
+	int ret;
+
+	user_irq = xdev->h2c_chan_num + xdev->c2h_chan_num + user_irq_index;
+	if (user_irq >= xdev->irq_num) {
+		xdma_err(xdev, "invalid user irq index");
+		return -EINVAL;
+	}
+	user_irq += xdev->irq_start;
+
+	ret = request_irq(user_irq, handler, flags, "xdma-user", arg);
+	if (ret) {
+		xdma_err(xdev, "request irq failed, %d", ret);
+		return ret;
+	}
+
+	ret = xdma_write_reg(xdev, XDMA_IRQ_BASE, XDMA_IRQ_USER_INT_EN_W1S,
+			     (1 << user_irq_index));
+	if (ret) {
+		xdma_err(xdev, "set user irq mask failed, %d", ret);
+		free_irq(user_irq, arg);
+		return ret;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(xdma_request_user_irq);
+
  /**
   * xdma_remove - Driver remove function
   * @pdev: Pointer to the platform_device structure
include/linux/dma/amd_xdma.h new file +7 -0
new file mode 100644
index 000000000000..b70486121ca6
@@ -0,0 +1,17 @@
+/* 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/dma/amd_xdma.h line 17

Quoted 10 lines
include/linux/dma/amd_xdma.h new file +10 -0
+
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+
+int xdma_request_user_irq(struct platform_device *pdev, u32 user_irq_index,
+			  irq_handler_t handler, void *arg, ulong flags);
+void xdma_free_user_irq(struct platform_device *pdev, u32 user_irq_index,
+			void *arg);
+
+#endif /* _DMAENGINE_AMD_XDMA_H */

Hi,
The user IRQ logic is unusable, if you have other IP cores with linux drivers (eg. spi or i2c) connected to that IRQs like we (and many other users as well) have on our PCIe card. You can't use the already existing xiic or xilinx-spi drivers with your xdma driver!

You must split the "IRQ enable" and "IRQ request" operations for your driver to be usable with the other platform drivers in linux. Instead of "xdma_request_user_irq" there must be something like "xdma_enable_user_irq" that only enables the IRQ in the IP block, but does not "eat" the IRQ so you can pass it to the initialization of the platform driver of xiic or xilinx-spi.

M.

author maintainer
#4 lore raw

Re: [PATCH V4 XDMA 2/2] dmaengine: xilinx: xdma: Add user logic interrupt support

Quoted 173 lines · Martin Tůma
Quoted 165 lines · 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 register/unregister interrupt handler for a given interrupt wire index.

---
  MAINTAINERS                  |  1 + drivers/dma/xilinx/xdma.c    | 80 ++++++++++++++++++++++++++++++++++++ include/linux/dma/amd_xdma.h | 17 ++++++++

  3 files changed, 98 insertions(+)

  create mode 100644 include/linux/dma/amd_xdma.h

MAINTAINERS +0 -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 +2 -0
index 58a57e03bef5..884942cd2a37 100644
@@ -25,6 +25,7 @@
   #include <linux/dmapool.h>
   #include <linux/regmap.h>
   #include <linux/dmaengine.h>
+#include <linux/dma/amd_xdma.h>
   #include <linux/platform_device.h>
   #include <linux/platform_data/amd_xdma.h>
   #include <linux/dma-mapping.h>
@@ -736,6 +737,7 @@ static int xdma_set_vector_reg(struct xdma_device 
 *xdev, u32 vec_tbl_start,
   static int xdma_irq_init(struct xdma_device *xdev)
   {
       u32 irq = xdev->irq_start;
+    u32 user_irq_start;
       int i, j, ret;
         /* return failure if there are not enough IRQs */
@@ -786,6 +788,18 @@ static int xdma_irq_init(struct xdma_device *xdev)
           goto failed;
       }

  +    /* config user IRQ registers if needed */
+    user_irq_start = xdev->h2c_chan_num + xdev->c2h_chan_num; +    if (xdev->irq_num > user_irq_start) {
+        ret = xdma_set_vector_reg(xdev, XDMA_IRQ_USER_VEC_NUM, +                      user_irq_start,
+                      xdev->irq_num - user_irq_start); +        if (ret) {
+            xdma_err(xdev, "failed to set user vectors: %d", ret); +            goto failed;
+        }
+    }
+
      /* enable interrupt */
      ret = xdma_enable_intr(xdev);
      if (ret) {

drivers/dma/xilinx/xdma.c +0 -0
@@ -816,6 +830,72 @@ static bool xdma_filter_fn(struct dma_chan 
 *chan, void *param)
       return true;
   }

  +/**
+ * xdma_free_user_irq - Free user interrupt
+ * @pdev: Pointer to the platform_device structure
+ * @user_irq_index: User IRQ index
+ * @arg: User interrupt cookie
+ */
+void xdma_free_user_irq(struct platform_device *pdev, u32 user_irq_index,
+            void *arg)

drivers/dma/xilinx/xdma.c +5 -0
+{
+    struct xdma_device *xdev = platform_get_drvdata(pdev);
+    u32 user_irq;
+
+    user_irq = xdev->h2c_chan_num + xdev->c2h_chan_num + 

user_irq_index;
+    if (user_irq >= xdev->irq_num) {
+        xdma_err(xdev, "invalid user irq index"); +        return;
+    }
+    user_irq += xdev->irq_start;

drivers/dma/xilinx/xdma.c +17 -0
+
+    xdma_write_reg(xdev, XDMA_IRQ_BASE, XDMA_IRQ_USER_INT_EN_W1C,
+               (1 << user_irq_index));
+
+    free_irq(user_irq, arg);
+}
+EXPORT_SYMBOL(xdma_free_user_irq);
+
+/**
+ * xdma_request_user_irq - Register user interrupt
+ * @pdev: Pointer to the platform_device structure
+ * @user_irq_index: User IRQ index
+ * @flags: Handling flags
+ * @handler: User interrupt handler
+ * @arg: User interrupt cookie
+ */
+int xdma_request_user_irq(struct platform_device *pdev, u32 

user_irq_index,
+              irq_handler_t handler, void *arg, ulong flags)

drivers/dma/xilinx/xdma.c +6 -0
+{
+    struct xdma_device *xdev = platform_get_drvdata(pdev);
+    u32 user_irq;
+    int ret;
+
+    user_irq = xdev->h2c_chan_num + xdev->c2h_chan_num + 

user_irq_index;
+    if (user_irq >= xdev->irq_num) {
+        xdma_err(xdev, "invalid user irq index"); +        return -EINVAL;
+    }
+    user_irq += xdev->irq_start;

drivers/dma/xilinx/xdma.c +19 -0
+
+    ret = request_irq(user_irq, handler, flags, "xdma-user", arg);
+    if (ret) {
+        xdma_err(xdev, "request irq failed, %d", ret);
+        return ret;
+    }
+
+    ret = xdma_write_reg(xdev, XDMA_IRQ_BASE, XDMA_IRQ_USER_INT_EN_W1S,
+                 (1 << user_irq_index));
+    if (ret) {
+        xdma_err(xdev, "set user irq mask failed, %d", ret);
+        free_irq(user_irq, arg);
+        return ret;
+    }
+
+    return 0;
+}
+EXPORT_SYMBOL(xdma_request_user_irq);
+

  /**
   * xdma_remove - Driver remove function
   * @pdev: Pointer to the platform_device structure

include/linux/dma/amd_xdma.h new file +12 -0
new file mode 100644
index 000000000000..b70486121ca6
@@ -0,0 +1,17 @@
+/* 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_request_user_irq(struct platform_device *pdev, u32 

user_irq_index,
+              irq_handler_t handler, void *arg, ulong flags); +void xdma_free_user_irq(struct platform_device *pdev, u32 user_irq_index,
+            void *arg);

include/linux/dma/amd_xdma.h

Quoted 2 lines
include/linux/dma/amd_xdma.h new file +2 -0
+
+#endif /* _DMAENGINE_AMD_XDMA_H */

Hi,
The user IRQ logic is unusable, if you have other IP cores with linux drivers (eg. spi or i2c) connected to that IRQs like we (and many other users as well) have on our PCIe card. You can't use the already existing xiic or xilinx-spi drivers with your xdma driver!

Quoted 5 lines

You must split the "IRQ enable" and "IRQ request" operations for your driver to be usable with the other platform drivers in linux. Instead of "xdma_request_user_irq" there must be something like "xdma_enable_user_irq" that only enables the IRQ in the IP block, but does not "eat" the IRQ so you can pass it to the initialization of the platform driver of xiic or xilinx-spi.

M.

Okay, I got the point. How about changing request/remove APIs to enable/disable APIs as below

     xdma_enable_user_irq(struct platform_device *pdev, u32 user_irq_index, u32 *irq)

            user_irq_index: user logic interrupt wire index. (XDMA driver determines how system IRQs are mapped to DMA channels and user logic wires)

            irq: IRQ number returned for registering interrupt handler (request_irq()) or passing to existing platform driver.

    xdma_disable_user_irq(struct platform_device *pdev, u32 user_irq_index)

Does this make sense to you?

Thanks,

Lizhi

#5 lore raw

Re: [PATCH V4 XDMA 2/2] dmaengine: xilinx: xdma: Add user logic interrupt support

Quoted 8 lines · Lizhi Hou

Okay, I got the point. How about changing request/remove APIs to enable/disable APIs as below

     xdma_enable_user_irq(struct platform_device *pdev, u32
user_irq_index, u32 *irq)

            user_irq_index: user logic interrupt wire index. (XDMA
driver determines how system IRQs are mapped to DMA channels and user logic wires)

Quoted 8 lines

            irq: IRQ number returned for registering interrupt handler
(request_irq()) or passing to existing platform driver.

    xdma_disable_user_irq(struct platform_device *pdev, u32
user_irq_index)

Does this make sense to you?

I think even the "irq" parameter in the enable function is surplus as the parent driver (the driver of the actual PCIe card) knows* what PCI irq he has to allocate without XDMA providing the number.

xdma_enable_user_irq(struct platform_device *pdev, u32 user_irq_index); xdma_disable_user_irq(struct platform_device *pdev, u32 user_irq_index);

should be all that is needed.

M.

* something like:
pci_irq_vector((pdev), PCI_BAR_ID) + NUM_C2H_CHANNELS + NUM_H2C_CHANNELS can be used from the PCIe driver

author maintainer
#6 lore raw

Re: [PATCH V4 XDMA 2/2] dmaengine: xilinx: xdma: Add user logic interrupt support

Quoted 20 lines · Martin Tůma
Quoted 4 lines · Lizhi Hou

Okay, I got the point. How about changing request/remove APIs to enable/disable APIs as below

      xdma_enable_user_irq(struct platform_device *pdev, u32 user_irq_index, u32 *irq)

Quoted 8 lines

             user_irq_index: user logic interrupt wire index. (XDMA driver determines how system IRQs are mapped to DMA channels and user logic wires)

             irq: IRQ number returned for registering interrupt handler (request_irq()) or passing to existing platform driver.

     xdma_disable_user_irq(struct platform_device *pdev, u32 user_irq_index)

Does this make sense to you?

I think even the "irq" parameter in the enable function is surplus as the parent driver (the driver of the actual PCIe card) knows* what PCI irq he has to allocate without XDMA providing the number.

xdma_enable_user_irq(struct platform_device *pdev, u32 user_irq_index); xdma_disable_user_irq(struct platform_device *pdev, u32 user_irq_index);

Quoted 7 lines

should be all that is needed.

M.

* something like:
pci_irq_vector((pdev), PCI_BAR_ID) + NUM_C2H_CHANNELS + NUM_H2C_CHANNELS can be used from the PCIe driver

How does parent driver know the first few vectors will be assigned to DMA channel?  Parent diver should not assume the first (NUM_C2H_CHANNELS+NUM_H2C_CHANNELS) are for DMA channel.

Parent driver passes the system IRQ range  to XDMA driver, and only XDMA driver knows what IRQs are used by DMA channel and what IRQs are mapped to user logic wires. I would keep the "u32 *irq" argument.

Thanks,

Lizhi

#7 lore raw

Re: [PATCH V4 XDMA 2/2] dmaengine: xilinx: xdma: Add user logic interrupt support

Quoted 26 lines · Lizhi Hou
Quoted 24 lines · Martin Tůma
Quoted 4 lines · Lizhi Hou

Okay, I got the point. How about changing request/remove APIs to enable/disable APIs as below

      xdma_enable_user_irq(struct platform_device *pdev, u32 user_irq_index, u32 *irq)

Quoted 8 lines

             user_irq_index: user logic interrupt wire index. (XDMA driver determines how system IRQs are mapped to DMA channels and user logic wires)

             irq: IRQ number returned for registering interrupt handler (request_irq()) or passing to existing platform driver.

     xdma_disable_user_irq(struct platform_device *pdev, u32 user_irq_index)

Does this make sense to you?

I think even the "irq" parameter in the enable function is surplus as the parent driver (the driver of the actual PCIe card) knows* what PCI irq he has to allocate without XDMA providing the number.

xdma_enable_user_irq(struct platform_device *pdev, u32 user_irq_index); xdma_disable_user_irq(struct platform_device *pdev, u32 user_irq_index);

should be all that is needed.

M.

Quoted 8 lines
Quoted 3 lines

* something like:
pci_irq_vector((pdev), PCI_BAR_ID) + NUM_C2H_CHANNELS + NUM_H2C_CHANNELS can be used from the PCIe driver

How does parent driver know the first few vectors will be assigned to DMA channel?  Parent diver should not assume the first (NUM_C2H_CHANNELS+NUM_H2C_CHANNELS) are for DMA channel.

Parent driver passes the system IRQ range  to XDMA driver, and only XDMA driver knows what IRQs are used by DMA channel and what IRQs are mapped to user logic wires. I would keep the "u32 *irq" argument.

The parent driver knows how much DMA channels it wants/allocates. If it is possible to allocate different IRQs than the first NUM_C2H_CHANNELS + NUM_H2C_CHANNELS to the XDMA IP core, than that parameter may be needed, but I haven't seen such HW. Moreover, every parent driver author should IMHO know how the channel and user IRQs are mapped in their specific HW configuration so this info can be "hard-wired" in the parent driver, but I'm fine with it when the irq parameter is kept anyway. All I really need is that the enable/disable logic is split from the irq allocate/register logic so I can use the other platform drivers.

M.

author maintainer
#8 lore raw

Re: [PATCH V4 XDMA 2/2] dmaengine: xilinx: xdma: Add user logic interrupt support

Quoted 31 lines · Martin Tůma
Quoted 30 lines · Lizhi Hou
Quoted 27 lines · Martin Tůma
Quoted 4 lines · Lizhi Hou

Okay, I got the point. How about changing request/remove APIs to enable/disable APIs as below

      xdma_enable_user_irq(struct platform_device *pdev, u32 user_irq_index, u32 *irq)

Quoted 8 lines

             user_irq_index: user logic interrupt wire index. (XDMA driver determines how system IRQs are mapped to DMA channels and user logic wires)

             irq: IRQ number returned for registering interrupt handler (request_irq()) or passing to existing platform driver.

     xdma_disable_user_irq(struct platform_device *pdev, u32 user_irq_index)

Does this make sense to you?

I think even the "irq" parameter in the enable function is surplus as the parent driver (the driver of the actual PCIe card) knows* what PCI irq he has to allocate without XDMA providing the number.

xdma_enable_user_irq(struct platform_device *pdev, u32 user_irq_index); xdma_disable_user_irq(struct platform_device *pdev, u32 user_irq_index);

should be all that is needed.

M.

* something like:
pci_irq_vector((pdev), PCI_BAR_ID) + NUM_C2H_CHANNELS + NUM_H2C_CHANNELS can be used from the PCIe driver

Quoted 8 lines
Quoted 4 lines

How does parent driver know the first few vectors will be assigned to DMA channel?  Parent diver should not assume the first (NUM_C2H_CHANNELS+NUM_H2C_CHANNELS) are for DMA channel.

Parent driver passes the system IRQ range  to XDMA driver, and only XDMA driver knows what IRQs are used by DMA channel and what IRQs are mapped to user logic wires. I would keep the "u32 *irq" argument.

The parent driver knows how much DMA channels it wants/allocates. If it is possible to allocate different IRQs than the first NUM_C2H_CHANNELS + NUM_H2C_CHANNELS to the XDMA IP core, than that parameter may be needed, but I haven't seen such HW. Moreover, every parent driver author should IMHO know how the channel and user IRQs are mapped in their specific HW configuration so this info can be "hard-wired" in the parent driver, but I'm fine with it when the irq parameter is kept anyway. All I really need is that the enable/disable logic is split from the irq allocate/register logic so I can use the other platform drivers.

M.

Thanks Mark, all your comments are very helpful. And glad to know you are fine with irq parameter. The IRQ binding is set by xdma driver ( xdma_set_vector_reg() ). That means xdma driver is able to map any system IRQ to dma channel or user logic. That is why I prefer to keep irq parameter. Just a FYI.

Lizhi