Skip to contentSkip to conversation

drm/ttm: Explain why ttm_bo_add_move_fence uses a shared slot

PATCH Applied Daniel Vetter 4 participants 4 messages May 19, 2021 – May 20, 2021

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

PATCH 1/1 drm/ttm: Explain why ttm_bo_add_move_fence uses a shared slot

Motivated because I got confused and Christian confirmed why this works. I think this is non-obvious enough that it merits a slightly longer comment.

Cc Christian König <[email protected]>
Cc Christian Koenig <[email protected]>
Cc Huang Rui <[email protected]>
Cc Thomas Hellström <[email protected]>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +3 -1
index ca1b098b6a56..51a94fd63bd7 100644
@@ -682,7 +682,9 @@ int ttm_mem_evict_first(struct ttm_device *bdev,
 }
 
 /*
- * Add the last move fence to the BO and reserve a new shared slot.
+ * Add the last move fence to the BO and reserve a new shared slot. We only use
+ * a shared slot to avoid unecessary sync and rely on the subsequent bo move to
+ * either stall or use an exclusive fence respectively set bo->moving.
  */
 static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
 				 struct ttm_resource_manager *man,
Signature · 1 line
2.31.0
Reviewed-by on v1 1/1
#1 lore raw

Am 19.05.21 um 10:24 schrieb Daniel Vetter:

Quoted 9 lines

Motivated because I got confused and Christian confirmed why this works. I think this is non-obvious enough that it merits a slightly longer comment.

Cc Christian König <[email protected]>
Cc Christian Koenig <[email protected]>
Cc Huang Rui <[email protected]>
Cc Thomas Hellström <[email protected]>
Quoted 19 lines
---
  drivers/gpu/drm/ttm/ttm_bo.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +3 -1
index ca1b098b6a56..51a94fd63bd7 100644
@@ -682,7 +682,9 @@ int ttm_mem_evict_first(struct ttm_device *bdev,
  }
 
  /*
- * Add the last move fence to the BO and reserve a new shared slot.
+ * Add the last move fence to the BO and reserve a new shared slot. We only use
+ * a shared slot to avoid unecessary sync and rely on the subsequent bo move to
+ * either stall or use an exclusive fence respectively set bo->moving.
   */
  static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
  				 struct ttm_resource_manager *man,
#2 lore raw
Quoted 5 lines · Christian König

Am 19.05.21 um 10:24 schrieb Daniel Vetter:

Quoted 4 lines

Motivated because I got confused and Christian confirmed why this works. I think this is non-obvious enough that it merits a slightly longer comment.

Quoted 7 lines
Quoted 5 lines
Cc Christian König <[email protected]>
Cc Christian Koenig <[email protected]>
Cc Huang Rui <[email protected]>
Cc Thomas Hellström <[email protected]>

Applied to drm-misc-next, thanks for reviewing.
-Daniel

Quoted 20 lines
Quoted 19 lines
---
  drivers/gpu/drm/ttm/ttm_bo.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +3 -1
index ca1b098b6a56..51a94fd63bd7 100644
@@ -682,7 +682,9 @@ int ttm_mem_evict_first(struct ttm_device *bdev,
  }
  /*
- * Add the last move fence to the BO and reserve a new shared slot.
+ * Add the last move fence to the BO and reserve a new shared slot. We only use
+ * a shared slot to avoid unecessary sync and rely on the subsequent bo move to
+ * either stall or use an exclusive fence respectively set bo->moving.
   */
  static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
  				 struct ttm_resource_manager *man,
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Acked-by on v1 1/1
#3 lore raw
In reply to Daniel Vetter
Quoted 9 lines · Daniel Vetter

Motivated because I got confused and Christian confirmed why this works. I think this is non-obvious enough that it merits a slightly longer comment.

Cc Christian König <[email protected]>
Cc Christian Koenig <[email protected]>
Cc Huang Rui <[email protected]>
Cc Thomas Hellström <[email protected]>
Quoted 22 lines
---
 drivers/gpu/drm/ttm/ttm_bo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +3 -1
index ca1b098b6a56..51a94fd63bd7 100644
@@ -682,7 +682,9 @@ int ttm_mem_evict_first(struct ttm_device *bdev,
 }
 
 /*
- * Add the last move fence to the BO and reserve a new shared slot.
+ * Add the last move fence to the BO and reserve a new shared slot. We only use
+ * a shared slot to avoid unecessary sync and rely on the subsequent bo move to
+ * either stall or use an exclusive fence respectively set bo->moving.
  */
 static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
 				 struct ttm_resource_manager *man,
Signature · 1 line
2.31.0