Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dma-fence: Change signature of __dma_fence_is_later

With the goal of reducing the need for drivers to touch (and dereference)
fence->ops, we change the prototype of __dma_fence_is_later() to take
fence instead of fence->ops.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20250515095004.28318-2-tvrtko.ursulin@igalia.com
Signed-off-by: Christian König <christian.koenig@amd.com>

authored by

Tvrtko Ursulin and committed by
Christian König
549810e9 4963049e

+15 -14
+1 -1
drivers/dma-buf/dma-fence-chain.c
··· 252 252 chain->prev_seqno = 0; 253 253 254 254 /* Try to reuse the context of the previous chain node. */ 255 - if (prev_chain && __dma_fence_is_later(seqno, prev->seqno, prev->ops)) { 255 + if (prev_chain && __dma_fence_is_later(prev, seqno, prev->seqno)) { 256 256 context = prev->context; 257 257 chain->prev_seqno = prev->seqno; 258 258 } else {
+1 -1
drivers/dma-buf/sw_sync.c
··· 170 170 { 171 171 struct sync_timeline *parent = dma_fence_parent(fence); 172 172 173 - return !__dma_fence_is_later(fence->seqno, parent->value, fence->ops); 173 + return !__dma_fence_is_later(fence, fence->seqno, parent->value); 174 174 } 175 175 176 176 static void timeline_fence_set_deadline(struct dma_fence *fence, ktime_t deadline)
+1 -1
drivers/gpu/drm/xe/xe_hw_fence.c
··· 165 165 u32 seqno = xe_map_rd(xe, &fence->seqno_map, 0, u32); 166 166 167 167 return dma_fence->error || 168 - !__dma_fence_is_later(dma_fence->seqno, seqno, dma_fence->ops); 168 + !__dma_fence_is_later(dma_fence, dma_fence->seqno, seqno); 169 169 } 170 170 171 171 static bool xe_hw_fence_enable_signaling(struct dma_fence *dma_fence)
+8 -6
drivers/gpu/drm/xe/xe_sched_job.c
··· 216 216 217 217 bool xe_sched_job_started(struct xe_sched_job *job) 218 218 { 219 + struct dma_fence *fence = dma_fence_chain_contained(job->fence); 219 220 struct xe_lrc *lrc = job->q->lrc[0]; 220 221 221 - return !__dma_fence_is_later(xe_sched_job_lrc_seqno(job), 222 - xe_lrc_start_seqno(lrc), 223 - dma_fence_chain_contained(job->fence)->ops); 222 + return !__dma_fence_is_later(fence, 223 + xe_sched_job_lrc_seqno(job), 224 + xe_lrc_start_seqno(lrc)); 224 225 } 225 226 226 227 bool xe_sched_job_completed(struct xe_sched_job *job) 227 228 { 229 + struct dma_fence *fence = dma_fence_chain_contained(job->fence); 228 230 struct xe_lrc *lrc = job->q->lrc[0]; 229 231 230 232 /* ··· 234 232 * parallel handshake is done. 235 233 */ 236 234 237 - return !__dma_fence_is_later(xe_sched_job_lrc_seqno(job), 238 - xe_lrc_seqno(lrc), 239 - dma_fence_chain_contained(job->fence)->ops); 235 + return !__dma_fence_is_later(fence, 236 + xe_sched_job_lrc_seqno(job), 237 + xe_lrc_seqno(lrc)); 240 238 } 241 239 242 240 void xe_sched_job_arm(struct xe_sched_job *job)
+4 -5
include/linux/dma-fence.h
··· 441 441 442 442 /** 443 443 * __dma_fence_is_later - return if f1 is chronologically later than f2 444 + * @fence: fence in whose context to do the comparison 444 445 * @f1: the first fence's seqno 445 446 * @f2: the second fence's seqno from the same context 446 - * @ops: dma_fence_ops associated with the seqno 447 447 * 448 448 * Returns true if f1 is chronologically later than f2. Both fences must be 449 449 * from the same context, since a seqno is not common across contexts. 450 450 */ 451 - static inline bool __dma_fence_is_later(u64 f1, u64 f2, 452 - const struct dma_fence_ops *ops) 451 + static inline bool __dma_fence_is_later(struct dma_fence *fence, u64 f1, u64 f2) 453 452 { 454 453 /* This is for backward compatibility with drivers which can only handle 455 454 * 32bit sequence numbers. Use a 64bit compare when the driver says to 456 455 * do so. 457 456 */ 458 - if (ops->use_64bit_seqno) 457 + if (fence->ops->use_64bit_seqno) 459 458 return f1 > f2; 460 459 461 460 return (int)(lower_32_bits(f1) - lower_32_bits(f2)) > 0; ··· 474 475 if (WARN_ON(f1->context != f2->context)) 475 476 return false; 476 477 477 - return __dma_fence_is_later(f1->seqno, f2->seqno, f1->ops); 478 + return __dma_fence_is_later(f1, f1->seqno, f2->seqno); 478 479 } 479 480 480 481 /**