Re: [PATCH 09/15] PCI: endpoint: Add pci-ep-dma helper for exported DMA ABI v1

From: Koichiro Den

Date: Thu Sep 03 2026 - 13:32:48 EST


On Tue, Sep 01, 2026 at 04:35:18PM +0200, Manivannan Sadhasivam wrote:
> On Sat, Aug 22, 2026 at 12:41:32AM +0900, Koichiro Den wrote:
> > On Fri, Mar 13, 2026 at 01:49:59AM +0900, Koichiro Den wrote:
> > > Add a generic helper that packages controller-owned DMA resources into a
> > > peer-visible BAR slice described by exported DMA ABI v1.
> > >
> > > pci_epf_alloc_dma() queries EPC auxiliary resources, delegates the
> > > requested DMA read channels, builds an ABI header in coherent memory,
> > > and assembles the BAR region list covering the header, controller
> > > register window, and per-channel descriptor windows. If the controller
> > > control window is not already BAR-backed, map it into the exported slice
> > > so the peer still sees a self-contained layout.
> > >
> > > The first ABI is designed based on the DesignWare unrolled eDMA model,
> > > but it is intended to be vendor-neutral. It exports delegated READ
> > > channels only, which are the channels the host uses to send data from
> > > host memory into the endpoint.
> > >
> > > Signed-off-by: Koichiro Den <den@xxxxxxxxxxxxx>
> > > ---
> > > drivers/pci/endpoint/Makefile | 2 +-
> > > drivers/pci/endpoint/pci-ep-dma.c | 342 ++++++++++++++++++++++++++++++
> > > include/linux/pci-ep-dma.h | 130 ++++++++++++
> > > 3 files changed, 473 insertions(+), 1 deletion(-)
> > > create mode 100644 drivers/pci/endpoint/pci-ep-dma.c
> > > create mode 100644 include/linux/pci-ep-dma.h
> > >
> > > diff --git a/drivers/pci/endpoint/Makefile b/drivers/pci/endpoint/Makefile
> > > index b4869d52053a..94824f3ed5a1 100644
> > > --- a/drivers/pci/endpoint/Makefile
> > > +++ b/drivers/pci/endpoint/Makefile
> > > @@ -5,5 +5,5 @@
> > >
> > > obj-$(CONFIG_PCI_ENDPOINT_CONFIGFS) += pci-ep-cfs.o
> > > obj-$(CONFIG_PCI_ENDPOINT) += pci-epc-core.o pci-epf-core.o\
> > > - pci-epc-mem.o functions/
> > > + pci-epc-mem.o pci-ep-dma.o functions/
> > > obj-$(CONFIG_PCI_ENDPOINT_MSI_DOORBELL) += pci-ep-msi.o
> > > diff --git a/drivers/pci/endpoint/pci-ep-dma.c b/drivers/pci/endpoint/pci-ep-dma.c
> > > new file mode 100644
> > > index 000000000000..2a996f9b1424
> > > --- /dev/null
> > > +++ b/drivers/pci/endpoint/pci-ep-dma.c
> >
> > ---[snip]---
> >
> > > diff --git a/include/linux/pci-ep-dma.h b/include/linux/pci-ep-dma.h
> > > new file mode 100644
> > > index 000000000000..0ef6f9eb8593
> > > --- /dev/null
> > > +++ b/include/linux/pci-ep-dma.h
> >
> > Hi Mani, (Cc: Frank, Niklas)
> >
> > Perhaps it's time to reincarnate this series, with much of it reworked.
> >
> > Following the discussion here:
> > https://lore.kernel.org/r/fg7cma2ccvdgjgcref7qa4q7ocvvume5dteekedikszebkq7rd@uhrjfp3nmmwh/
> > I am now thinking of dropping the generic pci-ep-dma helper and
> > include/linux/pci-ep-dma.h altogether, as I understand the direction is to keep
> > the DMA export within the vNTB/ntb_hw_epf path *as much as possible*.
> >
> > The old wire layout was consumed by pci-epf-vntb.c, ntb_hw_epf.c, and
> > dw-edma-aux.c (see patch 13). That is why I put pci-ep-dma.h under
> > include/linux/. For the rework, I am thinking ntb_hw_epf should decode it and
> > pass only the resulting resources to dw-edma-aux. This keeps the wire format
> > between pci-epf-vntb and ntb_hw_epf. At that point, defining the same small
> > layout in both files might even be preferable to adding another shared header in
> > include/linux/.
> >
> > Mani, does this direction look acceptable to you? I would also appreciate your
> > view on the linked discussion when you have a chance.
> >
>
> Sounds good to me. My only concern is exposing the remote DMA functionality as a
> new EPF driver. As long as you keep the changes within the NTB drivers, I'm fine
> with it.

Thanks for the confirmation!

Note: the latest (as of today) is v4:
https://lore.kernel.org/r/20260903082327.2345602-1-den@xxxxxxxxxxxxx/
The series title is unchanged.

Best regards,
Koichiro

>
> - Mani
>
> --
> மணிவண்ணன் சதாசிவம்