Skip to contentSkip to conversation

drm/ttm: warn when resv objs are mixed in a bulk_move

PATCH In review Christian König 2 participants 2 messages Mar 12, 2024 – Mar 13, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/ttm: warn when resv objs are mixed in a bulk_move

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.

---
 drivers/gpu/drm/ttm/ttm_resource.c | 1 +
 include/drm/ttm/ttm_resource.h     | 3 +++
 2 files changed, 4 insertions(+)
drivers/gpu/drm/ttm/ttm_resource.c +1 -0
index 65155f2013ca..be8d286513f9 100644
@@ -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);
 	}
 }
include/drm/ttm/ttm_resource.h +3 -0
index 7561023db43d..69769355139f 100644
@@ -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];
Signature · 1 line
2.34.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Christian König

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.

Tested with Xe CI,

Quoted 38 lines

---
 drivers/gpu/drm/ttm/ttm_resource.c | 1 +
 include/drm/ttm/ttm_resource.h     | 3 +++

 2 files changed, 4 insertions(+)
drivers/gpu/drm/ttm/ttm_resource.c +1 -0
index 65155f2013ca..be8d286513f9 100644
@@ -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);

  }
 }

include/drm/ttm/ttm_resource.h +1 -0
index 7561023db43d..69769355139f 100644
@@ -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];