Skip to content

Commit 70982ee

Browse files
xinhui panairlied
authored andcommitted
drm/ttm: Fix a deadlock if the target BO is not idle during swap
The ret value might be -EBUSY, caller will think lru lock is still locked but actually NOT. So return -ENOSPC instead. Otherwise we hit list corruption. ttm_bo_cleanup_refs might fail too if BO is not idle. If we return 0, caller(ttm_tt_populate -> ttm_global_swapout ->ttm_device_swapout) will be stuck as we actually did not free any BO memory. This usually happens when the fence is not signaled for a long time. Signed-off-by: xinhui pan <[email protected]> Reviewed-by: Christian König <[email protected]> Fixes: ebd5985 ("drm/ttm: move swapout logic around v3") Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
1 parent b011522 commit 70982ee

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/gpu/drm/ttm/ttm_bo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,9 +1160,9 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,
11601160
}
11611161

11621162
if (bo->deleted) {
1163-
ttm_bo_cleanup_refs(bo, false, false, locked);
1163+
ret = ttm_bo_cleanup_refs(bo, false, false, locked);
11641164
ttm_bo_put(bo);
1165-
return 0;
1165+
return ret == -EBUSY ? -ENOSPC : ret;
11661166
}
11671167

11681168
ttm_bo_del_from_lru(bo);
@@ -1216,7 +1216,7 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,
12161216
if (locked)
12171217
dma_resv_unlock(bo->base.resv);
12181218
ttm_bo_put(bo);
1219-
return ret;
1219+
return ret == -EBUSY ? -ENOSPC : ret;
12201220
}
12211221

12221222
void ttm_bo_tt_destroy(struct ttm_buffer_object *bo)

0 commit comments

Comments
 (0)