From: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
To: "Christian König" <christian.koenig@amd.com>,
dri-devel@lists.freedesktop.org
Cc: Sumit Semwal <sumit.semwal@linaro.org>,
Gustavo Padovan <gustavo@padovan.org>,
Matthew Brost <matthew.brost@intel.com>,
Lucas De Marchi <lucas.demarchi@intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
amd-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org, kernel-dev@igalia.com
Subject: Re: [RFC v2 03/13] dma-fence: Use a flag for 64-bit seqnos
Date: Mon, 12 May 2025 10:20:08 +0100 [thread overview]
Message-ID: <24fd309e-fb2e-433b-ad9b-f846f296cd2f@igalia.com> (raw)
In-Reply-To: <48ca64e8-09a8-4321-a84a-e33f2d32e552@amd.com>
On 12/05/2025 09:17, Christian König wrote:
> On 5/9/25 17:33, Tvrtko Ursulin wrote:
>> With the goal of reducing the need for drivers to touch (and dereference)
>> fence->ops, we move the 64-bit seqnos flag from struct dma_fence_ops to
>> the fence->flags.
>>
>> Drivers which were setting this flag are changed to use new
>> dma_fence_init64() instead of dma_fence_init().
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
>
> My idea was to copy the flag from the ops during init, but that should work as well.
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Thanks!
One alternative to dma_fence_init64() I was thinking about is to perhaps
have add dma_fence_init_flags(). Especially in the context of patch 4/13
where it would then look cleaner for callers such as
dma_fence_chain_init(). 4/13 aside, how would dma_fence_init_flags look
to you? It is a little bit more verbose is one thing. And if we are not
doing 4/13, verbosity coupled with a single benefit perhaps it is best
to leave dma_fence_init64() as is?
Regards,
Tvrtko
>> ---
>> drivers/dma-buf/dma-fence-chain.c | 5 ++---
>> drivers/dma-buf/dma-fence.c | 9 +++++++++
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c | 5 ++---
>> include/linux/dma-fence.h | 6 +++++-
>> 4 files changed, 18 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/dma-buf/dma-fence-chain.c b/drivers/dma-buf/dma-fence-chain.c
>> index 90424f23fd73..a8a90acf4f34 100644
>> --- a/drivers/dma-buf/dma-fence-chain.c
>> +++ b/drivers/dma-buf/dma-fence-chain.c
>> @@ -218,7 +218,6 @@ static void dma_fence_chain_set_deadline(struct dma_fence *fence,
>> }
>>
>> const struct dma_fence_ops dma_fence_chain_ops = {
>> - .use_64bit_seqno = true,
>> .get_driver_name = dma_fence_chain_get_driver_name,
>> .get_timeline_name = dma_fence_chain_get_timeline_name,
>> .enable_signaling = dma_fence_chain_enable_signaling,
>> @@ -262,8 +261,8 @@ void dma_fence_chain_init(struct dma_fence_chain *chain,
>> seqno = max(prev->seqno, seqno);
>> }
>>
>> - dma_fence_init(&chain->base, &dma_fence_chain_ops,
>> - &chain->lock, context, seqno);
>> + dma_fence_init64(&chain->base, &dma_fence_chain_ops, &chain->lock,
>> + context, seqno);
>>
>> /*
>> * Chaining dma_fence_chain container together is only allowed through
>> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
>> index f0cdd3e99d36..33661658f684 100644
>> --- a/drivers/dma-buf/dma-fence.c
>> +++ b/drivers/dma-buf/dma-fence.c
>> @@ -1023,3 +1023,12 @@ dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>> trace_dma_fence_init(fence);
>> }
>> EXPORT_SYMBOL(dma_fence_init);
>> +
>> +void
>> +dma_fence_init64(struct dma_fence *fence, const struct dma_fence_ops *ops,
>> + spinlock_t *lock, u64 context, u64 seqno)
>> +{
>> + dma_fence_init(fence, ops, lock, context, seqno);
>> + __set_bit(DMA_FENCE_FLAG_SEQNO64_BIT, &fence->flags);
>> +}
>> +EXPORT_SYMBOL(dma_fence_init64);
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c
>> index 51cddfa3f1e8..5d26797356a3 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c
>> @@ -71,7 +71,6 @@ static void amdgpu_tlb_fence_work(struct work_struct *work)
>> }
>>
>> static const struct dma_fence_ops amdgpu_tlb_fence_ops = {
>> - .use_64bit_seqno = true,
>> .get_driver_name = amdgpu_tlb_fence_get_driver_name,
>> .get_timeline_name = amdgpu_tlb_fence_get_timeline_name
>> };
>> @@ -101,8 +100,8 @@ void amdgpu_vm_tlb_fence_create(struct amdgpu_device *adev, struct amdgpu_vm *vm
>> INIT_WORK(&f->work, amdgpu_tlb_fence_work);
>> spin_lock_init(&f->lock);
>>
>> - dma_fence_init(&f->base, &amdgpu_tlb_fence_ops, &f->lock,
>> - vm->tlb_fence_context, atomic64_read(&vm->tlb_seq));
>> + dma_fence_init64(&f->base, &amdgpu_tlb_fence_ops, &f->lock,
>> + vm->tlb_fence_context, atomic64_read(&vm->tlb_seq));
>>
>> /* TODO: We probably need a separate wq here */
>> dma_fence_get(&f->base);
>> diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
>> index 48b5202c531d..ac6535716dbe 100644
>> --- a/include/linux/dma-fence.h
>> +++ b/include/linux/dma-fence.h
>> @@ -97,6 +97,7 @@ struct dma_fence {
>> };
>>
>> enum dma_fence_flag_bits {
>> + DMA_FENCE_FLAG_SEQNO64_BIT,
>> DMA_FENCE_FLAG_SIGNALED_BIT,
>> DMA_FENCE_FLAG_TIMESTAMP_BIT,
>> DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
>> @@ -262,6 +263,9 @@ struct dma_fence_ops {
>> void dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>> spinlock_t *lock, u64 context, u64 seqno);
>>
>> +void dma_fence_init64(struct dma_fence *fence, const struct dma_fence_ops *ops,
>> + spinlock_t *lock, u64 context, u64 seqno);
>> +
>> void dma_fence_release(struct kref *kref);
>> void dma_fence_free(struct dma_fence *fence);
>> void dma_fence_describe(struct dma_fence *fence, struct seq_file *seq);
>> @@ -454,7 +458,7 @@ static inline bool __dma_fence_is_later(struct dma_fence *fence, u64 f1, u64 f2)
>> * 32bit sequence numbers. Use a 64bit compare when the driver says to
>> * do so.
>> */
>> - if (fence->ops->use_64bit_seqno)
>> + if (test_bit(DMA_FENCE_FLAG_SEQNO64_BIT, &fence->flags))
>> return f1 > f2;
>>
>> return (int)(lower_32_bits(f1) - lower_32_bits(f2)) > 0;
>
next prev parent reply other threads:[~2025-05-12 9:20 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-09 15:33 [RFC v2 00/13] Some (drm_sched_|dma_)fence lifetime issues Tvrtko Ursulin
2025-05-09 15:33 ` [RFC v2 01/13] drm/i915: Use provided dma_fence_is_chain Tvrtko Ursulin
2025-05-09 15:47 ` Matthew Brost
2025-05-12 8:05 ` Christian König
2025-05-12 8:11 ` Tvrtko Ursulin
2025-05-09 15:33 ` [RFC v2 02/13] dma-fence: Change signature of __dma_fence_is_later Tvrtko Ursulin
2025-05-12 8:13 ` Christian König
2025-05-09 15:33 ` [RFC v2 03/13] dma-fence: Use a flag for 64-bit seqnos Tvrtko Ursulin
2025-05-12 8:12 ` Tvrtko Ursulin
2025-05-12 8:17 ` Christian König
2025-05-12 9:20 ` Tvrtko Ursulin [this message]
2025-05-09 15:33 ` [RFC v2 04/13] dma-fence: Move array and chain checks to flags Tvrtko Ursulin
2025-05-12 8:19 ` Christian König
2025-05-12 9:14 ` Tvrtko Ursulin
2025-05-12 17:57 ` Christian König
2025-05-09 15:33 ` [RFC v2 05/13] dma-fence: Add helpers for accessing driver and timeline name Tvrtko Ursulin
2025-05-12 8:20 ` Christian König
2025-05-09 15:33 ` [RFC v2 06/13] dma-fence: Use driver and timeline name helpers internally Tvrtko Ursulin
2025-05-12 8:22 ` Christian König
2025-05-12 9:05 ` Tvrtko Ursulin
2025-05-09 15:33 ` [RFC v2 07/13] sync_file: Use dma-fence driver and timeline name helpers Tvrtko Ursulin
2025-05-12 8:25 ` Christian König
2025-05-09 15:33 ` [RFC v2 08/13] drm/amdgpu: " Tvrtko Ursulin
2025-05-12 8:27 ` Christian König
2025-05-12 9:07 ` Tvrtko Ursulin
2025-05-09 15:33 ` [RFC v2 09/13] drm/i915: " Tvrtko Ursulin
2025-05-12 8:28 ` Christian König
2025-05-09 15:33 ` [RFC v2 10/13] dma-fence: Add safe access helpers and document the rules Tvrtko Ursulin
2025-05-13 14:16 ` Rob Clark
2025-05-14 10:01 ` Tvrtko Ursulin
2025-05-14 13:57 ` Rob Clark
2025-05-14 14:58 ` Tvrtko Ursulin
2025-05-14 15:38 ` Rob Clark
2025-05-09 15:33 ` [RFC v2 11/13] sync_file: Protect access to driver and timeline name Tvrtko Ursulin
2025-05-09 15:33 ` [RFC v2 12/13] drm/i915: " Tvrtko Ursulin
2025-05-09 15:33 ` [RFC v2 13/13] drm/xe: Make dma-fences compliant with the safe access rules Tvrtko Ursulin
2025-05-12 14:11 ` Matthew Brost
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=24fd309e-fb2e-433b-ad9b-f846f296cd2f@igalia.com \
--to=tvrtko.ursulin@igalia.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gustavo@padovan.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=kernel-dev@igalia.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=matthew.brost@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=sumit.semwal@linaro.org \
/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