From: "Christian König" <christian.koenig@amd.com>
To: Philipp Stanner <phasta@kernel.org>,
Sumit Semwal <sumit.semwal@linaro.org>,
Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
Danilo Krummrich <dakr@kernel.org>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dma-buf/dma-fence: Document why signaled-bit is set early
Date: Mon, 26 Oct 2026 11:46:18 +0100 [thread overview]
Message-ID: <1a76be29-7c68-47c9-9c76-443a409db151@amd.com> (raw)
In-Reply-To: <20261023100047.2589846-3-phasta@kernel.org>
On 10/23/26 12:00, Philipp Stanner wrote:
> There have been repeated discussions about why the signaled-bit is set
> before a fence is actually done signaling. Repeatedly, people try to
> change that.
>
> As long as the bit can be read locklessly, for example by
> dma_fence_is_signaled(), the bit cannot be set at any other place.
>
> Document that to reduce further noise about the topic.
>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> I thought that if people repeatedly try to make a change, and it
> repeatedly gets rejected, then we can all save ourselves time and work
> by quickly documenting it :-)
>
> This way, we also remember in 5 years *why* something was or wasn't
> done.
>
> Philipp
> ---
> drivers/dma-buf/dma-fence.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index bd58688b81a7..a71e18a9e346 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -359,6 +359,16 @@ void dma_fence_signal_timestamp_locked(struct dma_fence *fence,
>
> dma_fence_assert_held(fence);
>
> + /*
> + * It would be better to set the bit after the callbacks ran so that the
> + * fast-path-check in dma_fence_is_signaled() cannot return true while
> + * they are running.
> + *
> + * That is, however, impossible because many parties now check for the
> + * signaled-state of a fence in their callbacks (or in the work_items
> + * kicked by them). So we have to keep setting it here as long as the
> + * signaled-bit is read locklessly by anyone.
> + */
> if (unlikely(test_and_set_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
> &fence->flags)))
> return;
>
> base-commit: cf5d8e390e2ac2cfa24a50645efdbb9f0eebe65f
prev parent reply other threads:[~2026-10-26 10:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 10:00 Philipp Stanner
2026-10-26 10:46 ` Christian König [this message]
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=1a76be29-7c68-47c9-9c76-443a409db151@amd.com \
--to=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=phasta@kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tvrtko.ursulin@igalia.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
all inboxes | Powered by JetHome®