Skip to content

Commit

Permalink
drm/i915/selftests: Check timeout before flush and cond checks
Browse files Browse the repository at this point in the history
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: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200330121644.25277-1-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson committed Mar 30, 2020
1 parent 8b6d457 commit 4b379a4
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions drivers/gpu/drm/i915/gt/selftest_lrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,41 @@ static void engine_heartbeat_enable(struct intel_engine_cs *engine,
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,
struct i915_request *rq,
unsigned long timeout)
{
timeout += jiffies;
do {
cond_resched();
intel_engine_flush_submission(engine);

if (READ_ONCE(engine->execlists.pending[0]))
continue;
bool done = time_after(jiffies, timeout);

if (i915_request_is_active(rq))
if (i915_request_completed(rq)) /* that was quick! */
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;
} while (time_before(jiffies, timeout));

return -ETIME;
if (done)
return -ETIME;

cond_resched();
} while (1);
}

static int wait_for_reset(struct intel_engine_cs *engine,
Expand Down

0 comments on commit 4b379a4

Please sign in to comment.