xilinx XDMA driver
Subsystems (3)
Lizhi Hou
maintainerv12 cover xilinx XDMA driver
Hello,
This V12 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 v11:
- minor fixes based on review comments.
Changes since v10:
- Added Tested-by Martin Tuma [email protected]
Changes since v9:
- Cleanup code based on review comments.
Changes since v8:
- Fixed test robot failure on s390.
Changes since v7:
- Used pci device pointer for dma_pool_create().
Changes since v6:
- Fixed descriptor filling bug.
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 | 14 + drivers/dma/xilinx/Makefile | 1 + drivers/dma/xilinx/xdma-regs.h | 166 +++++ drivers/dma/xilinx/xdma.c | 974 +++++++++++++++++++++++++ include/linux/dma/amd_xdma.h | 16 + include/linux/platform_data/amd_xdma.h | 34 + 7 files changed, 1216 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
Lizhi Hou
maintainerPATCH RESEND v12 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 | 14 + drivers/dma/xilinx/Makefile | 1 + drivers/dma/xilinx/xdma-regs.h | 166 +++++ drivers/dma/xilinx/xdma.c | 893 +++++++++++++++++++++++++ include/linux/platform_data/amd_xdma.h | 34 + 6 files changed, 1118 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
@@ -22575,6 +22575,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 +14 -0
@@ -735,6 +735,20 @@ config XILINX_DMA the scatter gather interface with multiple channels independent configuration support. +config XILINX_XDMA + tristate "Xilinx DMA/Bridge Subsystem DMA Engine" + depends on HAS_IOMEM + 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. + config XILINX_ZYNQMP_DMA tristate "Xilinx ZynqMP DMA Engine" depends on ARCH_ZYNQ || MICROBLAZE || ARM64 || COMPILE_TEST
drivers/dma/xilinx/Makefile +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_XILINX_DMA) += xilinx_dma.o +obj-$(CONFIG_XILINX_XDMA) += xdma.o obj-$(CONFIG_XILINX_ZYNQMP_DMA) += zynqmp_dma.o obj-$(CONFIG_XILINX_ZYNQMP_DPDMA) += xilinx_dpdma.o
drivers/dma/xilinx/xdma-regs.h new file +166 -0
166 lines not on this page · raw message
drivers/dma/xilinx/xdma.c new file +893 -0
893 lines not on this page · raw message
include/linux/platform_data/amd_xdma.h new file +34 -0
@@ -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
Re: [RESEND PATCH V12 XDMA 1/2] dmaengine: xilinx: xdma: Add xilinx xdma driver
Hi Lizhi,
Quoted 19 lines · Lizhi Hou
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.htmlThe 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/IntroductionThis driver implements dmaengine APIs.
- probe the available DMA channels
- usedma_slave_mapfor channel lookup
- use virtual channel to manage dmaengine tx descriptors
- implementdevice_prep_slave_sgcallback to handle host scatter gather list
- implementdevice_configto config device address for DMA transfer
Quoted 5 lines
Signed-off-by Lizhi Hou <[email protected]>Signed-off-by Sonal Santan <[email protected]>Signed-off-by Max Zhen <[email protected]>Signed-off-by Brian Xu <[email protected]>Tested-by Martin Tuma <[email protected]>
Thanks for your patch, which is now commit 17ce252266c7f016 ("dmaengine: xilinx: xdma: Add xilinx xdma driver") in dmaengine/next.
drivers/dma/Kconfig config XILINX_DMA · line 743
Quoted 12 lines
drivers/dma/Kconfig +6
-0@@ -735,6 +735,20 @@ config XILINX_DMA the scatter gather interface with multiple channels independent configuration support. +config XILINX_XDMA + tristate "Xilinx DMA/Bridge Subsystem DMA Engine" + depends on HAS_IOMEM + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + select REGMAP_MMIO
No platform dependencies at all, while this is a platform driver that relies on some other not-yet-existing driver creating an "xdma" platform device?
Quoted 14 lines
drivers/dma/Kconfig +8
-0+ 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. + config XILINX_ZYNQMP_DMA tristate "Xilinx ZynqMP DMA Engine" depends on ARCH_ZYNQ || MICROBLAZE || ARM64 || COMPILE_TEST
drivers/dma/xilinx/xdma.c line 780
Quoted 8 lines
drivers/dma/xilinx/xdma.c new file +7
-0+/** +* xdma_probe - Driver probe function +* @pdev: Pointer to the platform_device structure +*/ +static int xdma_probe (struct platform_device *pdev) +{ +struct xdma_platdata *pdata =dev_get_platdata (&pdev->dev);
Platform data? No DT?
Do we still accept plain platform drivers?
drivers/dma/xilinx/xdma.c line 878
Quoted 4 lines
drivers/dma/xilinx/xdma.c new file +4
-0+static const struct platform_device_id xdma_id_table[] = { + {"xdma" ,0 }, + { }, +};
This table is not needed, as the single entry matches driver.name below.
drivers/dma/xilinx/xdma.c line 889
Quoted 11 lines
drivers/dma/xilinx/xdma.c new file +11
-0+ +static struct platform_driver xdma_driver = { + .driver = { + .name ="xdma" , + }, + .id_table = xdma_id_table, + .probe = xdma_probe, + .remove = xdma_remove, +}; + +module_platform_driver (xdma_driver);
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [RESEND PATCH V12 XDMA 1/2] dmaengine: xilinx: xdma: Add xilinx xdma driver
Quoted 3 lines · Geert Uytterhoeven
No platform dependencies at all, while this is a platform driver that relies on some other not-yet-existing driver creating an "xdma" platform device?
There is at least one "already-existing" driver based on this driver that is waiting in the v4l2 queue for xdma - our MGB4 driver:
https://patchwork.kernel.org/project/linux-media/patch/[email protected]/
And I'm quiet sure that more are to come when the xdma driver becomes finally available as the FPGA IP core is used in many more PCIe cards.
M.
Re: [RESEND PATCH V12 XDMA 1/2] dmaengine: xilinx: xdma: Add xilinx xdma driver
Hi Martin,
Quoted 8 lines · Martin Tůma
Quoted 3 lines · Geert Uytterhoeven
No platform dependencies at all, while this is a platform driver that relies on some other not-yet-existing driver creating an "xdma" platform device?
There is at least one "already-existing" driver based on this driver that is waiting in the v4l2 queue for xdma - our MGB4 driver:
https://patchwork.kernel.org/project/linux-media/patch/[email protected]/
Thanks for the link!
As VIDEO_MGB4 selects XILINX_XDMA, perhaps XILINX_XDMA can be made invisible, unless compile-testing?
config XILINX_XDMA
tristate "Xilinx DMA/Bridge Subsystem DMA Engine" if COMPILE_TEST
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [RESEND PATCH V12 XDMA 1/2] dmaengine: xilinx: xdma: Add xilinx xdma driver
Quoted 17 lines · Geert Uytterhoeven
Hi Martin,
Quoted 8 lines · Martin Tůma
Quoted 3 lines · Geert Uytterhoeven
No platform dependencies at all, while this is a platform driver that relies on some other not-yet-existing driver creating an "xdma" platform device?
There is at least one "already-existing" driver based on this driver that is waiting in the v4l2 queue for xdma - our MGB4 driver:
https://patchwork.kernel.org/project/linux-media/patch/[email protected]/Thanks for the link!
As
VIDEO_MGB4selectsXILINX_XDMA, perhapsXILINX_XDMAcan be made invisible, unless compile-testing?
Quoted 7 lines
config
XILINX_XDMA
tristate "Xilinx DMA/Bridge Subsystem DMA Engine" ifCOMPILE_TESTGr{oetje,eeting}s,
Geert
Hi,
I think that the XDMA driver will always be used by a superior PCIe card driver like in our case (mgb4) and using it separately makes no sense/is not possible, so disabling it until some of the superior drivers selects it makes sense for me. But what about out-of-the-tree modules based on xdma? Making the module "invisible" will make compile them much harder I guess? And there will be proprietary drivers based on xdma, see Xilinx XRT: https://github.com/houlz0507/XRT-1/tree/xdma_v4_usage
The xdma authors from Xilinx will definitely give you a more authoritative answer. I'm just a "random" user of the xdma module. Originally our mgb4 driver was based on our own xdma sub-driver (in turn based on some old "test" driver from Xilinx) which I was glad we could abandon when this xdma driver has appeared. I helped the xdma module to become usable for PCIe cards like our v4l2 grabber, but the original intents of the xdma driver are unknown to me. If it is XRT, than Xilinx will probably like the module to stay visible.
M.
Lizhi Hou
maintainerRe: [RESEND PATCH V12 XDMA 1/2] dmaengine: xilinx: xdma: Add xilinx xdma driver
Quoted 27 lines · Martin Tůma
Quoted 18 lines · Geert Uytterhoeven
Hi Martin,
Quoted 9 lines · Martin Tůma
Quoted 3 lines · Geert Uytterhoeven
No platform dependencies at all, while this is a platform driver that relies on some other not-yet-existing driver creating an "xdma" platform device?
There is at least one "already-existing" driver based on this driver that is waiting in the v4l2 queue for xdma - our MGB4 driver:
https://patchwork.kernel.org/project/linux-media/patch/[email protected]/Thanks for the link!
As
VIDEO_MGB4selectsXILINX_XDMA, perhapsXILINX_XDMAcan be made invisible, unless compile-testing?Quoted 7 lines
config
XILINX_XDMA
tristate "Xilinx DMA/Bridge Subsystem DMA Engine" ifCOMPILE_TESTGr{oetje,eeting}s,
Geert
Quoted 7 lines
Hi,
I think that the XDMA driver will always be used by a superior PCIe card driver like in our case (mgb4) and using it separately makes no sense/is not possible, so disabling it until some of the superior drivers selects it makes sense for me. But what about out-of-the-tree modules based on xdma? Making the module "invisible" will make compile them much harder I guess? And there will be proprietary drivers based on xdma, see Xilinx XRT: https://github.com/houlz0507/XRT-1/tree/xdma_v4_usageThe xdma authors from Xilinx will definitely give you a more authoritative answer. I'm just a "random" user of the xdma module. Originally our mgb4 driver was based on our own xdma sub-driver (in turn based on some old "test" driver from Xilinx) which I was glad we could abandon when this xdma driver has appeared. I helped the xdma module to become usable for PCIe cards like our v4l2 grabber, but the original intents of the xdma driver are unknown to me. If it is XRT, than Xilinx will probably like the module to stay visible.
M.
There are PCIe devices which use the XDMA IP and would use this xdma driver. Out of tree drivers for Xilinx/AMD Alveo devices can switch to this in kernel xdma driver.
Thanks,
Lizhi
Lizhi Hou
maintainerRe: [RESEND PATCH V12 XDMA 1/2] dmaengine: xilinx: xdma: Add xilinx xdma driver
In reply to Geert UytterhoevenQuoted 60 lines · Geert Uytterhoeven
Hi Lizhi,
Quoted 19 lines · Lizhi Hou
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.htmlThe 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/IntroductionThis driver implements dmaengine APIs.
- probe the available DMA channels
- usedma_slave_mapfor channel lookup
- use virtual channel to manage dmaengine tx descriptors
- implementdevice_prep_slave_sgcallback to handle host scatter gather list
- implementdevice_configto config device address for DMA transferQuoted 5 lines
Signed-off-by Lizhi Hou <[email protected]>Signed-off-by Sonal Santan <[email protected]>Signed-off-by Max Zhen <[email protected]>Signed-off-by Brian Xu <[email protected]>Tested-by Martin Tuma <[email protected]>Thanks for your patch, which is now commit
17ce252266c7f016("dmaengine: xilinx: xdma: Add xilinx xdma driver") in dmaengine/next.drivers/dma/Kconfig config XILINX_DMA · line 743
Quoted 12 lines
drivers/dma/Kconfig +6
-0@@ -735,6 +735,20 @@ config XILINX_DMA the scatter gather interface with multiple channels independent configuration support. +config XILINX_XDMA + tristate "Xilinx DMA/Bridge Subsystem DMA Engine" + depends on HAS_IOMEM + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + select REGMAP_MMIONo platform dependencies at all, while this is a platform driver that relies on some other not-yet-existing driver creating an "xdma" platform device?
Quoted 14 lines
drivers/dma/Kconfig +8
-0+ 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. + config XILINX_ZYNQMP_DMA tristate "Xilinx ZynqMP DMA Engine" depends on ARCH_ZYNQ || MICROBLAZE || ARM64 || COMPILE_TESTdrivers/dma/xilinx/xdma.c new file +1
-0+/**
Quoted 8 lines
drivers/dma/xilinx/xdma.c line 780
Quoted 6 lines
+ *
xdma_probe- Driver probe function
+ * @pdev: Pointer to theplatform_devicestructure
+ */drivers/dma/xilinx/xdma.c new file +3
-0+static int xdma_probe (struct platform_device *pdev) +{ +struct xdma_platdata *pdata =dev_get_platdata (&pdev->dev);Platform data? No DT?
Do we still accept plain platform drivers?
The XDMA driver needs to support both the non-DT and DT use cases.
For the non-DT case the parent PCIe device driver will create the xdma platform device and pass the required information to the xdma driver. An example is https://lore.kernel.org/dmaengine/[email protected]/
For the DT use case, the xdma device will be populated by the FDT. This part is WIP and will be enabled with future patches.
Quoted 6 lines
drivers/dma/xilinx/xdma.c line 878
Quoted 5 lines
drivers/dma/xilinx/xdma.c new file +4
-0+static const struct platform_device_id xdma_id_table[] = { + {"xdma" ,0 }, + { }, +};This table is not needed, as the single entry matches driver.name below.
Thanks. I will create a patch to fix this.
Lizhi
Quoted 16 lines
drivers/dma/xilinx/xdma.c line 889
Quoted 12 lines
drivers/dma/xilinx/xdma.c new file +11
-0+ +static struct platform_driver xdma_driver = { + .driver = { + .name ="xdma" , + }, + .id_table = xdma_id_table, + .probe = xdma_probe, + .remove = xdma_remove, +}; + +module_platform_driver (xdma_driver);Gr{oetje,eeting}s,
Geert
Lizhi Hou
maintainerPATCH RESEND v12 2/2 dmaengine: xilinx: xdma: Add user logic interrupt support
In reply to Lizhi HouThe 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 | 81 ++++++++++++++++++++++++++++++++++++ include/linux/dma/amd_xdma.h | 16 +++++++ 3 files changed, 98 insertions(+) create mode 100644 include/linux/dma/amd_xdma.h
MAINTAINERS +1 -0
@@ -22583,6 +22583,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 +81 -0
105 lines not on this page · raw message
include/linux/dma/amd_xdma.h new file +16 -0
@@ -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