drm/i915/execlists: Flush the CS events before unpinning
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 3 Oct 2018 11:09:41 +0000 (12:09 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 3 Oct 2018 13:27:16 +0000 (14:27 +0100)
commitbc2477f7d3f3083d344b327e358e43093054023c
treeac712e1f3adaa26e78b25abf0fc4bbcd74f465ad
parent8f5c6fe46d6c1a49d01fc675170283599284b98f
drm/i915/execlists: Flush the CS events before unpinning

Inside the execlists submission tasklet, we often make the mistake of
assuming that everything beneath the request is available for use.
However, the submission and the request live on two separate timelines,
and the request contents may be freed from an early retirement before we
have had a chance to run the submission tasklet (think ksoftirqd). To
safeguard ourselves against any mistakes, flush the tasklet before we
unpin the context if execlists still has a reference to this context.

v2: Pull hw_context->active tracking into schedule_in and schedule_out.

References: 60367132a214 ("drm/i915: Avoid use-after-free of ctx in request tracepoints")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181003110941.27886-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem_context.h
drivers/gpu/drm/i915/intel_lrc.c