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

drm/i915: Drop stealing of bits from i915_sw_fence function pointer

Rather than stealing bits from i915_sw_fence function pointer use
separate fields for function pointer and flags. If using two different
fields, the 4 byte alignment for the i915_sw_fence function pointer can
also be dropped.

v2:
(CI)
- Set new function field rather than flags in __i915_sw_fence_init
v3:
(Tvrtko)
- Remove BUG_ON(!fence->flags) in reinit as that will now blow up
- Only define fence->flags if CONFIG_DRM_I915_SW_FENCE_CHECK_DAG is
defined
v4:
- Rebase, resend for CI

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Alan Previn <alan.previn.teres.alexis@intel.com>
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211116194929.10211-1-matthew.brost@intel.com

authored by

Matthew Brost and committed by
John Harrison
44505168 2a67b18e

+41 -34
+1 -1
drivers/gpu/drm/i915/display/intel_display.c
··· 9967 9967 intel_atomic_commit_tail(state); 9968 9968 } 9969 9969 9970 - static int __i915_sw_fence_call 9970 + static int 9971 9971 intel_atomic_commit_ready(struct i915_sw_fence *fence, 9972 9972 enum i915_sw_fence_notify notify) 9973 9973 {
+1 -1
drivers/gpu/drm/i915/gem/i915_gem_context.c
··· 1001 1001 free_engines(engines); 1002 1002 } 1003 1003 1004 - static int __i915_sw_fence_call 1004 + static int 1005 1005 engines_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state) 1006 1006 { 1007 1007 struct i915_gem_engines *engines =
+1 -1
drivers/gpu/drm/i915/gt/intel_context.c
··· 364 364 return 0; 365 365 } 366 366 367 - static int __i915_sw_fence_call 367 + static int 368 368 sw_fence_dummy_notify(struct i915_sw_fence *sf, 369 369 enum i915_sw_fence_notify state) 370 370 {
+2 -2
drivers/gpu/drm/i915/i915_request.c
··· 719 719 intel_context_cancel_request(rq->context, rq); 720 720 } 721 721 722 - static int __i915_sw_fence_call 722 + static int 723 723 submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state) 724 724 { 725 725 struct i915_request *request = ··· 755 755 return NOTIFY_DONE; 756 756 } 757 757 758 - static int __i915_sw_fence_call 758 + static int 759 759 semaphore_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state) 760 760 { 761 761 struct i915_request *rq = container_of(fence, typeof(*rq), semaphore);
+17 -11
drivers/gpu/drm/i915/i915_sw_fence.c
··· 18 18 #define I915_SW_FENCE_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr) 19 19 #endif 20 20 21 + #ifdef CONFIG_DRM_I915_SW_FENCE_CHECK_DAG 21 22 static DEFINE_SPINLOCK(i915_sw_fence_lock); 23 + #endif 22 24 23 25 #define WQ_FLAG_BITS \ 24 26 BITS_PER_TYPE(typeof_member(struct wait_queue_entry, flags)) ··· 36 34 37 35 static void *i915_sw_fence_debug_hint(void *addr) 38 36 { 39 - return (void *)(((struct i915_sw_fence *)addr)->flags & I915_SW_FENCE_MASK); 37 + return (void *)(((struct i915_sw_fence *)addr)->fn); 40 38 } 41 39 42 40 #ifdef CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS ··· 128 126 static int __i915_sw_fence_notify(struct i915_sw_fence *fence, 129 127 enum i915_sw_fence_notify state) 130 128 { 131 - i915_sw_fence_notify_t fn; 132 - 133 - fn = (i915_sw_fence_notify_t)(fence->flags & I915_SW_FENCE_MASK); 134 - return fn(fence, state); 129 + return fence->fn(fence, state); 135 130 } 136 131 137 132 #ifdef CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS ··· 241 242 const char *name, 242 243 struct lock_class_key *key) 243 244 { 244 - BUG_ON(!fn || (unsigned long)fn & ~I915_SW_FENCE_MASK); 245 + BUG_ON(!fn); 245 246 246 247 __init_waitqueue_head(&fence->wait, name, key); 247 - fence->flags = (unsigned long)fn; 248 + fence->fn = fn; 249 + #ifdef CONFIG_DRM_I915_SW_FENCE_CHECK_DAG 250 + fence->flags = 0; 251 + #endif 248 252 249 253 i915_sw_fence_reinit(fence); 250 254 } ··· 259 257 atomic_set(&fence->pending, 1); 260 258 fence->error = 0; 261 259 262 - I915_SW_FENCE_BUG_ON(!fence->flags); 263 260 I915_SW_FENCE_BUG_ON(!list_empty(&fence->wait.head)); 264 261 } 265 262 ··· 280 279 return 0; 281 280 } 282 281 282 + #ifdef CONFIG_DRM_I915_SW_FENCE_CHECK_DAG 283 283 static bool __i915_sw_fence_check_if_after(struct i915_sw_fence *fence, 284 284 const struct i915_sw_fence * const signaler) 285 285 { ··· 324 322 unsigned long flags; 325 323 bool err; 326 324 327 - if (!IS_ENABLED(CONFIG_DRM_I915_SW_FENCE_CHECK_DAG)) 328 - return false; 329 - 330 325 spin_lock_irqsave(&i915_sw_fence_lock, flags); 331 326 err = __i915_sw_fence_check_if_after(fence, signaler); 332 327 __i915_sw_fence_clear_checked_bit(fence); ··· 331 332 332 333 return err; 333 334 } 335 + #else 336 + static bool i915_sw_fence_check_if_after(struct i915_sw_fence *fence, 337 + const struct i915_sw_fence * const signaler) 338 + { 339 + return false; 340 + } 341 + #endif 334 342 335 343 static int __i915_sw_fence_await_sw_fence(struct i915_sw_fence *fence, 336 344 struct i915_sw_fence *signaler,
+13 -12
drivers/gpu/drm/i915/i915_sw_fence.h
··· 17 17 18 18 struct completion; 19 19 struct dma_resv; 20 - 21 - struct i915_sw_fence { 22 - wait_queue_head_t wait; 23 - unsigned long flags; 24 - atomic_t pending; 25 - int error; 26 - }; 27 - 28 - #define I915_SW_FENCE_CHECKED_BIT 0 /* used internally for DAG checking */ 29 - #define I915_SW_FENCE_PRIVATE_BIT 1 /* available for use by owner */ 30 - #define I915_SW_FENCE_MASK (~3) 20 + struct i915_sw_fence; 31 21 32 22 enum i915_sw_fence_notify { 33 23 FENCE_COMPLETE, ··· 26 36 27 37 typedef int (*i915_sw_fence_notify_t)(struct i915_sw_fence *, 28 38 enum i915_sw_fence_notify state); 29 - #define __i915_sw_fence_call __aligned(4) 39 + 40 + struct i915_sw_fence { 41 + wait_queue_head_t wait; 42 + i915_sw_fence_notify_t fn; 43 + #ifdef CONFIG_DRM_I915_SW_FENCE_CHECK_DAG 44 + unsigned long flags; 45 + #endif 46 + atomic_t pending; 47 + int error; 48 + }; 49 + 50 + #define I915_SW_FENCE_CHECKED_BIT 0 /* used internally for DAG checking */ 30 51 31 52 void __i915_sw_fence_init(struct i915_sw_fence *fence, 32 53 i915_sw_fence_notify_t fn,
+1 -1
drivers/gpu/drm/i915/i915_sw_fence_work.c
··· 23 23 dma_fence_put(&f->dma); 24 24 } 25 25 26 - static int __i915_sw_fence_call 26 + static int 27 27 fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state) 28 28 { 29 29 struct dma_fence_work *f = container_of(fence, typeof(*f), chain);
+1 -1
drivers/gpu/drm/i915/selftests/i915_sw_fence.c
··· 28 28 29 29 #include "../i915_selftest.h" 30 30 31 - static int __i915_sw_fence_call 31 + static int 32 32 fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state) 33 33 { 34 34 switch (state) {
+4 -4
drivers/gpu/drm/i915/selftests/lib_sw_fence.c
··· 26 26 27 27 /* Small library of different fence types useful for writing tests */ 28 28 29 - static int __i915_sw_fence_call 29 + static int 30 30 nop_fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state) 31 31 { 32 32 return NOTIFY_DONE; ··· 41 41 __init_waitqueue_head(&fence->wait, name, key); 42 42 atomic_set(&fence->pending, 1); 43 43 fence->error = 0; 44 - fence->flags = (unsigned long)nop_fence_notify; 44 + fence->fn = nop_fence_notify; 45 45 } 46 46 47 47 void onstack_fence_fini(struct i915_sw_fence *fence) 48 48 { 49 - if (!fence->flags) 49 + if (!fence->fn) 50 50 return; 51 51 52 52 i915_sw_fence_commit(fence); ··· 89 89 }; 90 90 }; 91 91 92 - static int __i915_sw_fence_call 92 + static int 93 93 heap_fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state) 94 94 { 95 95 struct heap_fence *h = container_of(fence, typeof(*h), fence);