Commit 460d02ba authored by Chris Wilson's avatar Chris Wilson

drm/i915: Encode fence specific waitqueue behaviour into the wait.flags

Use the wait_queue_entry.flags to denote the special fence behaviour
(flattening continuations along fence chains, and for propagating
errors) rather than trying to detect ordinary waiters by their
functions.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarMatthew Brost <matthew.brost@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201216165850.25030-1-chris@chris-wilson.co.uk
parent 45233ab2
...@@ -18,10 +18,15 @@ ...@@ -18,10 +18,15 @@
#define I915_SW_FENCE_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr) #define I915_SW_FENCE_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
#endif #endif
#define I915_SW_FENCE_FLAG_ALLOC BIT(3) /* after WQ_FLAG_* for safety */
static DEFINE_SPINLOCK(i915_sw_fence_lock); static DEFINE_SPINLOCK(i915_sw_fence_lock);
#define WQ_FLAG_BITS \
BITS_PER_TYPE(typeof_member(struct wait_queue_entry, flags))
/* after WQ_FLAG_* for safety */
#define I915_SW_FENCE_FLAG_FENCE BIT(WQ_FLAG_BITS - 1)
#define I915_SW_FENCE_FLAG_ALLOC BIT(WQ_FLAG_BITS - 2)
enum { enum {
DEBUG_FENCE_IDLE = 0, DEBUG_FENCE_IDLE = 0,
DEBUG_FENCE_NOTIFY, DEBUG_FENCE_NOTIFY,
...@@ -154,10 +159,10 @@ static void __i915_sw_fence_wake_up_all(struct i915_sw_fence *fence, ...@@ -154,10 +159,10 @@ static void __i915_sw_fence_wake_up_all(struct i915_sw_fence *fence,
spin_lock_irqsave_nested(&x->lock, flags, 1 + !!continuation); spin_lock_irqsave_nested(&x->lock, flags, 1 + !!continuation);
if (continuation) { if (continuation) {
list_for_each_entry_safe(pos, next, &x->head, entry) { list_for_each_entry_safe(pos, next, &x->head, entry) {
if (pos->func == autoremove_wake_function) if (pos->flags & I915_SW_FENCE_FLAG_FENCE)
pos->func(pos, TASK_NORMAL, 0, continuation);
else
list_move_tail(&pos->entry, continuation); list_move_tail(&pos->entry, continuation);
else
pos->func(pos, TASK_NORMAL, 0, continuation);
} }
} else { } else {
LIST_HEAD(extra); LIST_HEAD(extra);
...@@ -166,9 +171,9 @@ static void __i915_sw_fence_wake_up_all(struct i915_sw_fence *fence, ...@@ -166,9 +171,9 @@ static void __i915_sw_fence_wake_up_all(struct i915_sw_fence *fence,
list_for_each_entry_safe(pos, next, &x->head, entry) { list_for_each_entry_safe(pos, next, &x->head, entry) {
int wake_flags; int wake_flags;
wake_flags = fence->error;
if (pos->func == autoremove_wake_function)
wake_flags = 0; wake_flags = 0;
if (pos->flags & I915_SW_FENCE_FLAG_FENCE)
wake_flags = fence->error;
pos->func(pos, TASK_NORMAL, wake_flags, &extra); pos->func(pos, TASK_NORMAL, wake_flags, &extra);
} }
...@@ -332,8 +337,8 @@ static int __i915_sw_fence_await_sw_fence(struct i915_sw_fence *fence, ...@@ -332,8 +337,8 @@ static int __i915_sw_fence_await_sw_fence(struct i915_sw_fence *fence,
struct i915_sw_fence *signaler, struct i915_sw_fence *signaler,
wait_queue_entry_t *wq, gfp_t gfp) wait_queue_entry_t *wq, gfp_t gfp)
{ {
unsigned int pending;
unsigned long flags; unsigned long flags;
int pending;
debug_fence_assert(fence); debug_fence_assert(fence);
might_sleep_if(gfpflags_allow_blocking(gfp)); might_sleep_if(gfpflags_allow_blocking(gfp));
...@@ -349,7 +354,7 @@ static int __i915_sw_fence_await_sw_fence(struct i915_sw_fence *fence, ...@@ -349,7 +354,7 @@ static int __i915_sw_fence_await_sw_fence(struct i915_sw_fence *fence,
if (unlikely(i915_sw_fence_check_if_after(fence, signaler))) if (unlikely(i915_sw_fence_check_if_after(fence, signaler)))
return -EINVAL; return -EINVAL;
pending = 0; pending = I915_SW_FENCE_FLAG_FENCE;
if (!wq) { if (!wq) {
wq = kmalloc(sizeof(*wq), gfp); wq = kmalloc(sizeof(*wq), gfp);
if (!wq) { if (!wq) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment