[RFC PATCH 09/18] drm/amdgpu: Don't mark VRAM as a busy placement for VRAM|GTT resources
Friedrich Vock
friedrich.vock at gmx.de
Wed Apr 24 16:56:59 UTC 2024
We will never try evicting things from VRAM for these resources anyway.
This affects TTM buffer uneviction logic, which would otherwise try to
move these buffers into VRAM (clashing with VRAM-only allocations).
Signed-off-by: Friedrich Vock <friedrich.vock at gmx.de>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 5834a95d680d9..85c10d8086188 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -127,6 +127,7 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev);
struct ttm_placement *placement = &abo->placement;
struct ttm_place *places = abo->placements;
+ bool skip_vram_busy = false;
u64 flags = abo->flags;
u32 c = 0;
@@ -156,6 +157,13 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
if (flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)
places[c].flags |= TTM_PL_FLAG_CONTIGUOUS;
c++;
+
+ /*
+ * If GTT is preferred by the buffer as well, don't try VRAM when it's
+ * busy.
+ */
+ if ((domain & abo->preferred_domains) & AMDGPU_GEM_DOMAIN_GTT)
+ skip_vram_busy = true;
}
if (domain & AMDGPU_GEM_DOMAIN_DOORBELL) {
@@ -223,6 +231,11 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
placement->num_busy_placement = c;
placement->busy_placement = places;
+
+ if (skip_vram_busy) {
+ --placement->num_busy_placement;
+ ++placement->busy_placement;
+ }
}
/**
--
2.44.0
More information about the amd-gfx
mailing list