Skip to contentSkip to conversation

drm/amdgpu: Wipe all VRAM on free when RAS is enabled

PATCH In review Felix Kuehling 2 participants 2 messages Jan 25, 2022 – Jan 26, 2022

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

PATCH 1/1 drm/amdgpu: Wipe all VRAM on free when RAS is enabled

On GPUs with RAS, poison can propagate between processes if VRAM is not cleared when it is freed or allocated. The reason is, that not all write accesses clear RAS poison. 32-byte writes by the SDMA engine do clear RAS poison. Clearing memory in the background when it is freed should avoid major performance impact. KFD has been doing this already for a long time.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -0
index ff9dc377a3a0..36bb41b027ec 100644
@@ -575,6 +575,9 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
 	if (!amdgpu_bo_support_uswc(bo->flags))
 		bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC;
 
+	if (adev->ras_enabled)
+		bo->flags |= AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE;
+
 	bo->tbo.bdev = &adev->mman.bdev;
 	if (bp->domain & (AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA |
 			  AMDGPU_GEM_DOMAIN_GDS))
Signature · 1 line
2.32.0
maintainer
#1 lore raw

Am 25.01.22 um 16:58 schrieb Felix Kuehling:

Quoted 7 lines

On GPUs with RAS, poison can propagate between processes if VRAM is not cleared when it is freed or allocated. The reason is, that not all write accesses clear RAS poison. 32-byte writes by the SDMA engine do clear RAS poison. Clearing memory in the background when it is freed should avoid major performance impact. KFD has been doing this already for a long time.

That looks even better than what I had in mind. Reviewed-by: Christian König <[email protected]>.

Quoted 18 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -0
index ff9dc377a3a0..36bb41b027ec 100644
@@ -575,6 +575,9 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
  	if (!amdgpu_bo_support_uswc(bo->flags))
  		bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC;
 
+	if (adev->ras_enabled)
+		bo->flags |= AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE;
+
  	bo->tbo.bdev = &adev->mman.bdev;
  	if (bp->domain & (AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA |
  			  AMDGPU_GEM_DOMAIN_GDS))