diff mbox series

drm/ttm: reserve the move fence space first

Message ID 20250325064622.1627619-1-Prike.Liang@amd.com (mailing list archive)
State New
Headers show
Series drm/ttm: reserve the move fence space first | expand

Commit Message

Prike Liang March 25, 2025, 6:46 a.m. UTC
Reserve the move fence space before adding the fence
to reserve objection.

Signed-off-by: Prike Liang <Prike.Liang@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Christian König March 25, 2025, 8:55 a.m. UTC | #1
Am 25.03.25 um 07:46 schrieb Prike Liang:
> 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.

>
> Signed-off-by: Prike Liang <Prike.Liang@amd.com>
> ---
>  drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index f9a84d07dcbc..d5eab0078360 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -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;
>  }
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index f9a84d07dcbc..d5eab0078360 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -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;
 }