drm/i915: Replace reset_wait_queue with default_wake_function

If we change the wait_queue_t from using the autoremove_wake_function to
the default_wake_function, we no longer have to restore the wait_queue_t
entry on the wait_queue_head_t list after being woken up by it, as we
are unusual in sleeping multiple times on the same wait_queue_t.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170223074422.4125-14-chris@chris-wilson.co.uk
This commit is contained in:
Chris Wilson 2017-02-23 07:44:19 +00:00
parent 591c0fb85d
commit a49625f906
1 changed files with 7 additions and 23 deletions

View File

@ -945,16 +945,6 @@ void __i915_add_request(struct drm_i915_gem_request *request, bool flush_caches)
local_bh_enable(); /* Kick the execlists tasklet if just scheduled */ local_bh_enable(); /* Kick the execlists tasklet if just scheduled */
} }
static void reset_wait_queue(wait_queue_head_t *q, wait_queue_t *wait)
{
unsigned long flags;
spin_lock_irqsave(&q->lock, flags);
if (list_empty(&wait->task_list))
__add_wait_queue(q, wait);
spin_unlock_irqrestore(&q->lock, flags);
}
static unsigned long local_clock_us(unsigned int *cpu) static unsigned long local_clock_us(unsigned int *cpu)
{ {
unsigned long t; unsigned long t;
@ -1059,8 +1049,8 @@ long i915_wait_request(struct drm_i915_gem_request *req,
const int state = flags & I915_WAIT_INTERRUPTIBLE ? const int state = flags & I915_WAIT_INTERRUPTIBLE ?
TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE; TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE;
wait_queue_head_t *errq = &req->i915->gpu_error.wait_queue; wait_queue_head_t *errq = &req->i915->gpu_error.wait_queue;
DEFINE_WAIT(reset); DEFINE_WAIT_FUNC(reset, default_wake_function);
DEFINE_WAIT(exec); DEFINE_WAIT_FUNC(exec, default_wake_function);
struct intel_wait wait; struct intel_wait wait;
might_sleep(); might_sleep();
@ -1079,13 +1069,13 @@ long i915_wait_request(struct drm_i915_gem_request *req,
trace_i915_gem_request_wait_begin(req, flags); trace_i915_gem_request_wait_begin(req, flags);
add_wait_queue(&req->execute, &exec);
if (flags & I915_WAIT_LOCKED) if (flags & I915_WAIT_LOCKED)
add_wait_queue(errq, &reset); add_wait_queue(errq, &reset);
intel_wait_init(&wait); intel_wait_init(&wait);
restart: restart:
reset_wait_queue(&req->execute, &exec);
if (!intel_wait_update_request(&wait, req)) { if (!intel_wait_update_request(&wait, req)) {
do { do {
set_current_state(state); set_current_state(state);
@ -1097,26 +1087,21 @@ restart:
i915_reset_in_progress(&req->i915->gpu_error)) { i915_reset_in_progress(&req->i915->gpu_error)) {
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
i915_reset(req->i915); i915_reset(req->i915);
reset_wait_queue(errq, &reset);
continue; continue;
} }
if (signal_pending_state(state, current)) { if (signal_pending_state(state, current)) {
timeout = -ERESTARTSYS; timeout = -ERESTARTSYS;
break; goto complete;
} }
if (!timeout) { if (!timeout) {
timeout = -ETIME; timeout = -ETIME;
break; goto complete;
} }
timeout = io_schedule_timeout(timeout); timeout = io_schedule_timeout(timeout);
} while (1); } while (1);
finish_wait(&req->execute, &exec);
if (timeout < 0)
goto complete;
GEM_BUG_ON(!intel_wait_has_seqno(&wait)); GEM_BUG_ON(!intel_wait_has_seqno(&wait));
} }
@ -1176,7 +1161,6 @@ wakeup:
i915_reset_in_progress(&req->i915->gpu_error)) { i915_reset_in_progress(&req->i915->gpu_error)) {
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
i915_reset(req->i915); i915_reset(req->i915);
reset_wait_queue(errq, &reset);
continue; continue;
} }
@ -1191,11 +1175,11 @@ wakeup:
} }
intel_engine_remove_wait(req->engine, &wait); intel_engine_remove_wait(req->engine, &wait);
__set_current_state(TASK_RUNNING);
complete: complete:
__set_current_state(TASK_RUNNING);
if (flags & I915_WAIT_LOCKED) if (flags & I915_WAIT_LOCKED)
remove_wait_queue(errq, &reset); remove_wait_queue(errq, &reset);
remove_wait_queue(&req->execute, &exec);
trace_i915_gem_request_wait_end(req); trace_i915_gem_request_wait_end(req);
return timeout; return timeout;