drm/i915/gt: Be paranoid and reset the GPU before release
diff mbox series

Message ID 20200117125849.3024805-1-chris@chris-wilson.co.uk
State New
Headers show
Series
  • drm/i915/gt: Be paranoid and reset the GPU before release
Related show

Commit Message

Chris Wilson Jan. 17, 2020, 12:58 p.m. UTC
Just in the very unlikely case we have not stopped the GPU before we
return the pages being used by the GPU to the system, force a reset.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/intel_engine_cs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Matthew Auld Jan. 17, 2020, 5:49 p.m. UTC | #1
On Fri, 17 Jan 2020 at 12:59, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> Just in the very unlikely case we have not stopped the GPU before we
> return the pages being used by the GPU to the system, force a reset.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
index 2d0ef5fc6748..08c7b49ccdaf 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
@@ -392,6 +392,18 @@  void intel_engines_release(struct intel_gt *gt)
 	struct intel_engine_cs *engine;
 	enum intel_engine_id id;
 
+	/*
+	 * Before we release the resources held by engine, we must be certain
+	 * that the HW is no longer accessing them -- having the GPU scribble
+	 * to or read from a page being used for something else causes no end
+	 * of fun.
+	 *
+	 * The GPU should be reset by this point, but assume the worst just
+	 * in case we aborted before completely initialising the engines.
+	 */
+	if (!INTEL_INFO(gt->i915)->gpu_reset_clobbers_display)
+		__intel_gt_reset(gt, ALL_ENGINES);
+
 	/* Decouple the backend; but keep the layout for late GPU resets */
 	for_each_engine(engine, gt, id) {
 		if (!engine->release)