[PATCH v3 0/3] PCI: endpoint: Add PCI DMA endpoint function (part 3/3)

From: Koichiro Den

Date: Sat Jun 20 2026 - 13:09:03 EST


Hi,

This is v3, part 3 of three series for PCI endpoint DMA.

The three series are:

* part 1: dmaengine: dw-edma: Prepare for PCI EP DMA
* part 2: PCI: endpoint: Expose endpoint DMA resources
* part 3: PCI: endpoint: Add PCI DMA endpoint function

This series adds the host-side metadata parser, the pci-epf-dma endpoint
function driver, and documentation.

The endpoint function exposes selected endpoint-integrated DMA channels as
a separate PCI DMA controller function. The host-side dw-edma-pcie driver
discovers the BAR metadata, requests the final layout, and registers the
exposed channels with DMAengine. Host clients then submit transfers through
the regular DMAengine API. The endpoint function keeps the metadata BAR
stable and uses a separate DMA window BAR for resources that need dynamic
subrange mappings.

No fixed PCI ID is assigned by this series. Users provide the PCI
vendor/device ID through configfs and bind dw-edma-pcie explicitly, for
example with driver_override.


Dependencies
============

This series is based on linux-next next-20260619 and depends on parts 1
and 2:

[PATCH v3 00/13] dmaengine: dw-edma: Prepare for PCI EP DMA (part 1/3)
https://lore.kernel.org/dmaengine/20260620170040.3756043-1-den@xxxxxxxxxxxxx/

[PATCH v3 0/5] PCI: endpoint: Expose endpoint DMA resources (part 2/3)
https://lore.kernel.org/linux-pci/20260620170438.3756593-1-den@xxxxxxxxxxxxx/


Open question for the full series
=================================

One remaining design question is how to support endpoint controllers that
can expose only one PF. One option is to keep pci-epf-dma as a separate
function and require multi-function endpoint support. Another is to fold
the DMA functionality into vNTB for such platforms, similar to the earlier,
likely superseded, separate series:

[PATCH 00/15] PCI: endpoint: Remote DMA support via vNTB
https://lore.kernel.org/linux-pci/20260312165005.1148676-1-den@xxxxxxxxxxxxx/

My intention is for the first real consumer to be an NTB netdev/transport
over vNTB, using this DMA path to accelerate data transfers. Embedding DMA
support in vNTB would make that acceleration available even on endpoint
controllers that do not support multiple functions. However, it would also
make the vNTB code significantly more complex. The separate PCI DMA EPF
model in this series keeps the design cleaner and more modular.


Note
====

This series touches both dmaengine and PCI endpoint code. I kept the
dw-edma-pcie metadata parser together with the endpoint function so the
metadata producer and consumer can be reviewed in one place.

If the general direction looks acceptable, the dw-edma-pcie patch may need
a dmaengine Ack if this series is routed through the PCI endpoint tree.


Tested on
=========

The RC-to-EP data path was tested with a small out-of-tree DMAengine
client. The host submits a DMA_MEM_TO_DEV transfer through dw-edma-pcie,
which uses a DesignWare eDMA read channel to copy host memory into
endpoint memory.

Tested with these endpoint/root-complex pairs:

* R-Car S4 EP + R-Car S4 RC:
eDMA unroll; DMA register window mapped through a BAR subrange
* RK3588 EP + CD8180 RC:
eDMA unroll; DMA register window fixed in BAR space
* SpacemiT K3 EP + CD8180 RC:
HDMA native linked-list; DMA register window fixed in BAR space

Note: The SpacemiT K3 test used the vendor Ubuntu kernel
(6.18.3-5-spacemit-generic), which includes pcie-spacemit-ep.c, with the
required prerequisite series backported.

---
Changelog
=========

Changes in v3:
- Select endpoint DMA match data before copying DMA data and require
driver_override for the generic endpoint DMA fallback. (Sashiko)
- Accept HDMA native linked-list endpoint DMA metadata.
- Consume logical DMA channels separately from descriptor memory resources.
(Sashiko)
- Delegate channels through the EPC DMA channel delegation API instead of
v2's EPC-provided DMAengine filter callbacks.
- Allow HDMA native linked-list channels to be delegated at channel
granularity.
- Preserve HOST_REQ across link-down and retry DMA window submaps on the
next link-up.
- Drop trailing colons from documentation subsection headings. (Randy)
- Document HDMA native linked-list mode support and the current non-LL
limitation.

Changes in v2:
- Follow the part 1/3 and part 2/3 v2 channel-claim model: pci-epf-dma
now claims delegated channels through DMAengine filter information from
EPC auxiliary resources.
- Select raw-address dw-edma-pcie platform ops from the endpoint DMA
match entry instead of using a match flag.

v2: https://lore.kernel.org/linux-pci/20260525063456.3317509-1-den@xxxxxxxxxxxxx/
v1: https://lore.kernel.org/linux-pci/20260521063638.2843021-1-den@xxxxxxxxxxxxx/


Best regards,
Koichiro


Koichiro Den (3):
dmaengine: dw-edma-pcie: Discover endpoint DMA metadata
PCI: endpoint: Add DMA endpoint function
Documentation: PCI: Add PCI DMA endpoint function documentation

Documentation/PCI/endpoint/index.rst | 2 +
.../PCI/endpoint/pci-dma-function.rst | 188 +++
Documentation/PCI/endpoint/pci-dma-howto.rst | 201 +++
drivers/dma/dw-edma/dw-edma-pcie.c | 380 ++++-
drivers/pci/endpoint/functions/Kconfig | 14 +
drivers/pci/endpoint/functions/Makefile | 1 +
drivers/pci/endpoint/functions/pci-epf-dma.c | 1420 +++++++++++++++++
7 files changed, 2204 insertions(+), 2 deletions(-)
create mode 100644 Documentation/PCI/endpoint/pci-dma-function.rst
create mode 100644 Documentation/PCI/endpoint/pci-dma-howto.rst
create mode 100644 drivers/pci/endpoint/functions/pci-epf-dma.c

--
2.51.0