Skip to contentSkip to conversation

net/mlx5: Declare no DMA segment boundary restriction

PATCH Applied Tariq Toukan 4 participants 8 messages Nov 20 – Nov 25

Subsystems (4)
lore
Share & tools
lore

Tariq Toukan

author maintainer
#0 lore raw

cover net/mlx5: Declare no DMA segment boundary restriction

Hi,

This series by Yishai declares that the mlx5 devices have no DMA segment boundary restriction.

Regards,
Tariq

Yishai Hadas (2):
net/mlx5: Declare no DMA segment boundary restriction net/mlx5: Declare no DMA segment boundary for data direct device

 drivers/net/ethernet/mellanox/mlx5/core/data_direct.c | 1 +
 drivers/net/ethernet/mellanox/mlx5/core/main.c        | 1 +
 2 files changed, 2 insertions(+)

base-commit: 2208ab00f4f213ade91ab775e7f8c4dacdcc856e

Signature · 1 line
2.44.0
author maintainer
#1 lore raw

PATCH 1/2 net/mlx5: Declare no DMA segment boundary restriction

From: Yishai Hadas <[email protected]>

The PCI core initialises every PCI device with a DMA segment boundary mask of 0xffffffff in pci_device_add(), which forbids any segment from crossing a 4GB-aligned address regardless of its length. mlx5_core raises the default maximum segment size to 2GB but never overrides the boundary, although the device has no such limitation.

Consumers such as ib_umem_get() coalesce physically contiguous pages up to the maximum segment size without consulting the boundary mask. Registering a large MR can therefore produce a segment that crosses a 4GB-aligned address, which the DMA API debug checker reports:

DMA-API: mlx5_core 0000:08:00.0: mapping sg segment across boundary [start=0x00000002ffe27000] [end=0x000000030020efff] [boundary=0x00000000ffffffff]

The segment is about 4MB long, well below the 2GB maximum, but it spans the 12GB (0x300000000) boundary: the upper halves of start and end are 0x2 and 0x3.

Set the segment boundary mask to ULONG_MAX so the DMA constraints declared for the device match what the hardware supports.

---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/main.c +1 -0
index 079e91c98041..b3f4d319d29e 100644
@@ -190,6 +190,7 @@ static int set_dma_caps(struct pci_dev *pdev)
 	}
 
 	dma_set_max_seg_size(&pdev->dev, 2u * 1024 * 1024 * 1024);
+	dma_set_seg_boundary(&pdev->dev, ULONG_MAX);
 	return err;
 }
 
Signature · 1 line
2.44.0
#2 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 21 lines

From: Yishai Hadas <[email protected]>

The PCI core initialises every PCI device with a DMA segment boundary mask of 0xffffffff in pci_device_add(), which forbids any segment from crossing a 4GB-aligned address regardless of its length. mlx5_core raises the default maximum segment size to 2GB but never overrides the boundary, although the device has no such limitation.

Consumers such as ib_umem_get() coalesce physically contiguous pages up to the maximum segment size without consulting the boundary mask. Registering a large MR can therefore produce a segment that crosses a 4GB-aligned address, which the DMA API debug checker reports:

DMA-API: mlx5_core 0000:08:00.0: mapping sg segment across boundary [start=0x00000002ffe27000] [end=0x000000030020efff] [boundary=0x00000000ffffffff]

The segment is about 4MB long, well below the 2GB maximum, but it spans the 12GB (0x300000000) boundary: the upper halves of start and end are 0x2 and 0x3.

Quoted 6 lines

Set the segment boundary mask to ULONG_MAX so the DMA constraints declared for the device match what the hardware supports.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Reviewed-by on v1 1/2
#3 lore raw
In reply to Tariq Toukan
Quoted 21 lines

From: Yishai Hadas <[email protected]>

The PCI core initialises every PCI device with a DMA segment boundary mask of 0xffffffff in pci_device_add(), which forbids any segment from crossing a 4GB-aligned address regardless of its length. mlx5_core raises the default maximum segment size to 2GB but never overrides the boundary, although the device has no such limitation.

Consumers such as ib_umem_get() coalesce physically contiguous pages up to the maximum segment size without consulting the boundary mask. Registering a large MR can therefore produce a segment that crosses a 4GB-aligned address, which the DMA API debug checker reports:

DMA-API: mlx5_core 0000:08:00.0: mapping sg segment across boundary [start=0x00000002ffe27000] [end=0x000000030020efff] [boundary=0x00000000ffffffff]

The segment is about 4MB long, well below the 2GB maximum, but it spans the 12GB (0x300000000) boundary: the upper halves of start and end are 0x2 and 0x3.

Quoted 6 lines

Set the segment boundary mask to ULONG_MAX so the DMA constraints declared for the device match what the hardware supports.

author maintainer
#4 lore raw

PATCH 2/2 net/mlx5: Declare no DMA segment boundary for data direct device

In reply to Tariq Toukan

From: Yishai Hadas <[email protected]>

The PCI core initialises every PCI device with a DMA segment boundary mask of 0xffffffff in pci_device_add(), which forbids any segment from crossing a 4GB-aligned address regardless of its length. The data direct device raises the default maximum segment size to 2GB but keeps that boundary, although it has no such limitation.

Declare that explicitly, in line with mlx5_core, to avoid a mismatch between the declared constraints and the hardware capabilities.

---
 drivers/net/ethernet/mellanox/mlx5/core/data_direct.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/data_direct.c +1 -0
index 5afb11a2a9f0..73eef8bbc327 100644
@@ -103,6 +103,7 @@ static int mlx5_data_direct_set_dma_caps(struct pci_dev *pdev)
 	}
 
 	dma_set_max_seg_size(&pdev->dev, SZ_2G);
+	dma_set_seg_boundary(&pdev->dev, ULONG_MAX);
 	return 0;
 }
 
Signature · 1 line
2.44.0
#5 lore raw

Re: [PATCH net-next 2/2] net/mlx5: Declare no DMA segment boundary for data direct device

Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

From: Yishai Hadas <[email protected]>

The PCI core initialises every PCI device with a DMA segment boundary mask of 0xffffffff in pci_device_add(), which forbids any segment from crossing a 4GB-aligned address regardless of its length. The data direct device raises the default maximum segment size to 2GB but keeps that boundary, although it has no such limitation.

Quoted 6 lines

Declare that explicitly, in line with mlx5_core, to avoid a mismatch between the declared constraints and the hardware capabilities.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH net-next 2/2] net/mlx5: Declare no DMA segment boundary for data direct device

In reply to Tariq Toukan
Quoted 8 lines

From: Yishai Hadas <[email protected]>

The PCI core initialises every PCI device with a DMA segment boundary mask of 0xffffffff in pci_device_add(), which forbids any segment from crossing a 4GB-aligned address regardless of its length. The data direct device raises the default maximum segment size to 2GB but keeps that boundary, although it has no such limitation.

Quoted 6 lines

Declare that explicitly, in line with mlx5_core, to avoid a mismatch between the declared constraints and the hardware capabilities.

#7 lore raw
In reply to Tariq Toukan
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 9 lines · On Fri, 20 Nov 2026 10:18:17 +0200 you wrote:

Hi,

This series by Yishai declares that the mlx5 devices have no DMA segment boundary restriction.

Regards,
Tariq

[...]

Here is the summary with links:
- [net-next,1/2] net/mlx5: Declare no DMA segment boundary restriction

    https://git.kernel.org/netdev/net-next/c/0ef669aa10e6
  - [net-next,2/2] net/mlx5: Declare no DMA segment boundary for data direct device
    https://git.kernel.org/netdev/net-next/c/7e25d974eb36

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html