[PATCH 1/8] drm/i915/ttm: fix purge handling in i915_ttm_move()

Matthew Auld matthew.auld at intel.com
Thu Jan 26 10:02:07 UTC 2023


The purge function assumes the object is idle, and therefore doesn't
spawn a ghost object. Otherwise we might see explosions. Also if purge
somehow fails, then we should probably bail, but that should be
extremely rare in practice.

Signed-off-by: Matthew Auld <matthew.auld at intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
index 76dd9e5e1a8b..1d0a9dc12c87 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
@@ -612,9 +612,17 @@ int i915_ttm_move(struct ttm_buffer_object *bo, bool evict,
 		return ret;
 
 	if (obj->mm.madv != I915_MADV_WILLNEED) {
-		i915_ttm_purge(obj);
+		ret = dma_resv_wait_timeout(bo->base.resv,
+					    DMA_RESV_USAGE_BOOKKEEP,
+					    true, MAX_SCHEDULE_TIMEOUT);
+		if (ret < 0)
+			return ret;
+		if (ret == 0)
+			return -EBUSY;
+
+		ret = i915_ttm_purge(obj);
 		ttm_resource_free(bo, &dst_mem);
-		return 0;
+		return ret;
 	}
 
 	/* Populate ttm with pages if needed. Typically system memory. */
-- 
2.39.1



More information about the Intel-gfx-trybot mailing list