[PATCH 5/7] drm/ttm: move zombie handling into ttm_bo_evict
Christian König
ckoenig.leichtzumerken at gmail.com
Wed Jul 16 16:04:24 UTC 2025
Both callers do the same thing, so we can trivially unify that.
Signed-off-by: Christian König <christian.koenig at amd.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 2a4b98bfde57..87e81e36bbd4 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -368,6 +368,13 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,
struct ttm_place hop;
int ret = 0;
+ if (ttm_bo_is_zombie(bo)) {
+ ret = ttm_bo_wait_ctx(bo, ctx);
+ if (!ret)
+ ttm_bo_cleanup_memtype_use(bo);
+ return ret;
+ }
+
memset(&hop, 0, sizeof(hop));
dma_resv_assert_held(bo->base.resv);
@@ -475,13 +482,7 @@ int ttm_bo_evict_first(struct ttm_device *bdev, struct ttm_resource_manager *man
if (!bo->resource || bo->resource->mem_type != mem_type)
goto out_bo_moved;
- if (ttm_bo_is_zombie(bo)) {
- ret = ttm_bo_wait_ctx(bo, ctx);
- if (!ret)
- ttm_bo_cleanup_memtype_use(bo);
- } else {
- ret = ttm_bo_evict(bo, ctx);
- }
+ ret = ttm_bo_evict(bo, ctx);
out_bo_moved:
dma_resv_unlock(bo->base.resv);
out_no_lock:
@@ -529,14 +530,7 @@ static s64 ttm_bo_evict_cb(struct ttm_lru_walk *walk, struct ttm_buffer_object *
if (bo->pin_count || !bo->bdev->funcs->eviction_valuable(bo, evict_walk->place))
return 0;
- if (ttm_bo_is_zombie(bo)) {
- lret = ttm_bo_wait_ctx(bo, walk->arg.ctx);
- if (!lret)
- ttm_bo_cleanup_memtype_use(bo);
- } else {
- lret = ttm_bo_evict(bo, walk->arg.ctx);
- }
-
+ lret = ttm_bo_evict(bo, walk->arg.ctx);
if (lret)
goto out;
--
2.43.0
More information about the Intel-xe
mailing list