mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Tvrtko Ursulin <tursulin@ursulin.net>,
	Philipp Stanner <phasta@kernel.org>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Gustavo Padovan <gustavo@padovan.org>,
	Daniel Almeida <daniel.almeida@collabora.com>
Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] dma-buf/dma-fence: Unify return codes for signalled fences
Date: Tue, 25 Nov 2025 14:30:52 +0100	[thread overview]
Message-ID: <914ba746-c32f-405b-97fd-d61dfa9073c3@amd.com> (raw)
In-Reply-To: <44d30056-612f-4563-ad9f-92696c5a803a@ursulin.net>

On 11/25/25 14:20, Tvrtko Ursulin wrote:
> On 25/11/2025 10:44, Philipp Stanner wrote:
>> Almost all users of dma_fence_signal() ignore the return code which
>> would indicate that the fence was already signaled. The same return code
>> by dma_fence_add_callback() cannot be ignored, however, because it's
>> needed to detect races.
>>
>> For an already signaled fence, dma_fence_signal() returns -EINVAL,
>> whereas dma_fence_add_callback() returns -ENOENT.
>>
>> Unify the error codes by having dma_fence_signal() return -ENOENT, too.
>>
>> Signed-off-by: Philipp Stanner <phasta@kernel.org>
>> ---
>>   drivers/dma-buf/dma-fence.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
>> index 3a48896ded62..09d97624e647 100644
>> --- a/drivers/dma-buf/dma-fence.c
>> +++ b/drivers/dma-buf/dma-fence.c
>> @@ -373,7 +373,7 @@ int dma_fence_signal_timestamp_locked(struct dma_fence *fence,
>>       lockdep_assert_held(fence->lock);
>>         if (unlikely(__dma_fence_is_signaled(fence)))
>> -        return -EINVAL;
>> +        return -ENOENT;
>>         /* Stash the cb_list before replacing it with the timestamp */
>>       list_replace(&fence->cb_list, &cb_list);
> 
> Story checks out AFAICT - only two callers fetch the error, xe and kfd, and neither does anything with it. So I'd say it makes sense to unify the errno.

To be honest it rather sounds like removing the error code is the right thing to do.

IIRC the policy was initially that drivers should signal a fence only once and when they do it multiple times then that is an error.

But we quickly found that with opportunistically checking that this policy is actually not helpful and dropped it.

The error return code here is basically just a leftover from this policy and not useful as far as I can see.

Regards,
Christian. 

> 
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
> 
> Regards,
> 
> Tvrtko
> 
> P.S. Just not sure of the 1/2 on which this one ends depending on. I *think* I suggested the helper in the context of some discussion long long time ago but what it was? And what about all the drivers which look at the signaled bit directly?


  parent reply	other threads:[~2025-11-25 13:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-25 10:44 [PATCH 1/2] dma-buf: Add __dma_fence_is_signaled() Philipp Stanner
2025-11-25 10:44 ` [PATCH 2/2] dma-buf/dma-fence: Unify return codes for signalled fences Philipp Stanner
2025-11-25 13:20   ` Tvrtko Ursulin
2025-11-25 13:28     ` Philipp Stanner
2025-11-25 13:30     ` Christian König [this message]
2025-11-25 13:35 ` [PATCH 1/2] dma-buf: Add __dma_fence_is_signaled() Christian König
2025-12-01 15:46 ` Steven Price
2025-12-01 15:48   ` Philipp Stanner
2025-12-09 15:45 ` kernel test robot

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=914ba746-c32f-405b-97fd-d61dfa9073c3@amd.com \
    --to=christian.koenig@amd.com \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo@padovan.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=phasta@kernel.org \
    --cc=sumit.semwal@linaro.org \
    --cc=tursulin@ursulin.net \
    /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

all inboxes | Powered by JetHome®