Skip to content

fpga: add dma-buf based FPGA programming interface

Aravind Thokala dri-devel linux-doc linux-fpga linux-media lkml sashiko-reviews 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2fpga: Add dma-buf interface for FPGA programmingDocumentation/userspace-api/ioctl/ioctl-number.rst MAINTAINERS drivers/fpga/Kconfig +5 more+249 -00 replies
2/2fpga: versal: add dma-buf programming supportdrivers/fpga/versal-fpga.c+32 -11 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] fpga: add dma-buf based FPGA programming interface

Some systems need to load large FPGA configuration images. The FPGA subsystem allows loading images from the filesystem, but this requires the entire image to be loaded into kernel memory first. For drivers that need a DMA-capable buffer for programming, the data is then copied again into DMA memory. This creates needless memory pressure and delays due to the extra copy.

This series adds dma-buf support that allows userspace to allocate a buffer directly from a DMA heap, write the FPGA image into it, and pass the file descriptor to the kernel via ioctl — skipping the intermediate kernel buffer entirely.

Userspace flow:
1. Allocate buffer from /dev/dma_heap/ (e.g., CMA heap)
2. mmap the buffer and write the FPGA image into it
3. ioctl(/dev/fpgaX, FPGA_IOCTL_LOAD_DMA_BUF, &dmabuf_fd)

The dma-buf logic is implemented as a separate layer on top of the FPGA manager, keeping buffer management separate from the write path. Individual FPGA drivers opt in by calling fpga_dmabuf_register().
---
This work is based on the approach discussed in [1].

[1] https://lore.kernel.org/all/[email protected]/
---
Aravind Thokala (2):
fpga: Add dma-buf interface for FPGA programming
fpga: versal: add dma-buf programming support

 .../userspace-api/ioctl/ioctl-number.rst      |   1 +
 MAINTAINERS                                   |   1 +
 drivers/fpga/Kconfig                          |   9 +
 drivers/fpga/Makefile                         |   2 +
 drivers/fpga/fpga-dmabuf.c                    | 198 ++++++++++++++++++
 drivers/fpga/versal-fpga.c                    |  33 ++-
 include/linux/fpga/fpga-dmabuf.h              |  22 ++
 include/linux/fpga/fpga-mgr.h                 |   1 +
 include/uapi/linux/fpga.h                     |  15 ++
 9 files changed, 281 insertions(+), 1 deletion(-)
 create mode 100644 drivers/fpga/fpga-dmabuf.c
 create mode 100644 include/linux/fpga/fpga-dmabuf.h
 create mode 100644 include/uapi/linux/fpga.h
Signature · 1 line
2.34.1