[2/4] drm/i915: Manually flush barriers on eviction
diff mbox series

Message ID 20191202144702.2536644-2-chris@chris-wilson.co.uk
State New
Headers show
Series
  • [1/4] drm/i915: Lift i915_vma_pin() out of intel_renderstate_emit()
Related show

Commit Message

Chris Wilson Dec. 2, 2019, 2:47 p.m. UTC
As the caller may be keeping the engines awake, even though
wait-for-idle will flush the contexts, the contexts will not be unpinned
until the engine is parked. Manually flush the idle barriers to ensure
that any context that can be unpinned, will be.

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

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index 7e62c310290f..0ff4be9b2954 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -28,7 +28,7 @@ 
 
 #include <drm/i915_drm.h>
 
-#include "gem/i915_gem_context.h"
+#include "gt/intel_engine_heartbeat.h"
 #include "gt/intel_gt_requests.h"
 
 #include "i915_drv.h"
@@ -40,6 +40,10 @@  I915_SELFTEST_DECLARE(static struct igt_evict_ctl {
 
 static int ggtt_flush(struct intel_gt *gt)
 {
+	struct intel_engine_cs *engine;
+	enum intel_engine_id id;
+	int ret;
+
 	/*
 	 * Not everything in the GGTT is tracked via vma (otherwise we
 	 * could evict as required with minimal stalling) so we are forced
@@ -47,6 +51,21 @@  static int ggtt_flush(struct intel_gt *gt)
 	 * the hopes that we can then remove contexts and the like only
 	 * bound by their active reference.
 	 */
+	ret = intel_gt_wait_for_idle(gt, MAX_SCHEDULE_TIMEOUT);
+	if (ret)
+		return ret;
+
+	/*
+	 * The engines may be kept awake by the caller and so skip the expected
+	 * barrier flushes (needed for unpinning contexts) upon parking.
+	 */
+	for_each_engine(engine, gt, id) {
+		ret = intel_engine_flush_barriers(engine);
+		if (ret)
+			return ret;
+	}
+
+	/* And once more for the barriers */
 	return intel_gt_wait_for_idle(gt, MAX_SCHEDULE_TIMEOUT);
 }