Skip to contentSkip to conversation

make PCIe DMA work on Broadcom BCM2711

PATCH In review Md Rayhanul Islam 3 participants 11 messages Sep 19 – Oct 3

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover make PCIe DMA work on Broadcom BCM2711

DPDK cannot transmit a single packet on a Raspberry Pi Compute Module 4 with an Intel I210. Nothing reports an error: rte_eth_tx_burst() returns the full count, the link is up at 1 Gbps, and testpmd in txonly mode still shows TX-packets: 0. Received data is DMA'd somewhere other than the mbuf. The same card works on x86, and the same board works through the kernel's igb driver.

This has been reported twice and never explained: on Stack Overflow in October 2023 with DPDK 23.07 [1], where TX-dropped equalled TX-total at 55 million with both vfio-noiommu and uio_pci_generic, and on dpdk-users in January 2026 with DPDK 25.03 [2]. Two years apart, so this is the platform, not a regression.

There are two independent causes, hence two patches.

First, the PCIe host bridge does not present memory to devices at CPU physical addresses. Its device tree says so, and DPDK does not look:

  $ hexdump -C /proc/device-tree/scb/pcie@7d500000/dma-ranges
  02000000 00000004 00000000  00000000 00000000  00000001 00000000

PCI memory space | bus 0x4_0000_0000 | CPU 0x0 | size 4 GiB

A device reaching CPU physical address P must therefore be programmed with P + 0x4_0000_0000. In IOVA_PA mode every ring and mbuf address DPDK hands the NIC falls outside the inbound window and is discarded silently. Patch 1 reads the translation from the host bridge and applies it to IOVAs; that alone made the NIC transmit.

Second, the bus is not cache coherent -- no "dma-coherent" on the bridge or any ancestor -- so the NIC read stale rings: zeroed descriptors with DD set and null buffer addresses. Patch 2 does the cache maintenance the kernel DMA API would do. Two details took the longest to find:

- Cleaning to the point of unification (DC CVAU) was not enough. Only a clean to the point of coherency made the device see CPU stores.

- A clean writes back a whole 64-byte line, which holds four descriptors, so cleaning one erased DD bits the NIC had just set on its neighbours. TX completion therefore comes from the hardware head register, and RX descriptors are refilled a whole line at a time, once every descriptor in that line has come back.

The cache maintenance sits in the driver. Every driver on such a bus needs the same thing, so an arch or EAL helper may be the better home; I kept it local to e1000 for a first submission and am happy to move it.

Each patch documents its own half, since the failure gives nothing to search for.

The device is bound to uio_pci_generic throughout: this SoC has no IOMMU, so VFIO cannot be used to sidestep the address question.

Tested on a Compute Module 4 (BCM2711, 4 GB, Cortex-A72, 64-byte cache lines) with an I210 (8086:1533 rev 03) on uio_pci_generic, Ubuntu 22.04 arm64, kernel 5.15, pcie_aspm=off. With this series applied to current main, testpmd txonly reaches 1.42 Mpps at 64-byte frames, which is 1 GbE line rate, with 0 TX errors; without it, TX-packets stays 0. The same code based on v25.03 also passed a 300k-frame MAC loopback with no loss and byte-exact payloads, and 390-run round-trip campaigns against a second board with ICMP and UDP probes, 100 to 1500 byte packets, 1k pkt/s to line rate, with no unexplained loss.

Not tested: any other board, SoC or NIC. The offset is read from the device tree rather than hardcoded, but I have only seen this platform. Only e1000 was changed, so other drivers on a non-coherent bus still read stale descriptors.

[1] https://stackoverflow.com/questions/77225289/
[2] https://mails.dpdk.org/archives/users/2026-January/008433.html

Md Rayhanul Islam (2):
eal/linux: apply PCIe inbound DMA translation
net/e1000: maintain caches on non-coherent DMA

 .mailmap                                  |   1 +
 doc/guides/linux_gsg/bcm2711_platform.rst |  71 ++++++
 doc/guides/linux_gsg/index.rst            |   1 +
 doc/guides/rel_notes/release_26_11.rst    |  16 ++
 drivers/net/intel/e1000/igb_rxtx.c        | 356 +++++++++++++++++++++++++++++-
 lib/eal/linux/eal_memory.c                | 265 +++++++++++++++++++++-
 6 files changed, 697 insertions(+), 13 deletions(-)
 create mode 100644 doc/guides/linux_gsg/bcm2711_platform.rst
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 eal/linux: apply PCIe inbound DMA translation

On some platforms a device does not see memory at the CPU's physical
addresses: the PCIe host bridge translates inbound traffic. An IOVA in RTE_IOVA_PA mode is then an address the device cannot reach, so its reads and writes fall outside the bridge's inbound window and are dropped with no error reported.

On a Raspberry Pi Compute Module 4 (BCM2711) with an Intel I210, the host bridge declares in its device tree "dma-ranges" that CPU physical address 0 is reached at bus address 0x4_0000_0000. Without that offset the NIC reported link up but never completed a DMA: testpmd in txonly mode left TX-packets at 0, and received data never reached the mbufs.

Read the translation from the PCI host bridge "dma-ranges" in the device tree and add it to IOVAs in rte_mem_virt2iova() and the legacy memory path. Platforms that declare no translation, and those with no device tree, keep an identity mapping. DPDK_IOVA_PA_OFFSET overrides it.

---
 .mailmap                                  |   1 +
 doc/guides/linux_gsg/bcm2711_platform.rst |  45 ++++
 doc/guides/linux_gsg/index.rst            |   1 +
 doc/guides/rel_notes/release_26_11.rst    |   8 +
 lib/eal/linux/eal_memory.c                | 265 +++++++++++++++++++++-
 5 files changed, 318 insertions(+), 2 deletions(-)
 create mode 100644 doc/guides/linux_gsg/bcm2711_platform.rst
.mailmap +1 -0
index 9e45cdce8f..9fd78db7e2 100644
@@ -1032,6 +1032,7 @@ Marek Mical <[email protected]>
 Marek Zalfresso-jundzillo <[email protected]>
 Maria Lingemark <[email protected]>
 Mario Carrillo <[email protected]>
+Md Rayhanul Islam <[email protected]>
 Mário Kuka <[email protected]>
 Mariusz Drost <[email protected]>
 Mark Asselstine <[email protected]>
doc/guides/linux_gsg/bcm2711_platform.rst new file +45 -0

45 lines not on this page · raw message

doc/guides/linux_gsg/index.rst +1 -0
index f739edd6ca..480909ec2c 100644
@@ -20,3 +20,4 @@ Getting Started Guide for Linux
     enable_func
     nic_perf_intel_platform
     amd_platform
+    bcm2711_platform
doc/guides/rel_notes/release_26_11.rst +8 -0
index 4b3e5d995c..37452b2a3f 100644
@@ -55,6 +55,14 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added PCIe inbound DMA address translation on Linux.**
+
+  EAL now reads the PCIe host bridge "dma-ranges" property from the device
+  tree and applies the translation it declares to IOVAs, so devices on a
+  platform whose inbound window is not identity-mapped, such as the
+  Broadcom BCM2711 on Raspberry Pi 4 and Compute Module 4, can reach
+  system memory.
+
 
 Removed Items
 -------------
lib/eal/linux/eal_memory.c +263 -2

295 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 net/e1000: maintain caches on non-coherent DMA

In reply to Md Rayhanul Islam

When the PCIe bus is not cache coherent, the NIC can read stale memory. The kernel's DMA API cleans the cache before handing a buffer to a device; DPDK writes descriptors straight into hugepage memory and rings the doorbell.

On a BCM2711 (Raspberry Pi Compute Module 4, Cortex-A72, 64-byte cache lines) with an Intel I210, the NIC fetched the previous contents of the rings -- zeroed descriptors with DD set and null buffer addresses -- so transmits never completed and received data was DMA'd to address zero. Cleaning to the point of unification was not enough; the device saw the CPU's stores only after a clean to the point of coherency.

Cleaning writes back a whole 64-byte line, which holds four descriptors, so cleaning one just written also restored stale status for its neighbours and erased DD bits the NIC had set.

When the device is described by a device tree and no ancestor declares "dma-coherent", on arm64:

- clean the D-cache (DC CVAC) over descriptors and packet data before the tail register lets the NIC read them;
- invalidate (DC CIVAC) descriptor status and received data before reading what the NIC wrote;
- take TX completion from the hardware head register instead of the DD bits;
- write RX buffer addresses back one whole cache line at a time, once every descriptor in that line has been returned and consumed.

This is a no-op on cache-coherent platforms and non-arm64 builds, and DPDK_DMA_NONCOHERENT forces it either way.

---
 doc/guides/linux_gsg/bcm2711_platform.rst |  30 +-
 doc/guides/rel_notes/release_26_11.rst    |   8 +
 drivers/net/intel/e1000/igb_rxtx.c        | 356 +++++++++++++++++++++-
 3 files changed, 381 insertions(+), 13 deletions(-)
doc/guides/linux_gsg/bcm2711_platform.rst +28 -2
index 5a774607da..3be149e2f7 100644
@@ -5,8 +5,8 @@ Running DPDK on Broadcom BCM2711 platforms
 ==========================================
 
 The Broadcom BCM2711, used on the Raspberry Pi 4 and Compute Module 4,
-has a platform property that must be taken into account before a PCIe
-device can DMA correctly.  It is handled automatically; this page
+needs two platform properties to be taken into account before a PCIe
+device can DMA correctly.  Both are handled automatically; this page
 describes what happens and how to check it.
 
 PCIe inbound address translation
@@ -36,6 +36,32 @@ variable, given in hexadecimal.  Without the translation, a device
 reports link up and counts packets in its own registers while never
 completing a DMA.
 
+Non-cache-coherent DMA
+----------------------
+
+The PCIe bus is not cache coherent: neither ``pcie@7d500000`` nor any of
+its ancestors declares ``dma-coherent``.  A device therefore does not see
+data the CPU has only written to its caches, and the CPU does not see
+data the device has written to memory.
+
+The ``e1000`` (igb) driver handles this when it detects a
+device-tree-described device with no ``dma-coherent`` ancestor, on arm64.
+It cleans the data cache over descriptors and packet data before the tail
+register is written, and invalidates it before reading what the device
+wrote.  Because a cache line covers four descriptors, TX completion is
+taken from the hardware head register rather than the DD bits, and RX
+descriptors are refilled one whole cache line at a time.
+
+This is logged at device probe::
+
+   E1000_INIT: 0000:01:00.0: PCIe DMA is not cache coherent,
+   cleaning 64-byte D-cache lines before each DMA
+
+It can be forced on or off with ``DPDK_DMA_NONCOHERENT=1`` or ``0``.
+
+Other drivers running on this platform need equivalent handling; only
+``e1000`` implements it today.
+
 Recommended settings
 --------------------
 
doc/guides/rel_notes/release_26_11.rst +8 -0
index 37452b2a3f..e292cc3714 100644
@@ -63,6 +63,14 @@ New Features
   Broadcom BCM2711 on Raspberry Pi 4 and Compute Module 4, can reach
   system memory.
 
+* **Added non-coherent DMA support to the e1000 (igb) driver.**
+
+  The driver now performs the cache maintenance required on a PCIe bus
+  that is not cache coherent, taking TX completion from the hardware head
+  register and refilling RX descriptors a cache line at a time.  It is
+  enabled when the device is described by a device tree whose bus does not
+  declare "dma-coherent", on arm64.
+
 
 Removed Items
 -------------
drivers/net/intel/e1000/igb_rxtx.c +345 -11

529 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw
In reply to Md Rayhanul Islam
Quoted 68 lines · On Fri, 18 Sep 2026 18:50:42 -0400 Md Rayhanul Islam <[email protected]> wrote:

DPDK cannot transmit a single packet on a Raspberry Pi Compute Module 4 with an Intel I210. Nothing reports an error: rte_eth_tx_burst() returns the full count, the link is up at 1 Gbps, and testpmd in txonly mode still shows TX-packets: 0. Received data is DMA'd somewhere other than the mbuf. The same card works on x86, and the same board works through the kernel's igb driver.

This has been reported twice and never explained: on Stack Overflow in October 2023 with DPDK 23.07 [1], where TX-dropped equalled TX-total at 55 million with both vfio-noiommu and uio_pci_generic, and on dpdk-users in January 2026 with DPDK 25.03 [2]. Two years apart, so this is the platform, not a regression.

There are two independent causes, hence two patches.

First, the PCIe host bridge does not present memory to devices at CPU physical addresses. Its device tree says so, and DPDK does not look:

  $ hexdump -C /proc/device-tree/scb/pcie@7d500000/dma-ranges
  02000000 00000004 00000000  00000000 00000000  00000001 00000000

PCI memory space | bus 0x4_0000_0000 | CPU 0x0 | size 4 GiB

A device reaching CPU physical address P must therefore be programmed with P + 0x4_0000_0000. In IOVA_PA mode every ring and mbuf address DPDK hands the NIC falls outside the inbound window and is discarded silently. Patch 1 reads the translation from the host bridge and applies it to IOVAs; that alone made the NIC transmit.

Second, the bus is not cache coherent -- no "dma-coherent" on the bridge or any ancestor -- so the NIC read stale rings: zeroed descriptors with DD set and null buffer addresses. Patch 2 does the cache maintenance the kernel DMA API would do. Two details took the longest to find:

- Cleaning to the point of unification (DC CVAU) was not enough. Only a clean to the point of coherency made the device see CPU stores.

- A clean writes back a whole 64-byte line, which holds four descriptors, so cleaning one erased DD bits the NIC had just set on its neighbours. TX completion therefore comes from the hardware head register, and RX descriptors are refilled a whole line at a time, once every descriptor in that line has come back.

The cache maintenance sits in the driver. Every driver on such a bus needs the same thing, so an arch or EAL helper may be the better home; I kept it local to e1000 for a first submission and am happy to move it.

Each patch documents its own half, since the failure gives nothing to search for.

The device is bound to uio_pci_generic throughout: this SoC has no IOMMU, so VFIO cannot be used to sidestep the address question.

Tested on a Compute Module 4 (BCM2711, 4 GB, Cortex-A72, 64-byte cache lines) with an I210 (8086:1533 rev 03) on uio_pci_generic, Ubuntu 22.04 arm64, kernel 5.15, pcie_aspm=off. With this series applied to current main, testpmd txonly reaches 1.42 Mpps at 64-byte frames, which is 1 GbE line rate, with 0 TX errors; without it, TX-packets stays 0. The same code based on v25.03 also passed a 300k-frame MAC loopback with no loss and byte-exact payloads, and 390-run round-trip campaigns against a second board with ICMP and UDP probes, 100 to 1500 byte packets, 1k pkt/s to line rate, with no unexplained loss.

Not tested: any other board, SoC or NIC. The offset is read from the device tree rather than hardcoded, but I have only seen this platform. Only e1000 was changed, so other drivers on a non-coherent bus still read stale descriptors.

Quoted 6 lines

[1] https://stackoverflow.com/questions/77225289/
[2] https://mails.dpdk.org/archives/users/2026-January/008433.html

Md Rayhanul Islam (2):
eal/linux: apply PCIe inbound DMA translation
net/e1000: maintain caches on non-coherent DMA

Short observations:
1. Too much AI generated slop, extra docs, comments on everything. New code should look like the surrounding code.
This looks like AI wasn't quite sure and left lots of docs for future self.
2. Handling DMA coherence should not be in the driver.
It should be done in EAL.
3. EAL helpers should be similar to helpers used in other OS (Linux and FreeBSD) when handling DMA issues.

AI observations:

Patch 1

- The offset is a property of one host bridge but is applied to every IOVA in the process, and it comes from whichever PCI node readdir() finds first under /proc/device-tree. BCM2712 already has several PCIe controllers with different dma-ranges. The offset has to come from the bridge the probed device sits behind. That is bus driver
work: walk /sys/bus/pci/devices/<bdf> up to the host bridge of_node and read dma-ranges there, the same walk patch 2 does for dma-coherent. Bus scan runs before memory init and already feeds IOVA mode selection, so the offset can be delivered the same way.

- Lazy scan inside rte_mem_virt2iova() with a racy static is the wrong lifecycle. Compute once at init and keep it in shared mem_config so secondaries see the same value.

- No environment variables. If an override is needed it is an EAL option.

Patch 2

- The asm has no dsb after the dc loops, and DPDK's arm64 barriers are all dmb, which do not order cache maintenance. The clean can still be in flight when the tail register is written.

- EL0 cannot execute dc ivac, only civac, so every buffer the device may write must be cleaned before it is handed over. TX data and descriptors are cleaned, RX buffers on refill are not. Dirty lines from the application's previous use of the mbuf get written back over received data. txonly/rxonly/loopback never modify packets in place so the tests would not catch it; macswap would.

- TX completion from TDH: check the I210 datasheet. TDH advances when the descriptor is fetched, not when the data DMA completes, and the kernel igb driver never uses it for cleanup. Freeing the mbuf on TDH can corrupt frames still in flight.

- Coherence state is a process-global static set in queue_setup. Two ports on different buses get one answer, and a secondary process never runs queue_setup so it treats the device as coherent. Needs to be per-device, set by the bus, in shared device data.

- Every descriptor on every platform now tests igb_dma_noncoherent. Use separate burst functions selected at setup and leave the coherent path alone.

- em_rxtx.c in the same PMD is untouched.

The right next step is an RFC for the EAL sync API and the bus hook, with igb as the first user, rather than a v2 of these patches.

#4 lore raw
Quoted 74 lines · Stephen Hemminger
Quoted 71 lines · On Fri, 18 Sep 2026 18:50:42 -0400 Md Rayhanul Islam <[email protected]> wrote:

DPDK cannot transmit a single packet on a Raspberry Pi Compute Module 4 with an Intel I210. Nothing reports an error: rte_eth_tx_burst() returns the full count, the link is up at 1 Gbps, and testpmd in txonly mode still shows TX-packets: 0. Received data is DMA'd somewhere other than the mbuf. The same card works on x86, and the same board works through the kernel's igb driver.

This has been reported twice and never explained: on Stack Overflow in October 2023 with DPDK 23.07 [1], where TX-dropped equalled TX-total at 55 million with both vfio-noiommu and uio_pci_generic, and on dpdk-users in January 2026 with DPDK 25.03 [2]. Two years apart, so this is the platform, not a regression.

There are two independent causes, hence two patches.

First, the PCIe host bridge does not present memory to devices at CPU physical addresses. Its device tree says so, and DPDK does not look:

  $ hexdump -C /proc/device-tree/scb/pcie@7d500000/dma-ranges
  02000000 00000004 00000000  00000000 00000000  00000001 00000000

PCI memory space | bus 0x4_0000_0000 | CPU 0x0 | size 4 GiB

A device reaching CPU physical address P must therefore be programmed with P + 0x4_0000_0000. In IOVA_PA mode every ring and mbuf address DPDK hands the NIC falls outside the inbound window and is discarded silently. Patch 1 reads the translation from the host bridge and applies it to IOVAs; that alone made the NIC transmit.

Second, the bus is not cache coherent -- no "dma-coherent" on the bridge or any ancestor -- so the NIC read stale rings: zeroed descriptors with DD set and null buffer addresses. Patch 2 does the cache maintenance the kernel DMA API would do. Two details took the longest to find:

- Cleaning to the point of unification (DC CVAU) was not enough. Only a clean to the point of coherency made the device see CPU stores.

- A clean writes back a whole 64-byte line, which holds four descriptors, so cleaning one erased DD bits the NIC had just set on its neighbours. TX completion therefore comes from the hardware head register, and RX descriptors are refilled a whole line at a time, once every descriptor in that line has come back.

The cache maintenance sits in the driver. Every driver on such a bus needs the same thing, so an arch or EAL helper may be the better home; I kept it local to e1000 for a first submission and am happy to move it.

Each patch documents its own half, since the failure gives nothing to search for.

The device is bound to uio_pci_generic throughout: this SoC has no IOMMU, so VFIO cannot be used to sidestep the address question.

Tested on a Compute Module 4 (BCM2711, 4 GB, Cortex-A72, 64-byte cache lines) with an I210 (8086:1533 rev 03) on uio_pci_generic, Ubuntu 22.04 arm64, kernel 5.15, pcie_aspm=off. With this series applied to current main, testpmd txonly reaches 1.42 Mpps at 64-byte frames, which is 1 GbE line rate, with 0 TX errors; without it, TX-packets stays 0. The same code based on v25.03 also passed a 300k-frame MAC loopback with no loss and byte-exact payloads, and 390-run round-trip campaigns against a second board with ICMP and UDP probes, 100 to 1500 byte packets, 1k pkt/s to line rate, with no unexplained loss.

Not tested: any other board, SoC or NIC. The offset is read from the device tree rather than hardcoded, but I have only seen this platform. Only e1000 was changed, so other drivers on a non-coherent bus still read stale descriptors.

[1] https://stackoverflow.com/questions/77225289/
[2] https://mails.dpdk.org/archives/users/2026-January/008433.html

Quoted 8 lines
Quoted 3 lines

Md Rayhanul Islam (2):
eal/linux: apply PCIe inbound DMA translation
net/e1000: maintain caches on non-coherent DMA

Short observations:
1. Too much AI generated slop, extra docs, comments on everything. New code should look like the surrounding code.
This looks like AI wasn't quite sure and left lots of docs for future self.

I really don't view this as a bad thing. A little too much detail in the comments is better for the future than too little. Given these patches touch areas outside the usual behaviour we expect from DPDK platforms, having extra comments is definitely useful.

/Bruce

#5 lore raw
Quoted 6 lines · On Mon, 21 Sep 2026 09:56:17 +0100 Bruce Richardson…
Quoted 5 lines

Short observations:
1. Too much AI generated slop, extra docs, comments on everything. New code should look like the surrounding code.
This looks like AI wasn't quite sure and left lots of docs for future self.

Quoted 7 lines

I really don't view this as a bad thing. A little too much detail in the comments is better for the future than too little. Given these patches touch areas outside the usual behaviour we expect from DPDK platforms, having extra comments is definitely useful.

/Bruce

There is a fine line between a couple of sentences and three paragraphs

#6 lore raw

Hello,

Thank you for the detailed review. I am reworking the series as an RFC for the EAL DMA API and PCI bus hook, with igb as the first user.

DMA properties now come from each device’s host bridge, and cache handling is in EAL. I will also revise RX buffer reuse, TX completion, and descriptor ownership, and add separate burst functions for non-coherent DMA.

I will also remove the extra guide and shorten the comments.

Best regards,
Rayhan

Quoted 20 lines · Stephen Hemminger
Quoted 5 lines · On Mon, 21 Sep 2026 09:56:17 +0100 Bruce Richardson…
Quoted 5 lines

Short observations:
1. Too much AI generated slop, extra docs, comments on everything. New code should look like the surrounding code.
This looks like AI wasn't quite sure and left lots of docs for

future self.

Quoted 8 lines

I really don't view this as a bad thing. A little too much detail in the comments is better for the future than too little. Given these patches touch areas outside the usual behaviour we expect from DPDK platforms, having extra comments is definitely useful.

/Bruce

There is a fine line between a couple of sentences and three paragraphs

#7 lore raw

cover per-device DMA properties, with igb as the first user

In reply to Md Rayhanul Islam

This RFC reworks the BCM2711 DMA fix around a per-device DMA context and an EAL sync API, after the feedback on the first posting [1].

On Raspberry Pi 4 / Compute Module 4 the PCIe host bridge translates DMA addresses and is not cache coherent, so a device such as the Intel I210 cannot DMA at all without both being handled.

What changed since the first posting:

* The translation and the coherency are read per device from its own bridge, not kept as one process-wide offset. EAL no longer rewrites IOVAs; the driver translates where it programs the hardware.
* A driver opts in with RTE_PCI_DRV_DMA_NONCOHERENT, and the bus refuses such a device to any driver that has not. That replaces the refusal written into em by hand.
* The cache maintenance is an experimental EAL interface with explicit directions, and the loops end in DSB SY.
* Completion comes from the Done bits, not the head register.
* Both environment variables are gone.

Tested between two Compute Module 4 boards with Intel I210s, both running this series: testpmd txonly holds 1.42 Mpps with 64-byte frames, and a 512 MB UDP transfer with DPDK at both ends arrives byte-identical. Built with GCC and with clang 14 -Werror.

[1] https://inbox.dpdk.org/dev/[email protected]/

Md Rayhanul Islam (2):
eal/pci: add per-device DMA translation and synchronization net/e1000: support non-coherent DMA

 .mailmap                               |   1 +
 doc/guides/rel_notes/release_26_11.rst |  20 ++
 drivers/bus/pci/bus_pci_driver.h       |   2 +
 drivers/bus/pci/linux/pci.c            |   6 +
 drivers/bus/pci/linux/pci_dma_ranges.c | 168 ++++++++++
 drivers/bus/pci/linux/pci_init.h       |   2 +
 drivers/bus/pci/meson.build            |   1 +
 drivers/bus/pci/pci_common.c           |  17 +
 drivers/bus/pci/private.h              |   2 +
 drivers/bus/pci/rte_bus_pci.h          |  52 ++++
 drivers/net/intel/e1000/e1000_ethdev.h |  19 ++
 drivers/net/intel/e1000/igb_ethdev.c   |   9 +-
 drivers/net/intel/e1000/igb_rxtx.c     | 409 +++++++++++++++++++++++--
 lib/eal/include/meson.build            |   1 +
 lib/eal/include/rte_mem_sync.h         | 133 ++++++++
 15 files changed, 815 insertions(+), 27 deletions(-)
 create mode 100644 drivers/bus/pci/linux/pci_dma_ranges.c
 create mode 100644 lib/eal/include/rte_mem_sync.h
Signature · 1 line
2.34.1
#8 lore raw

RFC PATCH 1/2 eal/pci: add per-device DMA translation and synchronization

Some PCIe platforms, such as BCM2711, translate DMA addresses and are not cache coherent. Both belong to the bridge above a device, so one offset applied to the whole process is wrong on a board with two controllers.

Read them per device. The PCI bus walks the device's sysfs ancestry to its bridge, and a driver copies the result with rte_pci_get_dma_info(). Addresses are translated where they are programmed into the hardware, with rte_pci_dma_iova(), so EAL IOVAs are untouched. Properties this parser cannot express mark that one device unusable rather than failing the scan.

A driver must set RTE_PCI_DRV_DMA_NONCOHERENT before the bus hands it such a device. Only bridges in the compatible table are read, so other platforms keep the behavior they have today.

Add rte_mem_sync_for_device() and rte_mem_sync_for_cpu(), named after dma_sync_single_for_{device,cpu}(), with explicit transfer directions, and rte_mem_dcache_line_size(). On arm64 they are DC CVAC and DC CIVAC loops closed with DSB SY, since the DPDK barriers are DMB and do not order cache maintenance. EL0 cannot execute DC IVAC, so the CPU-side helper cleans as well as invalidates.

---
 .mailmap                               |   1 +
 doc/guides/rel_notes/release_26_11.rst |  15 +++
 drivers/bus/pci/bus_pci_driver.h       |   2 +
 drivers/bus/pci/linux/pci.c            |   6 +
 drivers/bus/pci/linux/pci_dma_ranges.c | 168 +++++++++++++++++++++++++
 drivers/bus/pci/linux/pci_init.h       |   2 +
 drivers/bus/pci/meson.build            |   1 +
 drivers/bus/pci/pci_common.c           |  17 +++
 drivers/bus/pci/private.h              |   2 +
 drivers/bus/pci/rte_bus_pci.h          |  52 ++++++++
 lib/eal/include/meson.build            |   1 +
 lib/eal/include/rte_mem_sync.h         | 133 ++++++++++++++++++++
 12 files changed, 400 insertions(+)
 create mode 100644 drivers/bus/pci/linux/pci_dma_ranges.c
 create mode 100644 lib/eal/include/rte_mem_sync.h
.mailmap +1 -0
index 9e45cdce8f..9fd78db7e2 100644
@@ -1032,6 +1032,7 @@ Marek Mical <[email protected]>
 Marek Zalfresso-jundzillo <[email protected]>
 Maria Lingemark <[email protected]>
 Mario Carrillo <[email protected]>
+Md Rayhanul Islam <[email protected]>
 Mário Kuka <[email protected]>
 Mariusz Drost <[email protected]>
 Mark Asselstine <[email protected]>
doc/guides/rel_notes/release_26_11.rst +15 -0
index 4b3e5d995c..a752c94bbf 100644
@@ -55,6 +55,21 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added per-device DMA properties to the PCI bus.**
+
+  The Linux PCI bus reads the address translation and the cache coherency
+  of the host bridge above a device from the device tree, and exposes them
+  through ``rte_pci_get_dma_info()`` and ``rte_pci_dma_iova()``.  A driver
+  must set ``RTE_PCI_DRV_DMA_NONCOHERENT`` before the bus gives it a device
+  that needs either.  Devices behind a translating, non-coherent bridge,
+  such as those on the Broadcom BCM2711, can now be used.
+
+* **Added cache maintenance helpers for non-coherent DMA.**
+
+  ``rte_mem_sync_for_device()`` and ``rte_mem_sync_for_cpu()`` hand a buffer
+  between the CPU and a device whose DMA is not coherent with the caches,
+  with an explicit transfer direction.
+
 
 Removed Items
 -------------
drivers/bus/pci/bus_pci_driver.h +2 -0
index c04ebddf59..216e4beb20 100644
@@ -140,6 +140,8 @@ struct rte_pci_driver {
 #define RTE_PCI_DRV_KEEP_MAPPED_RES 0x0020
 /** Device driver needs IOVA as VA and cannot work with IOVA as PA */
 #define RTE_PCI_DRV_NEED_IOVA_AS_VA 0x0040
+/** Driver translates DMA addresses and maintains caches itself. */
+#define RTE_PCI_DRV_DMA_NONCOHERENT 0x0080
 
 /**
  * Register a PCI driver.
drivers/bus/pci/linux/pci.c +6 -0
index 9aae0a5d14..55c989c55d 100644
@@ -220,6 +220,8 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
 	dev = &pdev->device;
 	dev->addr = *addr;
 
+	pci_dt_read_dma_info(dev, dirname);
+
 	/* get vendor id */
 	snprintf(filename, sizeof(filename), "%s/vendor", dirname);
 	if (eal_parse_sysfs_value(filename, &tmp) < 0) {
@@ -335,6 +337,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
 				rte_bus_insert_device(&rte_pci_bus, &dev2->device, &dev->device);
 			} else { /* already registered */
 				if (!rte_dev_is_probed(&dev2->device)) {
+					RTE_PCI_DEVICE_INTERNAL(dev2)->dma = pdev->dma;
 					dev2->kdrv = dev->kdrv;
 					dev2->max_vfs = dev->max_vfs;
 					dev2->id = dev->id;
@@ -591,6 +594,9 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv,
 {
 	enum rte_iova_mode iova_mode = RTE_IOVA_DC;
 
+	if (RTE_PCI_DEVICE_INTERNAL_CONST(pdev)->dma.size != 0)
+		return RTE_IOVA_PA;
+
 	switch (pdev->kdrv) {
 	case RTE_PCI_KDRV_VFIO: {
 		static int is_vfio_noiommu_enabled = -1;
drivers/bus/pci/linux/pci_dma_ranges.c new file +168 -0

168 lines not on this page · raw message

drivers/bus/pci/linux/pci_init.h +2 -0
index 6949dd57d9..fcbf5cdfa2 100644
@@ -73,4 +73,6 @@ int pci_vfio_unmap_resource(struct rte_pci_device *dev);
 
 int pci_vfio_is_enabled(void);
 
+void pci_dt_read_dma_info(struct rte_pci_device *dev, const char *dirname);
+
 #endif /* EAL_PCI_INIT_H_ */
drivers/bus/pci/meson.build +1 -0
index fede114dc7..9e9b27ef4d 100644
@@ -10,6 +10,7 @@ if is_linux
     sources += files(
             'pci_common_uio.c',
             'linux/pci.c',
+            'linux/pci_dma_ranges.c',
             'linux/pci_uio.c',
             'linux/pci_vfio.c',
     )
drivers/bus/pci/pci_common.c +17 -0
index dc8db80d3b..14efb46d23 100644
@@ -142,6 +142,14 @@ pci_unmap_resource(void *requested_addr, size_t size)
 		PCI_LOG(DEBUG, "  PCI memory unmapped at %p", requested_addr);
 }
 
+RTE_EXPORT_INTERNAL_SYMBOL(rte_pci_get_dma_info)
+void
+rte_pci_get_dma_info(const struct rte_pci_device *dev,
+		struct rte_pci_dma_info *info)
+{
+	*info = RTE_PCI_DEVICE_INTERNAL_CONST(dev)->dma;
+}
+
 static bool
 pci_bus_match(const struct rte_driver *drv, const struct rte_device *dev)
 {
@@ -186,6 +194,7 @@ pci_probe_device(struct rte_driver *drv, struct rte_device *dev)
 	struct rte_pci_device *pci_dev = RTE_BUS_DEVICE(dev, *pci_dev);
 	struct rte_pci_driver *pci_drv = RTE_BUS_DRIVER(drv, *pci_drv);
 	struct rte_pci_addr *loc = &pci_dev->addr;
+	const struct rte_pci_dma_info *dma;
 	bool already_probed;
 	int ret;
 
@@ -196,6 +205,14 @@ pci_probe_device(struct rte_driver *drv, struct rte_device *dev)
 	if (pci_dev->device.numa_node < 0 && rte_socket_count() > 1)
 		PCI_LOG(INFO, "Device %s is not NUMA-aware", pci_dev->name);
 
+	dma = &RTE_PCI_DEVICE_INTERNAL(pci_dev)->dma;
+	if (dma->unusable || ((dma->noncoherent || dma->size != 0) &&
+			!(pci_drv->drv_flags & RTE_PCI_DRV_DMA_NONCOHERENT))) {
+		PCI_LOG(ERR, "%s: %s does not handle this device's DMA properties",
+			pci_dev->name, pci_drv->driver.name);
+		return -ENOTSUP;
+	}
+
 	already_probed = (pci_dev->intr_handle != NULL);
 	if (already_probed && !(pci_drv->drv_flags & RTE_PCI_DRV_PROBE_AGAIN)) {
 		PCI_LOG(DEBUG, "Device %s is already probed", pci_dev->device.name);
drivers/bus/pci/private.h +2 -0
index 8103c32881..5a0286dbc0 100644
@@ -13,6 +13,7 @@
 #include <rte_log.h>
 #include <rte_os_shim.h>
 #include <rte_pci.h>
+#include <rte_bus_pci.h>
 
 extern int pci_bus_logtype;
 #define RTE_LOGTYPE_PCI_BUS pci_bus_logtype
@@ -41,6 +42,7 @@ struct rte_pci_region {
 
 struct rte_pci_device_internal {
 	struct rte_pci_device device;
+	struct rte_pci_dma_info dma;
 	/* PCI regions provided by e.g. VFIO. */
 	struct rte_pci_region region[RTE_MAX_PCI_REGIONS];
 };
drivers/bus/pci/rte_bus_pci.h +52 -0

58 lines not on this page · raw message

lib/eal/include/meson.build +1 -0
index aef5824e5f..9eabd91773 100644
@@ -32,6 +32,7 @@ headers += files(
         'rte_lock_annotations.h',
         'rte_malloc.h',
         'rte_mcslock.h',
+        'rte_mem_sync.h',
         'rte_memory.h',
         'rte_memzone.h',
         'rte_pci_dev_feature_defs.h',
lib/eal/include/rte_mem_sync.h new file +133 -0

133 lines not on this page · raw message

Signature · 1 line
2.34.1
#9 lore raw

RFC PATCH 2/2 net/e1000: support non-coherent DMA

In reply to Md Rayhanul Islam

On non-coherent systems the NIC reads stale descriptors and packet data. Seen on a BCM2711 Compute Module 4 with an Intel I210: transmits never completed and received data went to address zero.

Take the DMA context from the bus at probe, keep it in the shared adapter data so secondary processes see it, and install separate TX and RX bursts for such devices. They translate every address against the device window and synchronize buffers and descriptors. Both come from one inlined template with a constant flag, so the coherent datapath is unchanged.

Four descriptors share a cache line. Invalidate a line before writing into it, so cleaning it afterwards keeps the Done bits the NIC wrote on the neighbours; without that a burst loses about three packets of every sixteen. Completion is the Done bit, never the head register, which advances when a descriptor is fetched rather than when its data has been read. Receive descriptors are refilled a whole line at a time, and receive buffers are cleaned before handover and rejected unless they are direct, cache-line aligned and inside the window.

The em driver, which shares net/e1000 with igb, does not set RTE_PCI_DRV_DMA_NONCOHERENT, so on non-coherent systems the PCI bus does not probe em devices; they fail cleanly instead of running with stale DMA.

Tested between two Compute Module 4 boards with Intel I210s: testpmd txonly holds 1.42 Mpps at 1 GbE line rate, and a 512 MB transfer with DPDK at both ends arrives byte-identical.

---
 doc/guides/rel_notes/release_26_11.rst |   5 +
 drivers/net/intel/e1000/e1000_ethdev.h |  19 ++
 drivers/net/intel/e1000/igb_ethdev.c   |   9 +-
 drivers/net/intel/e1000/igb_rxtx.c     | 409 +++++++++++++++++++++++--
 4 files changed, 415 insertions(+), 27 deletions(-)
doc/guides/rel_notes/release_26_11.rst +5 -0
index a752c94bbf..5883f0aeb8 100644
@@ -70,6 +70,11 @@ New Features
   between the CPU and a device whose DMA is not coherent with the caches,
   with an explicit transfer direction.
 
+* **Updated e1000 driver.**
+
+  * Added non-coherent DMA support to ``igb``, through burst functions
+    selected at probe so that coherent platforms are unaffected.
+
 
 Removed Items
 -------------
drivers/net/intel/e1000/e1000_ethdev.h +19 -0
index 0907c7c259..979c661f09 100644
@@ -11,6 +11,8 @@
 #include <rte_flow.h>
 #include <rte_time.h>
 #include <rte_pci.h>
+#include <rte_bus_pci.h>
+#include <rte_mem_sync.h>
 
 #define E1000_INTEL_VENDOR_ID 0x8086
 
@@ -283,6 +285,8 @@ struct e1000_adapter {
 	struct e1000_vf_info    *vfdata;
 	struct e1000_filter_info filter;
 	bool stopped;
+	struct rte_pci_dma_info dma;	/**< DMA window of the bridge above. */
+	bool dma_active;		/**< translate and maintain caches. */
 	struct rte_timecounter  systime_tc;
 	struct rte_timecounter  rx_tstamp_tc;
 	struct rte_timecounter  tx_tstamp_tc;
@@ -428,6 +432,21 @@ int eth_igb_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 
 int eth_igb_tx_done_cleanup(void *txq, uint32_t free_cnt);
 
+int igb_dma_probe(struct rte_eth_dev *dev);
+
+void igb_dma_set_burst(struct rte_eth_dev *dev);
+
+#if defined(RTE_ARCH_ARM64)
+uint16_t eth_igb_recv_pkts_nc(void *rxq, struct rte_mbuf **rx_pkts,
+		uint16_t nb_pkts);
+
+uint16_t eth_igb_recv_scattered_pkts_nc(void *rxq, struct rte_mbuf **rx_pkts,
+		uint16_t nb_pkts);
+
+uint16_t eth_igb_xmit_pkts_nc(void *txq, struct rte_mbuf **tx_pkts,
+		uint16_t nb_pkts);
+#endif
+
 int eth_igb_rx_init(struct rte_eth_dev *dev);
 
 void eth_igb_tx_init(struct rte_eth_dev *dev);
drivers/net/intel/e1000/igb_ethdev.c +8 -1
index 524c030be6..287f2a0105 100644
@@ -809,9 +809,15 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY){
 		if (eth_dev->data->scattered_rx)
 			eth_dev->rx_pkt_burst = &eth_igb_recv_scattered_pkts;
+		igb_dma_set_burst(eth_dev);
 		return 0;
 	}
 
+	error = igb_dma_probe(eth_dev);
+	if (error != 0)
+		return error;
+	igb_dma_set_burst(eth_dev);
+
 	rte_eth_copy_pci_info(eth_dev, pci_dev);
 
 	hw->hw_addr= (void *)pci_dev->mem_resource[0].addr;
@@ -1097,7 +1103,8 @@ static int eth_igb_pci_remove(struct rte_pci_device *pci_dev)
 
 static struct rte_pci_driver rte_igb_pmd = {
 	.id_table = pci_id_igb_map,
-	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
+		RTE_PCI_DRV_DMA_NONCOHERENT,
 	.probe = eth_igb_pci_probe,
 	.remove = eth_igb_pci_remove,
 };
drivers/net/intel/e1000/igb_rxtx.c +383 -26

678 lines not on this page · raw message

Signature · 1 line
2.34.1
#10 lore raw

Re: [RFC PATCH 0/2] per-device DMA properties, with igb as the first user

In reply to Md Rayhanul Islam
Quoted 20 lines · On Fri, 2 Oct 2026 16:09:25 -0400 Md Rayhanul Islam <[email protected]> wrote:

This RFC reworks the BCM2711 DMA fix around a per-device DMA context and an EAL sync API, after the feedback on the first posting [1].

On Raspberry Pi 4 / Compute Module 4 the PCIe host bridge translates DMA addresses and is not cache coherent, so a device such as the Intel I210 cannot DMA at all without both being handled.

What changed since the first posting:

* The translation and the coherency are read per device from its own bridge, not kept as one process-wide offset. EAL no longer rewrites IOVAs; the driver translates where it programs the hardware.
* A driver opts in with RTE_PCI_DRV_DMA_NONCOHERENT, and the bus refuses such a device to any driver that has not. That replaces the refusal written into em by hand.
* The cache maintenance is an experimental EAL interface with explicit directions, and the loops end in DSB SY.
* Completion comes from the Done bits, not the head register.
* Both environment variables are gone.

Quoted 4 lines

Tested between two Compute Module 4 boards with Intel I210s, both running this series: testpmd txonly holds 1.42 Mpps with 64-byte frames, and a 512 MB UDP transfer with DPDK at both ends arrives byte-identical. Built with GCC and with clang 14 -Werror.

More detailed review with AI, I had to direct it to ignore using AF_XDP in this case.

Native PMDs on Raspberry Pi class boards are a reasonable goal, and the analysis of descriptor line sharing is good. Needs rework before a non-RFC version.

Direction
- Split the series: (1) detection and refusing to probe, which is a fix on its own since igb on a CM4 today DMAs to bus address 0; (2) the EAL cache maintenance API; (3) driver support.
- Coherency detection should not depend on the bridge allowlist, only window parsing does. On arm64 DT, no dma-coherent means non-coherent (same as of_dma_is_coherent()). At least warn for any DT host bridge without it.
- igb will not be the last PMD (igc is next). Line ownership rules for rings, mempool validation against the window and burst variant selection belong in common code, not copied per driver.
- An address limit is a property of memory. Enforce it at hugepage allocation (extend rte_mem_set_dma_mask(); a bit mask can't express 3 GB) and keep only the offset add in the datapath.
- Document that this needs uio_pci_generic or vfio-noiommu. VFIO with an IOMMU refuses non-coherent devices.

Translation
- BCM2711 does not translate: pcie0 dma-ranges is 1:1 with a 3 GB limit.
- BCM2712 (Pi 5, CM5) does (PCIe 0x10_0000_0000 maps to CPU 0), but the parser rejects it: 64-bit memory space code, more than one dma-ranges entry (MSI window, plus a 32-bit window on pcie2), and brcm,bcm2712-pcie is not in the table. The offset path has never run.

Bus and EAL
- PCI_LOG uses dev->name before pci_common_set() sets it.
- --iova-mode=va overrides the forced PA. Probe must check rte_eal_iova_mode() == RTE_IOVA_PA.
- The DT walk runs for every PCI device on every platform. Skip it when /sys/firmware/devicetree does not exist.
- rte_pci_dma_info is driver-only API; it goes in bus_pci_driver.h.
- rte_mem_sync.h: arch code goes in lib/eal/arm/include behind a generic/ header. "Empty on coherent platforms" is wrong (it is empty on non-arm64). Read CTR_EL0 once at init, since it can trap. Stride by the CTR_EL0 line size, not RTE_CACHE_LINE_MIN_SIZE. for_cpu is clean+invalidate, so RTE_ASSERT alignment. Add a test in app/test.

igb
- Per-packet validation (igb_tx_pkt_reachable, igb_rx_buf_usable) belongs at queue setup or in tx_prepare. TX silently stops the burst, so retrying applications spin. RX stalls and counts as mbuf allocation failure.
- Context descriptors are written before the segment loop, so their lines are never acquired.
- The acquire narrows the DD loss window but does not close it. Correctness rests on the last_rs fallback; document that.
- last_rs is updated per packet, so the in-burst fallback checks a descriptor not yet posted. Snapshot it at burst entry and reset it in igb_reset_tx_queue().
- The dma_per_line fallback to 1 is dead code, and if ever reached it would reintroduce the bug. Make it an error.
- The new fields at the head of the queue structs push the coherent path's hot fields down. Move them to the end and show pahole.
- TXDCTL: if OR-ing into WTHRESH is wrong, it is wrong on every platform. Fix it separately with a Fixes: tag, and explain forcing wthresh to 0.
- Nits: limits.h and unistd.h are unused, igb_dma_set_burst() in the igbvf path is dead, and the error on 32-bit Arm is misleading.

Testing
- 1.42 Mpps is not 64 byte line rate (1.488). What frame size?
- Need RX and io/mac fwd numbers, runs with checksum, VLAN insert and TSO offloads, and a Pi 5.
- Board RAM size? On a 4 or 8 GB CM4, hugepages can land above 3 GB.