Skip to contentSkip to conversation

drm/ttm: reserve the move fence space first

PATCH NAK Prike Liang 2 participants 2 messages Mar 25, 2025

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

PATCH 1/1 drm/ttm: reserve the move fence space first

Reserve the move fence space before adding the fence to reserve objection.

---
 drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +7 -1
index f9a84d07dcbc..d5eab0078360 100644
@@ -646,9 +646,15 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
 		return ret;
 	}
 
+	ret = dma_resv_reserve_fences(bo->base.resv, 1);
+	if (ret) {
+		pr_err("Resv shared move fence space failed\n");
+		goto err_resv;
+	}
+
 	dma_resv_add_fence(bo->base.resv, fence, DMA_RESV_USAGE_KERNEL);
 
-	ret = dma_resv_reserve_fences(bo->base.resv, 1);
+err_resv:
 	dma_fence_put(fence);
 	return ret;
 }
Signature · 1 line
2.34.1
#1 lore raw

Am 25.03.25 um 07:46 schrieb Prike Liang:

Quoted 2 lines

Reserve the move fence space before adding the fence to reserve objection.

NAK, the caller is doing this. We are just reserving a new slot for the next move here.

Aborting without noting the fence is illegal and would lead to memory corruption.

Regards,
Christian.

Quoted 27 lines
---
 drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +7 -1
index f9a84d07dcbc..d5eab0078360 100644
@@ -646,9 +646,15 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
 		return ret;
 	}
 
+	ret = dma_resv_reserve_fences(bo->base.resv, 1);
+	if (ret) {
+		pr_err("Resv shared move fence space failed\n");
+		goto err_resv;
+	}
+
 	dma_resv_add_fence(bo->base.resv, fence, DMA_RESV_USAGE_KERNEL);
 
-	ret = dma_resv_reserve_fences(bo->base.resv, 1);
+err_resv:
 	dma_fence_put(fence);
 	return ret;
 }