drm/i915/gt: Check carefully for an idle engine in wait-for-idle
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 23 Apr 2020 08:59:39 +0000 (09:59 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 23 Apr 2020 15:16:32 +0000 (16:16 +0100)
commitb97f77baa845e779341150881bdc12971da18e52
tree508d607236d5686f5888f04d0c07ed9da4202510
parent36fe164d8d780f6eb93f1ffa4ab5d3e9e3e81711
drm/i915/gt: Check carefully for an idle engine in wait-for-idle

intel_gt_wait_for_idle() tries to wait until all the outstanding requests
are retired and the GPU is idle. As a side effect of retiring requests,
we may submit more work to flush any pm barriers, and so the
wait-for-idle tries to flush the background pm work and catch the new
requests. However, if the work completed in the background before we
were able to flush, it would queue the extra barrier request without us
noticing -- and so we would return from wait-for-idle with one request
remaining. (This breaks e.g. record_default_state where we need to wait
until that barrier is retired, and it may slow suspend down by causing
us to wait on the background retirement worker as opposed to immediately
retiring the barrier.)

However, since we track if there has been a submission since the engine
pm barrier, we can very quickly detect if the idle barrier is still
outstanding.

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/1763
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200423085940.28168-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gt/intel_gt_requests.c