public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/msm: make sure last_fence is always updated
@ 2025-10-10 14:39 Anna Maniscalco
  2025-10-10 17:30 ` Konrad Dybcio
  2025-10-10 19:09 ` Alexey Minnekhanov
  0 siblings, 2 replies; 5+ messages in thread
From: Anna Maniscalco @ 2025-10-10 14:39 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
	Sean Paul, Marijn Suijten, David Airlie, Simona Vetter,
	Antonino Maniscalco
  Cc: linux-arm-msm, dri-devel, freedreno, linux-kernel,
	Anna Maniscalco

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.

Fixes: 92395af63a99 ("drm/msm: Add VM_BIND submitqueue")
---
Signed-off-by: Anna Maniscalco <anna.maniscalco2000@gmail.com>
---
Changes in v2:
- Only update last_fence on vm_bind path
- Link to v1: https://lore.kernel.org/r/20251010-close_fence_wait_fix-v1-1-fd3e394dcadd@gmail.com
---
 drivers/gpu/drm/msm/msm_gem_submit.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index 3ab3b27134f93b01236fec5833a18a6e2ad2cf5e..75d9f357437006ff261db148901e176eae670d41 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -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,
-- 
Anna Maniscalco <anna.maniscalco2000@gmail.com>


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] drm/msm: make sure last_fence is always updated
  2025-10-10 14:39 [PATCH v2] drm/msm: make sure last_fence is always updated Anna Maniscalco
@ 2025-10-10 17:30 ` Konrad Dybcio
  2025-10-11 13:46   ` Anna Maniscalco
  2025-10-10 19:09 ` Alexey Minnekhanov
  1 sibling, 1 reply; 5+ messages in thread
From: Konrad Dybcio @ 2025-10-10 17:30 UTC (permalink / raw)
  To: Anna Maniscalco, Rob Clark, Dmitry Baryshkov, Abhinav Kumar,
	Jessica Zhang, Sean Paul, Marijn Suijten, David Airlie,
	Simona Vetter, Antonino Maniscalco
  Cc: linux-arm-msm, dri-devel, freedreno, linux-kernel

On 10/10/25 4:39 PM, Anna Maniscalco wrote:
> 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.
> 
> Fixes: 92395af63a99 ("drm/msm: Add VM_BIND submitqueue")
> ---
> Signed-off-by: Anna Maniscalco <anna.maniscalco2000@gmail.com>

Your sign-off will be removed by git, as it appears below the '---' line

Konrad

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] drm/msm: make sure last_fence is always updated
  2025-10-10 14:39 [PATCH v2] drm/msm: make sure last_fence is always updated Anna Maniscalco
  2025-10-10 17:30 ` Konrad Dybcio
@ 2025-10-10 19:09 ` Alexey Minnekhanov
  2025-10-11 13:48   ` Anna Maniscalco
  1 sibling, 1 reply; 5+ messages in thread
From: Alexey Minnekhanov @ 2025-10-10 19:09 UTC (permalink / raw)
  To: Anna Maniscalco, Rob Clark, Dmitry Baryshkov, Abhinav Kumar,
	Jessica Zhang, Sean Paul, Marijn Suijten, David Airlie,
	Simona Vetter, Antonino Maniscalco
  Cc: linux-arm-msm, dri-devel, freedreno, linux-kernel

On 10.10.2025 17:39, Anna Maniscalco wrote:
> 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.
> 
> Fixes: 92395af63a99 ("drm/msm: Add VM_BIND submitqueue")
> ---
> Signed-off-by: Anna Maniscalco <anna.maniscalco2000@gmail.com>
> ---
> Changes in v2:
> - Only update last_fence on vm_bind path
> - Link to v1: https://lore.kernel.org/r/20251010-close_fence_wait_fix-v1-1-fd3e394dcadd@gmail.com
> ---
>   drivers/gpu/drm/msm/msm_gem_submit.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
> index 3ab3b27134f93b01236fec5833a18a6e2ad2cf5e..75d9f357437006ff261db148901e176eae670d41 100644
> --- a/drivers/gpu/drm/msm/msm_gem_submit.c
> +++ b/drivers/gpu/drm/msm/msm_gem_submit.c
> @@ -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,

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] drm/msm: make sure last_fence is always updated
  2025-10-10 17:30 ` Konrad Dybcio
@ 2025-10-11 13:46   ` Anna Maniscalco
  0 siblings, 0 replies; 5+ messages in thread
From: Anna Maniscalco @ 2025-10-11 13:46 UTC (permalink / raw)
  To: Konrad Dybcio, Rob Clark, Dmitry Baryshkov, Abhinav Kumar,
	Jessica Zhang, Sean Paul, Marijn Suijten, David Airlie,
	Simona Vetter, Antonino Maniscalco
  Cc: linux-arm-msm, dri-devel, freedreno, linux-kernel

On 10/10/25 7:30 PM, Konrad Dybcio wrote:
> On 10/10/25 4:39 PM, Anna Maniscalco wrote:
>> 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.
>>
>> Fixes: 92395af63a99 ("drm/msm: Add VM_BIND submitqueue")
>> ---
>> Signed-off-by: Anna Maniscalco <anna.maniscalco2000@gmail.com>
> 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,
-- 
Anna Maniscalco <anna.maniscalco2000@gmail.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] drm/msm: make sure last_fence is always updated
  2025-10-10 19:09 ` Alexey Minnekhanov
@ 2025-10-11 13:48   ` Anna Maniscalco
  0 siblings, 0 replies; 5+ messages in thread
From: Anna Maniscalco @ 2025-10-11 13:48 UTC (permalink / raw)
  To: Alexey Minnekhanov, Rob Clark, Dmitry Baryshkov, Abhinav Kumar,
	Jessica Zhang, Sean Paul, Marijn Suijten, David Airlie,
	Simona Vetter, Antonino Maniscalco
  Cc: linux-arm-msm, dri-devel, freedreno, linux-kernel

On 10/10/25 9:09 PM, Alexey Minnekhanov wrote:
> On 10.10.2025 17:39, Anna Maniscalco wrote:
>> 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.
>>
>> Fixes: 92395af63a99 ("drm/msm: Add VM_BIND submitqueue")
>> ---
>> Signed-off-by: Anna Maniscalco <anna.maniscalco2000@gmail.com>
>> ---
>> Changes in v2:
>> - Only update last_fence on vm_bind path
>> - Link to v1: 
>> https://lore.kernel.org/r/20251010-close_fence_wait_fix-v1-1-fd3e394dcadd@gmail.com
>> ---
>>   drivers/gpu/drm/msm/msm_gem_submit.c | 9 +++++----
>>   1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c 
>> b/drivers/gpu/drm/msm/msm_gem_submit.c
>> index 
>> 3ab3b27134f93b01236fec5833a18a6e2ad2cf5e..75d9f357437006ff261db148901e176eae670d41 
>> 100644
>> --- a/drivers/gpu/drm/msm/msm_gem_submit.c
>> +++ b/drivers/gpu/drm/msm/msm_gem_submit.c
>> @@ -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,
>
> 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
>
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,
-- 
Anna Maniscalco <anna.maniscalco2000@gmail.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-10-11 13:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-10 14:39 [PATCH v2] drm/msm: make sure last_fence is always updated Anna Maniscalco
2025-10-10 17:30 ` Konrad Dybcio
2025-10-11 13:46   ` Anna Maniscalco
2025-10-10 19:09 ` Alexey Minnekhanov
2025-10-11 13:48   ` Anna Maniscalco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox