Skip to contentSkip to conversation

drm/amdgpu: immediately use GTT for new allocations

PATCH In review Christian König 2 participants 2 messages Mar 27, 2025

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

PATCH 1/1 drm/amdgpu: immediately use GTT for new allocations

Only use GTT as a fallback if we already have a backing store. This prevents evictions when an application constantly allocates and frees new memory.

Partially fixes
https://gitlab.freedesktop.org/drm/amd/-/issues/3844#note_2833985.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -2
index d09db052e282..d90e9daf5a50 100644
@@ -163,8 +163,8 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
 		 * When GTT is just an alternative to VRAM make sure that we
 		 * only use it as fallback and still try to fill up VRAM first.
 		 */
-		if (domain & abo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM &&
-		    !(adev->flags & AMD_IS_APU))
+		if (abo->tbo.resource && !(adev->flags & AMD_IS_APU) &&
+		    domain & abo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM)
 			places[c].flags |= TTM_PL_FLAG_FALLBACK;
 		c++;
 	}
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Christian König

Only use GTT as a fallback if we already have a backing store. This prevents evictions when an application constantly allocates and frees new memory.

Partially fixes
https://gitlab.freedesktop.org/drm/amd/-/issues/3844#note_2833985.

Fixes 216c1282dde3 ("drm/amdgpu: use GTT only as fallback for VRAM|GTT")
Quoted 23 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -3
index d09db052e282..d90e9daf5a50 100644
@@ -163,8 +163,8 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
                 * When GTT is just an alternative to VRAM make sure that we
                 * only use it as fallback and still try to fill up VRAM first.
                 */
-               if (domain & abo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM &&
-                   !(adev->flags & AMD_IS_APU))
+               if (abo->tbo.resource && !(adev->flags & AMD_IS_APU) &&
+                   domain & abo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM)
                        places[c].flags |= TTM_PL_FLAG_FALLBACK;
                c++;
        }
--

2.34.1