drm/amdkfd: reserve a fence slot while locking the BO
Subsystems (3)
PATCH 1/1 drm/amdkfd: reserve a fence slot while locking the BO
Looks like the KFD still needs this.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
@@ -1103,7 +1103,7 @@ static int reserve_bo_and_vm(struct kgd_mem *mem,if (unlikely (ret)) goto error; - ret =drm_exec_lock_obj (&ctx->exec, &bo->tbo.base); + ret =drm_exec_prepare_obj (&ctx->exec, &bo->tbo.base,1 );drm_exec_retry_on_contention (&ctx->exec);if (unlikely (ret)) goto error;
Signature · 1 line
2.34.1
[Public]
________________________________
From: amd-gfx <[email protected]> on behalf of Christian König <[email protected]>
Sent: Friday, October 20, 2023 8:33 AM
To: Shi, Leslie <[email protected]>; Kuehling, Felix <[email protected]>; [email protected] <[email protected]>
Cc: Koenig, Christian <[email protected]>
Subject: [PATCH] drm/amdkfd: reserve a fence slot while locking the BO
Looks like the KFD still needs this.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
@@ -1103,7 +1103,7 @@ static int reserve_bo_and_vm(struct kgd_mem *mem,if (unlikely (ret)) goto error; - ret =drm_exec_lock_obj (&ctx->exec, &bo->tbo.base); + ret =drm_exec_prepare_obj (&ctx->exec, &bo->tbo.base,1 );drm_exec_retry_on_contention (&ctx->exec);if (unlikely (ret)) goto error;
--
2.34.1
Quoted 4 lines · Christian König
Looks like the KFD still needs this.
Signed-off-by Christian König <[email protected]>Fixes 8abc1eb2987a ("drm/amdkfd: switch over to using drm_exec v3")
To fix the immediate problem, this patch is
As I understand it, this reserves a fence slot for adding an eviction fence. I'm not convinced that this is the right place to do this. Not all callers of reserve_bo_and_vm add eviction fences. In another patch series I added the fence slot reservation in a new helper function amdgpu_amdkfd_bo_validate_and_fence.
Taking another step back, as I understand it, the pre-reservation of fence slots is there to avoid late failures after submitting commands to the HW. This isn't really a problem for KFD because eviction fences aren't directly linked to commands submitted to the HW. It's more like a place holder for future user mode submissions. So I think it's OK to reserve the fence slot just before attaching the fence to a BO resv. We don't have to do the pre-reservation here.
Regards,
Felix
Quoted 17 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-1@@ -1103,7 +1103,7 @@ static int reserve_bo_and_vm(struct kgd_mem *mem,if (unlikely (ret)) goto error; - ret =drm_exec_lock_obj (&ctx->exec, &bo->tbo.base); + ret =drm_exec_prepare_obj (&ctx->exec, &bo->tbo.base,1 );drm_exec_retry_on_contention (&ctx->exec);if (unlikely (ret)) goto error;