Commit 4b379a48 authored by Chris Wilson's avatar Chris Wilson

drm/i915/selftests: Check timeout before flush and cond checks

Allow a bit of leniency for the CPU scheduler to be distracted while we
flush the tasklet and so ensure that we always check the status of the
request once more before timing out.

v2: Wait until the HW acked the submit, and we do any secondary actions
for the submit (e.g. timeslices)
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200330121644.25277-1-chris@chris-wilson.co.uk
parent 8b6d457f
...@@ -68,26 +68,41 @@ static void engine_heartbeat_enable(struct intel_engine_cs *engine, ...@@ -68,26 +68,41 @@ static void engine_heartbeat_enable(struct intel_engine_cs *engine,
engine->props.heartbeat_interval_ms = saved; engine->props.heartbeat_interval_ms = saved;
} }
static bool is_active(struct i915_request *rq)
{
if (i915_request_is_active(rq))
return true;
if (i915_request_on_hold(rq))
return true;
if (i915_request_started(rq))
return true;
return false;
}
static int wait_for_submit(struct intel_engine_cs *engine, static int wait_for_submit(struct intel_engine_cs *engine,
struct i915_request *rq, struct i915_request *rq,
unsigned long timeout) unsigned long timeout)
{ {
timeout += jiffies; timeout += jiffies;
do { do {
cond_resched(); bool done = time_after(jiffies, timeout);
intel_engine_flush_submission(engine);
if (READ_ONCE(engine->execlists.pending[0]))
continue;
if (i915_request_is_active(rq)) if (i915_request_completed(rq)) /* that was quick! */
return 0; return 0;
if (i915_request_started(rq)) /* that was quick! */ /* Wait until the HW has acknowleged the submission (or err) */
intel_engine_flush_submission(engine);
if (!READ_ONCE(engine->execlists.pending[0]) && is_active(rq))
return 0; return 0;
} while (time_before(jiffies, timeout));
if (done)
return -ETIME; return -ETIME;
cond_resched();
} while (1);
} }
static int wait_for_reset(struct intel_engine_cs *engine, static int wait_for_reset(struct intel_engine_cs *engine,
......
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