[CI 8/8] drm/xe/bo: Allow migrating local bos to TT to make room in VRAM
Thomas Hellström
thomas.hellstrom at linux.intel.com
Wed Mar 20 10:10:20 UTC 2024
If VRAM is full and we want to evict local bos we can't typically
do that, since we require all local bos to be residient at
execution time.
But we're allowed to migrate to TT if that's a valid placement
for GPU access, so in that case, do that.
Fixes: 24f947d58fe5 ("drm/xe: Use DRM GPUVM helpers for external- and evicted objects")
Cc: Thomas Hellström <thomas.hellstrom at linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
Cc: Matthew Brost <matthew.brost at intel.com>
Cc: Lucas De Marchi <lucas.demarchi at intel.com>
Cc: Oded Gabbay <ogabbay at kernel.org>
Signed-off-by: Thomas Hellström <thomas.hellstrom at linux.intel.com>
---
drivers/gpu/drm/xe/xe_bo.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index da1f28224057..bbc926f9b0c4 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -1049,6 +1049,21 @@ static void xe_ttm_bo_delete_mem_notify(struct ttm_buffer_object *ttm_bo)
}
}
+/*
+ * Does @bo have @mem_type as an allowed placement?
+ */
+static bool xe_bo_may_reside_in(const struct xe_bo *bo, unsigned int mem_type)
+{
+ const struct ttm_placement *placement = &bo->placement;
+ unsigned int i;
+
+ for (i = 0; i < placement->num_placement; ++i) {
+ if (placement->placement[i].mem_type == mem_type)
+ return true;
+ }
+ return false;
+}
+
static bool xe_bo_eviction_valuable(struct ttm_buffer_object *ttm_bo,
const struct ttm_place *place)
{
@@ -1062,6 +1077,10 @@ static bool xe_bo_eviction_valuable(struct ttm_buffer_object *ttm_bo,
/* Not bound to the vm? */
if (list_empty(&ttm_bo->base.gpuva.list))
goto allow;
+ /* Is the bo gpu accessible even if placed in TT? */
+ if (ttm_bo->resource && ttm_bo->resource->mem_type !=
+ XE_PL_TT && xe_bo_may_reside_in(xe_bo, XE_PL_TT))
+ goto allow;
return false;
}
}
--
2.44.0
More information about the Intel-xe
mailing list