AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: "Khatri, Sunil" <sukhatri@amd.com>,
	Sunil Khatri <sunil.khatri@amd.com>,
	Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [Patch v1 1/4] drm/amdgpu/userq: no need to use local variable ret
Date: Thu, 26 Mar 2026 13:52:13 +0100	[thread overview]
Message-ID: <e6d580ff-0ca3-4043-8e60-454254633998@amd.com> (raw)
In-Reply-To: <e477110b-f1c2-4a5b-980c-be2d7e8cd6ae@amd.com>



On 3/26/26 13:26, Khatri, Sunil wrote:
> 
> On 26-03-2026 05:38 pm, Christian König wrote:
>> On 3/26/26 09:55, Sunil Khatri wrote:
>>> In function amdgpu_userq_evict use the function return
>>> value in the if condition instead.
>>>
>>> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
>>> ---
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 8 ++------
>>>  1 file changed, 2 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
>>> index aa0e6eea9436..2a1832fce6d2 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
>>> @@ -1308,17 +1308,13 @@ void
>>>  amdgpu_userq_evict(struct amdgpu_userq_mgr *uq_mgr)
>>>  {
>>>  	struct amdgpu_device *adev = uq_mgr->adev;
>>> -	int ret;
>>>  
>>>  	/* Wait for any pending userqueue fence work to finish */
>>> -	ret = amdgpu_userq_wait_for_signal(uq_mgr);
>>> -	if (ret)
>>> +	if (amdgpu_userq_wait_for_signal(uq_mgr))
>>>  		dev_err(adev->dev, "Not evicting userqueue, timeout waiting for work\n");
>> That actually looks like a pretty bad idea. Instead we should start printing the error code.
> Sure could add an error code in the logging.
>> But before we do that I would rather like to know why amdgpu_userq_wait_for_signal() can fail?
> dma_fence_wait_timeout is what could fail and we are returning -ETIMEDOUT. We could totally avoid checking for the error here completely as we are already printing the error in
> the called function below.
> ret=dma_fence_wait_timeout(f, true, msecs_to_jiffies(100));

*sigh* I explicitly NAKed that timeout before. Please change that to the maximum.

Additional to that please drop the extra call to dma_fence_is_signaled() before the wait, such stuff is completely superfluous.

Then the second parameter to dma_fence_wait_timeout should be false, this way we can't be interrupted any more and don't need to check the return value for errors.

Thanks for take a look at that,
Christian.

>                 if(ret<=0) {
>                         drm_file_err(uq_mgr->file, "Timed out waiting for fence=%llu:%llu\n",
>                                      f->context, f->seqno);
>         return-ETIMEDOUT;
>                 }
>> That should never happen in the first place.
>>
>> Regards,
>> Christian.
>>
>>>  
>>> -	ret = amdgpu_userq_evict_all(uq_mgr);
>>> -	if (ret)
>>> +	if (amdgpu_userq_evict_all(uq_mgr))
>>>  		dev_err(adev->dev, "Failed to evict userqueue\n");
> Here also the below function returns error and printing error too. We could avoid the return value here too as we are already printing the error.
> amdgpu_userq_preempt_helper(queue);
>                 if(r)
>                         ret=r;
> 
> 
> Regards
> Sunil Khatri
> 
>>> -
>>>  }
>>>  
>>>  int amdgpu_userq_mgr_init(struct amdgpu_userq_mgr *userq_mgr, struct drm_file *file_priv,


  reply	other threads:[~2026-03-26 12:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-26  8:55 [Patch v1 0/4] Bunch of patches to do trivial clean up and Sunil Khatri
2026-03-26  8:55 ` [Patch v1 1/4] drm/amdgpu/userq: no need to use local variable ret Sunil Khatri
2026-03-26 12:08   ` Christian König
2026-03-26 12:26     ` Khatri, Sunil
2026-03-26 12:52       ` Christian König [this message]
2026-03-26  8:55 ` [Patch v1 2/4] drm/amdgpu/userq: no need to use local variable here for return Sunil Khatri
2026-03-26 12:09   ` Christian König
2026-03-26 12:30     ` Khatri, Sunil
2026-03-26 12:55       ` Christian König
2026-03-26  8:56 ` [Patch v1 3/4] " Sunil Khatri
2026-03-26 12:11   ` Christian König
2026-03-26 12:32     ` Khatri, Sunil
2026-03-26  8:56 ` [Patch v1 4/4] drm/amdgpu/userq: Fix the code alignment for readability Sunil Khatri
2026-03-26 12:12   ` Christian König

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=e6d580ff-0ca3-4043-8e60-454254633998@amd.com \
    --to=christian.koenig@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=sukhatri@amd.com \
    --cc=sunil.khatri@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox