From: Philipp Stanner <phasta@kernel.org>
To: "Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>,
"Danilo Krummrich" <dakr@kernel.org>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Philipp Stanner <phasta@kernel.org>
Subject: [PATCH] dma-buf/dma-fence: Document why signaled-bit is set early
Date: Fri, 23 Oct 2026 12:00:49 +0200 [thread overview]
Message-ID: <20261023100047.2589846-3-phasta@kernel.org> (raw)
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>
---
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
--
2.56.0
reply other threads:[~2026-10-23 10:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261023100047.2589846-3-phasta@kernel.org \
--to=phasta@kernel.org \
--cc=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.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®