mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/3] NTB: Allow drivers to provide DMA mapping device
@ 2026-03-06  3:14 Koichiro Den
  2026-03-06  3:14 ` [PATCH v2 1/3] NTB: core: Add .get_dma_dev() callback to ntb_dev_ops Koichiro Den
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Koichiro Den @ 2026-03-06  3:14 UTC (permalink / raw)
  To: Jon Mason, Dave Jiang, Allen Hubbe, Manivannan Sadhasivam,
	Krzysztof Wilczyński, Kishon Vijay Abraham I, Bjorn Helgaas,
	Frank Li, Niklas Cassel
  Cc: ntb, linux-kernel, linux-pci

Hi,

Some NTB implementations are backed by a "virtual" PCI device, while the
actual DMA mapping context (IOMMU domain) belongs to a different device.

One example is vNTB, where the NTB device is represented as a virtual
PCI endpoint function, but DMA operations must be performed against the
EPC parent device, which owns the IOMMU context.

Currently, vNTB on an IOMMU-backed EPC does not work because the
"virtual" PCI device is used for DMA API operations, while the actual
IOMMU domain belongs to the EPC parent device. This series fixes that.

Note that there are two related but separable DMA-mapping issues in this
area:

  1). Selecting the correct struct device for DMA API operations used for
      MW translation setup and coherent buffer allocation.

  2). The existing RX-side dmaengine path in ntb_transport, where the MW
      source buffer may later be re-mapped against a per-queue dmaengine
      device ("double mapping"). The current physically-contiguous
      allocation workaround is about that existing issue.

This series is only about (1). It does not attempt to solve the larger
initialization-order / per-queue dmaengine issue behind (2), nor does it
change the current behavior of that path. In particular, this is not a
series to eliminate or redesign the existing "double mapping" behavior.

This series introduces an optional .get_dma_dev() callback in struct
ntb_dev_ops, together with a helper ntb_get_dma_dev(). If the callback
is not implemented, the helper falls back to the current default
behavior.  Drivers that implement .get_dma_dev() must return a non-NULL
struct device.

  - Patch 1/3: Add .get_dma_dev() to struct ntb_dev_ops and provide
               ntb_get_dma_dev().

  - Patch 2/3: Switch ntb_transport MW buffer allocation/free paths to use
               ntb_get_dma_dev().

  - Patch 3/3: Implement .get_dma_dev() for vNTB by returning the EPC
               parent device.

As suggested by Dave at:
https://lore.kernel.org/all/17cdfa38-16d5-49cc-ac61-20b606a4308b@intel.com/
I expect patch 1 and 2 to get NTB acks, patch 3 to get PCI EP ack, and
the full series to be taken through the PCI EP tree.

Best regards,
Koichiro

---
Changes since v1:
  - Reworked the series so that the actual user (vNTB) is included in
    the same series.
  - Clarified in the cover letter that this series only addresses the
    DMA-mapping device selection for MW translation, and does not
    attempt to solve the existing RX-side dmaengine "double mapping"
    issue.


Koichiro Den (3):
  NTB: core: Add .get_dma_dev() callback to ntb_dev_ops
  NTB: ntb_transport: Use ntb_get_dma_dev() for DMA buffers
  PCI: endpoint: pci-epf-vntb: Implement .get_dma_dev()

 drivers/ntb/ntb_transport.c                   | 14 +++++------
 drivers/pci/endpoint/functions/pci-epf-vntb.c |  9 ++++++++
 include/linux/ntb.h                           | 23 +++++++++++++++++++
 3 files changed, 39 insertions(+), 7 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-26 17:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-06  3:14 [PATCH v2 0/3] NTB: Allow drivers to provide DMA mapping device Koichiro Den
2026-03-06  3:14 ` [PATCH v2 1/3] NTB: core: Add .get_dma_dev() callback to ntb_dev_ops Koichiro Den
2026-03-06  3:14 ` [PATCH v2 2/3] NTB: ntb_transport: Use ntb_get_dma_dev() for DMA buffers Koichiro Den
2026-03-06  3:14 ` [PATCH v2 3/3] PCI: endpoint: pci-epf-vntb: Implement .get_dma_dev() Koichiro Den
2026-03-06 15:24   ` Dave Jiang
2026-03-26 17:19 ` [PATCH v2 0/3] NTB: Allow drivers to provide DMA mapping device Manivannan Sadhasivam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®