The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH V1] accel/amdxdna: Use mmput_async() in the job run error path
@ 2026-12-01 18:20 Lizhi Hou
  2026-12-01 18:35 ` Max Zhen
  0 siblings, 1 reply; 2+ messages in thread
From: Lizhi Hou @ 2026-12-01 18:20 UTC (permalink / raw)
  To: ogabbay, quic_jhugo, dri-devel, mario.limonciello,
	karol.wachowski, max.zhen
  Cc: Lizhi Hou, linux-kernel, sonal.santan

aie2_sched_job_run() runs from the DRM scheduler worker, not from the
submitting process, and the job only holds an mmgrab() reference to the
address space. If the process exits after the mmget_not_zero() at the
top of the function, the mmput() in the error path drops the last
mm_users reference and calls __mmput() -> exit_mmap() ->
mmu_notifier_release(), which invokes amdxdna_hmm_invalidate().

That handler waits with MAX_SCHEDULE_TIMEOUT for the fences of the BO.
The fence attached to the BO reservation object is the finished fence of
this very job, which the scheduler only signals once run_job() has
returned. The scheduler worker therefore blocks forever waiting for a
fence that only it can cause to be signalled, and stalls every other
context sharing the scheduler work queue.

Use mmput_async() so that the address space teardown is deferred and
run_job() can return.

Calling mmput_async() after aie2_job_put() is safe today because the
submit reference is still held until aie2_sched_job_free(). Swapping
the two lines makes it easier to read.

Fixes: aac243092b70 ("accel/amdxdna: Add command execution")
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
---
 drivers/accel/amdxdna/aie2_ctx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c
index 582e171b5fd7..0a6be8ba8e3c 100644
--- a/drivers/accel/amdxdna/aie2_ctx.c
+++ b/drivers/accel/amdxdna/aie2_ctx.c
@@ -453,8 +453,8 @@ aie2_sched_job_run(struct drm_sched_job *sched_job)
 	if (ret) {
 		amdxdna_io_stats_job_done(job->hwctx->client);
 		dma_fence_put(job->fence);
+		mmput_async(job->mm);
 		aie2_job_put(job);
-		mmput(job->mm);
 		fence = ERR_PTR(ret);
 	} else {
 		/*
-- 
2.34.1


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

* Re: [PATCH V1] accel/amdxdna: Use mmput_async() in the job run error path
  2026-12-01 18:20 [PATCH V1] accel/amdxdna: Use mmput_async() in the job run error path Lizhi Hou
@ 2026-12-01 18:35 ` Max Zhen
  0 siblings, 0 replies; 2+ messages in thread
From: Max Zhen @ 2026-12-01 18:35 UTC (permalink / raw)
  To: Lizhi Hou, ogabbay, quic_jhugo, dri-devel, mario.limonciello,
	karol.wachowski
  Cc: linux-kernel, sonal.santan



On 12/1/2026 Tue 10:20, Lizhi Hou wrote:
> aie2_sched_job_run() runs from the DRM scheduler worker, not from the
> submitting process, and the job only holds an mmgrab() reference to the
> address space. If the process exits after the mmget_not_zero() at the
> top of the function, the mmput() in the error path drops the last
> mm_users reference and calls __mmput() -> exit_mmap() ->
> mmu_notifier_release(), which invokes amdxdna_hmm_invalidate().
> 
> That handler waits with MAX_SCHEDULE_TIMEOUT for the fences of the BO.
> The fence attached to the BO reservation object is the finished fence of
> this very job, which the scheduler only signals once run_job() has
> returned. The scheduler worker therefore blocks forever waiting for a
> fence that only it can cause to be signalled, and stalls every other
> context sharing the scheduler work queue.
> 
> Use mmput_async() so that the address space teardown is deferred and
> run_job() can return.
> 
> Calling mmput_async() after aie2_job_put() is safe today because the
> submit reference is still held until aie2_sched_job_free(). Swapping
> the two lines makes it easier to read.
> 
> Fixes: aac243092b70 ("accel/amdxdna: Add command execution")
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Reviewed-by: Max Zhen <max.zhen@amd.com>
> ---
>   drivers/accel/amdxdna/aie2_ctx.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c
> index 582e171b5fd7..0a6be8ba8e3c 100644
> --- a/drivers/accel/amdxdna/aie2_ctx.c
> +++ b/drivers/accel/amdxdna/aie2_ctx.c
> @@ -453,8 +453,8 @@ aie2_sched_job_run(struct drm_sched_job *sched_job)
>   	if (ret) {
>   		amdxdna_io_stats_job_done(job->hwctx->client);
>   		dma_fence_put(job->fence);
> +		mmput_async(job->mm);
>   		aie2_job_put(job);
> -		mmput(job->mm);
>   		fence = ERR_PTR(ret);
>   	} else {
>   		/*


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

end of thread, other threads:[~2026-12-01 18:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 18:20 [PATCH V1] accel/amdxdna: Use mmput_async() in the job run error path Lizhi Hou
2026-12-01 18:35 ` Max Zhen

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