* [PATCH 0/3] dma-buf: dma-fence: Remove dma_fence_init64()
@ 2026-11-05 11:35 Philipp Stanner
2026-11-05 11:35 ` [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init() Philipp Stanner
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Philipp Stanner @ 2026-11-05 11:35 UTC (permalink / raw)
To: Min Ma, Lizhi Hou, Oded Gabbay, Rob Herring (Arm), Tomeu Vizoso,
Karol Wachowski, Andrzej Kacprowski, Heiko Stuebner, Sumit Semwal,
Christian König, Philipp Stanner, Felix Kuehling,
Alex Deucher, David Airlie, Simona Vetter, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Lucas Stach, Russell King,
Christian Gmeiner, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, Alessio Belle, Luigi Santivetti, Qiang Yu,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, Lyude Paul, Danilo Krummrich,
Boris Brezillon, Steven Price, Adrián Larumbe, Liviu Dudau,
Dave Airlie, Gerd Hoffmann, Matthew Brost, Natalie Vock,
Arun Pravin, Matthew Auld, Thomas Hellström, Melissa Wen,
Maíra Canal, Dave Stevenson, Raspberry Pi Kernel Maintenance,
Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, Zack Rusin,
Broadcom internal kernel review list, Thierry Reding,
Mikko Perttunen, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Neill Kapron, Greg Kroah-Hartman, Alice Ryhl,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Daniel Almeida,
Tamir Duberstein, Alexandre Courbot, Onur Özkan,
Sunil Khatri, Prike Liang, Vitaly Prosyak, Jesse Zhang,
Timur Kristóf, Srinivasan Shanmugam, David Rosca,
Marco Crivellari, Krzysztof Karas, Andi Shyti, Janusz Krzysztofik,
Shixiong Ou, Jouni Högander, Joel Fernandes,
Thadeu Lima de Souza Cascardo, Pierre-Eric Pelloux-Prayer,
Al Viro, Michael Bommarito, Sam Day, Gabriel Prostitis
Cc: dri-devel, linux-kernel, linux-media, amd-gfx, etnaviv, intel-gfx,
imagination, lima, linux-arm-msm, freedreno, nouveau,
virtualization, spice-devel, intel-xe, linux-tegra, linux-iio,
linux-usb, rust-for-linux
We recently had a discussion about reworking dma_fence init to close a
race-window [1].
The community agreement seems to have been that we can get rid of
dma_fence_init64(), so let's do that already. In the meantime we can
continue our discussions regarding the race in [1].
This also touches the Rust dma_fence, which actually should use 64-bit
seqnos (was forgotten so far). Rust fence has no users currently, so
needs no backporting, so I would like to address that in a distinct
patch.
Tested on Nouveau with and without the SEQNO64 flag. Nouveau also uses
the USER flag, so I hope we're fine.
P.
[1] https://lore.kernel.org/dri-devel/20261029095542.1526750-3-phasta@kernel.org/
Philipp Stanner (3):
dma-buf: dma-fence: Add flags parameter to dma_fence_init()
dma-buf: Port users of dma_fence_init64()
dma-buf: dma-fence: Remove dma_fence_init64()
drivers/accel/amdxdna/amdxdna_ctx.c | 2 +-
drivers/accel/ethosu/ethosu_job.c | 2 +-
drivers/accel/ivpu/ivpu_job.c | 2 +-
drivers/accel/rocket/rocket_job.c | 2 +-
drivers/dma-buf/dma-fence-array.c | 2 +-
drivers/dma-buf/dma-fence-chain.c | 4 +-
drivers/dma-buf/dma-fence.c | 58 +++++++++----------
drivers/dma-buf/st-dma-fence-chain.c | 2 +-
drivers/dma-buf/st-dma-fence-unwrap.c | 2 +-
drivers/dma-buf/st-dma-fence.c | 2 +-
drivers/dma-buf/st-dma-resv.c | 2 +-
drivers/dma-buf/sw_sync.c | 2 +-
.../gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c | 2 +-
.../drm/amd/amdgpu/amdgpu_eviction_fence.c | 7 ++-
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +-
.../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 5 +-
.../gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c | 5 +-
drivers/gpu/drm/drm_crtc.c | 2 +-
drivers/gpu/drm/drm_writeback.c | 2 +-
drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 +-
drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 2 +-
drivers/gpu/drm/i915/i915_request.c | 2 +-
drivers/gpu/drm/i915/i915_sw_fence_work.c | 2 +-
drivers/gpu/drm/i915/i915_vma_resource.c | 2 +-
.../gpu/drm/i915/selftests/i915_sw_fence.c | 2 +-
drivers/gpu/drm/imagination/pvr_ccb.c | 2 +-
drivers/gpu/drm/imagination/pvr_queue.c | 2 +-
drivers/gpu/drm/lima/lima_sched.c | 2 +-
drivers/gpu/drm/msm/msm_fence.c | 2 +-
drivers/gpu/drm/nouveau/nouveau_fence.c | 4 +-
drivers/gpu/drm/panfrost/panfrost_job.c | 2 +-
drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
drivers/gpu/drm/qxl/qxl_release.c | 2 +-
drivers/gpu/drm/radeon/radeon_fence.c | 2 +-
drivers/gpu/drm/scheduler/sched_fence.c | 4 +-
.../gpu/drm/scheduler/tests/mock_scheduler.c | 2 +-
drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 2 +-
.../gpu/drm/ttm/tests/ttm_bo_validate_test.c | 2 +-
drivers/gpu/drm/v3d/v3d_fence.c | 2 +-
drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
drivers/gpu/drm/vgem/vgem_fence.c | 2 +-
drivers/gpu/drm/virtio/virtgpu_fence.c | 2 +-
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +-
drivers/gpu/drm/xe/xe_hw_fence.c | 2 +-
drivers/gpu/drm/xe/xe_oa.c | 2 +-
drivers/gpu/drm/xe/xe_preempt_fence.c | 2 +-
drivers/gpu/drm/xe/xe_tlb_inval.c | 2 +-
drivers/gpu/host1x/fence.c | 2 +-
drivers/iio/industrialio-buffer.c | 2 +-
drivers/usb/gadget/function/f_fs.c | 2 +-
include/linux/dma-fence.h | 14 +++--
rust/kernel/dma_buf/dma_fence.rs | 2 +-
52 files changed, 95 insertions(+), 94 deletions(-)
base-commit: 8258a37702b9b9cf27f5c0ea07625e3e6bd74f5a
--
2.56.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init()
2026-11-05 11:35 [PATCH 0/3] dma-buf: dma-fence: Remove dma_fence_init64() Philipp Stanner
@ 2026-11-05 11:35 ` Philipp Stanner
2026-11-05 11:54 ` sashiko-bot
2026-11-05 12:06 ` Tvrtko Ursulin
2026-11-05 11:35 ` [PATCH 2/3] dma-buf: Port users of dma_fence_init64() Philipp Stanner
` (2 subsequent siblings)
3 siblings, 2 replies; 14+ messages in thread
From: Philipp Stanner @ 2026-11-05 11:35 UTC (permalink / raw)
To: Min Ma, Lizhi Hou, Oded Gabbay, Rob Herring (Arm), Tomeu Vizoso,
Karol Wachowski, Andrzej Kacprowski, Heiko Stuebner, Sumit Semwal,
Christian König, Philipp Stanner, Felix Kuehling,
Alex Deucher, David Airlie, Simona Vetter, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Lucas Stach, Russell King,
Christian Gmeiner, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, Alessio Belle, Luigi Santivetti, Qiang Yu,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, Lyude Paul, Danilo Krummrich,
Boris Brezillon, Steven Price, Adrián Larumbe, Liviu Dudau,
Dave Airlie, Gerd Hoffmann, Matthew Brost, Natalie Vock,
Arun Pravin, Matthew Auld, Thomas Hellström, Melissa Wen,
Maíra Canal, Dave Stevenson, Raspberry Pi Kernel Maintenance,
Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, Zack Rusin,
Broadcom internal kernel review list, Thierry Reding,
Mikko Perttunen, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Neill Kapron, Greg Kroah-Hartman, Alice Ryhl,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Daniel Almeida,
Tamir Duberstein, Alexandre Courbot, Onur Özkan,
Sunil Khatri, Prike Liang, Vitaly Prosyak, Jesse Zhang,
Timur Kristóf, Srinivasan Shanmugam, David Rosca,
Marco Crivellari, Krzysztof Karas, Andi Shyti, Janusz Krzysztofik,
Shixiong Ou, Jouni Högander, Joel Fernandes,
Thadeu Lima de Souza Cascardo, Pierre-Eric Pelloux-Prayer,
Al Viro, Michael Bommarito, Sam Day, Gabriel Prostitis
Cc: dri-devel, linux-kernel, linux-media, amd-gfx, etnaviv, intel-gfx,
imagination, lima, linux-arm-msm, freedreno, nouveau,
virtualization, spice-devel, intel-xe, linux-tegra, linux-iio,
linux-usb, rust-for-linux
Currently, there are two init functions for dma_fence, dma_fence_init()
and dma_fence_init64().
Since more future user options for dma_fence initialization would
require distinct init functions, too, it is better to do this in a
unified way.
Add a flags field to dma_fence_init(). Adjust all affected drivers,
preserving the old behavior.
Support the SEQNO64 flag, and add a check-function so that the user only
sets valid bits.
Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
drivers/accel/amdxdna/amdxdna_ctx.c | 2 +-
drivers/accel/ethosu/ethosu_job.c | 2 +-
drivers/accel/ivpu/ivpu_job.c | 2 +-
drivers/accel/rocket/rocket_job.c | 2 +-
drivers/dma-buf/dma-fence-array.c | 2 +-
drivers/dma-buf/dma-fence.c | 31 ++++++++++++++++---
drivers/dma-buf/st-dma-fence-chain.c | 2 +-
drivers/dma-buf/st-dma-fence-unwrap.c | 2 +-
drivers/dma-buf/st-dma-fence.c | 2 +-
drivers/dma-buf/st-dma-resv.c | 2 +-
drivers/dma-buf/sw_sync.c | 2 +-
.../gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c | 2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +-
drivers/gpu/drm/drm_crtc.c | 2 +-
drivers/gpu/drm/drm_writeback.c | 2 +-
drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 +-
drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 2 +-
drivers/gpu/drm/i915/i915_request.c | 2 +-
drivers/gpu/drm/i915/i915_sw_fence_work.c | 2 +-
drivers/gpu/drm/i915/i915_vma_resource.c | 2 +-
.../gpu/drm/i915/selftests/i915_sw_fence.c | 2 +-
drivers/gpu/drm/imagination/pvr_ccb.c | 2 +-
drivers/gpu/drm/imagination/pvr_queue.c | 2 +-
drivers/gpu/drm/lima/lima_sched.c | 2 +-
drivers/gpu/drm/msm/msm_fence.c | 2 +-
drivers/gpu/drm/nouveau/nouveau_fence.c | 4 +--
drivers/gpu/drm/panfrost/panfrost_job.c | 2 +-
drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
drivers/gpu/drm/qxl/qxl_release.c | 2 +-
drivers/gpu/drm/radeon/radeon_fence.c | 2 +-
drivers/gpu/drm/scheduler/sched_fence.c | 4 +--
.../gpu/drm/scheduler/tests/mock_scheduler.c | 2 +-
drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 2 +-
.../gpu/drm/ttm/tests/ttm_bo_validate_test.c | 2 +-
drivers/gpu/drm/v3d/v3d_fence.c | 2 +-
drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
drivers/gpu/drm/vgem/vgem_fence.c | 2 +-
drivers/gpu/drm/virtio/virtgpu_fence.c | 2 +-
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +-
drivers/gpu/drm/xe/xe_hw_fence.c | 2 +-
drivers/gpu/drm/xe/xe_oa.c | 2 +-
drivers/gpu/drm/xe/xe_preempt_fence.c | 2 +-
drivers/gpu/drm/xe/xe_tlb_inval.c | 2 +-
drivers/gpu/host1x/fence.c | 2 +-
drivers/iio/industrialio-buffer.c | 2 +-
drivers/usb/gadget/function/f_fs.c | 2 +-
include/linux/dma-fence.h | 12 +++++--
rust/kernel/dma_buf/dma_fence.rs | 2 +-
48 files changed, 83 insertions(+), 56 deletions(-)
diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/amdxdna_ctx.c
index f4004630dc1b..f2245541f1ee 100644
--- a/drivers/accel/amdxdna/amdxdna_ctx.c
+++ b/drivers/accel/amdxdna/amdxdna_ctx.c
@@ -53,7 +53,7 @@ static struct dma_fence *amdxdna_fence_create(struct amdxdna_hwctx *hwctx)
spin_lock_init(&fence->lock);
/* Unique timeline context prevents eviction from shared BO reservation. */
- dma_fence_init(&fence->base, &fence_ops, &fence->lock, dma_fence_context_alloc(1), 0);
+ dma_fence_init(&fence->base, &fence_ops, &fence->lock, dma_fence_context_alloc(1), 0, 0);
return &fence->base;
}
diff --git a/drivers/accel/ethosu/ethosu_job.c b/drivers/accel/ethosu/ethosu_job.c
index d656b3ec670e..d4fc71436cae 100644
--- a/drivers/accel/ethosu/ethosu_job.c
+++ b/drivers/accel/ethosu/ethosu_job.c
@@ -219,7 +219,7 @@ static struct dma_fence *ethosu_job_run(struct drm_sched_job *sched_job)
return NULL;
dma_fence_init(fence, ðosu_fence_ops, &dev->fence_lock,
- dev->fence_context, ++dev->emit_seqno);
+ dev->fence_context, ++dev->emit_seqno, 0);
dma_fence_get(fence);
ethosu_switch_perfmon(dev, job);
diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c
index 76bacabe496b..6b4f059fb209 100644
--- a/drivers/accel/ivpu/ivpu_job.c
+++ b/drivers/accel/ivpu/ivpu_job.c
@@ -519,7 +519,7 @@ static struct dma_fence *ivpu_fence_create(struct ivpu_device *vdev)
fence->vdev = vdev;
spin_lock_init(&fence->lock);
- dma_fence_init(&fence->base, &ivpu_fence_ops, &fence->lock, dma_fence_context_alloc(1), 1);
+ dma_fence_init(&fence->base, &ivpu_fence_ops, &fence->lock, dma_fence_context_alloc(1), 1, 0);
return &fence->base;
}
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index b2a00992c889..574c9ea802c9 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -61,7 +61,7 @@ static struct dma_fence *rocket_fence_create(struct rocket_core *core)
return ERR_PTR(-ENOMEM);
dma_fence_init(fence, &rocket_fence_ops, &core->fence_lock,
- core->fence_context, ++core->emit_seqno);
+ core->fence_context, ++core->emit_seqno, 0);
return fence;
}
diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
index 5e10e8df372f..e2dddbfddea2 100644
--- a/drivers/dma-buf/dma-fence-array.c
+++ b/drivers/dma-buf/dma-fence-array.c
@@ -205,7 +205,7 @@ void dma_fence_array_init(struct dma_fence_array *array,
array->num_fences = num_fences;
dma_fence_init(&array->base, &dma_fence_array_ops, NULL, context,
- seqno);
+ seqno, 0);
init_irq_work(&array->work, irq_dma_fence_array_work);
/*
diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index bd58688b81a7..a511cf755ee8 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -122,7 +122,7 @@ static const struct dma_fence_ops dma_fence_stub_ops = {
static int __init dma_fence_init_stub(void)
{
- dma_fence_init(&dma_fence_stub, &dma_fence_stub_ops, NULL, 0, 0);
+ dma_fence_init(&dma_fence_stub, &dma_fence_stub_ops, NULL, 0, 0, 0);
set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
&dma_fence_stub.flags);
dma_fence_signal(&dma_fence_stub);
@@ -156,7 +156,7 @@ struct dma_fence *dma_fence_allocate_private_stub(ktime_t timestamp)
if (fence == NULL)
return NULL;
- dma_fence_init(fence, &dma_fence_stub_ops, NULL, 0, 0);
+ dma_fence_init(fence, &dma_fence_stub_ops, NULL, 0, 0, 0);
set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
&fence->flags);
@@ -1063,7 +1063,6 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
spinlock_t *lock, u64 context, u64 seqno, unsigned long flags)
{
BUG_ON(!ops || !ops->get_driver_name || !ops->get_timeline_name);
-
kref_init(&fence->refcount);
/*
* While it is counter intuitive to protect a constant function pointer
@@ -1087,6 +1086,21 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
trace_dma_fence_init(fence);
}
+static bool dma_fence_flags_invalid(unsigned long flags)
+{
+ const unsigned long valid_fence_bits =
+ BIT(DMA_FENCE_FLAG_SEQNO64_BIT);
+ const unsigned long valid_user_bits =
+ GENMASK(
+ BITS_PER_TYPE(unsigned long) - 1,
+ DMA_FENCE_FLAG_USER_BITS
+ );
+ const unsigned long invalid_bits =
+ ~(valid_fence_bits | valid_user_bits);
+
+ return flags & invalid_bits;
+}
+
/**
* dma_fence_init - Initialize a custom fence.
* @fence: the fence to initialize
@@ -1094,6 +1108,7 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
* @lock: optional irqsafe spinlock to use for locking this fence
* @context: the execution context this fence is run on
* @seqno: a linear increasing sequence number for this context
+ * @flags: flags modifying a fence's behavior
*
* Initializes an allocated fence, the caller doesn't have to keep its
* refcount after committing with this fence, but it will need to hold a
@@ -1108,12 +1123,18 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
* introduction of the callback, but the external lock is still around. New
* users MUST NOT use external locks, as they force the issuer to outlive all
* fences that reference the lock.
+ *
+ * The @flags you can specify here are either DMA_FENCE_FLAG_SEQNO64_BIT or
+ * user-specified bits >= DMA_FENCE_FLAG_USER_BITS.
*/
void
dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
- spinlock_t *lock, u64 context, u64 seqno)
+ spinlock_t *lock, u64 context, u64 seqno,
+ unsigned long flags)
{
- __dma_fence_init(fence, ops, lock, context, seqno, 0UL);
+ WARN_ON(dma_fence_flags_invalid(flags));
+
+ __dma_fence_init(fence, ops, lock, context, seqno, flags);
}
EXPORT_SYMBOL(dma_fence_init);
diff --git a/drivers/dma-buf/st-dma-fence-chain.c b/drivers/dma-buf/st-dma-fence-chain.c
index e0d9b69bfa76..b9610df3ff19 100644
--- a/drivers/dma-buf/st-dma-fence-chain.c
+++ b/drivers/dma-buf/st-dma-fence-chain.c
@@ -52,7 +52,7 @@ static struct dma_fence *mock_fence(void)
return NULL;
spin_lock_init(&f->lock);
- dma_fence_init(&f->base, &mock_ops, &f->lock, 0, 0);
+ dma_fence_init(&f->base, &mock_ops, &f->lock, 0, 0, 0);
return &f->base;
}
diff --git a/drivers/dma-buf/st-dma-fence-unwrap.c b/drivers/dma-buf/st-dma-fence-unwrap.c
index c5353b36f0e4..dbebc3046d42 100644
--- a/drivers/dma-buf/st-dma-fence-unwrap.c
+++ b/drivers/dma-buf/st-dma-fence-unwrap.c
@@ -36,7 +36,7 @@ static struct dma_fence *__mock_fence(u64 context, u64 seqno)
return NULL;
spin_lock_init(&f->lock);
- dma_fence_init(&f->base, &mock_ops, &f->lock, context, seqno);
+ dma_fence_init(&f->base, &mock_ops, &f->lock, context, seqno, 0);
return &f->base;
}
diff --git a/drivers/dma-buf/st-dma-fence.c b/drivers/dma-buf/st-dma-fence.c
index cb62e606d0a2..b3f88e89cc44 100644
--- a/drivers/dma-buf/st-dma-fence.c
+++ b/drivers/dma-buf/st-dma-fence.c
@@ -31,7 +31,7 @@ static struct dma_fence *mock_fence(void)
if (!f)
return NULL;
- dma_fence_init(f, &mock_ops, NULL, 0, 0);
+ dma_fence_init(f, &mock_ops, NULL, 0, 0, 0);
return f;
}
diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c
index 0b96136bbd54..c3a920ab3fcf 100644
--- a/drivers/dma-buf/st-dma-resv.c
+++ b/drivers/dma-buf/st-dma-resv.c
@@ -35,7 +35,7 @@ static struct dma_fence *alloc_fence(void)
if (!f)
return NULL;
- dma_fence_init(f, &fence_ops, &fence_lock, 0, 0);
+ dma_fence_init(f, &fence_ops, &fence_lock, 0, 0, 0);
return f;
}
diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
index 8df20b0218a9..ce43af7e735e 100644
--- a/drivers/dma-buf/sw_sync.c
+++ b/drivers/dma-buf/sw_sync.c
@@ -258,7 +258,7 @@ static struct sync_pt *sync_pt_create(struct sync_timeline *obj,
sync_timeline_get(obj);
dma_fence_init(&pt->base, &timeline_fence_ops, &obj->lock,
- obj->context, value);
+ obj->context, value, 0);
INIT_LIST_HEAD(&pt->link);
spin_lock_irq(&obj->lock);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c
index 9b10d015671c..30ccdb3e0b47 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c
@@ -77,7 +77,7 @@ struct amdgpu_amdkfd_fence *amdgpu_amdkfd_fence_create(u64 context,
spin_lock_init(&fence->lock);
fence->context_id = context_id;
dma_fence_init(&fence->base, &amdkfd_fence_ops, &fence->lock,
- context, atomic_inc_return(&fence_seq));
+ context, atomic_inc_return(&fence_seq), 0);
return fence;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index bff2d38f3571..03e1974f8dda 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -112,7 +112,7 @@ void amdgpu_fence_emit(struct amdgpu_ring *ring, struct amdgpu_fence *af,
seq = ++ring->fence_drv.sync_seq;
dma_fence_init(fence, &amdgpu_fence_ops,
&ring->fence_drv.lock,
- adev->fence_context + ring->idx, seq);
+ adev->fence_context + ring->idx, seq, 0);
amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,
seq, flags | AMDGPU_FENCE_FLAG_INT);
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 63ead8ba6756..92641bc0a378 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -190,7 +190,7 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)
return NULL;
dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock,
- crtc->fence_context, ++crtc->fence_seqno);
+ crtc->fence_context, ++crtc->fence_seqno, 0);
return fence;
}
diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c
index b4a002e6d043..64b06b890f19 100644
--- a/drivers/gpu/drm/drm_writeback.c
+++ b/drivers/gpu/drm/drm_writeback.c
@@ -592,7 +592,7 @@ drm_writeback_get_out_fence(struct drm_writeback_connector *wb_connector)
dma_fence_init(fence, &drm_writeback_fence_ops,
&wb_connector->fence_lock, wb_connector->fence_context,
- ++wb_connector->fence_seqno);
+ ++wb_connector->fence_seqno, 0);
return fence;
}
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index e75dab5e407d..a10e4e4cf372 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1199,7 +1199,7 @@ static struct dma_fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu)
f->gpu = gpu;
dma_fence_init(&f->base, &etnaviv_fence_ops, &gpu->fence_spinlock,
- gpu->fence_context, ++gpu->next_fence);
+ gpu->fence_context, ++gpu->next_fence, 0);
return &f->base;
}
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
index 56489cc127d6..ffaa70191f27 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
@@ -437,7 +437,7 @@ i915_ttm_memcpy_work_arm(struct i915_ttm_memcpy_work *work,
int ret;
spin_lock_init(&work->lock);
- dma_fence_init(&work->fence, &dma_fence_memcpy_ops, &work->lock, 0, 0);
+ dma_fence_init(&work->fence, &dma_fence_memcpy_ops, &work->lock, 0, 0, 0);
dma_fence_get(&work->fence);
ret = dma_fence_add_callback(dep, &work->cb, __memcpy_cb);
if (ret) {
diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index f66f8efc7062..0f4fc9cc0033 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -953,7 +953,7 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp)
goto err_free;
dma_fence_init(&rq->fence, &i915_fence_ops, &rq->lock,
- tl->fence_context, seqno);
+ tl->fence_context, seqno, 0);
RCU_INIT_POINTER(rq->timeline, tl);
rq->hwsp_seqno = tl->hwsp_seqno;
diff --git a/drivers/gpu/drm/i915/i915_sw_fence_work.c b/drivers/gpu/drm/i915/i915_sw_fence_work.c
index 366418108f78..4cd44dd26e35 100644
--- a/drivers/gpu/drm/i915/i915_sw_fence_work.c
+++ b/drivers/gpu/drm/i915/i915_sw_fence_work.c
@@ -85,7 +85,7 @@ void dma_fence_work_init(struct dma_fence_work *f,
{
f->ops = ops;
spin_lock_init(&f->lock);
- dma_fence_init(&f->dma, &fence_ops, &f->lock, 0, 0);
+ dma_fence_init(&f->dma, &fence_ops, &f->lock, 0, 0, 0);
i915_sw_fence_init(&f->chain, fence_notify);
INIT_WORK(&f->work, fence_work);
}
diff --git a/drivers/gpu/drm/i915/i915_vma_resource.c b/drivers/gpu/drm/i915/i915_vma_resource.c
index a8f2112ce81f..19596410e32f 100644
--- a/drivers/gpu/drm/i915/i915_vma_resource.c
+++ b/drivers/gpu/drm/i915/i915_vma_resource.c
@@ -263,7 +263,7 @@ void __i915_vma_resource_init(struct i915_vma_resource *vma_res)
{
spin_lock_init(&vma_res->lock);
dma_fence_init(&vma_res->unbind_fence, &unbind_fence_ops,
- &vma_res->lock, 0, 0);
+ &vma_res->lock, 0, 0, 0);
refcount_set(&vma_res->hold_count, 1);
i915_sw_fence_init(&vma_res->chain, i915_vma_resource_fence_notify);
}
diff --git a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
index ecb2d718f6a6..d8d4f7057031 100644
--- a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
+++ b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
@@ -641,7 +641,7 @@ static struct dma_fence *alloc_dma_fence(void)
dma = kmalloc_obj(*dma);
if (dma)
- dma_fence_init(dma, &mock_fence_ops, &mock_fence_lock, 0, 0);
+ dma_fence_init(dma, &mock_fence_ops, &mock_fence_lock, 0, 0, 0);
return dma;
}
diff --git a/drivers/gpu/drm/imagination/pvr_ccb.c b/drivers/gpu/drm/imagination/pvr_ccb.c
index e408df74853d..7043b491fe54 100644
--- a/drivers/gpu/drm/imagination/pvr_ccb.c
+++ b/drivers/gpu/drm/imagination/pvr_ccb.c
@@ -645,7 +645,7 @@ pvr_kccb_reserve_slot(struct pvr_device *pvr_dev, struct dma_fence *f)
dma_fence_init(&fence->base, &pvr_kccb_fence_ops,
&pvr_dev->kccb.fence_ctx.lock,
pvr_dev->kccb.fence_ctx.id,
- atomic_inc_return(&pvr_dev->kccb.fence_ctx.seqno));
+ atomic_inc_return(&pvr_dev->kccb.fence_ctx.seqno), 0);
out_fence = dma_fence_get(&fence->base);
list_add_tail(&fence->node, &pvr_dev->kccb.waiters);
} else {
diff --git a/drivers/gpu/drm/imagination/pvr_queue.c b/drivers/gpu/drm/imagination/pvr_queue.c
index 24a8645aa913..34b826381aa2 100644
--- a/drivers/gpu/drm/imagination/pvr_queue.c
+++ b/drivers/gpu/drm/imagination/pvr_queue.c
@@ -305,7 +305,7 @@ pvr_queue_fence_init(struct dma_fence *f,
INIT_WORK(&fence->release_work, pvr_queue_fence_release_work);
dma_fence_init(&fence->base, fence_ops,
&fence_ctx->lock, fence_ctx->id,
- atomic_inc_return(&fence_ctx->seqno));
+ atomic_inc_return(&fence_ctx->seqno), 0);
}
/**
diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c
index 9a1e6b9ecbe5..fee595b9629a 100644
--- a/drivers/gpu/drm/lima/lima_sched.c
+++ b/drivers/gpu/drm/lima/lima_sched.c
@@ -97,7 +97,7 @@ static struct lima_fence *lima_fence_create(struct lima_sched_pipe *pipe)
fence->pipe = pipe;
dma_fence_init(&fence->base, &lima_fence_ops, &pipe->fence_lock,
- pipe->fence_context, ++pipe->fence_seqno);
+ pipe->fence_context, ++pipe->fence_seqno, 0);
return fence;
}
diff --git a/drivers/gpu/drm/msm/msm_fence.c b/drivers/gpu/drm/msm/msm_fence.c
index 3dca8e09c192..1ec59919c32e 100644
--- a/drivers/gpu/drm/msm/msm_fence.c
+++ b/drivers/gpu/drm/msm/msm_fence.c
@@ -197,5 +197,5 @@ msm_fence_init(struct dma_fence *fence, struct msm_fence_context *fctx)
WARN_ON(kref_read(&fence->refcount));
dma_fence_init(&f->base, &msm_fence_ops, &fctx->spinlock,
- fctx->context, ++fctx->last_fence);
+ fctx->context, ++fctx->last_fence, 0);
}
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 11e95c37ce50..97e20954c71b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -216,10 +216,10 @@ nouveau_fence_emit(struct nouveau_fence *fence)
if (priv->uevent)
dma_fence_init(&fence->base, &nouveau_fence_ops_uevent,
- &fctx->lock, fctx->context, ++fctx->sequence);
+ &fctx->lock, fctx->context, ++fctx->sequence, 0);
else
dma_fence_init(&fence->base, &nouveau_fence_ops_legacy,
- &fctx->lock, fctx->context, ++fctx->sequence);
+ &fctx->lock, fctx->context, ++fctx->sequence, 0);
kref_get(&fctx->fence_ref);
ret = fctx->emit(fence);
diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
index 4ddf4b722ddf..de242d275978 100644
--- a/drivers/gpu/drm/panfrost/panfrost_job.c
+++ b/drivers/gpu/drm/panfrost/panfrost_job.c
@@ -105,7 +105,7 @@ static struct dma_fence *panfrost_fence_create(struct panfrost_device *pfdev, in
fence->queue = js_num;
fence->seqno = ++js->queue[js_num].emit_seqno;
dma_fence_init(&fence->base, &panfrost_fence_ops, &js->job_lock,
- js->queue[js_num].fence_context, fence->seqno);
+ js->queue[js_num].fence_context, fence->seqno, 0);
return &fence->base;
}
diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
index a343c5180e01..c46f69ade7a0 100644
--- a/drivers/gpu/drm/panthor/panthor_sched.c
+++ b/drivers/gpu/drm/panthor/panthor_sched.c
@@ -3322,7 +3322,7 @@ queue_run_job(struct drm_sched_job *sched_job)
&panthor_queue_fence_ops,
&queue->fence_ctx.lock,
queue->fence_ctx.id,
- atomic64_inc_return(&queue->fence_ctx.seqno));
+ atomic64_inc_return(&queue->fence_ctx.seqno), 0);
job->profiling.slot = queue->profiling.seqno++;
if (queue->profiling.seqno == queue->profiling.slot_count)
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
index 06979d0e8a9f..2608d82f7370 100644
--- a/drivers/gpu/drm/qxl/qxl_release.c
+++ b/drivers/gpu/drm/qxl/qxl_release.c
@@ -430,7 +430,7 @@ void qxl_release_fence_buffer_objects(struct qxl_release *release)
* set the highest bits. This will break if we really allow exporting of dma-bufs.
*/
dma_fence_init(&release->base, &qxl_fence_ops, &qdev->release_lock,
- release->id | 0xf0000000, release->base.seqno);
+ release->id | 0xf0000000, release->base.seqno, 0);
trace_dma_fence_emit(&release->base);
list_for_each_entry(entry, &release->bos, list) {
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
index 8e9402b8811b..1360b5215f5e 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -148,7 +148,7 @@ int radeon_fence_emit(struct radeon_device *rdev,
dma_fence_init(&(*fence)->base, &radeon_fence_ops,
&rdev->fence_queue.lock,
rdev->fence_context + ring,
- seq);
+ seq, 0);
radeon_fence_ring_emit(rdev, ring, *fence);
trace_radeon_fence_emit(rdev_to_drm(rdev), ring, (*fence)->seq);
radeon_fence_schedule_check(rdev, ring);
diff --git a/drivers/gpu/drm/scheduler/sched_fence.c b/drivers/gpu/drm/scheduler/sched_fence.c
index b7a4cb921234..94ba0cf4fe02 100644
--- a/drivers/gpu/drm/scheduler/sched_fence.c
+++ b/drivers/gpu/drm/scheduler/sched_fence.c
@@ -229,9 +229,9 @@ void drm_sched_fence_init(struct drm_sched_fence *fence,
fence->sched = entity->rq->sched;
seq = atomic_inc_return(&entity->fence_seq);
dma_fence_init(&fence->scheduled, &drm_sched_fence_ops_scheduled,
- &fence->lock, entity->fence_context, seq);
+ &fence->lock, entity->fence_context, seq, 0);
dma_fence_init(&fence->finished, &drm_sched_fence_ops_finished,
- &fence->lock, entity->fence_context + 1, seq);
+ &fence->lock, entity->fence_context + 1, seq, 0);
}
module_init(drm_sched_fence_slab_init);
diff --git a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
index 2dfa3efef210..169792a4b329 100644
--- a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
+++ b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
@@ -173,7 +173,7 @@ static struct dma_fence *mock_sched_run_job(struct drm_sched_job *sched_job)
&drm_mock_sched_hw_fence_ops,
&sched->lock,
sched->hw_timeline.context,
- atomic_inc_return(&sched->hw_timeline.next_seqno));
+ atomic_inc_return(&sched->hw_timeline.next_seqno), 0);
dma_fence_get(&job->hw_fence); /* Reference for the job_list */
diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
index f3103307b5df..633cc7458505 100644
--- a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
+++ b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
@@ -450,7 +450,7 @@ static void ttm_bo_fini_shared_resv(struct kunit *test)
KUNIT_ASSERT_NOT_NULL(test, fence);
spin_lock_init(&fence_lock);
- dma_fence_init(fence, &mock_fence_ops, &fence_lock, 0, 0);
+ dma_fence_init(fence, &mock_fence_ops, &fence_lock, 0, 0, 0);
dma_resv_lock(external_resv, NULL);
dma_resv_reserve_fences(external_resv, 1);
diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c b/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
index 56ad8ef32584..e22a1335f166 100644
--- a/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
+++ b/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
@@ -57,7 +57,7 @@ static struct dma_fence *alloc_mock_fence(struct kunit *test)
fence = kunit_kzalloc(test, sizeof(*fence), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, fence);
- dma_fence_init(fence, &fence_ops, &fence_lock, 0, 0);
+ dma_fence_init(fence, &fence_ops, &fence_lock, 0, 0, 0);
return fence;
}
diff --git a/drivers/gpu/drm/v3d/v3d_fence.c b/drivers/gpu/drm/v3d/v3d_fence.c
index c500136d0455..1fdba5a21580 100644
--- a/drivers/gpu/drm/v3d/v3d_fence.c
+++ b/drivers/gpu/drm/v3d/v3d_fence.c
@@ -16,7 +16,7 @@ struct dma_fence *v3d_fence_create(struct v3d_dev *v3d, enum v3d_queue q)
fence->queue = q;
fence->seqno = ++queue->emit_seqno;
dma_fence_init(&fence->base, &v3d_fence_ops, &queue->queue_lock,
- queue->fence_context, fence->seqno);
+ queue->fence_context, fence->seqno, 0);
return &fence->base;
}
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index ff611c618d6b..420988d516c1 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -648,7 +648,7 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec,
exec->seqno = seqno;
dma_fence_init(&fence->base, &vc4_fence_ops, &vc4->job_lock,
- vc4->dma_fence_context, exec->seqno);
+ vc4->dma_fence_context, exec->seqno, 0);
fence->seqno = exec->seqno;
exec->fence = &fence->base;
diff --git a/drivers/gpu/drm/vgem/vgem_fence.c b/drivers/gpu/drm/vgem/vgem_fence.c
index 0e53ba7db629..18700e5f9167 100644
--- a/drivers/gpu/drm/vgem/vgem_fence.c
+++ b/drivers/gpu/drm/vgem/vgem_fence.c
@@ -77,7 +77,7 @@ static struct dma_fence *vgem_fence_create(struct vgem_file *vfile,
spin_lock_init(&fence->lock);
dma_fence_init(&fence->base, &vgem_fence_ops, &fence->lock,
- dma_fence_context_alloc(1), 1);
+ dma_fence_context_alloc(1), 1, 0);
timer_setup(&fence->timer, vgem_fence_timeout, TIMER_IRQSAFE);
diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c
index c3e66ef2133a..8e469391d2e4 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fence.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fence.c
@@ -76,7 +76,7 @@ struct virtio_gpu_fence *virtio_gpu_fence_alloc(struct virtio_gpu_device *vgdev,
*/
dma_fence_init(&fence->f, &virtio_gpu_fence_ops, &drv->lock,
- fence_context, 0);
+ fence_context, 0, 0);
return fence;
}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
index 384c6736cf6b..15f355dc6881 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
@@ -163,7 +163,7 @@ static int vmw_fence_obj_init(struct vmw_fence_manager *fman,
int ret = 0;
dma_fence_init(&fence->base, &vmw_fence_ops, &fman->lock,
- fman->ctx, seqno);
+ fman->ctx, seqno, 0);
fence->destroy = destroy;
spin_lock(&fman->lock);
diff --git a/drivers/gpu/drm/xe/xe_hw_fence.c b/drivers/gpu/drm/xe/xe_hw_fence.c
index 14720623ad00..30bfc42972e0 100644
--- a/drivers/gpu/drm/xe/xe_hw_fence.c
+++ b/drivers/gpu/drm/xe/xe_hw_fence.c
@@ -243,7 +243,7 @@ void xe_hw_fence_init(struct dma_fence *fence, struct xe_hw_fence_ctx *ctx,
INIT_LIST_HEAD(&hw_fence->irq_link);
dma_fence_init(fence, &xe_hw_fence_ops, &ctx->irq->lock,
- ctx->dma_fence_ctx, ctx->next_seqno++);
+ ctx->dma_fence_ctx, ctx->next_seqno++, 0);
trace_xe_hw_fence_create(hw_fence);
}
diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
index c9320feeafba..912840eeec50 100644
--- a/drivers/gpu/drm/xe/xe_oa.c
+++ b/drivers/gpu/drm/xe/xe_oa.c
@@ -1053,7 +1053,7 @@ static int xe_oa_emit_oa_config(struct xe_oa_stream *stream, struct xe_oa_config
/* Point of no return: initialize and set fence to signal */
spin_lock_init(&ofence->lock);
- dma_fence_init(&ofence->base, &xe_oa_fence_ops, &ofence->lock, 0, 0);
+ dma_fence_init(&ofence->base, &xe_oa_fence_ops, &ofence->lock, 0, 0, 0);
for (i = 0; i < stream->num_syncs; i++) {
if (stream->syncs[i].flags & DRM_XE_SYNC_FLAG_SIGNAL)
diff --git a/drivers/gpu/drm/xe/xe_preempt_fence.c b/drivers/gpu/drm/xe/xe_preempt_fence.c
index 4aa570fe745d..343f1ba1e1cd 100644
--- a/drivers/gpu/drm/xe/xe_preempt_fence.c
+++ b/drivers/gpu/drm/xe/xe_preempt_fence.c
@@ -154,7 +154,7 @@ xe_preempt_fence_arm(struct xe_preempt_fence *pfence, struct xe_exec_queue *q,
pfence->q = xe_exec_queue_get(q);
spin_lock_init(&pfence->lock);
dma_fence_init(&pfence->base, &preempt_fence_ops,
- &pfence->lock, context, seqno);
+ &pfence->lock, context, seqno, 0);
return &pfence->base;
}
diff --git a/drivers/gpu/drm/xe/xe_tlb_inval.c b/drivers/gpu/drm/xe/xe_tlb_inval.c
index c9cc5842d65b..1fd39434dc0e 100644
--- a/drivers/gpu/drm/xe/xe_tlb_inval.c
+++ b/drivers/gpu/drm/xe/xe_tlb_inval.c
@@ -544,7 +544,7 @@ void xe_tlb_inval_fence_init(struct xe_tlb_inval *tlb_inval,
spin_lock_irq(&tlb_inval->lock);
dma_fence_init(&fence->base, &inval_fence_ops, &tlb_inval->lock,
- dma_fence_context_alloc(1), 1);
+ dma_fence_context_alloc(1), 1, 0);
spin_unlock_irq(&tlb_inval->lock);
INIT_LIST_HEAD(&fence->link);
if (stack)
diff --git a/drivers/gpu/host1x/fence.c b/drivers/gpu/host1x/fence.c
index 1acf579c562b..7e074e72a055 100644
--- a/drivers/gpu/host1x/fence.c
+++ b/drivers/gpu/host1x/fence.c
@@ -136,7 +136,7 @@ struct dma_fence *host1x_fence_create(struct host1x_syncpt *sp, u32 threshold,
fence->timeout = timeout;
dma_fence_init(&fence->base, &host1x_syncpt_fence_ops, &sp->fences.lock,
- dma_fence_context_alloc(1), 0);
+ dma_fence_context_alloc(1), 0, 0);
INIT_DELAYED_WORK(&fence->timeout_work, do_fence_timeout);
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 4294101810fd..f7d6b294b63c 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -1904,7 +1904,7 @@ static int iio_buffer_enqueue_dmabuf(struct iio_dev_buffer_pair *ib,
* the dma_fence.
*/
dma_fence_init(&fence->base, &iio_buffer_dma_fence_ops,
- &fence->lock, priv->context, seqno);
+ &fence->lock, priv->context, seqno, 0);
ret = iio_dma_resv_lock(dmabuf, nonblock);
if (ret)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index c64a268e98a4..eb367a1666c2 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1733,7 +1733,7 @@ static int ffs_dmabuf_transfer(struct file *file,
seqno = atomic_add_return(1, &epfile->seqno);
dma_fence_init(&fence->base, &ffs_dmabuf_fence_ops,
- &priv->lock, priv->context, seqno);
+ &priv->lock, priv->context, seqno, 0);
resv_dir = epfile->in ? DMA_RESV_USAGE_READ : DMA_RESV_USAGE_WRITE;
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index dd07d128adc3..6f5c245d89ec 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -103,6 +103,12 @@ struct dma_fence {
int error;
};
+/** enum dma_fence_flag_bits - internal dma_fence flags
+ *
+ * These flags are all only for internal usage, except for
+ * @DMA_FENCE_FLAG_SEQNO64_BIT and the user bits beginning at
+ * @DMA_FENCE_FLAG_USER_BITS.
+ */
enum dma_fence_flag_bits {
DMA_FENCE_FLAG_INITIALIZED_BIT,
DMA_FENCE_FLAG_INLINE_LOCK_BIT,
@@ -110,6 +116,7 @@ enum dma_fence_flag_bits {
DMA_FENCE_FLAG_SIGNALED_BIT,
DMA_FENCE_FLAG_TIMESTAMP_BIT,
DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
+
DMA_FENCE_FLAG_USER_BITS, /* must always be last member */
};
@@ -279,11 +286,10 @@ 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);
-
+ spinlock_t *lock, u64 context, u64 seqno,
+ unsigned long flags);
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);
diff --git a/rust/kernel/dma_buf/dma_fence.rs b/rust/kernel/dma_buf/dma_fence.rs
index 18a43e1bb442..ee8fa4ecd6c1 100644
--- a/rust/kernel/dma_buf/dma_fence.rs
+++ b/rust/kernel/dma_buf/dma_fence.rs
@@ -736,7 +736,7 @@ pub fn new_fence(self) -> DriverFence<'a, T> {
// SAFETY: `fence_ptr` has been created directly above. It will live
// at least as long as `Self`. The same applies to `&Self::OPS`.
unsafe {
- bindings::dma_fence_init(fence_ptr, self.ops, null_ptr, self.data.fctx.nr, seqno)
+ bindings::dma_fence_init(fence_ptr, self.ops, null_ptr, self.data.fctx.nr, seqno, 0)
};
self.data.fctx.nr_of_unsignaled_fences.fetch_add(1, Relaxed);
--
2.56.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/3] dma-buf: Port users of dma_fence_init64()
2026-11-05 11:35 [PATCH 0/3] dma-buf: dma-fence: Remove dma_fence_init64() Philipp Stanner
2026-11-05 11:35 ` [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init() Philipp Stanner
@ 2026-11-05 11:35 ` Philipp Stanner
2026-11-05 11:49 ` sashiko-bot
2026-11-05 11:35 ` [PATCH 3/3] dma-buf: dma-fence: Remove dma_fence_init64() Philipp Stanner
2026-11-05 16:32 ` [PATCH 0/3] " Timur Kristóf
3 siblings, 1 reply; 14+ messages in thread
From: Philipp Stanner @ 2026-11-05 11:35 UTC (permalink / raw)
To: Min Ma, Lizhi Hou, Oded Gabbay, Rob Herring (Arm), Tomeu Vizoso,
Karol Wachowski, Andrzej Kacprowski, Heiko Stuebner, Sumit Semwal,
Christian König, Philipp Stanner, Felix Kuehling,
Alex Deucher, David Airlie, Simona Vetter, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Lucas Stach, Russell King,
Christian Gmeiner, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, Alessio Belle, Luigi Santivetti, Qiang Yu,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, Lyude Paul, Danilo Krummrich,
Boris Brezillon, Steven Price, Adrián Larumbe, Liviu Dudau,
Dave Airlie, Gerd Hoffmann, Matthew Brost, Natalie Vock,
Arun Pravin, Matthew Auld, Thomas Hellström, Melissa Wen,
Maíra Canal, Dave Stevenson, Raspberry Pi Kernel Maintenance,
Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, Zack Rusin,
Broadcom internal kernel review list, Thierry Reding,
Mikko Perttunen, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Neill Kapron, Greg Kroah-Hartman, Alice Ryhl,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Daniel Almeida,
Tamir Duberstein, Alexandre Courbot, Onur Özkan,
Sunil Khatri, Prike Liang, Vitaly Prosyak, Jesse Zhang,
Timur Kristóf, Srinivasan Shanmugam, David Rosca,
Marco Crivellari, Krzysztof Karas, Andi Shyti, Janusz Krzysztofik,
Shixiong Ou, Jouni Högander, Joel Fernandes,
Thadeu Lima de Souza Cascardo, Pierre-Eric Pelloux-Prayer,
Al Viro, Michael Bommarito, Sam Day, Gabriel Prostitis
Cc: dri-devel, linux-kernel, linux-media, amd-gfx, etnaviv, intel-gfx,
imagination, lima, linux-arm-msm, freedreno, nouveau,
virtualization, spice-devel, intel-xe, linux-tegra, linux-iio,
linux-usb, rust-for-linux
dma_fence_init() now natively allows for selecting 64-bit seqno support.
Port all users of dma_fence_init64() to this unified method.
Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
drivers/dma-buf/dma-fence-chain.c | 4 ++--
drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c | 7 ++++---
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 5 +++--
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c | 5 +++--
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/dma-buf/dma-fence-chain.c b/drivers/dma-buf/dma-fence-chain.c
index a588f55ea4d3..7d1495235577 100644
--- a/drivers/dma-buf/dma-fence-chain.c
+++ b/drivers/dma-buf/dma-fence-chain.c
@@ -261,8 +261,8 @@ void dma_fence_chain_init(struct dma_fence_chain *chain,
seqno = max(prev->seqno, seqno);
}
- dma_fence_init64(&chain->base, &dma_fence_chain_ops, NULL,
- context, seqno);
+ dma_fence_init(&chain->base, &dma_fence_chain_ops, NULL,
+ context, seqno, BIT(DMA_FENCE_FLAG_SEQNO64_BIT));
/*
* dma_fence_chain_enable_signaling() is invoked while holding
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
index f8652fd0525d..2924f34da316 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
@@ -133,9 +133,10 @@ int amdgpu_evf_mgr_rearm(struct amdgpu_eviction_fence_mgr *evf_mgr,
ev_fence->evf_mgr = evf_mgr;
get_task_comm(ev_fence->timeline_name, current);
spin_lock_init(&ev_fence->lock);
- dma_fence_init64(&ev_fence->base, &amdgpu_eviction_fence_ops,
- &ev_fence->lock, evf_mgr->ev_fence_ctx,
- atomic_inc_return(&evf_mgr->ev_fence_seq));
+ dma_fence_init(&ev_fence->base, &amdgpu_eviction_fence_ops,
+ &ev_fence->lock, evf_mgr->ev_fence_ctx,
+ atomic_inc_return(&evf_mgr->ev_fence_seq),
+ BIT(DMA_FENCE_FLAG_SEQNO64_BIT));
/* Remember it for newly added BOs */
dma_fence_put(evf_mgr->ev_fence);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
index c1257f530e9a..5329c13f4237 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
@@ -274,8 +274,9 @@ static void amdgpu_userq_fence_init(struct amdgpu_usermode_queue *userq,
bool signaled = false;
spin_lock_init(&fence->lock);
- dma_fence_init64(&fence->base, &amdgpu_userq_fence_ops, &fence->lock,
- fence_drv->context, seq);
+ dma_fence_init(&fence->base, &amdgpu_userq_fence_ops, &fence->lock,
+ fence_drv->context, seq,
+ BIT(DMA_FENCE_FLAG_SEQNO64_BIT));
/* Make sure the fence is visible to the hang detect worker */
dma_fence_put(userq->last_fence);
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 b0002c898386..f8cc258dcdef 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c
@@ -100,8 +100,9 @@ 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_init64(&f->base, &amdgpu_tlb_fence_ops, &f->lock,
- vm->tlb_fence_context, atomic64_read(&vm->tlb_seq));
+ dma_fence_init(&f->base, &amdgpu_tlb_fence_ops, &f->lock,
+ vm->tlb_fence_context, atomic64_read(&vm->tlb_seq),
+ BIT(DMA_FENCE_FLAG_SEQNO64_BIT));
/* TODO: We probably need a separate wq here */
dma_fence_get(&f->base);
--
2.56.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/3] dma-buf: dma-fence: Remove dma_fence_init64()
2026-11-05 11:35 [PATCH 0/3] dma-buf: dma-fence: Remove dma_fence_init64() Philipp Stanner
2026-11-05 11:35 ` [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init() Philipp Stanner
2026-11-05 11:35 ` [PATCH 2/3] dma-buf: Port users of dma_fence_init64() Philipp Stanner
@ 2026-11-05 11:35 ` Philipp Stanner
2026-11-05 11:43 ` sashiko-bot
2026-11-05 16:32 ` [PATCH 0/3] " Timur Kristóf
3 siblings, 1 reply; 14+ messages in thread
From: Philipp Stanner @ 2026-11-05 11:35 UTC (permalink / raw)
To: Min Ma, Lizhi Hou, Oded Gabbay, Rob Herring (Arm), Tomeu Vizoso,
Karol Wachowski, Andrzej Kacprowski, Heiko Stuebner, Sumit Semwal,
Christian König, Philipp Stanner, Felix Kuehling,
Alex Deucher, David Airlie, Simona Vetter, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Lucas Stach, Russell King,
Christian Gmeiner, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, Alessio Belle, Luigi Santivetti, Qiang Yu,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, Lyude Paul, Danilo Krummrich,
Boris Brezillon, Steven Price, Adrián Larumbe, Liviu Dudau,
Dave Airlie, Gerd Hoffmann, Matthew Brost, Natalie Vock,
Arun Pravin, Matthew Auld, Thomas Hellström, Melissa Wen,
Maíra Canal, Dave Stevenson, Raspberry Pi Kernel Maintenance,
Dmitry Osipenko, Gurchetan Singh, Chia-I Wu, Zack Rusin,
Broadcom internal kernel review list, Thierry Reding,
Mikko Perttunen, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Neill Kapron, Greg Kroah-Hartman, Alice Ryhl,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Daniel Almeida,
Tamir Duberstein, Alexandre Courbot, Onur Özkan,
Sunil Khatri, Prike Liang, Vitaly Prosyak, Jesse Zhang,
Timur Kristóf, Srinivasan Shanmugam, David Rosca,
Marco Crivellari, Krzysztof Karas, Andi Shyti, Janusz Krzysztofik,
Shixiong Ou, Jouni Högander, Joel Fernandes,
Thadeu Lima de Souza Cascardo, Pierre-Eric Pelloux-Prayer,
Al Viro, Michael Bommarito, Sam Day, Gabriel Prostitis
Cc: dri-devel, linux-kernel, linux-media, amd-gfx, etnaviv, intel-gfx,
imagination, lima, linux-arm-msm, freedreno, nouveau,
virtualization, spice-devel, intel-xe, linux-tegra, linux-iio,
linux-usb, rust-for-linux
All users of dma_fence_init64() have been removed. They now use the
respective initialization flag in dma_fence_init().
Remove dma_fence_init64().
Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
drivers/dma-buf/dma-fence.c | 27 ---------------------------
include/linux/dma-fence.h | 2 --
2 files changed, 29 deletions(-)
diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index a511cf755ee8..da784fd7bdae 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -1138,33 +1138,6 @@ dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
}
EXPORT_SYMBOL(dma_fence_init);
-/**
- * dma_fence_init64 - Initialize a custom fence with 64-bit seqno support.
- * @fence: the fence to initialize
- * @ops: the dma_fence_ops for operations on this fence
- * @lock: optional irqsafe spinlock to use for locking this fence
- * @context: the execution context this fence is run on
- * @seqno: a linear increasing sequence number for this context
- *
- * Initializes an allocated fence, the caller doesn't have to keep its
- * refcount after committing with this fence, but it will need to hold a
- * refcount again if &dma_fence_ops.enable_signaling gets called.
- *
- * Context and seqno are used for easy comparison between fences, allowing
- * to check which fence is later by simply using dma_fence_later().
- *
- * New users MUST NOT use external locks. Check the documentation in
- * dma_fence_init() to understand the motives behind the legacy use cases.
- */
-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,
- BIT(DMA_FENCE_FLAG_SEQNO64_BIT));
-}
-EXPORT_SYMBOL(dma_fence_init64);
-
/**
* dma_fence_driver_name - Access the driver name
* @fence: the fence to query
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index 6f5c245d89ec..56c4e5beaafe 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -288,8 +288,6 @@ 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,
unsigned long flags);
-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);
--
2.56.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 3/3] dma-buf: dma-fence: Remove dma_fence_init64()
2026-11-05 11:35 ` [PATCH 3/3] dma-buf: dma-fence: Remove dma_fence_init64() Philipp Stanner
@ 2026-11-05 11:43 ` sashiko-bot
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-05 11:43 UTC (permalink / raw)
To: Philipp Stanner
Cc: virtualization, linux-usb, Michael S. Tsirkin, Eugenio Perez
> All users of dma_fence_init64() have been removed. They now use the
> respective initialization flag in dma_fence_init().
>
> Remove dma_fence_init64().
>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105113529.1989375-2-phasta@kernel.org?part=3
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] dma-buf: Port users of dma_fence_init64()
2026-11-05 11:35 ` [PATCH 2/3] dma-buf: Port users of dma_fence_init64() Philipp Stanner
@ 2026-11-05 11:49 ` sashiko-bot
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-05 11:49 UTC (permalink / raw)
To: Philipp Stanner
Cc: virtualization, linux-usb, Michael S. Tsirkin, Eugenio Perez
> dma_fence_init() now natively allows for selecting 64-bit seqno support.
> Port all users of dma_fence_init64() to this unified method.
>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105113529.1989375-2-phasta@kernel.org?part=2
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init()
2026-11-05 11:35 ` [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init() Philipp Stanner
@ 2026-11-05 11:54 ` sashiko-bot
2026-11-05 12:06 ` Tvrtko Ursulin
1 sibling, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-05 11:54 UTC (permalink / raw)
To: Philipp Stanner
Cc: virtualization, linux-usb, Michael S. Tsirkin, Eugenio Perez
> Currently, there are two init functions for dma_fence, dma_fence_init()
> and dma_fence_init64().
>
> Since more future user options for dma_fence initialization would
> require distinct init functions, too, it is better to do this in a
> unified way.
>
> Add a flags field to dma_fence_init(). Adjust all affected drivers,
> preserving the old behavior.
>
> Support the SEQNO64 flag, and add a check-function so that the user only
> sets valid bits.
>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105113529.1989375-2-phasta@kernel.org?part=1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init()
2026-11-05 11:35 ` [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init() Philipp Stanner
2026-11-05 11:54 ` sashiko-bot
@ 2026-11-05 12:06 ` Tvrtko Ursulin
2026-11-05 12:35 ` Christian König
1 sibling, 1 reply; 14+ messages in thread
From: Tvrtko Ursulin @ 2026-11-05 12:06 UTC (permalink / raw)
To: Philipp Stanner, Christian König
Cc: dri-devel, linux-kernel, linux-media, amd-gfx, etnaviv, intel-gfx,
imagination, lima, linux-arm-msm, freedreno, nouveau,
virtualization, spice-devel, intel-xe, linux-tegra, linux-iio,
linux-usb, rust-for-linux
[I aggresively rewrote the To: list because my SMTP won't let me send
this as it was.]
On 05/11/2026 11:35, Philipp Stanner wrote:
> Currently, there are two init functions for dma_fence, dma_fence_init()
> and dma_fence_init64().
>
> Since more future user options for dma_fence initialization would
> require distinct init functions, too, it is better to do this in a
> unified way.
Why not add something like dma_fence_init_flags() and leave the 99% of
the callers out of the (huge) diff? Ie. just port dma_fence_init64() to
dma_fence_init_flags().
Also best to move the addition of dma_fence_flags_invalid() to the patch
which adds dma_fence_init_flags() and not have it in this one which is
supposed to be functionality neutral.
Regards,
Tvrtko
> Add a flags field to dma_fence_init(). Adjust all affected drivers,
> preserving the old behavior.
>
> Support the SEQNO64 flag, and add a check-function so that the user only
> sets valid bits.
>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
> ---
> drivers/accel/amdxdna/amdxdna_ctx.c | 2 +-
> drivers/accel/ethosu/ethosu_job.c | 2 +-
> drivers/accel/ivpu/ivpu_job.c | 2 +-
> drivers/accel/rocket/rocket_job.c | 2 +-
> drivers/dma-buf/dma-fence-array.c | 2 +-
> drivers/dma-buf/dma-fence.c | 31 ++++++++++++++++---
> drivers/dma-buf/st-dma-fence-chain.c | 2 +-
> drivers/dma-buf/st-dma-fence-unwrap.c | 2 +-
> drivers/dma-buf/st-dma-fence.c | 2 +-
> drivers/dma-buf/st-dma-resv.c | 2 +-
> drivers/dma-buf/sw_sync.c | 2 +-
> .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c | 2 +-
> drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +-
> drivers/gpu/drm/drm_crtc.c | 2 +-
> drivers/gpu/drm/drm_writeback.c | 2 +-
> drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 +-
> drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 2 +-
> drivers/gpu/drm/i915/i915_request.c | 2 +-
> drivers/gpu/drm/i915/i915_sw_fence_work.c | 2 +-
> drivers/gpu/drm/i915/i915_vma_resource.c | 2 +-
> .../gpu/drm/i915/selftests/i915_sw_fence.c | 2 +-
> drivers/gpu/drm/imagination/pvr_ccb.c | 2 +-
> drivers/gpu/drm/imagination/pvr_queue.c | 2 +-
> drivers/gpu/drm/lima/lima_sched.c | 2 +-
> drivers/gpu/drm/msm/msm_fence.c | 2 +-
> drivers/gpu/drm/nouveau/nouveau_fence.c | 4 +--
> drivers/gpu/drm/panfrost/panfrost_job.c | 2 +-
> drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
> drivers/gpu/drm/qxl/qxl_release.c | 2 +-
> drivers/gpu/drm/radeon/radeon_fence.c | 2 +-
> drivers/gpu/drm/scheduler/sched_fence.c | 4 +--
> .../gpu/drm/scheduler/tests/mock_scheduler.c | 2 +-
> drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 2 +-
> .../gpu/drm/ttm/tests/ttm_bo_validate_test.c | 2 +-
> drivers/gpu/drm/v3d/v3d_fence.c | 2 +-
> drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
> drivers/gpu/drm/vgem/vgem_fence.c | 2 +-
> drivers/gpu/drm/virtio/virtgpu_fence.c | 2 +-
> drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +-
> drivers/gpu/drm/xe/xe_hw_fence.c | 2 +-
> drivers/gpu/drm/xe/xe_oa.c | 2 +-
> drivers/gpu/drm/xe/xe_preempt_fence.c | 2 +-
> drivers/gpu/drm/xe/xe_tlb_inval.c | 2 +-
> drivers/gpu/host1x/fence.c | 2 +-
> drivers/iio/industrialio-buffer.c | 2 +-
> drivers/usb/gadget/function/f_fs.c | 2 +-
> include/linux/dma-fence.h | 12 +++++--
> rust/kernel/dma_buf/dma_fence.rs | 2 +-
> 48 files changed, 83 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/amdxdna_ctx.c
> index f4004630dc1b..f2245541f1ee 100644
> --- a/drivers/accel/amdxdna/amdxdna_ctx.c
> +++ b/drivers/accel/amdxdna/amdxdna_ctx.c
> @@ -53,7 +53,7 @@ static struct dma_fence *amdxdna_fence_create(struct amdxdna_hwctx *hwctx)
>
> spin_lock_init(&fence->lock);
> /* Unique timeline context prevents eviction from shared BO reservation. */
> - dma_fence_init(&fence->base, &fence_ops, &fence->lock, dma_fence_context_alloc(1), 0);
> + dma_fence_init(&fence->base, &fence_ops, &fence->lock, dma_fence_context_alloc(1), 0, 0);
> return &fence->base;
> }
>
> diff --git a/drivers/accel/ethosu/ethosu_job.c b/drivers/accel/ethosu/ethosu_job.c
> index d656b3ec670e..d4fc71436cae 100644
> --- a/drivers/accel/ethosu/ethosu_job.c
> +++ b/drivers/accel/ethosu/ethosu_job.c
> @@ -219,7 +219,7 @@ static struct dma_fence *ethosu_job_run(struct drm_sched_job *sched_job)
> return NULL;
>
> dma_fence_init(fence, ðosu_fence_ops, &dev->fence_lock,
> - dev->fence_context, ++dev->emit_seqno);
> + dev->fence_context, ++dev->emit_seqno, 0);
> dma_fence_get(fence);
>
> ethosu_switch_perfmon(dev, job);
> diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c
> index 76bacabe496b..6b4f059fb209 100644
> --- a/drivers/accel/ivpu/ivpu_job.c
> +++ b/drivers/accel/ivpu/ivpu_job.c
> @@ -519,7 +519,7 @@ static struct dma_fence *ivpu_fence_create(struct ivpu_device *vdev)
>
> fence->vdev = vdev;
> spin_lock_init(&fence->lock);
> - dma_fence_init(&fence->base, &ivpu_fence_ops, &fence->lock, dma_fence_context_alloc(1), 1);
> + dma_fence_init(&fence->base, &ivpu_fence_ops, &fence->lock, dma_fence_context_alloc(1), 1, 0);
>
> return &fence->base;
> }
> diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
> index b2a00992c889..574c9ea802c9 100644
> --- a/drivers/accel/rocket/rocket_job.c
> +++ b/drivers/accel/rocket/rocket_job.c
> @@ -61,7 +61,7 @@ static struct dma_fence *rocket_fence_create(struct rocket_core *core)
> return ERR_PTR(-ENOMEM);
>
> dma_fence_init(fence, &rocket_fence_ops, &core->fence_lock,
> - core->fence_context, ++core->emit_seqno);
> + core->fence_context, ++core->emit_seqno, 0);
>
> return fence;
> }
> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> index 5e10e8df372f..e2dddbfddea2 100644
> --- a/drivers/dma-buf/dma-fence-array.c
> +++ b/drivers/dma-buf/dma-fence-array.c
> @@ -205,7 +205,7 @@ void dma_fence_array_init(struct dma_fence_array *array,
> array->num_fences = num_fences;
>
> dma_fence_init(&array->base, &dma_fence_array_ops, NULL, context,
> - seqno);
> + seqno, 0);
> init_irq_work(&array->work, irq_dma_fence_array_work);
>
> /*
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index bd58688b81a7..a511cf755ee8 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -122,7 +122,7 @@ static const struct dma_fence_ops dma_fence_stub_ops = {
>
> static int __init dma_fence_init_stub(void)
> {
> - dma_fence_init(&dma_fence_stub, &dma_fence_stub_ops, NULL, 0, 0);
> + dma_fence_init(&dma_fence_stub, &dma_fence_stub_ops, NULL, 0, 0, 0);
> set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
> &dma_fence_stub.flags);
> dma_fence_signal(&dma_fence_stub);
> @@ -156,7 +156,7 @@ struct dma_fence *dma_fence_allocate_private_stub(ktime_t timestamp)
> if (fence == NULL)
> return NULL;
>
> - dma_fence_init(fence, &dma_fence_stub_ops, NULL, 0, 0);
> + dma_fence_init(fence, &dma_fence_stub_ops, NULL, 0, 0, 0);
> set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
> &fence->flags);
>
> @@ -1063,7 +1063,6 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
> spinlock_t *lock, u64 context, u64 seqno, unsigned long flags)
> {
> BUG_ON(!ops || !ops->get_driver_name || !ops->get_timeline_name);
> -
> kref_init(&fence->refcount);
> /*
> * While it is counter intuitive to protect a constant function pointer
> @@ -1087,6 +1086,21 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
> trace_dma_fence_init(fence);
> }
>
> +static bool dma_fence_flags_invalid(unsigned long flags)
> +{
> + const unsigned long valid_fence_bits =
> + BIT(DMA_FENCE_FLAG_SEQNO64_BIT);
> + const unsigned long valid_user_bits =
> + GENMASK(
> + BITS_PER_TYPE(unsigned long) - 1,
> + DMA_FENCE_FLAG_USER_BITS
> + );
> + const unsigned long invalid_bits =
> + ~(valid_fence_bits | valid_user_bits);
> +
> + return flags & invalid_bits;
> +}
> +
> /**
> * dma_fence_init - Initialize a custom fence.
> * @fence: the fence to initialize
> @@ -1094,6 +1108,7 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
> * @lock: optional irqsafe spinlock to use for locking this fence
> * @context: the execution context this fence is run on
> * @seqno: a linear increasing sequence number for this context
> + * @flags: flags modifying a fence's behavior
> *
> * Initializes an allocated fence, the caller doesn't have to keep its
> * refcount after committing with this fence, but it will need to hold a
> @@ -1108,12 +1123,18 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
> * introduction of the callback, but the external lock is still around. New
> * users MUST NOT use external locks, as they force the issuer to outlive all
> * fences that reference the lock.
> + *
> + * The @flags you can specify here are either DMA_FENCE_FLAG_SEQNO64_BIT or
> + * user-specified bits >= DMA_FENCE_FLAG_USER_BITS.
> */
> void
> dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
> - spinlock_t *lock, u64 context, u64 seqno)
> + spinlock_t *lock, u64 context, u64 seqno,
> + unsigned long flags)
> {
> - __dma_fence_init(fence, ops, lock, context, seqno, 0UL);
> + WARN_ON(dma_fence_flags_invalid(flags));
> +
> + __dma_fence_init(fence, ops, lock, context, seqno, flags);
> }
> EXPORT_SYMBOL(dma_fence_init);
>
> diff --git a/drivers/dma-buf/st-dma-fence-chain.c b/drivers/dma-buf/st-dma-fence-chain.c
> index e0d9b69bfa76..b9610df3ff19 100644
> --- a/drivers/dma-buf/st-dma-fence-chain.c
> +++ b/drivers/dma-buf/st-dma-fence-chain.c
> @@ -52,7 +52,7 @@ static struct dma_fence *mock_fence(void)
> return NULL;
>
> spin_lock_init(&f->lock);
> - dma_fence_init(&f->base, &mock_ops, &f->lock, 0, 0);
> + dma_fence_init(&f->base, &mock_ops, &f->lock, 0, 0, 0);
>
> return &f->base;
> }
> diff --git a/drivers/dma-buf/st-dma-fence-unwrap.c b/drivers/dma-buf/st-dma-fence-unwrap.c
> index c5353b36f0e4..dbebc3046d42 100644
> --- a/drivers/dma-buf/st-dma-fence-unwrap.c
> +++ b/drivers/dma-buf/st-dma-fence-unwrap.c
> @@ -36,7 +36,7 @@ static struct dma_fence *__mock_fence(u64 context, u64 seqno)
> return NULL;
>
> spin_lock_init(&f->lock);
> - dma_fence_init(&f->base, &mock_ops, &f->lock, context, seqno);
> + dma_fence_init(&f->base, &mock_ops, &f->lock, context, seqno, 0);
>
> return &f->base;
> }
> diff --git a/drivers/dma-buf/st-dma-fence.c b/drivers/dma-buf/st-dma-fence.c
> index cb62e606d0a2..b3f88e89cc44 100644
> --- a/drivers/dma-buf/st-dma-fence.c
> +++ b/drivers/dma-buf/st-dma-fence.c
> @@ -31,7 +31,7 @@ static struct dma_fence *mock_fence(void)
> if (!f)
> return NULL;
>
> - dma_fence_init(f, &mock_ops, NULL, 0, 0);
> + dma_fence_init(f, &mock_ops, NULL, 0, 0, 0);
> return f;
> }
>
> diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c
> index 0b96136bbd54..c3a920ab3fcf 100644
> --- a/drivers/dma-buf/st-dma-resv.c
> +++ b/drivers/dma-buf/st-dma-resv.c
> @@ -35,7 +35,7 @@ static struct dma_fence *alloc_fence(void)
> if (!f)
> return NULL;
>
> - dma_fence_init(f, &fence_ops, &fence_lock, 0, 0);
> + dma_fence_init(f, &fence_ops, &fence_lock, 0, 0, 0);
> return f;
> }
>
> diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
> index 8df20b0218a9..ce43af7e735e 100644
> --- a/drivers/dma-buf/sw_sync.c
> +++ b/drivers/dma-buf/sw_sync.c
> @@ -258,7 +258,7 @@ static struct sync_pt *sync_pt_create(struct sync_timeline *obj,
>
> sync_timeline_get(obj);
> dma_fence_init(&pt->base, &timeline_fence_ops, &obj->lock,
> - obj->context, value);
> + obj->context, value, 0);
> INIT_LIST_HEAD(&pt->link);
>
> spin_lock_irq(&obj->lock);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c
> index 9b10d015671c..30ccdb3e0b47 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c
> @@ -77,7 +77,7 @@ struct amdgpu_amdkfd_fence *amdgpu_amdkfd_fence_create(u64 context,
> spin_lock_init(&fence->lock);
> fence->context_id = context_id;
> dma_fence_init(&fence->base, &amdkfd_fence_ops, &fence->lock,
> - context, atomic_inc_return(&fence_seq));
> + context, atomic_inc_return(&fence_seq), 0);
>
> return fence;
> }
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> index bff2d38f3571..03e1974f8dda 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> @@ -112,7 +112,7 @@ void amdgpu_fence_emit(struct amdgpu_ring *ring, struct amdgpu_fence *af,
> seq = ++ring->fence_drv.sync_seq;
> dma_fence_init(fence, &amdgpu_fence_ops,
> &ring->fence_drv.lock,
> - adev->fence_context + ring->idx, seq);
> + adev->fence_context + ring->idx, seq, 0);
>
> amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,
> seq, flags | AMDGPU_FENCE_FLAG_INT);
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 63ead8ba6756..92641bc0a378 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -190,7 +190,7 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)
> return NULL;
>
> dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock,
> - crtc->fence_context, ++crtc->fence_seqno);
> + crtc->fence_context, ++crtc->fence_seqno, 0);
>
> return fence;
> }
> diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c
> index b4a002e6d043..64b06b890f19 100644
> --- a/drivers/gpu/drm/drm_writeback.c
> +++ b/drivers/gpu/drm/drm_writeback.c
> @@ -592,7 +592,7 @@ drm_writeback_get_out_fence(struct drm_writeback_connector *wb_connector)
>
> dma_fence_init(fence, &drm_writeback_fence_ops,
> &wb_connector->fence_lock, wb_connector->fence_context,
> - ++wb_connector->fence_seqno);
> + ++wb_connector->fence_seqno, 0);
>
> return fence;
> }
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> index e75dab5e407d..a10e4e4cf372 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> @@ -1199,7 +1199,7 @@ static struct dma_fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu)
> f->gpu = gpu;
>
> dma_fence_init(&f->base, &etnaviv_fence_ops, &gpu->fence_spinlock,
> - gpu->fence_context, ++gpu->next_fence);
> + gpu->fence_context, ++gpu->next_fence, 0);
>
> return &f->base;
> }
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
> index 56489cc127d6..ffaa70191f27 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
> @@ -437,7 +437,7 @@ i915_ttm_memcpy_work_arm(struct i915_ttm_memcpy_work *work,
> int ret;
>
> spin_lock_init(&work->lock);
> - dma_fence_init(&work->fence, &dma_fence_memcpy_ops, &work->lock, 0, 0);
> + dma_fence_init(&work->fence, &dma_fence_memcpy_ops, &work->lock, 0, 0, 0);
> dma_fence_get(&work->fence);
> ret = dma_fence_add_callback(dep, &work->cb, __memcpy_cb);
> if (ret) {
> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
> index f66f8efc7062..0f4fc9cc0033 100644
> --- a/drivers/gpu/drm/i915/i915_request.c
> +++ b/drivers/gpu/drm/i915/i915_request.c
> @@ -953,7 +953,7 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp)
> goto err_free;
>
> dma_fence_init(&rq->fence, &i915_fence_ops, &rq->lock,
> - tl->fence_context, seqno);
> + tl->fence_context, seqno, 0);
>
> RCU_INIT_POINTER(rq->timeline, tl);
> rq->hwsp_seqno = tl->hwsp_seqno;
> diff --git a/drivers/gpu/drm/i915/i915_sw_fence_work.c b/drivers/gpu/drm/i915/i915_sw_fence_work.c
> index 366418108f78..4cd44dd26e35 100644
> --- a/drivers/gpu/drm/i915/i915_sw_fence_work.c
> +++ b/drivers/gpu/drm/i915/i915_sw_fence_work.c
> @@ -85,7 +85,7 @@ void dma_fence_work_init(struct dma_fence_work *f,
> {
> f->ops = ops;
> spin_lock_init(&f->lock);
> - dma_fence_init(&f->dma, &fence_ops, &f->lock, 0, 0);
> + dma_fence_init(&f->dma, &fence_ops, &f->lock, 0, 0, 0);
> i915_sw_fence_init(&f->chain, fence_notify);
> INIT_WORK(&f->work, fence_work);
> }
> diff --git a/drivers/gpu/drm/i915/i915_vma_resource.c b/drivers/gpu/drm/i915/i915_vma_resource.c
> index a8f2112ce81f..19596410e32f 100644
> --- a/drivers/gpu/drm/i915/i915_vma_resource.c
> +++ b/drivers/gpu/drm/i915/i915_vma_resource.c
> @@ -263,7 +263,7 @@ void __i915_vma_resource_init(struct i915_vma_resource *vma_res)
> {
> spin_lock_init(&vma_res->lock);
> dma_fence_init(&vma_res->unbind_fence, &unbind_fence_ops,
> - &vma_res->lock, 0, 0);
> + &vma_res->lock, 0, 0, 0);
> refcount_set(&vma_res->hold_count, 1);
> i915_sw_fence_init(&vma_res->chain, i915_vma_resource_fence_notify);
> }
> diff --git a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
> index ecb2d718f6a6..d8d4f7057031 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
> @@ -641,7 +641,7 @@ static struct dma_fence *alloc_dma_fence(void)
>
> dma = kmalloc_obj(*dma);
> if (dma)
> - dma_fence_init(dma, &mock_fence_ops, &mock_fence_lock, 0, 0);
> + dma_fence_init(dma, &mock_fence_ops, &mock_fence_lock, 0, 0, 0);
>
> return dma;
> }
> diff --git a/drivers/gpu/drm/imagination/pvr_ccb.c b/drivers/gpu/drm/imagination/pvr_ccb.c
> index e408df74853d..7043b491fe54 100644
> --- a/drivers/gpu/drm/imagination/pvr_ccb.c
> +++ b/drivers/gpu/drm/imagination/pvr_ccb.c
> @@ -645,7 +645,7 @@ pvr_kccb_reserve_slot(struct pvr_device *pvr_dev, struct dma_fence *f)
> dma_fence_init(&fence->base, &pvr_kccb_fence_ops,
> &pvr_dev->kccb.fence_ctx.lock,
> pvr_dev->kccb.fence_ctx.id,
> - atomic_inc_return(&pvr_dev->kccb.fence_ctx.seqno));
> + atomic_inc_return(&pvr_dev->kccb.fence_ctx.seqno), 0);
> out_fence = dma_fence_get(&fence->base);
> list_add_tail(&fence->node, &pvr_dev->kccb.waiters);
> } else {
> diff --git a/drivers/gpu/drm/imagination/pvr_queue.c b/drivers/gpu/drm/imagination/pvr_queue.c
> index 24a8645aa913..34b826381aa2 100644
> --- a/drivers/gpu/drm/imagination/pvr_queue.c
> +++ b/drivers/gpu/drm/imagination/pvr_queue.c
> @@ -305,7 +305,7 @@ pvr_queue_fence_init(struct dma_fence *f,
> INIT_WORK(&fence->release_work, pvr_queue_fence_release_work);
> dma_fence_init(&fence->base, fence_ops,
> &fence_ctx->lock, fence_ctx->id,
> - atomic_inc_return(&fence_ctx->seqno));
> + atomic_inc_return(&fence_ctx->seqno), 0);
> }
>
> /**
> diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c
> index 9a1e6b9ecbe5..fee595b9629a 100644
> --- a/drivers/gpu/drm/lima/lima_sched.c
> +++ b/drivers/gpu/drm/lima/lima_sched.c
> @@ -97,7 +97,7 @@ static struct lima_fence *lima_fence_create(struct lima_sched_pipe *pipe)
>
> fence->pipe = pipe;
> dma_fence_init(&fence->base, &lima_fence_ops, &pipe->fence_lock,
> - pipe->fence_context, ++pipe->fence_seqno);
> + pipe->fence_context, ++pipe->fence_seqno, 0);
>
> return fence;
> }
> diff --git a/drivers/gpu/drm/msm/msm_fence.c b/drivers/gpu/drm/msm/msm_fence.c
> index 3dca8e09c192..1ec59919c32e 100644
> --- a/drivers/gpu/drm/msm/msm_fence.c
> +++ b/drivers/gpu/drm/msm/msm_fence.c
> @@ -197,5 +197,5 @@ msm_fence_init(struct dma_fence *fence, struct msm_fence_context *fctx)
> WARN_ON(kref_read(&fence->refcount));
>
> dma_fence_init(&f->base, &msm_fence_ops, &fctx->spinlock,
> - fctx->context, ++fctx->last_fence);
> + fctx->context, ++fctx->last_fence, 0);
> }
> diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
> index 11e95c37ce50..97e20954c71b 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_fence.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
> @@ -216,10 +216,10 @@ nouveau_fence_emit(struct nouveau_fence *fence)
>
> if (priv->uevent)
> dma_fence_init(&fence->base, &nouveau_fence_ops_uevent,
> - &fctx->lock, fctx->context, ++fctx->sequence);
> + &fctx->lock, fctx->context, ++fctx->sequence, 0);
> else
> dma_fence_init(&fence->base, &nouveau_fence_ops_legacy,
> - &fctx->lock, fctx->context, ++fctx->sequence);
> + &fctx->lock, fctx->context, ++fctx->sequence, 0);
> kref_get(&fctx->fence_ref);
>
> ret = fctx->emit(fence);
> diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
> index 4ddf4b722ddf..de242d275978 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_job.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_job.c
> @@ -105,7 +105,7 @@ static struct dma_fence *panfrost_fence_create(struct panfrost_device *pfdev, in
> fence->queue = js_num;
> fence->seqno = ++js->queue[js_num].emit_seqno;
> dma_fence_init(&fence->base, &panfrost_fence_ops, &js->job_lock,
> - js->queue[js_num].fence_context, fence->seqno);
> + js->queue[js_num].fence_context, fence->seqno, 0);
>
> return &fence->base;
> }
> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> index a343c5180e01..c46f69ade7a0 100644
> --- a/drivers/gpu/drm/panthor/panthor_sched.c
> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> @@ -3322,7 +3322,7 @@ queue_run_job(struct drm_sched_job *sched_job)
> &panthor_queue_fence_ops,
> &queue->fence_ctx.lock,
> queue->fence_ctx.id,
> - atomic64_inc_return(&queue->fence_ctx.seqno));
> + atomic64_inc_return(&queue->fence_ctx.seqno), 0);
>
> job->profiling.slot = queue->profiling.seqno++;
> if (queue->profiling.seqno == queue->profiling.slot_count)
> diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
> index 06979d0e8a9f..2608d82f7370 100644
> --- a/drivers/gpu/drm/qxl/qxl_release.c
> +++ b/drivers/gpu/drm/qxl/qxl_release.c
> @@ -430,7 +430,7 @@ void qxl_release_fence_buffer_objects(struct qxl_release *release)
> * set the highest bits. This will break if we really allow exporting of dma-bufs.
> */
> dma_fence_init(&release->base, &qxl_fence_ops, &qdev->release_lock,
> - release->id | 0xf0000000, release->base.seqno);
> + release->id | 0xf0000000, release->base.seqno, 0);
> trace_dma_fence_emit(&release->base);
>
> list_for_each_entry(entry, &release->bos, list) {
> diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
> index 8e9402b8811b..1360b5215f5e 100644
> --- a/drivers/gpu/drm/radeon/radeon_fence.c
> +++ b/drivers/gpu/drm/radeon/radeon_fence.c
> @@ -148,7 +148,7 @@ int radeon_fence_emit(struct radeon_device *rdev,
> dma_fence_init(&(*fence)->base, &radeon_fence_ops,
> &rdev->fence_queue.lock,
> rdev->fence_context + ring,
> - seq);
> + seq, 0);
> radeon_fence_ring_emit(rdev, ring, *fence);
> trace_radeon_fence_emit(rdev_to_drm(rdev), ring, (*fence)->seq);
> radeon_fence_schedule_check(rdev, ring);
> diff --git a/drivers/gpu/drm/scheduler/sched_fence.c b/drivers/gpu/drm/scheduler/sched_fence.c
> index b7a4cb921234..94ba0cf4fe02 100644
> --- a/drivers/gpu/drm/scheduler/sched_fence.c
> +++ b/drivers/gpu/drm/scheduler/sched_fence.c
> @@ -229,9 +229,9 @@ void drm_sched_fence_init(struct drm_sched_fence *fence,
> fence->sched = entity->rq->sched;
> seq = atomic_inc_return(&entity->fence_seq);
> dma_fence_init(&fence->scheduled, &drm_sched_fence_ops_scheduled,
> - &fence->lock, entity->fence_context, seq);
> + &fence->lock, entity->fence_context, seq, 0);
> dma_fence_init(&fence->finished, &drm_sched_fence_ops_finished,
> - &fence->lock, entity->fence_context + 1, seq);
> + &fence->lock, entity->fence_context + 1, seq, 0);
> }
>
> module_init(drm_sched_fence_slab_init);
> diff --git a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
> index 2dfa3efef210..169792a4b329 100644
> --- a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
> +++ b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
> @@ -173,7 +173,7 @@ static struct dma_fence *mock_sched_run_job(struct drm_sched_job *sched_job)
> &drm_mock_sched_hw_fence_ops,
> &sched->lock,
> sched->hw_timeline.context,
> - atomic_inc_return(&sched->hw_timeline.next_seqno));
> + atomic_inc_return(&sched->hw_timeline.next_seqno), 0);
>
> dma_fence_get(&job->hw_fence); /* Reference for the job_list */
>
> diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> index f3103307b5df..633cc7458505 100644
> --- a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> +++ b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> @@ -450,7 +450,7 @@ static void ttm_bo_fini_shared_resv(struct kunit *test)
> KUNIT_ASSERT_NOT_NULL(test, fence);
>
> spin_lock_init(&fence_lock);
> - dma_fence_init(fence, &mock_fence_ops, &fence_lock, 0, 0);
> + dma_fence_init(fence, &mock_fence_ops, &fence_lock, 0, 0, 0);
>
> dma_resv_lock(external_resv, NULL);
> dma_resv_reserve_fences(external_resv, 1);
> diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c b/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
> index 56ad8ef32584..e22a1335f166 100644
> --- a/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
> +++ b/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
> @@ -57,7 +57,7 @@ static struct dma_fence *alloc_mock_fence(struct kunit *test)
> fence = kunit_kzalloc(test, sizeof(*fence), GFP_KERNEL);
> KUNIT_ASSERT_NOT_NULL(test, fence);
>
> - dma_fence_init(fence, &fence_ops, &fence_lock, 0, 0);
> + dma_fence_init(fence, &fence_ops, &fence_lock, 0, 0, 0);
>
> return fence;
> }
> diff --git a/drivers/gpu/drm/v3d/v3d_fence.c b/drivers/gpu/drm/v3d/v3d_fence.c
> index c500136d0455..1fdba5a21580 100644
> --- a/drivers/gpu/drm/v3d/v3d_fence.c
> +++ b/drivers/gpu/drm/v3d/v3d_fence.c
> @@ -16,7 +16,7 @@ struct dma_fence *v3d_fence_create(struct v3d_dev *v3d, enum v3d_queue q)
> fence->queue = q;
> fence->seqno = ++queue->emit_seqno;
> dma_fence_init(&fence->base, &v3d_fence_ops, &queue->queue_lock,
> - queue->fence_context, fence->seqno);
> + queue->fence_context, fence->seqno, 0);
>
> return &fence->base;
> }
> diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
> index ff611c618d6b..420988d516c1 100644
> --- a/drivers/gpu/drm/vc4/vc4_gem.c
> +++ b/drivers/gpu/drm/vc4/vc4_gem.c
> @@ -648,7 +648,7 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec,
> exec->seqno = seqno;
>
> dma_fence_init(&fence->base, &vc4_fence_ops, &vc4->job_lock,
> - vc4->dma_fence_context, exec->seqno);
> + vc4->dma_fence_context, exec->seqno, 0);
> fence->seqno = exec->seqno;
> exec->fence = &fence->base;
>
> diff --git a/drivers/gpu/drm/vgem/vgem_fence.c b/drivers/gpu/drm/vgem/vgem_fence.c
> index 0e53ba7db629..18700e5f9167 100644
> --- a/drivers/gpu/drm/vgem/vgem_fence.c
> +++ b/drivers/gpu/drm/vgem/vgem_fence.c
> @@ -77,7 +77,7 @@ static struct dma_fence *vgem_fence_create(struct vgem_file *vfile,
>
> spin_lock_init(&fence->lock);
> dma_fence_init(&fence->base, &vgem_fence_ops, &fence->lock,
> - dma_fence_context_alloc(1), 1);
> + dma_fence_context_alloc(1), 1, 0);
>
> timer_setup(&fence->timer, vgem_fence_timeout, TIMER_IRQSAFE);
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c
> index c3e66ef2133a..8e469391d2e4 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_fence.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_fence.c
> @@ -76,7 +76,7 @@ struct virtio_gpu_fence *virtio_gpu_fence_alloc(struct virtio_gpu_device *vgdev,
> */
>
> dma_fence_init(&fence->f, &virtio_gpu_fence_ops, &drv->lock,
> - fence_context, 0);
> + fence_context, 0, 0);
>
> return fence;
> }
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> index 384c6736cf6b..15f355dc6881 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> @@ -163,7 +163,7 @@ static int vmw_fence_obj_init(struct vmw_fence_manager *fman,
> int ret = 0;
>
> dma_fence_init(&fence->base, &vmw_fence_ops, &fman->lock,
> - fman->ctx, seqno);
> + fman->ctx, seqno, 0);
> fence->destroy = destroy;
>
> spin_lock(&fman->lock);
> diff --git a/drivers/gpu/drm/xe/xe_hw_fence.c b/drivers/gpu/drm/xe/xe_hw_fence.c
> index 14720623ad00..30bfc42972e0 100644
> --- a/drivers/gpu/drm/xe/xe_hw_fence.c
> +++ b/drivers/gpu/drm/xe/xe_hw_fence.c
> @@ -243,7 +243,7 @@ void xe_hw_fence_init(struct dma_fence *fence, struct xe_hw_fence_ctx *ctx,
> INIT_LIST_HEAD(&hw_fence->irq_link);
>
> dma_fence_init(fence, &xe_hw_fence_ops, &ctx->irq->lock,
> - ctx->dma_fence_ctx, ctx->next_seqno++);
> + ctx->dma_fence_ctx, ctx->next_seqno++, 0);
>
> trace_xe_hw_fence_create(hw_fence);
> }
> diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
> index c9320feeafba..912840eeec50 100644
> --- a/drivers/gpu/drm/xe/xe_oa.c
> +++ b/drivers/gpu/drm/xe/xe_oa.c
> @@ -1053,7 +1053,7 @@ static int xe_oa_emit_oa_config(struct xe_oa_stream *stream, struct xe_oa_config
>
> /* Point of no return: initialize and set fence to signal */
> spin_lock_init(&ofence->lock);
> - dma_fence_init(&ofence->base, &xe_oa_fence_ops, &ofence->lock, 0, 0);
> + dma_fence_init(&ofence->base, &xe_oa_fence_ops, &ofence->lock, 0, 0, 0);
>
> for (i = 0; i < stream->num_syncs; i++) {
> if (stream->syncs[i].flags & DRM_XE_SYNC_FLAG_SIGNAL)
> diff --git a/drivers/gpu/drm/xe/xe_preempt_fence.c b/drivers/gpu/drm/xe/xe_preempt_fence.c
> index 4aa570fe745d..343f1ba1e1cd 100644
> --- a/drivers/gpu/drm/xe/xe_preempt_fence.c
> +++ b/drivers/gpu/drm/xe/xe_preempt_fence.c
> @@ -154,7 +154,7 @@ xe_preempt_fence_arm(struct xe_preempt_fence *pfence, struct xe_exec_queue *q,
> pfence->q = xe_exec_queue_get(q);
> spin_lock_init(&pfence->lock);
> dma_fence_init(&pfence->base, &preempt_fence_ops,
> - &pfence->lock, context, seqno);
> + &pfence->lock, context, seqno, 0);
>
> return &pfence->base;
> }
> diff --git a/drivers/gpu/drm/xe/xe_tlb_inval.c b/drivers/gpu/drm/xe/xe_tlb_inval.c
> index c9cc5842d65b..1fd39434dc0e 100644
> --- a/drivers/gpu/drm/xe/xe_tlb_inval.c
> +++ b/drivers/gpu/drm/xe/xe_tlb_inval.c
> @@ -544,7 +544,7 @@ void xe_tlb_inval_fence_init(struct xe_tlb_inval *tlb_inval,
>
> spin_lock_irq(&tlb_inval->lock);
> dma_fence_init(&fence->base, &inval_fence_ops, &tlb_inval->lock,
> - dma_fence_context_alloc(1), 1);
> + dma_fence_context_alloc(1), 1, 0);
> spin_unlock_irq(&tlb_inval->lock);
> INIT_LIST_HEAD(&fence->link);
> if (stack)
> diff --git a/drivers/gpu/host1x/fence.c b/drivers/gpu/host1x/fence.c
> index 1acf579c562b..7e074e72a055 100644
> --- a/drivers/gpu/host1x/fence.c
> +++ b/drivers/gpu/host1x/fence.c
> @@ -136,7 +136,7 @@ struct dma_fence *host1x_fence_create(struct host1x_syncpt *sp, u32 threshold,
> fence->timeout = timeout;
>
> dma_fence_init(&fence->base, &host1x_syncpt_fence_ops, &sp->fences.lock,
> - dma_fence_context_alloc(1), 0);
> + dma_fence_context_alloc(1), 0, 0);
>
> INIT_DELAYED_WORK(&fence->timeout_work, do_fence_timeout);
>
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 4294101810fd..f7d6b294b63c 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -1904,7 +1904,7 @@ static int iio_buffer_enqueue_dmabuf(struct iio_dev_buffer_pair *ib,
> * the dma_fence.
> */
> dma_fence_init(&fence->base, &iio_buffer_dma_fence_ops,
> - &fence->lock, priv->context, seqno);
> + &fence->lock, priv->context, seqno, 0);
>
> ret = iio_dma_resv_lock(dmabuf, nonblock);
> if (ret)
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index c64a268e98a4..eb367a1666c2 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -1733,7 +1733,7 @@ static int ffs_dmabuf_transfer(struct file *file,
> seqno = atomic_add_return(1, &epfile->seqno);
>
> dma_fence_init(&fence->base, &ffs_dmabuf_fence_ops,
> - &priv->lock, priv->context, seqno);
> + &priv->lock, priv->context, seqno, 0);
>
> resv_dir = epfile->in ? DMA_RESV_USAGE_READ : DMA_RESV_USAGE_WRITE;
>
> diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
> index dd07d128adc3..6f5c245d89ec 100644
> --- a/include/linux/dma-fence.h
> +++ b/include/linux/dma-fence.h
> @@ -103,6 +103,12 @@ struct dma_fence {
> int error;
> };
>
> +/** enum dma_fence_flag_bits - internal dma_fence flags
> + *
> + * These flags are all only for internal usage, except for
> + * @DMA_FENCE_FLAG_SEQNO64_BIT and the user bits beginning at
> + * @DMA_FENCE_FLAG_USER_BITS.
> + */
> enum dma_fence_flag_bits {
> DMA_FENCE_FLAG_INITIALIZED_BIT,
> DMA_FENCE_FLAG_INLINE_LOCK_BIT,
> @@ -110,6 +116,7 @@ enum dma_fence_flag_bits {
> DMA_FENCE_FLAG_SIGNALED_BIT,
> DMA_FENCE_FLAG_TIMESTAMP_BIT,
> DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
> +
> DMA_FENCE_FLAG_USER_BITS, /* must always be last member */
> };
>
> @@ -279,11 +286,10 @@ 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);
> -
> + spinlock_t *lock, u64 context, u64 seqno,
> + unsigned long flags);
> 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);
> diff --git a/rust/kernel/dma_buf/dma_fence.rs b/rust/kernel/dma_buf/dma_fence.rs
> index 18a43e1bb442..ee8fa4ecd6c1 100644
> --- a/rust/kernel/dma_buf/dma_fence.rs
> +++ b/rust/kernel/dma_buf/dma_fence.rs
> @@ -736,7 +736,7 @@ pub fn new_fence(self) -> DriverFence<'a, T> {
> // SAFETY: `fence_ptr` has been created directly above. It will live
> // at least as long as `Self`. The same applies to `&Self::OPS`.
> unsafe {
> - bindings::dma_fence_init(fence_ptr, self.ops, null_ptr, self.data.fctx.nr, seqno)
> + bindings::dma_fence_init(fence_ptr, self.ops, null_ptr, self.data.fctx.nr, seqno, 0)
> };
>
> self.data.fctx.nr_of_unsignaled_fences.fetch_add(1, Relaxed);
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init()
2026-11-05 12:06 ` Tvrtko Ursulin
@ 2026-11-05 12:35 ` Christian König
2026-11-05 12:48 ` Philipp Stanner
2026-11-05 12:51 ` Tvrtko Ursulin
0 siblings, 2 replies; 14+ messages in thread
From: Christian König @ 2026-11-05 12:35 UTC (permalink / raw)
To: Tvrtko Ursulin, Philipp Stanner
Cc: dri-devel, linux-kernel, linux-media, amd-gfx, etnaviv, intel-gfx,
imagination, lima, linux-arm-msm, freedreno, nouveau,
virtualization, spice-devel, intel-xe, linux-tegra, linux-iio,
linux-usb, rust-for-linux
On 11/5/26 13:06, Tvrtko Ursulin wrote:
>
> [I aggresively rewrote the To: list because my SMTP won't let me send this as it was.]
>
> On 05/11/2026 11:35, Philipp Stanner wrote:
>> Currently, there are two init functions for dma_fence, dma_fence_init()
>> and dma_fence_init64().
>>
>> Since more future user options for dma_fence initialization would
>> require distinct init functions, too, it is better to do this in a
>> unified way.
>
> Why not add something like dma_fence_init_flags() and leave the 99% of the callers out of the (huge) diff? Ie. just port dma_fence_init64() to dma_fence_init_flags().
Well one advantage of the Linux kernel is to avoid such wrappers. I think having more than one function for the same thing basically just adds more confusion.
That's also why I would really like to just have one dma_fence_signal() and not like five (or was it four?) variants.
> Also best to move the addition of dma_fence_flags_invalid() to the patch which adds dma_fence_init_flags() and not have it in this one which is supposed to be functionality neutral.
Well this is the first time you can actually specify flags so that kind of makes sense to now add the check as well.
Regards,
Christian.
>
> Regards,
>
> Tvrtko
>
>> Add a flags field to dma_fence_init(). Adjust all affected drivers,
>> preserving the old behavior.
>>
>> Support the SEQNO64 flag, and add a check-function so that the user only
>> sets valid bits.
>>
>> Signed-off-by: Philipp Stanner <phasta@kernel.org>
>> ---
>> drivers/accel/amdxdna/amdxdna_ctx.c | 2 +-
>> drivers/accel/ethosu/ethosu_job.c | 2 +-
>> drivers/accel/ivpu/ivpu_job.c | 2 +-
>> drivers/accel/rocket/rocket_job.c | 2 +-
>> drivers/dma-buf/dma-fence-array.c | 2 +-
>> drivers/dma-buf/dma-fence.c | 31 ++++++++++++++++---
>> drivers/dma-buf/st-dma-fence-chain.c | 2 +-
>> drivers/dma-buf/st-dma-fence-unwrap.c | 2 +-
>> drivers/dma-buf/st-dma-fence.c | 2 +-
>> drivers/dma-buf/st-dma-resv.c | 2 +-
>> drivers/dma-buf/sw_sync.c | 2 +-
>> .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c | 2 +-
>> drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +-
>> drivers/gpu/drm/drm_crtc.c | 2 +-
>> drivers/gpu/drm/drm_writeback.c | 2 +-
>> drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 +-
>> drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 2 +-
>> drivers/gpu/drm/i915/i915_request.c | 2 +-
>> drivers/gpu/drm/i915/i915_sw_fence_work.c | 2 +-
>> drivers/gpu/drm/i915/i915_vma_resource.c | 2 +-
>> .../gpu/drm/i915/selftests/i915_sw_fence.c | 2 +-
>> drivers/gpu/drm/imagination/pvr_ccb.c | 2 +-
>> drivers/gpu/drm/imagination/pvr_queue.c | 2 +-
>> drivers/gpu/drm/lima/lima_sched.c | 2 +-
>> drivers/gpu/drm/msm/msm_fence.c | 2 +-
>> drivers/gpu/drm/nouveau/nouveau_fence.c | 4 +--
>> drivers/gpu/drm/panfrost/panfrost_job.c | 2 +-
>> drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
>> drivers/gpu/drm/qxl/qxl_release.c | 2 +-
>> drivers/gpu/drm/radeon/radeon_fence.c | 2 +-
>> drivers/gpu/drm/scheduler/sched_fence.c | 4 +--
>> .../gpu/drm/scheduler/tests/mock_scheduler.c | 2 +-
>> drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 2 +-
>> .../gpu/drm/ttm/tests/ttm_bo_validate_test.c | 2 +-
>> drivers/gpu/drm/v3d/v3d_fence.c | 2 +-
>> drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
>> drivers/gpu/drm/vgem/vgem_fence.c | 2 +-
>> drivers/gpu/drm/virtio/virtgpu_fence.c | 2 +-
>> drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +-
>> drivers/gpu/drm/xe/xe_hw_fence.c | 2 +-
>> drivers/gpu/drm/xe/xe_oa.c | 2 +-
>> drivers/gpu/drm/xe/xe_preempt_fence.c | 2 +-
>> drivers/gpu/drm/xe/xe_tlb_inval.c | 2 +-
>> drivers/gpu/host1x/fence.c | 2 +-
>> drivers/iio/industrialio-buffer.c | 2 +-
>> drivers/usb/gadget/function/f_fs.c | 2 +-
>> include/linux/dma-fence.h | 12 +++++--
>> rust/kernel/dma_buf/dma_fence.rs | 2 +-
>> 48 files changed, 83 insertions(+), 56 deletions(-)
>>
>> diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/amdxdna_ctx.c
>> index f4004630dc1b..f2245541f1ee 100644
>> --- a/drivers/accel/amdxdna/amdxdna_ctx.c
>> +++ b/drivers/accel/amdxdna/amdxdna_ctx.c
>> @@ -53,7 +53,7 @@ static struct dma_fence *amdxdna_fence_create(struct amdxdna_hwctx *hwctx)
>> spin_lock_init(&fence->lock);
>> /* Unique timeline context prevents eviction from shared BO reservation. */
>> - dma_fence_init(&fence->base, &fence_ops, &fence->lock, dma_fence_context_alloc(1), 0);
>> + dma_fence_init(&fence->base, &fence_ops, &fence->lock, dma_fence_context_alloc(1), 0, 0);
>> return &fence->base;
>> }
>> diff --git a/drivers/accel/ethosu/ethosu_job.c b/drivers/accel/ethosu/ethosu_job.c
>> index d656b3ec670e..d4fc71436cae 100644
>> --- a/drivers/accel/ethosu/ethosu_job.c
>> +++ b/drivers/accel/ethosu/ethosu_job.c
>> @@ -219,7 +219,7 @@ static struct dma_fence *ethosu_job_run(struct drm_sched_job *sched_job)
>> return NULL;
>> dma_fence_init(fence, ðosu_fence_ops, &dev->fence_lock,
>> - dev->fence_context, ++dev->emit_seqno);
>> + dev->fence_context, ++dev->emit_seqno, 0);
>> dma_fence_get(fence);
>> ethosu_switch_perfmon(dev, job);
>> diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c
>> index 76bacabe496b..6b4f059fb209 100644
>> --- a/drivers/accel/ivpu/ivpu_job.c
>> +++ b/drivers/accel/ivpu/ivpu_job.c
>> @@ -519,7 +519,7 @@ static struct dma_fence *ivpu_fence_create(struct ivpu_device *vdev)
>> fence->vdev = vdev;
>> spin_lock_init(&fence->lock);
>> - dma_fence_init(&fence->base, &ivpu_fence_ops, &fence->lock, dma_fence_context_alloc(1), 1);
>> + dma_fence_init(&fence->base, &ivpu_fence_ops, &fence->lock, dma_fence_context_alloc(1), 1, 0);
>> return &fence->base;
>> }
>> diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
>> index b2a00992c889..574c9ea802c9 100644
>> --- a/drivers/accel/rocket/rocket_job.c
>> +++ b/drivers/accel/rocket/rocket_job.c
>> @@ -61,7 +61,7 @@ static struct dma_fence *rocket_fence_create(struct rocket_core *core)
>> return ERR_PTR(-ENOMEM);
>> dma_fence_init(fence, &rocket_fence_ops, &core->fence_lock,
>> - core->fence_context, ++core->emit_seqno);
>> + core->fence_context, ++core->emit_seqno, 0);
>> return fence;
>> }
>> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
>> index 5e10e8df372f..e2dddbfddea2 100644
>> --- a/drivers/dma-buf/dma-fence-array.c
>> +++ b/drivers/dma-buf/dma-fence-array.c
>> @@ -205,7 +205,7 @@ void dma_fence_array_init(struct dma_fence_array *array,
>> array->num_fences = num_fences;
>> dma_fence_init(&array->base, &dma_fence_array_ops, NULL, context,
>> - seqno);
>> + seqno, 0);
>> init_irq_work(&array->work, irq_dma_fence_array_work);
>> /*
>> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
>> index bd58688b81a7..a511cf755ee8 100644
>> --- a/drivers/dma-buf/dma-fence.c
>> +++ b/drivers/dma-buf/dma-fence.c
>> @@ -122,7 +122,7 @@ static const struct dma_fence_ops dma_fence_stub_ops = {
>> static int __init dma_fence_init_stub(void)
>> {
>> - dma_fence_init(&dma_fence_stub, &dma_fence_stub_ops, NULL, 0, 0);
>> + dma_fence_init(&dma_fence_stub, &dma_fence_stub_ops, NULL, 0, 0, 0);
>> set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
>> &dma_fence_stub.flags);
>> dma_fence_signal(&dma_fence_stub);
>> @@ -156,7 +156,7 @@ struct dma_fence *dma_fence_allocate_private_stub(ktime_t timestamp)
>> if (fence == NULL)
>> return NULL;
>> - dma_fence_init(fence, &dma_fence_stub_ops, NULL, 0, 0);
>> + dma_fence_init(fence, &dma_fence_stub_ops, NULL, 0, 0, 0);
>> set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
>> &fence->flags);
>> @@ -1063,7 +1063,6 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>> spinlock_t *lock, u64 context, u64 seqno, unsigned long flags)
>> {
>> BUG_ON(!ops || !ops->get_driver_name || !ops->get_timeline_name);
>> -
>> kref_init(&fence->refcount);
>> /*
>> * While it is counter intuitive to protect a constant function pointer
>> @@ -1087,6 +1086,21 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>> trace_dma_fence_init(fence);
>> }
>> +static bool dma_fence_flags_invalid(unsigned long flags)
>> +{
>> + const unsigned long valid_fence_bits =
>> + BIT(DMA_FENCE_FLAG_SEQNO64_BIT);
>> + const unsigned long valid_user_bits =
>> + GENMASK(
>> + BITS_PER_TYPE(unsigned long) - 1,
>> + DMA_FENCE_FLAG_USER_BITS
>> + );
>> + const unsigned long invalid_bits =
>> + ~(valid_fence_bits | valid_user_bits);
>> +
>> + return flags & invalid_bits;
>> +}
>> +
>> /**
>> * dma_fence_init - Initialize a custom fence.
>> * @fence: the fence to initialize
>> @@ -1094,6 +1108,7 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>> * @lock: optional irqsafe spinlock to use for locking this fence
>> * @context: the execution context this fence is run on
>> * @seqno: a linear increasing sequence number for this context
>> + * @flags: flags modifying a fence's behavior
>> *
>> * Initializes an allocated fence, the caller doesn't have to keep its
>> * refcount after committing with this fence, but it will need to hold a
>> @@ -1108,12 +1123,18 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>> * introduction of the callback, but the external lock is still around. New
>> * users MUST NOT use external locks, as they force the issuer to outlive all
>> * fences that reference the lock.
>> + *
>> + * The @flags you can specify here are either DMA_FENCE_FLAG_SEQNO64_BIT or
>> + * user-specified bits >= DMA_FENCE_FLAG_USER_BITS.
>> */
>> void
>> dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>> - spinlock_t *lock, u64 context, u64 seqno)
>> + spinlock_t *lock, u64 context, u64 seqno,
>> + unsigned long flags)
>> {
>> - __dma_fence_init(fence, ops, lock, context, seqno, 0UL);
>> + WARN_ON(dma_fence_flags_invalid(flags));
>> +
>> + __dma_fence_init(fence, ops, lock, context, seqno, flags);
>> }
>> EXPORT_SYMBOL(dma_fence_init);
>> diff --git a/drivers/dma-buf/st-dma-fence-chain.c b/drivers/dma-buf/st-dma-fence-chain.c
>> index e0d9b69bfa76..b9610df3ff19 100644
>> --- a/drivers/dma-buf/st-dma-fence-chain.c
>> +++ b/drivers/dma-buf/st-dma-fence-chain.c
>> @@ -52,7 +52,7 @@ static struct dma_fence *mock_fence(void)
>> return NULL;
>> spin_lock_init(&f->lock);
>> - dma_fence_init(&f->base, &mock_ops, &f->lock, 0, 0);
>> + dma_fence_init(&f->base, &mock_ops, &f->lock, 0, 0, 0);
>> return &f->base;
>> }
>> diff --git a/drivers/dma-buf/st-dma-fence-unwrap.c b/drivers/dma-buf/st-dma-fence-unwrap.c
>> index c5353b36f0e4..dbebc3046d42 100644
>> --- a/drivers/dma-buf/st-dma-fence-unwrap.c
>> +++ b/drivers/dma-buf/st-dma-fence-unwrap.c
>> @@ -36,7 +36,7 @@ static struct dma_fence *__mock_fence(u64 context, u64 seqno)
>> return NULL;
>> spin_lock_init(&f->lock);
>> - dma_fence_init(&f->base, &mock_ops, &f->lock, context, seqno);
>> + dma_fence_init(&f->base, &mock_ops, &f->lock, context, seqno, 0);
>> return &f->base;
>> }
>> diff --git a/drivers/dma-buf/st-dma-fence.c b/drivers/dma-buf/st-dma-fence.c
>> index cb62e606d0a2..b3f88e89cc44 100644
>> --- a/drivers/dma-buf/st-dma-fence.c
>> +++ b/drivers/dma-buf/st-dma-fence.c
>> @@ -31,7 +31,7 @@ static struct dma_fence *mock_fence(void)
>> if (!f)
>> return NULL;
>> - dma_fence_init(f, &mock_ops, NULL, 0, 0);
>> + dma_fence_init(f, &mock_ops, NULL, 0, 0, 0);
>> return f;
>> }
>> diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c
>> index 0b96136bbd54..c3a920ab3fcf 100644
>> --- a/drivers/dma-buf/st-dma-resv.c
>> +++ b/drivers/dma-buf/st-dma-resv.c
>> @@ -35,7 +35,7 @@ static struct dma_fence *alloc_fence(void)
>> if (!f)
>> return NULL;
>> - dma_fence_init(f, &fence_ops, &fence_lock, 0, 0);
>> + dma_fence_init(f, &fence_ops, &fence_lock, 0, 0, 0);
>> return f;
>> }
>> diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
>> index 8df20b0218a9..ce43af7e735e 100644
>> --- a/drivers/dma-buf/sw_sync.c
>> +++ b/drivers/dma-buf/sw_sync.c
>> @@ -258,7 +258,7 @@ static struct sync_pt *sync_pt_create(struct sync_timeline *obj,
>> sync_timeline_get(obj);
>> dma_fence_init(&pt->base, &timeline_fence_ops, &obj->lock,
>> - obj->context, value);
>> + obj->context, value, 0);
>> INIT_LIST_HEAD(&pt->link);
>> spin_lock_irq(&obj->lock);
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c
>> index 9b10d015671c..30ccdb3e0b47 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c
>> @@ -77,7 +77,7 @@ struct amdgpu_amdkfd_fence *amdgpu_amdkfd_fence_create(u64 context,
>> spin_lock_init(&fence->lock);
>> fence->context_id = context_id;
>> dma_fence_init(&fence->base, &amdkfd_fence_ops, &fence->lock,
>> - context, atomic_inc_return(&fence_seq));
>> + context, atomic_inc_return(&fence_seq), 0);
>> return fence;
>> }
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
>> index bff2d38f3571..03e1974f8dda 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
>> @@ -112,7 +112,7 @@ void amdgpu_fence_emit(struct amdgpu_ring *ring, struct amdgpu_fence *af,
>> seq = ++ring->fence_drv.sync_seq;
>> dma_fence_init(fence, &amdgpu_fence_ops,
>> &ring->fence_drv.lock,
>> - adev->fence_context + ring->idx, seq);
>> + adev->fence_context + ring->idx, seq, 0);
>> amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,
>> seq, flags | AMDGPU_FENCE_FLAG_INT);
>> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
>> index 63ead8ba6756..92641bc0a378 100644
>> --- a/drivers/gpu/drm/drm_crtc.c
>> +++ b/drivers/gpu/drm/drm_crtc.c
>> @@ -190,7 +190,7 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)
>> return NULL;
>> dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock,
>> - crtc->fence_context, ++crtc->fence_seqno);
>> + crtc->fence_context, ++crtc->fence_seqno, 0);
>> return fence;
>> }
>> diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c
>> index b4a002e6d043..64b06b890f19 100644
>> --- a/drivers/gpu/drm/drm_writeback.c
>> +++ b/drivers/gpu/drm/drm_writeback.c
>> @@ -592,7 +592,7 @@ drm_writeback_get_out_fence(struct drm_writeback_connector *wb_connector)
>> dma_fence_init(fence, &drm_writeback_fence_ops,
>> &wb_connector->fence_lock, wb_connector->fence_context,
>> - ++wb_connector->fence_seqno);
>> + ++wb_connector->fence_seqno, 0);
>> return fence;
>> }
>> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
>> index e75dab5e407d..a10e4e4cf372 100644
>> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
>> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
>> @@ -1199,7 +1199,7 @@ static struct dma_fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu)
>> f->gpu = gpu;
>> dma_fence_init(&f->base, &etnaviv_fence_ops, &gpu->fence_spinlock,
>> - gpu->fence_context, ++gpu->next_fence);
>> + gpu->fence_context, ++gpu->next_fence, 0);
>> return &f->base;
>> }
>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
>> index 56489cc127d6..ffaa70191f27 100644
>> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
>> @@ -437,7 +437,7 @@ i915_ttm_memcpy_work_arm(struct i915_ttm_memcpy_work *work,
>> int ret;
>> spin_lock_init(&work->lock);
>> - dma_fence_init(&work->fence, &dma_fence_memcpy_ops, &work->lock, 0, 0);
>> + dma_fence_init(&work->fence, &dma_fence_memcpy_ops, &work->lock, 0, 0, 0);
>> dma_fence_get(&work->fence);
>> ret = dma_fence_add_callback(dep, &work->cb, __memcpy_cb);
>> if (ret) {
>> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
>> index f66f8efc7062..0f4fc9cc0033 100644
>> --- a/drivers/gpu/drm/i915/i915_request.c
>> +++ b/drivers/gpu/drm/i915/i915_request.c
>> @@ -953,7 +953,7 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp)
>> goto err_free;
>> dma_fence_init(&rq->fence, &i915_fence_ops, &rq->lock,
>> - tl->fence_context, seqno);
>> + tl->fence_context, seqno, 0);
>> RCU_INIT_POINTER(rq->timeline, tl);
>> rq->hwsp_seqno = tl->hwsp_seqno;
>> diff --git a/drivers/gpu/drm/i915/i915_sw_fence_work.c b/drivers/gpu/drm/i915/i915_sw_fence_work.c
>> index 366418108f78..4cd44dd26e35 100644
>> --- a/drivers/gpu/drm/i915/i915_sw_fence_work.c
>> +++ b/drivers/gpu/drm/i915/i915_sw_fence_work.c
>> @@ -85,7 +85,7 @@ void dma_fence_work_init(struct dma_fence_work *f,
>> {
>> f->ops = ops;
>> spin_lock_init(&f->lock);
>> - dma_fence_init(&f->dma, &fence_ops, &f->lock, 0, 0);
>> + dma_fence_init(&f->dma, &fence_ops, &f->lock, 0, 0, 0);
>> i915_sw_fence_init(&f->chain, fence_notify);
>> INIT_WORK(&f->work, fence_work);
>> }
>> diff --git a/drivers/gpu/drm/i915/i915_vma_resource.c b/drivers/gpu/drm/i915/i915_vma_resource.c
>> index a8f2112ce81f..19596410e32f 100644
>> --- a/drivers/gpu/drm/i915/i915_vma_resource.c
>> +++ b/drivers/gpu/drm/i915/i915_vma_resource.c
>> @@ -263,7 +263,7 @@ void __i915_vma_resource_init(struct i915_vma_resource *vma_res)
>> {
>> spin_lock_init(&vma_res->lock);
>> dma_fence_init(&vma_res->unbind_fence, &unbind_fence_ops,
>> - &vma_res->lock, 0, 0);
>> + &vma_res->lock, 0, 0, 0);
>> refcount_set(&vma_res->hold_count, 1);
>> i915_sw_fence_init(&vma_res->chain, i915_vma_resource_fence_notify);
>> }
>> diff --git a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
>> index ecb2d718f6a6..d8d4f7057031 100644
>> --- a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
>> +++ b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
>> @@ -641,7 +641,7 @@ static struct dma_fence *alloc_dma_fence(void)
>> dma = kmalloc_obj(*dma);
>> if (dma)
>> - dma_fence_init(dma, &mock_fence_ops, &mock_fence_lock, 0, 0);
>> + dma_fence_init(dma, &mock_fence_ops, &mock_fence_lock, 0, 0, 0);
>> return dma;
>> }
>> diff --git a/drivers/gpu/drm/imagination/pvr_ccb.c b/drivers/gpu/drm/imagination/pvr_ccb.c
>> index e408df74853d..7043b491fe54 100644
>> --- a/drivers/gpu/drm/imagination/pvr_ccb.c
>> +++ b/drivers/gpu/drm/imagination/pvr_ccb.c
>> @@ -645,7 +645,7 @@ pvr_kccb_reserve_slot(struct pvr_device *pvr_dev, struct dma_fence *f)
>> dma_fence_init(&fence->base, &pvr_kccb_fence_ops,
>> &pvr_dev->kccb.fence_ctx.lock,
>> pvr_dev->kccb.fence_ctx.id,
>> - atomic_inc_return(&pvr_dev->kccb.fence_ctx.seqno));
>> + atomic_inc_return(&pvr_dev->kccb.fence_ctx.seqno), 0);
>> out_fence = dma_fence_get(&fence->base);
>> list_add_tail(&fence->node, &pvr_dev->kccb.waiters);
>> } else {
>> diff --git a/drivers/gpu/drm/imagination/pvr_queue.c b/drivers/gpu/drm/imagination/pvr_queue.c
>> index 24a8645aa913..34b826381aa2 100644
>> --- a/drivers/gpu/drm/imagination/pvr_queue.c
>> +++ b/drivers/gpu/drm/imagination/pvr_queue.c
>> @@ -305,7 +305,7 @@ pvr_queue_fence_init(struct dma_fence *f,
>> INIT_WORK(&fence->release_work, pvr_queue_fence_release_work);
>> dma_fence_init(&fence->base, fence_ops,
>> &fence_ctx->lock, fence_ctx->id,
>> - atomic_inc_return(&fence_ctx->seqno));
>> + atomic_inc_return(&fence_ctx->seqno), 0);
>> }
>> /**
>> diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c
>> index 9a1e6b9ecbe5..fee595b9629a 100644
>> --- a/drivers/gpu/drm/lima/lima_sched.c
>> +++ b/drivers/gpu/drm/lima/lima_sched.c
>> @@ -97,7 +97,7 @@ static struct lima_fence *lima_fence_create(struct lima_sched_pipe *pipe)
>> fence->pipe = pipe;
>> dma_fence_init(&fence->base, &lima_fence_ops, &pipe->fence_lock,
>> - pipe->fence_context, ++pipe->fence_seqno);
>> + pipe->fence_context, ++pipe->fence_seqno, 0);
>> return fence;
>> }
>> diff --git a/drivers/gpu/drm/msm/msm_fence.c b/drivers/gpu/drm/msm/msm_fence.c
>> index 3dca8e09c192..1ec59919c32e 100644
>> --- a/drivers/gpu/drm/msm/msm_fence.c
>> +++ b/drivers/gpu/drm/msm/msm_fence.c
>> @@ -197,5 +197,5 @@ msm_fence_init(struct dma_fence *fence, struct msm_fence_context *fctx)
>> WARN_ON(kref_read(&fence->refcount));
>> dma_fence_init(&f->base, &msm_fence_ops, &fctx->spinlock,
>> - fctx->context, ++fctx->last_fence);
>> + fctx->context, ++fctx->last_fence, 0);
>> }
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
>> index 11e95c37ce50..97e20954c71b 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_fence.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
>> @@ -216,10 +216,10 @@ nouveau_fence_emit(struct nouveau_fence *fence)
>> if (priv->uevent)
>> dma_fence_init(&fence->base, &nouveau_fence_ops_uevent,
>> - &fctx->lock, fctx->context, ++fctx->sequence);
>> + &fctx->lock, fctx->context, ++fctx->sequence, 0);
>> else
>> dma_fence_init(&fence->base, &nouveau_fence_ops_legacy,
>> - &fctx->lock, fctx->context, ++fctx->sequence);
>> + &fctx->lock, fctx->context, ++fctx->sequence, 0);
>> kref_get(&fctx->fence_ref);
>> ret = fctx->emit(fence);
>> diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
>> index 4ddf4b722ddf..de242d275978 100644
>> --- a/drivers/gpu/drm/panfrost/panfrost_job.c
>> +++ b/drivers/gpu/drm/panfrost/panfrost_job.c
>> @@ -105,7 +105,7 @@ static struct dma_fence *panfrost_fence_create(struct panfrost_device *pfdev, in
>> fence->queue = js_num;
>> fence->seqno = ++js->queue[js_num].emit_seqno;
>> dma_fence_init(&fence->base, &panfrost_fence_ops, &js->job_lock,
>> - js->queue[js_num].fence_context, fence->seqno);
>> + js->queue[js_num].fence_context, fence->seqno, 0);
>> return &fence->base;
>> }
>> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
>> index a343c5180e01..c46f69ade7a0 100644
>> --- a/drivers/gpu/drm/panthor/panthor_sched.c
>> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
>> @@ -3322,7 +3322,7 @@ queue_run_job(struct drm_sched_job *sched_job)
>> &panthor_queue_fence_ops,
>> &queue->fence_ctx.lock,
>> queue->fence_ctx.id,
>> - atomic64_inc_return(&queue->fence_ctx.seqno));
>> + atomic64_inc_return(&queue->fence_ctx.seqno), 0);
>> job->profiling.slot = queue->profiling.seqno++;
>> if (queue->profiling.seqno == queue->profiling.slot_count)
>> diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
>> index 06979d0e8a9f..2608d82f7370 100644
>> --- a/drivers/gpu/drm/qxl/qxl_release.c
>> +++ b/drivers/gpu/drm/qxl/qxl_release.c
>> @@ -430,7 +430,7 @@ void qxl_release_fence_buffer_objects(struct qxl_release *release)
>> * set the highest bits. This will break if we really allow exporting of dma-bufs.
>> */
>> dma_fence_init(&release->base, &qxl_fence_ops, &qdev->release_lock,
>> - release->id | 0xf0000000, release->base.seqno);
>> + release->id | 0xf0000000, release->base.seqno, 0);
>> trace_dma_fence_emit(&release->base);
>> list_for_each_entry(entry, &release->bos, list) {
>> diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
>> index 8e9402b8811b..1360b5215f5e 100644
>> --- a/drivers/gpu/drm/radeon/radeon_fence.c
>> +++ b/drivers/gpu/drm/radeon/radeon_fence.c
>> @@ -148,7 +148,7 @@ int radeon_fence_emit(struct radeon_device *rdev,
>> dma_fence_init(&(*fence)->base, &radeon_fence_ops,
>> &rdev->fence_queue.lock,
>> rdev->fence_context + ring,
>> - seq);
>> + seq, 0);
>> radeon_fence_ring_emit(rdev, ring, *fence);
>> trace_radeon_fence_emit(rdev_to_drm(rdev), ring, (*fence)->seq);
>> radeon_fence_schedule_check(rdev, ring);
>> diff --git a/drivers/gpu/drm/scheduler/sched_fence.c b/drivers/gpu/drm/scheduler/sched_fence.c
>> index b7a4cb921234..94ba0cf4fe02 100644
>> --- a/drivers/gpu/drm/scheduler/sched_fence.c
>> +++ b/drivers/gpu/drm/scheduler/sched_fence.c
>> @@ -229,9 +229,9 @@ void drm_sched_fence_init(struct drm_sched_fence *fence,
>> fence->sched = entity->rq->sched;
>> seq = atomic_inc_return(&entity->fence_seq);
>> dma_fence_init(&fence->scheduled, &drm_sched_fence_ops_scheduled,
>> - &fence->lock, entity->fence_context, seq);
>> + &fence->lock, entity->fence_context, seq, 0);
>> dma_fence_init(&fence->finished, &drm_sched_fence_ops_finished,
>> - &fence->lock, entity->fence_context + 1, seq);
>> + &fence->lock, entity->fence_context + 1, seq, 0);
>> }
>> module_init(drm_sched_fence_slab_init);
>> diff --git a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
>> index 2dfa3efef210..169792a4b329 100644
>> --- a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
>> +++ b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
>> @@ -173,7 +173,7 @@ static struct dma_fence *mock_sched_run_job(struct drm_sched_job *sched_job)
>> &drm_mock_sched_hw_fence_ops,
>> &sched->lock,
>> sched->hw_timeline.context,
>> - atomic_inc_return(&sched->hw_timeline.next_seqno));
>> + atomic_inc_return(&sched->hw_timeline.next_seqno), 0);
>> dma_fence_get(&job->hw_fence); /* Reference for the job_list */
>> diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
>> index f3103307b5df..633cc7458505 100644
>> --- a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
>> +++ b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
>> @@ -450,7 +450,7 @@ static void ttm_bo_fini_shared_resv(struct kunit *test)
>> KUNIT_ASSERT_NOT_NULL(test, fence);
>> spin_lock_init(&fence_lock);
>> - dma_fence_init(fence, &mock_fence_ops, &fence_lock, 0, 0);
>> + dma_fence_init(fence, &mock_fence_ops, &fence_lock, 0, 0, 0);
>> dma_resv_lock(external_resv, NULL);
>> dma_resv_reserve_fences(external_resv, 1);
>> diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c b/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
>> index 56ad8ef32584..e22a1335f166 100644
>> --- a/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
>> +++ b/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
>> @@ -57,7 +57,7 @@ static struct dma_fence *alloc_mock_fence(struct kunit *test)
>> fence = kunit_kzalloc(test, sizeof(*fence), GFP_KERNEL);
>> KUNIT_ASSERT_NOT_NULL(test, fence);
>> - dma_fence_init(fence, &fence_ops, &fence_lock, 0, 0);
>> + dma_fence_init(fence, &fence_ops, &fence_lock, 0, 0, 0);
>> return fence;
>> }
>> diff --git a/drivers/gpu/drm/v3d/v3d_fence.c b/drivers/gpu/drm/v3d/v3d_fence.c
>> index c500136d0455..1fdba5a21580 100644
>> --- a/drivers/gpu/drm/v3d/v3d_fence.c
>> +++ b/drivers/gpu/drm/v3d/v3d_fence.c
>> @@ -16,7 +16,7 @@ struct dma_fence *v3d_fence_create(struct v3d_dev *v3d, enum v3d_queue q)
>> fence->queue = q;
>> fence->seqno = ++queue->emit_seqno;
>> dma_fence_init(&fence->base, &v3d_fence_ops, &queue->queue_lock,
>> - queue->fence_context, fence->seqno);
>> + queue->fence_context, fence->seqno, 0);
>> return &fence->base;
>> }
>> diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
>> index ff611c618d6b..420988d516c1 100644
>> --- a/drivers/gpu/drm/vc4/vc4_gem.c
>> +++ b/drivers/gpu/drm/vc4/vc4_gem.c
>> @@ -648,7 +648,7 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec,
>> exec->seqno = seqno;
>> dma_fence_init(&fence->base, &vc4_fence_ops, &vc4->job_lock,
>> - vc4->dma_fence_context, exec->seqno);
>> + vc4->dma_fence_context, exec->seqno, 0);
>> fence->seqno = exec->seqno;
>> exec->fence = &fence->base;
>> diff --git a/drivers/gpu/drm/vgem/vgem_fence.c b/drivers/gpu/drm/vgem/vgem_fence.c
>> index 0e53ba7db629..18700e5f9167 100644
>> --- a/drivers/gpu/drm/vgem/vgem_fence.c
>> +++ b/drivers/gpu/drm/vgem/vgem_fence.c
>> @@ -77,7 +77,7 @@ static struct dma_fence *vgem_fence_create(struct vgem_file *vfile,
>> spin_lock_init(&fence->lock);
>> dma_fence_init(&fence->base, &vgem_fence_ops, &fence->lock,
>> - dma_fence_context_alloc(1), 1);
>> + dma_fence_context_alloc(1), 1, 0);
>> timer_setup(&fence->timer, vgem_fence_timeout, TIMER_IRQSAFE);
>> diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c
>> index c3e66ef2133a..8e469391d2e4 100644
>> --- a/drivers/gpu/drm/virtio/virtgpu_fence.c
>> +++ b/drivers/gpu/drm/virtio/virtgpu_fence.c
>> @@ -76,7 +76,7 @@ struct virtio_gpu_fence *virtio_gpu_fence_alloc(struct virtio_gpu_device *vgdev,
>> */
>> dma_fence_init(&fence->f, &virtio_gpu_fence_ops, &drv->lock,
>> - fence_context, 0);
>> + fence_context, 0, 0);
>> return fence;
>> }
>> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
>> index 384c6736cf6b..15f355dc6881 100644
>> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
>> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
>> @@ -163,7 +163,7 @@ static int vmw_fence_obj_init(struct vmw_fence_manager *fman,
>> int ret = 0;
>> dma_fence_init(&fence->base, &vmw_fence_ops, &fman->lock,
>> - fman->ctx, seqno);
>> + fman->ctx, seqno, 0);
>> fence->destroy = destroy;
>> spin_lock(&fman->lock);
>> diff --git a/drivers/gpu/drm/xe/xe_hw_fence.c b/drivers/gpu/drm/xe/xe_hw_fence.c
>> index 14720623ad00..30bfc42972e0 100644
>> --- a/drivers/gpu/drm/xe/xe_hw_fence.c
>> +++ b/drivers/gpu/drm/xe/xe_hw_fence.c
>> @@ -243,7 +243,7 @@ void xe_hw_fence_init(struct dma_fence *fence, struct xe_hw_fence_ctx *ctx,
>> INIT_LIST_HEAD(&hw_fence->irq_link);
>> dma_fence_init(fence, &xe_hw_fence_ops, &ctx->irq->lock,
>> - ctx->dma_fence_ctx, ctx->next_seqno++);
>> + ctx->dma_fence_ctx, ctx->next_seqno++, 0);
>> trace_xe_hw_fence_create(hw_fence);
>> }
>> diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
>> index c9320feeafba..912840eeec50 100644
>> --- a/drivers/gpu/drm/xe/xe_oa.c
>> +++ b/drivers/gpu/drm/xe/xe_oa.c
>> @@ -1053,7 +1053,7 @@ static int xe_oa_emit_oa_config(struct xe_oa_stream *stream, struct xe_oa_config
>> /* Point of no return: initialize and set fence to signal */
>> spin_lock_init(&ofence->lock);
>> - dma_fence_init(&ofence->base, &xe_oa_fence_ops, &ofence->lock, 0, 0);
>> + dma_fence_init(&ofence->base, &xe_oa_fence_ops, &ofence->lock, 0, 0, 0);
>> for (i = 0; i < stream->num_syncs; i++) {
>> if (stream->syncs[i].flags & DRM_XE_SYNC_FLAG_SIGNAL)
>> diff --git a/drivers/gpu/drm/xe/xe_preempt_fence.c b/drivers/gpu/drm/xe/xe_preempt_fence.c
>> index 4aa570fe745d..343f1ba1e1cd 100644
>> --- a/drivers/gpu/drm/xe/xe_preempt_fence.c
>> +++ b/drivers/gpu/drm/xe/xe_preempt_fence.c
>> @@ -154,7 +154,7 @@ xe_preempt_fence_arm(struct xe_preempt_fence *pfence, struct xe_exec_queue *q,
>> pfence->q = xe_exec_queue_get(q);
>> spin_lock_init(&pfence->lock);
>> dma_fence_init(&pfence->base, &preempt_fence_ops,
>> - &pfence->lock, context, seqno);
>> + &pfence->lock, context, seqno, 0);
>> return &pfence->base;
>> }
>> diff --git a/drivers/gpu/drm/xe/xe_tlb_inval.c b/drivers/gpu/drm/xe/xe_tlb_inval.c
>> index c9cc5842d65b..1fd39434dc0e 100644
>> --- a/drivers/gpu/drm/xe/xe_tlb_inval.c
>> +++ b/drivers/gpu/drm/xe/xe_tlb_inval.c
>> @@ -544,7 +544,7 @@ void xe_tlb_inval_fence_init(struct xe_tlb_inval *tlb_inval,
>> spin_lock_irq(&tlb_inval->lock);
>> dma_fence_init(&fence->base, &inval_fence_ops, &tlb_inval->lock,
>> - dma_fence_context_alloc(1), 1);
>> + dma_fence_context_alloc(1), 1, 0);
>> spin_unlock_irq(&tlb_inval->lock);
>> INIT_LIST_HEAD(&fence->link);
>> if (stack)
>> diff --git a/drivers/gpu/host1x/fence.c b/drivers/gpu/host1x/fence.c
>> index 1acf579c562b..7e074e72a055 100644
>> --- a/drivers/gpu/host1x/fence.c
>> +++ b/drivers/gpu/host1x/fence.c
>> @@ -136,7 +136,7 @@ struct dma_fence *host1x_fence_create(struct host1x_syncpt *sp, u32 threshold,
>> fence->timeout = timeout;
>> dma_fence_init(&fence->base, &host1x_syncpt_fence_ops, &sp->fences.lock,
>> - dma_fence_context_alloc(1), 0);
>> + dma_fence_context_alloc(1), 0, 0);
>> INIT_DELAYED_WORK(&fence->timeout_work, do_fence_timeout);
>> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
>> index 4294101810fd..f7d6b294b63c 100644
>> --- a/drivers/iio/industrialio-buffer.c
>> +++ b/drivers/iio/industrialio-buffer.c
>> @@ -1904,7 +1904,7 @@ static int iio_buffer_enqueue_dmabuf(struct iio_dev_buffer_pair *ib,
>> * the dma_fence.
>> */
>> dma_fence_init(&fence->base, &iio_buffer_dma_fence_ops,
>> - &fence->lock, priv->context, seqno);
>> + &fence->lock, priv->context, seqno, 0);
>> ret = iio_dma_resv_lock(dmabuf, nonblock);
>> if (ret)
>> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
>> index c64a268e98a4..eb367a1666c2 100644
>> --- a/drivers/usb/gadget/function/f_fs.c
>> +++ b/drivers/usb/gadget/function/f_fs.c
>> @@ -1733,7 +1733,7 @@ static int ffs_dmabuf_transfer(struct file *file,
>> seqno = atomic_add_return(1, &epfile->seqno);
>> dma_fence_init(&fence->base, &ffs_dmabuf_fence_ops,
>> - &priv->lock, priv->context, seqno);
>> + &priv->lock, priv->context, seqno, 0);
>> resv_dir = epfile->in ? DMA_RESV_USAGE_READ : DMA_RESV_USAGE_WRITE;
>> diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
>> index dd07d128adc3..6f5c245d89ec 100644
>> --- a/include/linux/dma-fence.h
>> +++ b/include/linux/dma-fence.h
>> @@ -103,6 +103,12 @@ struct dma_fence {
>> int error;
>> };
>> +/** enum dma_fence_flag_bits - internal dma_fence flags
>> + *
>> + * These flags are all only for internal usage, except for
>> + * @DMA_FENCE_FLAG_SEQNO64_BIT and the user bits beginning at
>> + * @DMA_FENCE_FLAG_USER_BITS.
>> + */
>> enum dma_fence_flag_bits {
>> DMA_FENCE_FLAG_INITIALIZED_BIT,
>> DMA_FENCE_FLAG_INLINE_LOCK_BIT,
>> @@ -110,6 +116,7 @@ enum dma_fence_flag_bits {
>> DMA_FENCE_FLAG_SIGNALED_BIT,
>> DMA_FENCE_FLAG_TIMESTAMP_BIT,
>> DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
>> +
>> DMA_FENCE_FLAG_USER_BITS, /* must always be last member */
>> };
>> @@ -279,11 +286,10 @@ 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);
>> -
>> + spinlock_t *lock, u64 context, u64 seqno,
>> + unsigned long flags);
>> 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);
>> diff --git a/rust/kernel/dma_buf/dma_fence.rs b/rust/kernel/dma_buf/dma_fence.rs
>> index 18a43e1bb442..ee8fa4ecd6c1 100644
>> --- a/rust/kernel/dma_buf/dma_fence.rs
>> +++ b/rust/kernel/dma_buf/dma_fence.rs
>> @@ -736,7 +736,7 @@ pub fn new_fence(self) -> DriverFence<'a, T> {
>> // SAFETY: `fence_ptr` has been created directly above. It will live
>> // at least as long as `Self`. The same applies to `&Self::OPS`.
>> unsafe {
>> - bindings::dma_fence_init(fence_ptr, self.ops, null_ptr, self.data.fctx.nr, seqno)
>> + bindings::dma_fence_init(fence_ptr, self.ops, null_ptr, self.data.fctx.nr, seqno, 0)
>> };
>> self.data.fctx.nr_of_unsignaled_fences.fetch_add(1, Relaxed);
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init()
2026-11-05 12:35 ` Christian König
@ 2026-11-05 12:48 ` Philipp Stanner
2026-11-05 14:23 ` Christian König
2026-11-05 12:51 ` Tvrtko Ursulin
1 sibling, 1 reply; 14+ messages in thread
From: Philipp Stanner @ 2026-11-05 12:48 UTC (permalink / raw)
To: Christian König, Tvrtko Ursulin, Philipp Stanner
Cc: dri-devel, linux-kernel, linux-media, amd-gfx, etnaviv, intel-gfx,
imagination, lima, linux-arm-msm, freedreno, nouveau,
virtualization, spice-devel, intel-xe, linux-tegra, linux-iio,
linux-usb
-Cc rust-for-linux, since it was typo'ed and now misses the thread anyways..
On Thu, 2026-11-05 at 13:35 +0100, Christian König wrote:
> On 11/5/26 13:06, Tvrtko Ursulin wrote:
> >
> > [I aggresively rewrote the To: list because my SMTP won't let me
> > send this as it was.]
> >
> > On 05/11/2026 11:35, Philipp Stanner wrote:
> > > Currently, there are two init functions for dma_fence,
> > > dma_fence_init()
> > > and dma_fence_init64().
> > >
> > > Since more future user options for dma_fence initialization would
> > > require distinct init functions, too, it is better to do this in
> > > a
> > > unified way.
> >
> > Why not add something like dma_fence_init_flags() and leave the 99%
> > of the callers out of the (huge) diff? Ie. just port
> > dma_fence_init64() to dma_fence_init_flags().
>
> Well one advantage of the Linux kernel is to avoid such wrappers. I
> think having more than one function for the same thing basically just
> adds more confusion.
Do you think all future users would want SEQNO64 by default, btw?
>
> That's also why I would really like to just have one
> dma_fence_signal() and not like five (or was it four?) variants.
It should be dma_fence_signal(fence, error), anihilating
dma_fence_set_error(), which is just another massive incentive to add
race conditions.
P.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init()
2026-11-05 12:35 ` Christian König
2026-11-05 12:48 ` Philipp Stanner
@ 2026-11-05 12:51 ` Tvrtko Ursulin
2026-11-05 13:24 ` Philipp Stanner
1 sibling, 1 reply; 14+ messages in thread
From: Tvrtko Ursulin @ 2026-11-05 12:51 UTC (permalink / raw)
To: Christian König, Philipp Stanner
Cc: dri-devel, linux-kernel, linux-media, amd-gfx, etnaviv, intel-gfx,
imagination, lima, linux-arm-msm, freedreno, nouveau,
virtualization, spice-devel, intel-xe, linux-tegra, linux-iio,
linux-usb, rust-for-linux
On 05/11/2026 12:35, Christian König wrote:
> On 11/5/26 13:06, Tvrtko Ursulin wrote:
>>
>> [I aggresively rewrote the To: list because my SMTP won't let me send this as it was.]
>>
>> On 05/11/2026 11:35, Philipp Stanner wrote:
>>> Currently, there are two init functions for dma_fence, dma_fence_init()
>>> and dma_fence_init64().
>>>
>>> Since more future user options for dma_fence initialization would
>>> require distinct init functions, too, it is better to do this in a
>>> unified way.
>>
>> Why not add something like dma_fence_init_flags() and leave the 99% of the callers out of the (huge) diff? Ie. just port dma_fence_init64() to dma_fence_init_flags().
>
> Well one advantage of the Linux kernel is to avoid such wrappers. I think having more than one function for the same thing basically just adds more confusion.
Sure we can churn if we really want. But as 99% of callers will be
passing 0 it's not even very readable. Another option is variadic like
kmalloc_objs so flags can be optional. Anyway, for consideration only.
> That's also why I would really like to just have one dma_fence_signal() and not like five (or was it four?) variants.
>
>> Also best to move the addition of dma_fence_flags_invalid() to the patch which adds dma_fence_init_flags() and not have it in this one which is supposed to be functionality neutral.
>
> Well this is the first time you can actually specify flags so that kind of makes sense to now add the check as well.
Right, that comment was together with suggestion to add the
dma_fence_init_flags() as a separate patch.
Regards,
Tvrtko
>>> Add a flags field to dma_fence_init(). Adjust all affected drivers,
>>> preserving the old behavior.
>>>
>>> Support the SEQNO64 flag, and add a check-function so that the user only
>>> sets valid bits.
>>>
>>> Signed-off-by: Philipp Stanner <phasta@kernel.org>
>>> ---
>>> drivers/accel/amdxdna/amdxdna_ctx.c | 2 +-
>>> drivers/accel/ethosu/ethosu_job.c | 2 +-
>>> drivers/accel/ivpu/ivpu_job.c | 2 +-
>>> drivers/accel/rocket/rocket_job.c | 2 +-
>>> drivers/dma-buf/dma-fence-array.c | 2 +-
>>> drivers/dma-buf/dma-fence.c | 31 ++++++++++++++++---
>>> drivers/dma-buf/st-dma-fence-chain.c | 2 +-
>>> drivers/dma-buf/st-dma-fence-unwrap.c | 2 +-
>>> drivers/dma-buf/st-dma-fence.c | 2 +-
>>> drivers/dma-buf/st-dma-resv.c | 2 +-
>>> drivers/dma-buf/sw_sync.c | 2 +-
>>> .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c | 2 +-
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +-
>>> drivers/gpu/drm/drm_crtc.c | 2 +-
>>> drivers/gpu/drm/drm_writeback.c | 2 +-
>>> drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 +-
>>> drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 2 +-
>>> drivers/gpu/drm/i915/i915_request.c | 2 +-
>>> drivers/gpu/drm/i915/i915_sw_fence_work.c | 2 +-
>>> drivers/gpu/drm/i915/i915_vma_resource.c | 2 +-
>>> .../gpu/drm/i915/selftests/i915_sw_fence.c | 2 +-
>>> drivers/gpu/drm/imagination/pvr_ccb.c | 2 +-
>>> drivers/gpu/drm/imagination/pvr_queue.c | 2 +-
>>> drivers/gpu/drm/lima/lima_sched.c | 2 +-
>>> drivers/gpu/drm/msm/msm_fence.c | 2 +-
>>> drivers/gpu/drm/nouveau/nouveau_fence.c | 4 +--
>>> drivers/gpu/drm/panfrost/panfrost_job.c | 2 +-
>>> drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
>>> drivers/gpu/drm/qxl/qxl_release.c | 2 +-
>>> drivers/gpu/drm/radeon/radeon_fence.c | 2 +-
>>> drivers/gpu/drm/scheduler/sched_fence.c | 4 +--
>>> .../gpu/drm/scheduler/tests/mock_scheduler.c | 2 +-
>>> drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 2 +-
>>> .../gpu/drm/ttm/tests/ttm_bo_validate_test.c | 2 +-
>>> drivers/gpu/drm/v3d/v3d_fence.c | 2 +-
>>> drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
>>> drivers/gpu/drm/vgem/vgem_fence.c | 2 +-
>>> drivers/gpu/drm/virtio/virtgpu_fence.c | 2 +-
>>> drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +-
>>> drivers/gpu/drm/xe/xe_hw_fence.c | 2 +-
>>> drivers/gpu/drm/xe/xe_oa.c | 2 +-
>>> drivers/gpu/drm/xe/xe_preempt_fence.c | 2 +-
>>> drivers/gpu/drm/xe/xe_tlb_inval.c | 2 +-
>>> drivers/gpu/host1x/fence.c | 2 +-
>>> drivers/iio/industrialio-buffer.c | 2 +-
>>> drivers/usb/gadget/function/f_fs.c | 2 +-
>>> include/linux/dma-fence.h | 12 +++++--
>>> rust/kernel/dma_buf/dma_fence.rs | 2 +-
>>> 48 files changed, 83 insertions(+), 56 deletions(-)
>>>
>>> diff --git a/drivers/accel/amdxdna/amdxdna_ctx.c b/drivers/accel/amdxdna/amdxdna_ctx.c
>>> index f4004630dc1b..f2245541f1ee 100644
>>> --- a/drivers/accel/amdxdna/amdxdna_ctx.c
>>> +++ b/drivers/accel/amdxdna/amdxdna_ctx.c
>>> @@ -53,7 +53,7 @@ static struct dma_fence *amdxdna_fence_create(struct amdxdna_hwctx *hwctx)
>>> spin_lock_init(&fence->lock);
>>> /* Unique timeline context prevents eviction from shared BO reservation. */
>>> - dma_fence_init(&fence->base, &fence_ops, &fence->lock, dma_fence_context_alloc(1), 0);
>>> + dma_fence_init(&fence->base, &fence_ops, &fence->lock, dma_fence_context_alloc(1), 0, 0);
>>> return &fence->base;
>>> }
>>> diff --git a/drivers/accel/ethosu/ethosu_job.c b/drivers/accel/ethosu/ethosu_job.c
>>> index d656b3ec670e..d4fc71436cae 100644
>>> --- a/drivers/accel/ethosu/ethosu_job.c
>>> +++ b/drivers/accel/ethosu/ethosu_job.c
>>> @@ -219,7 +219,7 @@ static struct dma_fence *ethosu_job_run(struct drm_sched_job *sched_job)
>>> return NULL;
>>> dma_fence_init(fence, ðosu_fence_ops, &dev->fence_lock,
>>> - dev->fence_context, ++dev->emit_seqno);
>>> + dev->fence_context, ++dev->emit_seqno, 0);
>>> dma_fence_get(fence);
>>> ethosu_switch_perfmon(dev, job);
>>> diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c
>>> index 76bacabe496b..6b4f059fb209 100644
>>> --- a/drivers/accel/ivpu/ivpu_job.c
>>> +++ b/drivers/accel/ivpu/ivpu_job.c
>>> @@ -519,7 +519,7 @@ static struct dma_fence *ivpu_fence_create(struct ivpu_device *vdev)
>>> fence->vdev = vdev;
>>> spin_lock_init(&fence->lock);
>>> - dma_fence_init(&fence->base, &ivpu_fence_ops, &fence->lock, dma_fence_context_alloc(1), 1);
>>> + dma_fence_init(&fence->base, &ivpu_fence_ops, &fence->lock, dma_fence_context_alloc(1), 1, 0);
>>> return &fence->base;
>>> }
>>> diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
>>> index b2a00992c889..574c9ea802c9 100644
>>> --- a/drivers/accel/rocket/rocket_job.c
>>> +++ b/drivers/accel/rocket/rocket_job.c
>>> @@ -61,7 +61,7 @@ static struct dma_fence *rocket_fence_create(struct rocket_core *core)
>>> return ERR_PTR(-ENOMEM);
>>> dma_fence_init(fence, &rocket_fence_ops, &core->fence_lock,
>>> - core->fence_context, ++core->emit_seqno);
>>> + core->fence_context, ++core->emit_seqno, 0);
>>> return fence;
>>> }
>>> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
>>> index 5e10e8df372f..e2dddbfddea2 100644
>>> --- a/drivers/dma-buf/dma-fence-array.c
>>> +++ b/drivers/dma-buf/dma-fence-array.c
>>> @@ -205,7 +205,7 @@ void dma_fence_array_init(struct dma_fence_array *array,
>>> array->num_fences = num_fences;
>>> dma_fence_init(&array->base, &dma_fence_array_ops, NULL, context,
>>> - seqno);
>>> + seqno, 0);
>>> init_irq_work(&array->work, irq_dma_fence_array_work);
>>> /*
>>> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
>>> index bd58688b81a7..a511cf755ee8 100644
>>> --- a/drivers/dma-buf/dma-fence.c
>>> +++ b/drivers/dma-buf/dma-fence.c
>>> @@ -122,7 +122,7 @@ static const struct dma_fence_ops dma_fence_stub_ops = {
>>> static int __init dma_fence_init_stub(void)
>>> {
>>> - dma_fence_init(&dma_fence_stub, &dma_fence_stub_ops, NULL, 0, 0);
>>> + dma_fence_init(&dma_fence_stub, &dma_fence_stub_ops, NULL, 0, 0, 0);
>>> set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
>>> &dma_fence_stub.flags);
>>> dma_fence_signal(&dma_fence_stub);
>>> @@ -156,7 +156,7 @@ struct dma_fence *dma_fence_allocate_private_stub(ktime_t timestamp)
>>> if (fence == NULL)
>>> return NULL;
>>> - dma_fence_init(fence, &dma_fence_stub_ops, NULL, 0, 0);
>>> + dma_fence_init(fence, &dma_fence_stub_ops, NULL, 0, 0, 0);
>>> set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
>>> &fence->flags);
>>> @@ -1063,7 +1063,6 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>>> spinlock_t *lock, u64 context, u64 seqno, unsigned long flags)
>>> {
>>> BUG_ON(!ops || !ops->get_driver_name || !ops->get_timeline_name);
>>> -
>>> kref_init(&fence->refcount);
>>> /*
>>> * While it is counter intuitive to protect a constant function pointer
>>> @@ -1087,6 +1086,21 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>>> trace_dma_fence_init(fence);
>>> }
>>> +static bool dma_fence_flags_invalid(unsigned long flags)
>>> +{
>>> + const unsigned long valid_fence_bits =
>>> + BIT(DMA_FENCE_FLAG_SEQNO64_BIT);
>>> + const unsigned long valid_user_bits =
>>> + GENMASK(
>>> + BITS_PER_TYPE(unsigned long) - 1,
>>> + DMA_FENCE_FLAG_USER_BITS
>>> + );
>>> + const unsigned long invalid_bits =
>>> + ~(valid_fence_bits | valid_user_bits);
>>> +
>>> + return flags & invalid_bits;
>>> +}
>>> +
>>> /**
>>> * dma_fence_init - Initialize a custom fence.
>>> * @fence: the fence to initialize
>>> @@ -1094,6 +1108,7 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>>> * @lock: optional irqsafe spinlock to use for locking this fence
>>> * @context: the execution context this fence is run on
>>> * @seqno: a linear increasing sequence number for this context
>>> + * @flags: flags modifying a fence's behavior
>>> *
>>> * Initializes an allocated fence, the caller doesn't have to keep its
>>> * refcount after committing with this fence, but it will need to hold a
>>> @@ -1108,12 +1123,18 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>>> * introduction of the callback, but the external lock is still around. New
>>> * users MUST NOT use external locks, as they force the issuer to outlive all
>>> * fences that reference the lock.
>>> + *
>>> + * The @flags you can specify here are either DMA_FENCE_FLAG_SEQNO64_BIT or
>>> + * user-specified bits >= DMA_FENCE_FLAG_USER_BITS.
>>> */
>>> void
>>> dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>>> - spinlock_t *lock, u64 context, u64 seqno)
>>> + spinlock_t *lock, u64 context, u64 seqno,
>>> + unsigned long flags)
>>> {
>>> - __dma_fence_init(fence, ops, lock, context, seqno, 0UL);
>>> + WARN_ON(dma_fence_flags_invalid(flags));
>>> +
>>> + __dma_fence_init(fence, ops, lock, context, seqno, flags);
>>> }
>>> EXPORT_SYMBOL(dma_fence_init);
>>> diff --git a/drivers/dma-buf/st-dma-fence-chain.c b/drivers/dma-buf/st-dma-fence-chain.c
>>> index e0d9b69bfa76..b9610df3ff19 100644
>>> --- a/drivers/dma-buf/st-dma-fence-chain.c
>>> +++ b/drivers/dma-buf/st-dma-fence-chain.c
>>> @@ -52,7 +52,7 @@ static struct dma_fence *mock_fence(void)
>>> return NULL;
>>> spin_lock_init(&f->lock);
>>> - dma_fence_init(&f->base, &mock_ops, &f->lock, 0, 0);
>>> + dma_fence_init(&f->base, &mock_ops, &f->lock, 0, 0, 0);
>>> return &f->base;
>>> }
>>> diff --git a/drivers/dma-buf/st-dma-fence-unwrap.c b/drivers/dma-buf/st-dma-fence-unwrap.c
>>> index c5353b36f0e4..dbebc3046d42 100644
>>> --- a/drivers/dma-buf/st-dma-fence-unwrap.c
>>> +++ b/drivers/dma-buf/st-dma-fence-unwrap.c
>>> @@ -36,7 +36,7 @@ static struct dma_fence *__mock_fence(u64 context, u64 seqno)
>>> return NULL;
>>> spin_lock_init(&f->lock);
>>> - dma_fence_init(&f->base, &mock_ops, &f->lock, context, seqno);
>>> + dma_fence_init(&f->base, &mock_ops, &f->lock, context, seqno, 0);
>>> return &f->base;
>>> }
>>> diff --git a/drivers/dma-buf/st-dma-fence.c b/drivers/dma-buf/st-dma-fence.c
>>> index cb62e606d0a2..b3f88e89cc44 100644
>>> --- a/drivers/dma-buf/st-dma-fence.c
>>> +++ b/drivers/dma-buf/st-dma-fence.c
>>> @@ -31,7 +31,7 @@ static struct dma_fence *mock_fence(void)
>>> if (!f)
>>> return NULL;
>>> - dma_fence_init(f, &mock_ops, NULL, 0, 0);
>>> + dma_fence_init(f, &mock_ops, NULL, 0, 0, 0);
>>> return f;
>>> }
>>> diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c
>>> index 0b96136bbd54..c3a920ab3fcf 100644
>>> --- a/drivers/dma-buf/st-dma-resv.c
>>> +++ b/drivers/dma-buf/st-dma-resv.c
>>> @@ -35,7 +35,7 @@ static struct dma_fence *alloc_fence(void)
>>> if (!f)
>>> return NULL;
>>> - dma_fence_init(f, &fence_ops, &fence_lock, 0, 0);
>>> + dma_fence_init(f, &fence_ops, &fence_lock, 0, 0, 0);
>>> return f;
>>> }
>>> diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
>>> index 8df20b0218a9..ce43af7e735e 100644
>>> --- a/drivers/dma-buf/sw_sync.c
>>> +++ b/drivers/dma-buf/sw_sync.c
>>> @@ -258,7 +258,7 @@ static struct sync_pt *sync_pt_create(struct sync_timeline *obj,
>>> sync_timeline_get(obj);
>>> dma_fence_init(&pt->base, &timeline_fence_ops, &obj->lock,
>>> - obj->context, value);
>>> + obj->context, value, 0);
>>> INIT_LIST_HEAD(&pt->link);
>>> spin_lock_irq(&obj->lock);
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c
>>> index 9b10d015671c..30ccdb3e0b47 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c
>>> @@ -77,7 +77,7 @@ struct amdgpu_amdkfd_fence *amdgpu_amdkfd_fence_create(u64 context,
>>> spin_lock_init(&fence->lock);
>>> fence->context_id = context_id;
>>> dma_fence_init(&fence->base, &amdkfd_fence_ops, &fence->lock,
>>> - context, atomic_inc_return(&fence_seq));
>>> + context, atomic_inc_return(&fence_seq), 0);
>>> return fence;
>>> }
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
>>> index bff2d38f3571..03e1974f8dda 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
>>> @@ -112,7 +112,7 @@ void amdgpu_fence_emit(struct amdgpu_ring *ring, struct amdgpu_fence *af,
>>> seq = ++ring->fence_drv.sync_seq;
>>> dma_fence_init(fence, &amdgpu_fence_ops,
>>> &ring->fence_drv.lock,
>>> - adev->fence_context + ring->idx, seq);
>>> + adev->fence_context + ring->idx, seq, 0);
>>> amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,
>>> seq, flags | AMDGPU_FENCE_FLAG_INT);
>>> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
>>> index 63ead8ba6756..92641bc0a378 100644
>>> --- a/drivers/gpu/drm/drm_crtc.c
>>> +++ b/drivers/gpu/drm/drm_crtc.c
>>> @@ -190,7 +190,7 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc)
>>> return NULL;
>>> dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock,
>>> - crtc->fence_context, ++crtc->fence_seqno);
>>> + crtc->fence_context, ++crtc->fence_seqno, 0);
>>> return fence;
>>> }
>>> diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c
>>> index b4a002e6d043..64b06b890f19 100644
>>> --- a/drivers/gpu/drm/drm_writeback.c
>>> +++ b/drivers/gpu/drm/drm_writeback.c
>>> @@ -592,7 +592,7 @@ drm_writeback_get_out_fence(struct drm_writeback_connector *wb_connector)
>>> dma_fence_init(fence, &drm_writeback_fence_ops,
>>> &wb_connector->fence_lock, wb_connector->fence_context,
>>> - ++wb_connector->fence_seqno);
>>> + ++wb_connector->fence_seqno, 0);
>>> return fence;
>>> }
>>> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
>>> index e75dab5e407d..a10e4e4cf372 100644
>>> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
>>> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
>>> @@ -1199,7 +1199,7 @@ static struct dma_fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu)
>>> f->gpu = gpu;
>>> dma_fence_init(&f->base, &etnaviv_fence_ops, &gpu->fence_spinlock,
>>> - gpu->fence_context, ++gpu->next_fence);
>>> + gpu->fence_context, ++gpu->next_fence, 0);
>>> return &f->base;
>>> }
>>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
>>> index 56489cc127d6..ffaa70191f27 100644
>>> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
>>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
>>> @@ -437,7 +437,7 @@ i915_ttm_memcpy_work_arm(struct i915_ttm_memcpy_work *work,
>>> int ret;
>>> spin_lock_init(&work->lock);
>>> - dma_fence_init(&work->fence, &dma_fence_memcpy_ops, &work->lock, 0, 0);
>>> + dma_fence_init(&work->fence, &dma_fence_memcpy_ops, &work->lock, 0, 0, 0);
>>> dma_fence_get(&work->fence);
>>> ret = dma_fence_add_callback(dep, &work->cb, __memcpy_cb);
>>> if (ret) {
>>> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
>>> index f66f8efc7062..0f4fc9cc0033 100644
>>> --- a/drivers/gpu/drm/i915/i915_request.c
>>> +++ b/drivers/gpu/drm/i915/i915_request.c
>>> @@ -953,7 +953,7 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp)
>>> goto err_free;
>>> dma_fence_init(&rq->fence, &i915_fence_ops, &rq->lock,
>>> - tl->fence_context, seqno);
>>> + tl->fence_context, seqno, 0);
>>> RCU_INIT_POINTER(rq->timeline, tl);
>>> rq->hwsp_seqno = tl->hwsp_seqno;
>>> diff --git a/drivers/gpu/drm/i915/i915_sw_fence_work.c b/drivers/gpu/drm/i915/i915_sw_fence_work.c
>>> index 366418108f78..4cd44dd26e35 100644
>>> --- a/drivers/gpu/drm/i915/i915_sw_fence_work.c
>>> +++ b/drivers/gpu/drm/i915/i915_sw_fence_work.c
>>> @@ -85,7 +85,7 @@ void dma_fence_work_init(struct dma_fence_work *f,
>>> {
>>> f->ops = ops;
>>> spin_lock_init(&f->lock);
>>> - dma_fence_init(&f->dma, &fence_ops, &f->lock, 0, 0);
>>> + dma_fence_init(&f->dma, &fence_ops, &f->lock, 0, 0, 0);
>>> i915_sw_fence_init(&f->chain, fence_notify);
>>> INIT_WORK(&f->work, fence_work);
>>> }
>>> diff --git a/drivers/gpu/drm/i915/i915_vma_resource.c b/drivers/gpu/drm/i915/i915_vma_resource.c
>>> index a8f2112ce81f..19596410e32f 100644
>>> --- a/drivers/gpu/drm/i915/i915_vma_resource.c
>>> +++ b/drivers/gpu/drm/i915/i915_vma_resource.c
>>> @@ -263,7 +263,7 @@ void __i915_vma_resource_init(struct i915_vma_resource *vma_res)
>>> {
>>> spin_lock_init(&vma_res->lock);
>>> dma_fence_init(&vma_res->unbind_fence, &unbind_fence_ops,
>>> - &vma_res->lock, 0, 0);
>>> + &vma_res->lock, 0, 0, 0);
>>> refcount_set(&vma_res->hold_count, 1);
>>> i915_sw_fence_init(&vma_res->chain, i915_vma_resource_fence_notify);
>>> }
>>> diff --git a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
>>> index ecb2d718f6a6..d8d4f7057031 100644
>>> --- a/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
>>> +++ b/drivers/gpu/drm/i915/selftests/i915_sw_fence.c
>>> @@ -641,7 +641,7 @@ static struct dma_fence *alloc_dma_fence(void)
>>> dma = kmalloc_obj(*dma);
>>> if (dma)
>>> - dma_fence_init(dma, &mock_fence_ops, &mock_fence_lock, 0, 0);
>>> + dma_fence_init(dma, &mock_fence_ops, &mock_fence_lock, 0, 0, 0);
>>> return dma;
>>> }
>>> diff --git a/drivers/gpu/drm/imagination/pvr_ccb.c b/drivers/gpu/drm/imagination/pvr_ccb.c
>>> index e408df74853d..7043b491fe54 100644
>>> --- a/drivers/gpu/drm/imagination/pvr_ccb.c
>>> +++ b/drivers/gpu/drm/imagination/pvr_ccb.c
>>> @@ -645,7 +645,7 @@ pvr_kccb_reserve_slot(struct pvr_device *pvr_dev, struct dma_fence *f)
>>> dma_fence_init(&fence->base, &pvr_kccb_fence_ops,
>>> &pvr_dev->kccb.fence_ctx.lock,
>>> pvr_dev->kccb.fence_ctx.id,
>>> - atomic_inc_return(&pvr_dev->kccb.fence_ctx.seqno));
>>> + atomic_inc_return(&pvr_dev->kccb.fence_ctx.seqno), 0);
>>> out_fence = dma_fence_get(&fence->base);
>>> list_add_tail(&fence->node, &pvr_dev->kccb.waiters);
>>> } else {
>>> diff --git a/drivers/gpu/drm/imagination/pvr_queue.c b/drivers/gpu/drm/imagination/pvr_queue.c
>>> index 24a8645aa913..34b826381aa2 100644
>>> --- a/drivers/gpu/drm/imagination/pvr_queue.c
>>> +++ b/drivers/gpu/drm/imagination/pvr_queue.c
>>> @@ -305,7 +305,7 @@ pvr_queue_fence_init(struct dma_fence *f,
>>> INIT_WORK(&fence->release_work, pvr_queue_fence_release_work);
>>> dma_fence_init(&fence->base, fence_ops,
>>> &fence_ctx->lock, fence_ctx->id,
>>> - atomic_inc_return(&fence_ctx->seqno));
>>> + atomic_inc_return(&fence_ctx->seqno), 0);
>>> }
>>> /**
>>> diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c
>>> index 9a1e6b9ecbe5..fee595b9629a 100644
>>> --- a/drivers/gpu/drm/lima/lima_sched.c
>>> +++ b/drivers/gpu/drm/lima/lima_sched.c
>>> @@ -97,7 +97,7 @@ static struct lima_fence *lima_fence_create(struct lima_sched_pipe *pipe)
>>> fence->pipe = pipe;
>>> dma_fence_init(&fence->base, &lima_fence_ops, &pipe->fence_lock,
>>> - pipe->fence_context, ++pipe->fence_seqno);
>>> + pipe->fence_context, ++pipe->fence_seqno, 0);
>>> return fence;
>>> }
>>> diff --git a/drivers/gpu/drm/msm/msm_fence.c b/drivers/gpu/drm/msm/msm_fence.c
>>> index 3dca8e09c192..1ec59919c32e 100644
>>> --- a/drivers/gpu/drm/msm/msm_fence.c
>>> +++ b/drivers/gpu/drm/msm/msm_fence.c
>>> @@ -197,5 +197,5 @@ msm_fence_init(struct dma_fence *fence, struct msm_fence_context *fctx)
>>> WARN_ON(kref_read(&fence->refcount));
>>> dma_fence_init(&f->base, &msm_fence_ops, &fctx->spinlock,
>>> - fctx->context, ++fctx->last_fence);
>>> + fctx->context, ++fctx->last_fence, 0);
>>> }
>>> diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
>>> index 11e95c37ce50..97e20954c71b 100644
>>> --- a/drivers/gpu/drm/nouveau/nouveau_fence.c
>>> +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
>>> @@ -216,10 +216,10 @@ nouveau_fence_emit(struct nouveau_fence *fence)
>>> if (priv->uevent)
>>> dma_fence_init(&fence->base, &nouveau_fence_ops_uevent,
>>> - &fctx->lock, fctx->context, ++fctx->sequence);
>>> + &fctx->lock, fctx->context, ++fctx->sequence, 0);
>>> else
>>> dma_fence_init(&fence->base, &nouveau_fence_ops_legacy,
>>> - &fctx->lock, fctx->context, ++fctx->sequence);
>>> + &fctx->lock, fctx->context, ++fctx->sequence, 0);
>>> kref_get(&fctx->fence_ref);
>>> ret = fctx->emit(fence);
>>> diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
>>> index 4ddf4b722ddf..de242d275978 100644
>>> --- a/drivers/gpu/drm/panfrost/panfrost_job.c
>>> +++ b/drivers/gpu/drm/panfrost/panfrost_job.c
>>> @@ -105,7 +105,7 @@ static struct dma_fence *panfrost_fence_create(struct panfrost_device *pfdev, in
>>> fence->queue = js_num;
>>> fence->seqno = ++js->queue[js_num].emit_seqno;
>>> dma_fence_init(&fence->base, &panfrost_fence_ops, &js->job_lock,
>>> - js->queue[js_num].fence_context, fence->seqno);
>>> + js->queue[js_num].fence_context, fence->seqno, 0);
>>> return &fence->base;
>>> }
>>> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
>>> index a343c5180e01..c46f69ade7a0 100644
>>> --- a/drivers/gpu/drm/panthor/panthor_sched.c
>>> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
>>> @@ -3322,7 +3322,7 @@ queue_run_job(struct drm_sched_job *sched_job)
>>> &panthor_queue_fence_ops,
>>> &queue->fence_ctx.lock,
>>> queue->fence_ctx.id,
>>> - atomic64_inc_return(&queue->fence_ctx.seqno));
>>> + atomic64_inc_return(&queue->fence_ctx.seqno), 0);
>>> job->profiling.slot = queue->profiling.seqno++;
>>> if (queue->profiling.seqno == queue->profiling.slot_count)
>>> diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
>>> index 06979d0e8a9f..2608d82f7370 100644
>>> --- a/drivers/gpu/drm/qxl/qxl_release.c
>>> +++ b/drivers/gpu/drm/qxl/qxl_release.c
>>> @@ -430,7 +430,7 @@ void qxl_release_fence_buffer_objects(struct qxl_release *release)
>>> * set the highest bits. This will break if we really allow exporting of dma-bufs.
>>> */
>>> dma_fence_init(&release->base, &qxl_fence_ops, &qdev->release_lock,
>>> - release->id | 0xf0000000, release->base.seqno);
>>> + release->id | 0xf0000000, release->base.seqno, 0);
>>> trace_dma_fence_emit(&release->base);
>>> list_for_each_entry(entry, &release->bos, list) {
>>> diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
>>> index 8e9402b8811b..1360b5215f5e 100644
>>> --- a/drivers/gpu/drm/radeon/radeon_fence.c
>>> +++ b/drivers/gpu/drm/radeon/radeon_fence.c
>>> @@ -148,7 +148,7 @@ int radeon_fence_emit(struct radeon_device *rdev,
>>> dma_fence_init(&(*fence)->base, &radeon_fence_ops,
>>> &rdev->fence_queue.lock,
>>> rdev->fence_context + ring,
>>> - seq);
>>> + seq, 0);
>>> radeon_fence_ring_emit(rdev, ring, *fence);
>>> trace_radeon_fence_emit(rdev_to_drm(rdev), ring, (*fence)->seq);
>>> radeon_fence_schedule_check(rdev, ring);
>>> diff --git a/drivers/gpu/drm/scheduler/sched_fence.c b/drivers/gpu/drm/scheduler/sched_fence.c
>>> index b7a4cb921234..94ba0cf4fe02 100644
>>> --- a/drivers/gpu/drm/scheduler/sched_fence.c
>>> +++ b/drivers/gpu/drm/scheduler/sched_fence.c
>>> @@ -229,9 +229,9 @@ void drm_sched_fence_init(struct drm_sched_fence *fence,
>>> fence->sched = entity->rq->sched;
>>> seq = atomic_inc_return(&entity->fence_seq);
>>> dma_fence_init(&fence->scheduled, &drm_sched_fence_ops_scheduled,
>>> - &fence->lock, entity->fence_context, seq);
>>> + &fence->lock, entity->fence_context, seq, 0);
>>> dma_fence_init(&fence->finished, &drm_sched_fence_ops_finished,
>>> - &fence->lock, entity->fence_context + 1, seq);
>>> + &fence->lock, entity->fence_context + 1, seq, 0);
>>> }
>>> module_init(drm_sched_fence_slab_init);
>>> diff --git a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
>>> index 2dfa3efef210..169792a4b329 100644
>>> --- a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
>>> +++ b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
>>> @@ -173,7 +173,7 @@ static struct dma_fence *mock_sched_run_job(struct drm_sched_job *sched_job)
>>> &drm_mock_sched_hw_fence_ops,
>>> &sched->lock,
>>> sched->hw_timeline.context,
>>> - atomic_inc_return(&sched->hw_timeline.next_seqno));
>>> + atomic_inc_return(&sched->hw_timeline.next_seqno), 0);
>>> dma_fence_get(&job->hw_fence); /* Reference for the job_list */
>>> diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
>>> index f3103307b5df..633cc7458505 100644
>>> --- a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
>>> +++ b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
>>> @@ -450,7 +450,7 @@ static void ttm_bo_fini_shared_resv(struct kunit *test)
>>> KUNIT_ASSERT_NOT_NULL(test, fence);
>>> spin_lock_init(&fence_lock);
>>> - dma_fence_init(fence, &mock_fence_ops, &fence_lock, 0, 0);
>>> + dma_fence_init(fence, &mock_fence_ops, &fence_lock, 0, 0, 0);
>>> dma_resv_lock(external_resv, NULL);
>>> dma_resv_reserve_fences(external_resv, 1);
>>> diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c b/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
>>> index 56ad8ef32584..e22a1335f166 100644
>>> --- a/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
>>> +++ b/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c
>>> @@ -57,7 +57,7 @@ static struct dma_fence *alloc_mock_fence(struct kunit *test)
>>> fence = kunit_kzalloc(test, sizeof(*fence), GFP_KERNEL);
>>> KUNIT_ASSERT_NOT_NULL(test, fence);
>>> - dma_fence_init(fence, &fence_ops, &fence_lock, 0, 0);
>>> + dma_fence_init(fence, &fence_ops, &fence_lock, 0, 0, 0);
>>> return fence;
>>> }
>>> diff --git a/drivers/gpu/drm/v3d/v3d_fence.c b/drivers/gpu/drm/v3d/v3d_fence.c
>>> index c500136d0455..1fdba5a21580 100644
>>> --- a/drivers/gpu/drm/v3d/v3d_fence.c
>>> +++ b/drivers/gpu/drm/v3d/v3d_fence.c
>>> @@ -16,7 +16,7 @@ struct dma_fence *v3d_fence_create(struct v3d_dev *v3d, enum v3d_queue q)
>>> fence->queue = q;
>>> fence->seqno = ++queue->emit_seqno;
>>> dma_fence_init(&fence->base, &v3d_fence_ops, &queue->queue_lock,
>>> - queue->fence_context, fence->seqno);
>>> + queue->fence_context, fence->seqno, 0);
>>> return &fence->base;
>>> }
>>> diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
>>> index ff611c618d6b..420988d516c1 100644
>>> --- a/drivers/gpu/drm/vc4/vc4_gem.c
>>> +++ b/drivers/gpu/drm/vc4/vc4_gem.c
>>> @@ -648,7 +648,7 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec,
>>> exec->seqno = seqno;
>>> dma_fence_init(&fence->base, &vc4_fence_ops, &vc4->job_lock,
>>> - vc4->dma_fence_context, exec->seqno);
>>> + vc4->dma_fence_context, exec->seqno, 0);
>>> fence->seqno = exec->seqno;
>>> exec->fence = &fence->base;
>>> diff --git a/drivers/gpu/drm/vgem/vgem_fence.c b/drivers/gpu/drm/vgem/vgem_fence.c
>>> index 0e53ba7db629..18700e5f9167 100644
>>> --- a/drivers/gpu/drm/vgem/vgem_fence.c
>>> +++ b/drivers/gpu/drm/vgem/vgem_fence.c
>>> @@ -77,7 +77,7 @@ static struct dma_fence *vgem_fence_create(struct vgem_file *vfile,
>>> spin_lock_init(&fence->lock);
>>> dma_fence_init(&fence->base, &vgem_fence_ops, &fence->lock,
>>> - dma_fence_context_alloc(1), 1);
>>> + dma_fence_context_alloc(1), 1, 0);
>>> timer_setup(&fence->timer, vgem_fence_timeout, TIMER_IRQSAFE);
>>> diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c
>>> index c3e66ef2133a..8e469391d2e4 100644
>>> --- a/drivers/gpu/drm/virtio/virtgpu_fence.c
>>> +++ b/drivers/gpu/drm/virtio/virtgpu_fence.c
>>> @@ -76,7 +76,7 @@ struct virtio_gpu_fence *virtio_gpu_fence_alloc(struct virtio_gpu_device *vgdev,
>>> */
>>> dma_fence_init(&fence->f, &virtio_gpu_fence_ops, &drv->lock,
>>> - fence_context, 0);
>>> + fence_context, 0, 0);
>>> return fence;
>>> }
>>> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
>>> index 384c6736cf6b..15f355dc6881 100644
>>> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
>>> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
>>> @@ -163,7 +163,7 @@ static int vmw_fence_obj_init(struct vmw_fence_manager *fman,
>>> int ret = 0;
>>> dma_fence_init(&fence->base, &vmw_fence_ops, &fman->lock,
>>> - fman->ctx, seqno);
>>> + fman->ctx, seqno, 0);
>>> fence->destroy = destroy;
>>> spin_lock(&fman->lock);
>>> diff --git a/drivers/gpu/drm/xe/xe_hw_fence.c b/drivers/gpu/drm/xe/xe_hw_fence.c
>>> index 14720623ad00..30bfc42972e0 100644
>>> --- a/drivers/gpu/drm/xe/xe_hw_fence.c
>>> +++ b/drivers/gpu/drm/xe/xe_hw_fence.c
>>> @@ -243,7 +243,7 @@ void xe_hw_fence_init(struct dma_fence *fence, struct xe_hw_fence_ctx *ctx,
>>> INIT_LIST_HEAD(&hw_fence->irq_link);
>>> dma_fence_init(fence, &xe_hw_fence_ops, &ctx->irq->lock,
>>> - ctx->dma_fence_ctx, ctx->next_seqno++);
>>> + ctx->dma_fence_ctx, ctx->next_seqno++, 0);
>>> trace_xe_hw_fence_create(hw_fence);
>>> }
>>> diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
>>> index c9320feeafba..912840eeec50 100644
>>> --- a/drivers/gpu/drm/xe/xe_oa.c
>>> +++ b/drivers/gpu/drm/xe/xe_oa.c
>>> @@ -1053,7 +1053,7 @@ static int xe_oa_emit_oa_config(struct xe_oa_stream *stream, struct xe_oa_config
>>> /* Point of no return: initialize and set fence to signal */
>>> spin_lock_init(&ofence->lock);
>>> - dma_fence_init(&ofence->base, &xe_oa_fence_ops, &ofence->lock, 0, 0);
>>> + dma_fence_init(&ofence->base, &xe_oa_fence_ops, &ofence->lock, 0, 0, 0);
>>> for (i = 0; i < stream->num_syncs; i++) {
>>> if (stream->syncs[i].flags & DRM_XE_SYNC_FLAG_SIGNAL)
>>> diff --git a/drivers/gpu/drm/xe/xe_preempt_fence.c b/drivers/gpu/drm/xe/xe_preempt_fence.c
>>> index 4aa570fe745d..343f1ba1e1cd 100644
>>> --- a/drivers/gpu/drm/xe/xe_preempt_fence.c
>>> +++ b/drivers/gpu/drm/xe/xe_preempt_fence.c
>>> @@ -154,7 +154,7 @@ xe_preempt_fence_arm(struct xe_preempt_fence *pfence, struct xe_exec_queue *q,
>>> pfence->q = xe_exec_queue_get(q);
>>> spin_lock_init(&pfence->lock);
>>> dma_fence_init(&pfence->base, &preempt_fence_ops,
>>> - &pfence->lock, context, seqno);
>>> + &pfence->lock, context, seqno, 0);
>>> return &pfence->base;
>>> }
>>> diff --git a/drivers/gpu/drm/xe/xe_tlb_inval.c b/drivers/gpu/drm/xe/xe_tlb_inval.c
>>> index c9cc5842d65b..1fd39434dc0e 100644
>>> --- a/drivers/gpu/drm/xe/xe_tlb_inval.c
>>> +++ b/drivers/gpu/drm/xe/xe_tlb_inval.c
>>> @@ -544,7 +544,7 @@ void xe_tlb_inval_fence_init(struct xe_tlb_inval *tlb_inval,
>>> spin_lock_irq(&tlb_inval->lock);
>>> dma_fence_init(&fence->base, &inval_fence_ops, &tlb_inval->lock,
>>> - dma_fence_context_alloc(1), 1);
>>> + dma_fence_context_alloc(1), 1, 0);
>>> spin_unlock_irq(&tlb_inval->lock);
>>> INIT_LIST_HEAD(&fence->link);
>>> if (stack)
>>> diff --git a/drivers/gpu/host1x/fence.c b/drivers/gpu/host1x/fence.c
>>> index 1acf579c562b..7e074e72a055 100644
>>> --- a/drivers/gpu/host1x/fence.c
>>> +++ b/drivers/gpu/host1x/fence.c
>>> @@ -136,7 +136,7 @@ struct dma_fence *host1x_fence_create(struct host1x_syncpt *sp, u32 threshold,
>>> fence->timeout = timeout;
>>> dma_fence_init(&fence->base, &host1x_syncpt_fence_ops, &sp->fences.lock,
>>> - dma_fence_context_alloc(1), 0);
>>> + dma_fence_context_alloc(1), 0, 0);
>>> INIT_DELAYED_WORK(&fence->timeout_work, do_fence_timeout);
>>> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
>>> index 4294101810fd..f7d6b294b63c 100644
>>> --- a/drivers/iio/industrialio-buffer.c
>>> +++ b/drivers/iio/industrialio-buffer.c
>>> @@ -1904,7 +1904,7 @@ static int iio_buffer_enqueue_dmabuf(struct iio_dev_buffer_pair *ib,
>>> * the dma_fence.
>>> */
>>> dma_fence_init(&fence->base, &iio_buffer_dma_fence_ops,
>>> - &fence->lock, priv->context, seqno);
>>> + &fence->lock, priv->context, seqno, 0);
>>> ret = iio_dma_resv_lock(dmabuf, nonblock);
>>> if (ret)
>>> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
>>> index c64a268e98a4..eb367a1666c2 100644
>>> --- a/drivers/usb/gadget/function/f_fs.c
>>> +++ b/drivers/usb/gadget/function/f_fs.c
>>> @@ -1733,7 +1733,7 @@ static int ffs_dmabuf_transfer(struct file *file,
>>> seqno = atomic_add_return(1, &epfile->seqno);
>>> dma_fence_init(&fence->base, &ffs_dmabuf_fence_ops,
>>> - &priv->lock, priv->context, seqno);
>>> + &priv->lock, priv->context, seqno, 0);
>>> resv_dir = epfile->in ? DMA_RESV_USAGE_READ : DMA_RESV_USAGE_WRITE;
>>> diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
>>> index dd07d128adc3..6f5c245d89ec 100644
>>> --- a/include/linux/dma-fence.h
>>> +++ b/include/linux/dma-fence.h
>>> @@ -103,6 +103,12 @@ struct dma_fence {
>>> int error;
>>> };
>>> +/** enum dma_fence_flag_bits - internal dma_fence flags
>>> + *
>>> + * These flags are all only for internal usage, except for
>>> + * @DMA_FENCE_FLAG_SEQNO64_BIT and the user bits beginning at
>>> + * @DMA_FENCE_FLAG_USER_BITS.
>>> + */
>>> enum dma_fence_flag_bits {
>>> DMA_FENCE_FLAG_INITIALIZED_BIT,
>>> DMA_FENCE_FLAG_INLINE_LOCK_BIT,
>>> @@ -110,6 +116,7 @@ enum dma_fence_flag_bits {
>>> DMA_FENCE_FLAG_SIGNALED_BIT,
>>> DMA_FENCE_FLAG_TIMESTAMP_BIT,
>>> DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
>>> +
>>> DMA_FENCE_FLAG_USER_BITS, /* must always be last member */
>>> };
>>> @@ -279,11 +286,10 @@ 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);
>>> -
>>> + spinlock_t *lock, u64 context, u64 seqno,
>>> + unsigned long flags);
>>> 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);
>>> diff --git a/rust/kernel/dma_buf/dma_fence.rs b/rust/kernel/dma_buf/dma_fence.rs
>>> index 18a43e1bb442..ee8fa4ecd6c1 100644
>>> --- a/rust/kernel/dma_buf/dma_fence.rs
>>> +++ b/rust/kernel/dma_buf/dma_fence.rs
>>> @@ -736,7 +736,7 @@ pub fn new_fence(self) -> DriverFence<'a, T> {
>>> // SAFETY: `fence_ptr` has been created directly above. It will live
>>> // at least as long as `Self`. The same applies to `&Self::OPS`.
>>> unsafe {
>>> - bindings::dma_fence_init(fence_ptr, self.ops, null_ptr, self.data.fctx.nr, seqno)
>>> + bindings::dma_fence_init(fence_ptr, self.ops, null_ptr, self.data.fctx.nr, seqno, 0)
>>> };
>>> self.data.fctx.nr_of_unsignaled_fences.fetch_add(1, Relaxed);
>>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init()
2026-11-05 12:51 ` Tvrtko Ursulin
@ 2026-11-05 13:24 ` Philipp Stanner
0 siblings, 0 replies; 14+ messages in thread
From: Philipp Stanner @ 2026-11-05 13:24 UTC (permalink / raw)
To: Tvrtko Ursulin, Christian König, Philipp Stanner
Cc: dri-devel, linux-kernel, linux-media, amd-gfx, etnaviv, intel-gfx,
imagination, lima, linux-arm-msm, freedreno, nouveau,
virtualization, spice-devel, intel-xe, linux-tegra, linux-iio,
linux-usb
On Thu, 2026-11-05 at 12:51 +0000, Tvrtko Ursulin wrote:
> On 05/11/2026 12:35, Christian König wrote:
> > Well one advantage of the Linux kernel is to avoid such wrappers. I
> > think having more than one function for the same thing basically
> > just adds more confusion.
>
> Sure we can churn if we really want. But as 99% of callers will be
> passing 0 it's not even very readable. Another option is variadic like
> kmalloc_objs so flags can be optional. Anyway, for consideration only.
It has the advantage of forcing the reader to think about whether he
wants 64-bit sequence numbers or not. In Rust-fence, for example, we
completely overlooked that for months:
https://lore.kernel.org/rust-for-linux/20261023175750.2979015-2-phasta@kernel.org/
Besides unused flags fields are quite common in APIs. As I state in the
description, this is also for future extensions, see my race-flag (if
accepted) as one potential example.
It could also be used for canonically setting the user-flags, which
users currently do with a manual set_bit(NR, &fence.base.flags;
So I think it's safe to say that it's the right thing for long-term
reduction of churn and maintainability.
P.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init()
2026-11-05 12:48 ` Philipp Stanner
@ 2026-11-05 14:23 ` Christian König
0 siblings, 0 replies; 14+ messages in thread
From: Christian König @ 2026-11-05 14:23 UTC (permalink / raw)
To: phasta, Tvrtko Ursulin
Cc: dri-devel, linux-kernel, linux-media, amd-gfx, etnaviv, intel-gfx,
imagination, lima, linux-arm-msm, freedreno, nouveau,
virtualization, spice-devel, intel-xe, linux-tegra, linux-iio,
linux-usb
On 11/5/26 13:48, Philipp Stanner wrote:
> -Cc rust-for-linux, since it was typo'ed and now misses the thread anyways..
>
> On Thu, 2026-11-05 at 13:35 +0100, Christian König wrote:
>> On 11/5/26 13:06, Tvrtko Ursulin wrote:
>>>
>>> [I aggresively rewrote the To: list because my SMTP won't let me
>>> send this as it was.]
>>>
>>> On 05/11/2026 11:35, Philipp Stanner wrote:
>>>> Currently, there are two init functions for dma_fence,
>>>> dma_fence_init()
>>>> and dma_fence_init64().
>>>>
>>>> Since more future user options for dma_fence initialization would
>>>> require distinct init functions, too, it is better to do this in
>>>> a
>>>> unified way.
>>>
>>> Why not add something like dma_fence_init_flags() and leave the 99%
>>> of the callers out of the (huge) diff? Ie. just port
>>> dma_fence_init64() to dma_fence_init_flags().
>>
>> Well one advantage of the Linux kernel is to avoid such wrappers. I
>> think having more than one function for the same thing basically just
>> adds more confusion.
>
> Do you think all future users would want SEQNO64 by default, btw?
I was considering to invert the flag meaning, e.g. have SEQNO32 instead of SEQNO64.
But as I recently learned even on brand new x86 Intel CPUs you can do non 64bit aligned 64bit writes (yeah x86 architecture!) and PCIe devices see that as two 32bit writes to system memory which might or might not read coherently.
So assuming all future HW will be 64bit is clearly not possible.
>>
>> That's also why I would really like to just have one
>> dma_fence_signal() and not like five (or was it four?) variants.
>
> It should be dma_fence_signal(fence, error), anihilating
> dma_fence_set_error(), which is just another massive incentive to add
> race conditions.
Yeah I'm largely in favor of that as well.
Regards,
Christian.
>
>
> P.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/3] dma-buf: dma-fence: Remove dma_fence_init64()
2026-11-05 11:35 [PATCH 0/3] dma-buf: dma-fence: Remove dma_fence_init64() Philipp Stanner
` (2 preceding siblings ...)
2026-11-05 11:35 ` [PATCH 3/3] dma-buf: dma-fence: Remove dma_fence_init64() Philipp Stanner
@ 2026-11-05 16:32 ` Timur Kristóf
3 siblings, 0 replies; 14+ messages in thread
From: Timur Kristóf @ 2026-11-05 16:32 UTC (permalink / raw)
To: Philipp Stanner
Cc: dri-devel, linux-kernel, linux-media, amd-gfx, etnaviv, intel-gfx,
imagination, lima, linux-arm-msm, freedreno, nouveau,
virtualization, spice-devel, intel-xe, linux-tegra, linux-iio,
linux-usb, rust-for-linux
On Thu, 2026-11-05 at 12:35 +0100, Philipp Stanner wrote:
> We recently had a discussion about reworking dma_fence init to close
> a
> race-window [1].
>
> The community agreement seems to have been that we can get rid of
> dma_fence_init64(), so let's do that already. In the meantime we can
> continue our discussions regarding the race in [1].
>
> This also touches the Rust dma_fence, which actually should use 64-
> bit
> seqnos (was forgotten so far). Rust fence has no users currently, so
> needs no backporting, so I would like to address that in a distinct
> patch.
>
> Tested on Nouveau with and without the SEQNO64 flag. Nouveau also
> uses
> the USER flag, so I hope we're fine.
>
>
> P.
>
> [1]
> https://lore.kernel.org/dri-devel/20261029095542.1526750-3-phasta@kernel.org/
Makes good sense to me.
For the entire series:
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
(ps. I had to remove some recipients from this email because the
original had more than 100 recipients and gmail wouldn't let me reply
to all of them. Apologies for that.)
>
>
> Philipp Stanner (3):
> dma-buf: dma-fence: Add flags parameter to dma_fence_init()
> dma-buf: Port users of dma_fence_init64()
> dma-buf: dma-fence: Remove dma_fence_init64()
>
> drivers/accel/amdxdna/amdxdna_ctx.c | 2 +-
> drivers/accel/ethosu/ethosu_job.c | 2 +-
> drivers/accel/ivpu/ivpu_job.c | 2 +-
> drivers/accel/rocket/rocket_job.c | 2 +-
> drivers/dma-buf/dma-fence-array.c | 2 +-
> drivers/dma-buf/dma-fence-chain.c | 4 +-
> drivers/dma-buf/dma-fence.c | 58 +++++++++--------
> --
> drivers/dma-buf/st-dma-fence-chain.c | 2 +-
> drivers/dma-buf/st-dma-fence-unwrap.c | 2 +-
> drivers/dma-buf/st-dma-fence.c | 2 +-
> drivers/dma-buf/st-dma-resv.c | 2 +-
> drivers/dma-buf/sw_sync.c | 2 +-
> .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c | 2 +-
> .../drm/amd/amdgpu/amdgpu_eviction_fence.c | 7 ++-
> drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +-
> .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 5 +-
> .../gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c | 5 +-
> drivers/gpu/drm/drm_crtc.c | 2 +-
> drivers/gpu/drm/drm_writeback.c | 2 +-
> drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 +-
> drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 2 +-
> drivers/gpu/drm/i915/i915_request.c | 2 +-
> drivers/gpu/drm/i915/i915_sw_fence_work.c | 2 +-
> drivers/gpu/drm/i915/i915_vma_resource.c | 2 +-
> .../gpu/drm/i915/selftests/i915_sw_fence.c | 2 +-
> drivers/gpu/drm/imagination/pvr_ccb.c | 2 +-
> drivers/gpu/drm/imagination/pvr_queue.c | 2 +-
> drivers/gpu/drm/lima/lima_sched.c | 2 +-
> drivers/gpu/drm/msm/msm_fence.c | 2 +-
> drivers/gpu/drm/nouveau/nouveau_fence.c | 4 +-
> drivers/gpu/drm/panfrost/panfrost_job.c | 2 +-
> drivers/gpu/drm/panthor/panthor_sched.c | 2 +-
> drivers/gpu/drm/qxl/qxl_release.c | 2 +-
> drivers/gpu/drm/radeon/radeon_fence.c | 2 +-
> drivers/gpu/drm/scheduler/sched_fence.c | 4 +-
> .../gpu/drm/scheduler/tests/mock_scheduler.c | 2 +-
> drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 2 +-
> .../gpu/drm/ttm/tests/ttm_bo_validate_test.c | 2 +-
> drivers/gpu/drm/v3d/v3d_fence.c | 2 +-
> drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
> drivers/gpu/drm/vgem/vgem_fence.c | 2 +-
> drivers/gpu/drm/virtio/virtgpu_fence.c | 2 +-
> drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +-
> drivers/gpu/drm/xe/xe_hw_fence.c | 2 +-
> drivers/gpu/drm/xe/xe_oa.c | 2 +-
> drivers/gpu/drm/xe/xe_preempt_fence.c | 2 +-
> drivers/gpu/drm/xe/xe_tlb_inval.c | 2 +-
> drivers/gpu/host1x/fence.c | 2 +-
> drivers/iio/industrialio-buffer.c | 2 +-
> drivers/usb/gadget/function/f_fs.c | 2 +-
> include/linux/dma-fence.h | 14 +++--
> rust/kernel/dma_buf/dma_fence.rs | 2 +-
> 52 files changed, 95 insertions(+), 94 deletions(-)
>
>
> base-commit: 8258a37702b9b9cf27f5c0ea07625e3e6bd74f5a
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-11-05 16:32 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-05 11:35 [PATCH 0/3] dma-buf: dma-fence: Remove dma_fence_init64() Philipp Stanner
2026-11-05 11:35 ` [PATCH 1/3] dma-buf: dma-fence: Add flags parameter to dma_fence_init() Philipp Stanner
2026-11-05 11:54 ` sashiko-bot
2026-11-05 12:06 ` Tvrtko Ursulin
2026-11-05 12:35 ` Christian König
2026-11-05 12:48 ` Philipp Stanner
2026-11-05 14:23 ` Christian König
2026-11-05 12:51 ` Tvrtko Ursulin
2026-11-05 13:24 ` Philipp Stanner
2026-11-05 11:35 ` [PATCH 2/3] dma-buf: Port users of dma_fence_init64() Philipp Stanner
2026-11-05 11:49 ` sashiko-bot
2026-11-05 11:35 ` [PATCH 3/3] dma-buf: dma-fence: Remove dma_fence_init64() Philipp Stanner
2026-11-05 11:43 ` sashiko-bot
2026-11-05 16:32 ` [PATCH 0/3] " Timur Kristóf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox