Skip to contentSkip to conversation

drm/amdgpu: Mask out clear/wipe operation if buffer function is unavailable

PATCH In review Lang Yu 2 participants 2 messages Jun 16, 2025

Subsystems (2)
lore
Share & tools
lore

Lang Yu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Mask out clear/wipe operation if buffer function is unavailable

It makes no sense to use clear/wipe operation if buffer function is unavailable. It's useful in bring up phase when SDMA is not ready and/or disabled intentionally by amdgpu_ip_block_mask. This avoids manually masking out clear/wipe operation repeatedly.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +4 -0
index 3ac52d9b9d30..467c8a1911bc 100644
@@ -689,6 +689,10 @@ 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->mman.buffer_funcs_enabled)
+		bo->flags &= ~(AMDGPU_GEM_CREATE_VRAM_CLEARED |
+			       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.34.1
maintainer
#1 lore raw
Quoted 4 lines · Lang Yu

It makes no sense to use clear/wipe operation if buffer function is unavailable. It's useful in bring up phase when SDMA is not ready and/or disabled intentionally by amdgpu_ip_block_mask. This avoids manually masking out clear/wipe operation repeatedly.

Clear NAK. SDMA can be temporary unavailable during suspend/resume, but that doesn't mean that we can skip that.

Especially ignoring AMDGPU_GEM_CREATE_VRAM_CLEARED will just crash userspace.

Regards,
Christian.

Quoted 21 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +4 -0
index 3ac52d9b9d30..467c8a1911bc 100644
@@ -689,6 +689,10 @@ 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->mman.buffer_funcs_enabled)
+		bo->flags &= ~(AMDGPU_GEM_CREATE_VRAM_CLEARED |
+			       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))