drm/msm: make sure last_fence is always updated
PATCH v2 1/1 drm/msm: make sure last_fence is always updated
Update last_fence in the vm-bind path instead of kernel managed path.
last_fence is used to wait for work to finish in vm_bind contexts but not used for kernel managed contexts.
This fixes a bug where last_fence is not waited on context close leading to faults as resources are freed while in use.
---
---
Changes in v2:
- Only update last_fence on vm_bind path
- Link to v1: https://lore.kernel.org/r/[email protected]
--- drivers/gpu/drm/msm/msm_gem_submit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/msm_gem_submit.c +5 -4
@@ -414,6 +414,11 @@ static void submit_attach_object_fences(struct msm_gem_submit *submit) submit->user_fence,DMA_RESV_USAGE_BOOKKEEP , DMA_RESV_USAGE_BOOKKEEP); + + last_fence = vm->last_fence; + vm->last_fence =dma_fence_unwrap_merge (submit->user_fence, last_fence); +dma_fence_put (last_fence); +return ; }
@@ -427,10 +432,6 @@ static void submit_attach_object_fences(struct msm_gem_submit *submit)dma_resv_add_fence (obj->resv, submit->user_fence,DMA_RESV_USAGE_READ ); } - - last_fence = vm->last_fence; - vm->last_fence =dma_fence_unwrap_merge (submit->user_fence, last_fence); -dma_fence_put (last_fence); } static int submit_bo(struct msm_gem_submit *submit, uint32_t idx,
---
base-commit: b5bad77e1e3c7249e4c0c88f98477e1ee7669b63
change-id: 20251009-close_fence_wait_fix-00e1c2521eee
Best regards,
Signature · 1 line
Anna Maniscalco <[email protected]>
Quoted 11 lines · Anna Maniscalco
Update
last_fencein the vm-bind path instead of kernel managed path.
last_fenceis used to wait for work to finish invm_bindcontexts but not used for kernel managed contexts.This fixes a bug where
last_fenceis not waited on context close leading to faults as resources are freed while in use.Fixes 92395af63a99 ("drm/msm: Add VM_BIND submitqueue")---
Signed-off-by Anna Maniscalco <[email protected]>
Your sign-off will be removed by git, as it appears below the '---' line
Konrad
Quoted 51 lines · Anna Maniscalco
Update
last_fencein the vm-bind path instead of kernel managed path.
last_fenceis used to wait for work to finish invm_bindcontexts but not used for kernel managed contexts.This fixes a bug where
last_fenceis not waited on context close leading to faults as resources are freed while in use.Fixes 92395af63a99 ("drm/msm: Add VM_BIND submitqueue")---
Signed-off-by Anna Maniscalco <[email protected]>---
Changes in v2:
- Only updatelast_fenceonvm_bindpath
- Link to v1: https://lore.kernel.org/r/[email protected]--- drivers/gpu/drm/msm/msm_gem_submit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/msm_gem_submit.c +5
-5@@ -414,6 +414,11 @@ static void submit_attach_object_fences(struct msm_gem_submit *submit) submit->user_fence,DMA_RESV_USAGE_BOOKKEEP , DMA_RESV_USAGE_BOOKKEEP); + + last_fence = vm->last_fence; + vm->last_fence =dma_fence_unwrap_merge (submit->user_fence, last_fence); +dma_fence_put (last_fence); +return ; }@@ -427,10 +432,6 @@ static void submit_attach_object_fences(struct msm_gem_submit *submit)dma_resv_add_fence (obj->resv, submit->user_fence,DMA_RESV_USAGE_READ ); } - - last_fence = vm->last_fence; - vm->last_fence =dma_fence_unwrap_merge (submit->user_fence, last_fence); -dma_fence_put (last_fence); } static int submit_bo(struct msm_gem_submit *submit, uint32_t idx, ---base-commit:
b5bad77e1e3c7249e4c0c88f98477e1ee7669b63
change-id: 20251009-close_fence_wait_fix-00e1c2521eee
Quoted 1 line
Best regards,
Hi!
Since 6.17 I'm seeing gpu faults that were not present in 6.16, they look like [1].
I was hoping this patch can fix it, because faults go away if I comment out put_iova_spaces() inside msm_gem_close(), and this patch mentions close path and faults together, ... but no. Perhaps something else is wrong somewhere?
[1] https://paste.sr.ht/~minlexx/09a9b3d4bfff3e7be3e96cd88fe8cf34621cb655
--
Regards,
Alexey Minnekhanov
Quoted 9 lines · Konrad Dybcio
Quoted 8 lines · Anna Maniscalco
Update
last_fencein the vm-bind path instead of kernel managed path.
last_fenceis used to wait for work to finish invm_bindcontexts but not used for kernel managed contexts.This fixes a bug where
last_fenceis not waited on context close leading to faults as resources are freed while in use.
Quoted 6 lines
Quoted 3 lines
Fixes 92395af63a99 ("drm/msm: Add VM_BIND submitqueue")---
Signed-off-by Anna Maniscalco <[email protected]>Your sign-off will be removed by git, as it appears below the '---' line
Konrad
I sent a v3, thanks for pointing this out
Best regards,
Signature · 1 line
Anna Maniscalco <[email protected]>
Quoted 61 lines · Alexey Minnekhanov
Quoted 49 lines · Anna Maniscalco
Update
last_fencein the vm-bind path instead of kernel managed path.
last_fenceis used to wait for work to finish invm_bindcontexts but not used for kernel managed contexts.This fixes a bug where
last_fenceis not waited on context close leading to faults as resources are freed while in use.Fixes 92395af63a99 ("drm/msm: Add VM_BIND submitqueue")---
Signed-off-by Anna Maniscalco <[email protected]>---
Changes in v2:
- Only updatelast_fenceonvm_bindpath
- Link to v1:
https://lore.kernel.org/r/[email protected]
---
drivers/gpu/drm/msm/msm_gem_submit.c| 9 +++++----1 file changed, 5 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/msm_gem_submit.c +5
-0@@ -414,6 +414,11 @@ static void submit_attach_object_fences(struct msm_gem_submit *submit) submit->user_fence, DMA_RESV_USAGE_BOOKKEEP, DMA_RESV_USAGE_BOOKKEEP); + + last_fence = vm->last_fence; + vm->last_fence = dma_fence_unwrap_merge(submit->user_fence, last_fence); + dma_fence_put(last_fence); + return;}
@@ -427,10 +432,6 @@ static voidsubmit_attach_object_fences(struct msm_gem_submit *submit)dma_resv_add_fence(obj->resv, submit->user_fence, DMA_RESV_USAGE_READ);
}
-
-last_fence=vm->last_fence;
-vm->last_fence= dma_fence_unwrap_merge(submit->user_fence,last_fence);
-dma_fence_put(last_fence);
}
static int submit_bo(structmsm_gem_submit*submit,uint32_tidx,Quoted 5 lines
---
base-commit:b5bad77e1e3c7249e4c0c88f98477e1ee7669b63
change-id: 20251009-close_fence_wait_fix-00e1c2521eeeBest regards,
Hi!
Since 6.17 I'm seeing gpu faults that were not present in 6.16, they look like [1].
Quoted 11 lines
I was hoping this patch can fix it, because faults go away if I comment out
put_iova_spaces()insidemsm_gem_close(), and this patch mentions close path and faults together, ... but no. Perhaps something else is wrong somewhere?[1] https://paste.sr.ht/~minlexx/09a9b3d4bfff3e7be3e96cd88fe8cf34621cb655
Signature · 2 lines
Regards, Alexey Minnekhanov
If that fault appears when closing applications (which sounds likely given your workaround) then yes, this is very much the kind of fault this patch intends to fix.
Might be worth a try with this patch to see if it helps with your case.
Best regards,
Signature · 1 line
Anna Maniscalco <[email protected]>