All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Yogesh Mohan Marimuthu <yogesh.mohanmarimuthu@amd.com>,
	amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, sukhatri@amd.com
Subject: Re: [PATCH] drm/amdgpu/userq: fix userq_signal_ioctl stuck in drm_exec_until_all_locked()
Date: Mon, 7 Sep 2026 10:53:58 +0200	[thread overview]
Message-ID: <f9e8f8ff-ee5b-42d1-bc80-4ee22e4f3677@amd.com> (raw)
In-Reply-To: <20260907084719.3972-1-yogesh.mohanmarimuthu@amd.com>

On 9/7/26 10:47, Yogesh Mohan Marimuthu wrote:
> If in userq_signal_ioctl only bo_write_handles is passed and
> num_bo_read_handles is zero then if there is contention the code is stuck
> in drm_exec_until_all_locked()
> 
> This happens because read bo's are handled first and then write bo's in
> drm_exec_until_all_locked loop. When there is contention in one of the
> write bo, exec->contended bo is set and the loop is retried, but
> read bo is zero, still drm_exec_retry_on_contention() macro for read bo
> is executed without drm_exec_lock_contended() getting executed.
> drm_exec_retry_on_contention will keep going to beginning of the loop
> causing infinite loop.

Well that is a really good find but clear NAK to the solution.

This if this causes an infinite loop there is a bug somewhere in the drm_exec object.

My educated guess is that drm_exec_prepare_array() needs to call drm_exec_lock_contended() even when num_objects is zero.

Regards,
Christian.

> 
> Fix this by only locking and reserving fence for bo only if there are
> bo passed userq_signal_ioctl.
> 
> Observed this issue when testing with MR
> https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40808
> 
> Signed-off-by: Yogesh Mohan Marimuthu <yogesh.mohanmarimuthu@amd.com>
> ---
>  .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c   | 24 +++++++++++--------
>  1 file changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> index c270635c9..135e77837 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
> @@ -572,17 +572,21 @@ int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data,
>  		      (num_read_bo_handles + num_write_bo_handles));
>  
>  	drm_exec_until_all_locked(&exec) {
> -		r = drm_exec_prepare_array(&exec, gobj_read,
> -					   num_read_bo_handles, 1);
> -		drm_exec_retry_on_contention(&exec);
> -		if (r)
> -			goto exec_fini;
> +		if (num_read_bo_handles) {
> +			r = drm_exec_prepare_array(&exec, gobj_read,
> +						   num_read_bo_handles, 1);
> +			drm_exec_retry_on_contention(&exec);
> +			if (r)
> +				goto exec_fini;
> +		}
>  
> -		r = drm_exec_prepare_array(&exec, gobj_write,
> -					   num_write_bo_handles, 1);
> -		drm_exec_retry_on_contention(&exec);
> -		if (r)
> -			goto exec_fini;
> +		if (num_write_bo_handles) {
> +			r = drm_exec_prepare_array(&exec, gobj_write,
> +						   num_write_bo_handles, 1);
> +			drm_exec_retry_on_contention(&exec);
> +			if (r)
> +				goto exec_fini;
> +		}
>  	}
>  
>  	/* And publish the new fence in the BOs and syncobj */


  reply	other threads:[~2026-09-07  8:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07  8:47 [PATCH] drm/amdgpu/userq: fix userq_signal_ioctl stuck in drm_exec_until_all_locked() Yogesh Mohan Marimuthu
2026-09-07  8:53 ` Christian König [this message]
2026-09-07 14:42   ` Khatri, Sunil
2026-09-07 15:11     ` Christian König
2026-09-07 15:40       ` Khatri, Sunil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f9e8f8ff-ee5b-42d1-bc80-4ee22e4f3677@amd.com \
    --to=christian.koenig@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=sukhatri@amd.com \
    --cc=yogesh.mohanmarimuthu@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.