Skip to contentSkip to conversation

drm/amdgpu: disable peer-to-peer access for DCC-enabled GC12 VRAM surfaces

PATCH In review [email protected] 3 participants 3 messages Nov 6, 2025

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

PATCH 1/1 drm/amdgpu: disable peer-to-peer access for DCC-enabled GC12 VRAM surfaces

From: Vitaly Prosyak <[email protected]>

Certain multi-GPU configurations (especially GFX12) may hit data corruption when a DCC-compressed VRAM surface is shared across GPUs using peer-to-peer (P2P) DMA transfers.

Such surfaces rely on device-local metadata and cannot be safely accessed through a remote GPU’s page tables. Attempting to import a DCC-enabled surface through P2P leads to incorrect rendering or GPU faults.

This change disables P2P for DCC-enabled VRAM buffers that are contiguous and allocated on GFX12+ hardware. In these cases, the importer falls back to the standard system-memory path, avoiding invalid access to compressed surfaces.

Future work could consider optional migration (VRAM→System→VRAM) if a performance regression is observed when attach->peer2peer = false.

Tested on:
- Dual RX 9700 XT (Navi4x) setup
- GNOME and Wayland compositor scenarios
- Confirmed no corruption after disabling P2P under these conditions

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +14 -1
index 9a0bce3ba24c..d2d31031f672 100644
@@ -260,11 +260,24 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf,
 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
 
 #ifdef HAVE_STRUCT_DMA_BUF_ATTACH_OPS_ALLOW_PEER2PEER
+	/*
+	 * Disable peer-to-peer access for DCC-enabled VRAM surfaces on GFX12+.
+	 * Such buffers cannot be safely accessed over P2P due to device-local
+	 * compression metadata. Fallback to system-memory path instead.
+	 * Device supports GFX12 (GC 12.x or newer)
+	 * BO was created with the AMDGPU_GEM_CREATE_GFX12_DCC flag
+	 *
+	 */
+	if ((adev->ip_versions[GC_HWIP][0] >= IP_VERSION(12, 0, 0)) &&
+		bo->flags & AMDGPU_GEM_CREATE_GFX12_DCC) {
+		attach->peer2peer = false;
+		goto update_vm;
+	}
 	if (!amdgpu_dmabuf_is_xgmi_accessible(attach_adev, bo) &&
 	    pci_p2pdma_distance(adev->pdev, attach->dev, false) < 0)
 		attach->peer2peer = false;
 #endif
-
+update_vm:
 	amdgpu_vm_bo_update_shared(bo);
 
 	return 0;
Signature · 1 line
2.51.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · On 11/6/25 18:03, [email protected] wrote:

From: Vitaly Prosyak <[email protected]>

Certain multi-GPU configurations (especially GFX12) may hit data corruption when a DCC-compressed VRAM surface is shared across GPUs using peer-to-peer (P2P) DMA transfers.

Such surfaces rely on device-local metadata and cannot be safely accessed through a remote GPU’s page tables. Attempting to import a DCC-enabled surface through P2P leads to incorrect rendering or GPU faults.

This change disables P2P for DCC-enabled VRAM buffers that are contiguous and allocated on GFX12+ hardware. In these cases, the importer falls back to the standard system-memory path, avoiding invalid access to compressed surfaces.

Future work could consider optional migration (VRAM→System→VRAM) if a performance regression is observed when attach->peer2peer = false.

Quoted 7 lines

Tested on:
- Dual RX 9700 XT (Navi4x) setup
- GNOME and Wayland compositor scenarios
- Confirmed no corruption after disabling P2P under these conditions

Quoted 34 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +14 -1
index 9a0bce3ba24c..d2d31031f672 100644
@@ -260,11 +260,24 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf,
 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
 
 #ifdef HAVE_STRUCT_DMA_BUF_ATTACH_OPS_ALLOW_PEER2PEER
+	/*
+	 * Disable peer-to-peer access for DCC-enabled VRAM surfaces on GFX12+.
+	 * Such buffers cannot be safely accessed over P2P due to device-local
+	 * compression metadata. Fallback to system-memory path instead.
+	 * Device supports GFX12 (GC 12.x or newer)
+	 * BO was created with the AMDGPU_GEM_CREATE_GFX12_DCC flag
+	 *
+	 */
+	if ((adev->ip_versions[GC_HWIP][0] >= IP_VERSION(12, 0, 0)) &&
+		bo->flags & AMDGPU_GEM_CREATE_GFX12_DCC) {
+		attach->peer2peer = false;
+		goto update_vm;
+	}
 	if (!amdgpu_dmabuf_is_xgmi_accessible(attach_adev, bo) &&
 	    pci_p2pdma_distance(adev->pdev, attach->dev, false) < 0)
 		attach->peer2peer = false;
 #endif
-
+update_vm:
 	amdgpu_vm_bo_update_shared(bo);
 
 	return 0;
Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 35 lines · On Thu, Nov 6, 2025 at 12:21 PM <[email protected]> wrote:

From: Vitaly Prosyak <[email protected]>

Certain multi-GPU configurations (especially GFX12) may hit data corruption when a DCC-compressed VRAM surface is shared across GPUs using peer-to-peer (P2P) DMA transfers.

Such surfaces rely on device-local metadata and cannot be safely accessed through a remote GPU’s page tables. Attempting to import a DCC-enabled surface through P2P leads to incorrect rendering or GPU faults.

This change disables P2P for DCC-enabled VRAM buffers that are contiguous and allocated on GFX12+ hardware. In these cases, the importer falls back to the standard system-memory path, avoiding invalid access to compressed surfaces.

Future work could consider optional migration (VRAM→System→VRAM) if a performance regression is observed when attach->peer2peer = false.

Tested on:
- Dual RX 9700 XT (Navi4x) setup
- GNOME and Wayland compositor scenarios
- Confirmed no corruption after disabling P2P under these conditions

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +0 -0
index 9a0bce3ba24c..d2d31031f672 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf, · line 262

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +0 -0
@@ -260,11 +260,24 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf,
        struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
 
 #ifdef HAVE_STRUCT_DMA_BUF_ATTACH_OPS_ALLOW_PEER2PEER

This patch is against the DKMS tree, for upstream, please rebase before you commit. With that fixed:

Quoted 25 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +14 -2
+       /*
+        * Disable peer-to-peer access for DCC-enabled VRAM surfaces on GFX12+.
+        * Such buffers cannot be safely accessed over P2P due to device-local
+        * compression metadata. Fallback to system-memory path instead.
+        * Device supports GFX12 (GC 12.x or newer)
+        * BO was created with the AMDGPU_GEM_CREATE_GFX12_DCC flag
+        *
+        */
+       if ((adev->ip_versions[GC_HWIP][0] >= IP_VERSION(12, 0, 0)) &&
+               bo->flags & AMDGPU_GEM_CREATE_GFX12_DCC) {
+               attach->peer2peer = false;
+               goto update_vm;
+       }
        if (!amdgpu_dmabuf_is_xgmi_accessible(attach_adev, bo) &&
            pci_p2pdma_distance(adev->pdev, attach->dev, false) < 0)
                attach->peer2peer = false;
 #endif
-
+update_vm:
        amdgpu_vm_bo_update_shared(bo);
 
        return 0;
--

2.51.2