drm/ttm: warn when resv objs are mixed in a bulk_move
authorChristian König <christian.koenig@amd.com>
Tue, 12 Mar 2024 10:37:58 +0000 (11:37 +0100)
committerChristian König <christian.koenig@amd.com>
Wed, 20 Mar 2024 10:18:10 +0000 (11:18 +0100)
The BOs in a bulk move must share all the same reservation object
to make sure that we lock the whole bulk during eviction.

Actually document and enforce that with a warning.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240312105555.3065-1-christian.koenig@amd.com
drivers/gpu/drm/ttm/ttm_resource.c
include/drm/ttm/ttm_resource.h

index 65155f2013ca30fadd01f2d11d7e7335eb4469c0..be8d286513f927d05aebe768e3ea0c53e36d6a27 100644 (file)
@@ -105,6 +105,7 @@ static void ttm_lru_bulk_move_add(struct ttm_lru_bulk_move *bulk,
                pos->first = res;
                pos->last = res;
        } else {
+               WARN_ON(pos->first->bo->base.resv != res->bo->base.resv);
                ttm_lru_bulk_move_pos_tail(pos, res);
        }
 }
index 7561023db43d49a37b9f0eb547262a9c64712268..69769355139f2e1fda723e6dcd286ddef9fe4a4b 100644 (file)
@@ -251,6 +251,9 @@ struct ttm_lru_bulk_move_pos {
  *
  * Container for the current bulk move state. Should be used with
  * ttm_lru_bulk_move_init() and ttm_bo_set_bulk_move().
+ * All BOs in a bulk_move structure need to share the same reservation object to
+ * ensure that the bulk as a whole is locked for eviction even if only one BO of
+ * the bulk is evicted.
  */
 struct ttm_lru_bulk_move {
        struct ttm_lru_bulk_move_pos pos[TTM_NUM_MEM_TYPES][TTM_MAX_BO_PRIORITY];