drm/amdgpu: immediately use GTT for new allocations
authorChristian König <christian.koenig@amd.com>
Thu, 20 Mar 2025 13:46:18 +0000 (14:46 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 7 Apr 2025 18:30:57 +0000 (14:30 -0400)
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.

Signed-off-by: Christian König <christian.koenig@amd.com>
Fixes: 216c1282dde3 ("drm/amdgpu: use GTT only as fallback for VRAM|GTT")
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

index 80cd6f5273db3ab1c5224a5cfbcafdf7c90d7f4c..0b9987781f7622454bfd6db79126b9168d6bb225 100644 (file)
@@ -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++;
        }