[Intel-gfx] [PATCH] drm/i915: Priority boost for locked waits

Chris Wilson chris at chris-wilson.co.uk
Wed Jan 18 16:41:02 UTC 2017


We always try to do an unlocked wait before resorting to having a
blocking wait under the mutex - so we very rarely have to sleep under
the struct_mutex. However, when we do we want that wait to be as short
as possible as the struct_mutex is our BKL that will stall the driver and
all clients.

There should be no impact for all typical workloads.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 drivers/gpu/drm/i915/i915_gem.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index c1c2765bb8d0..47d17b227a05 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -395,6 +395,15 @@ i915_gem_object_wait_fence(struct dma_fence *fence,
 			rps = NULL;
 	}
 
+	/* Very rarely do we wait whilst holding the mutex. We try to always
+	 * do an unlocked wait before using a locked wait. However, when we
+	 * have to resort to a locked wait, we want that wait to be as short
+	 * as possible as the struct_mutex is our BKL that will stall the
+	 * driver and all clients.
+	 */
+	if (flags & I915_WAIT_LOCKED && rq->engine->schedule)
+		rq->engine->schedule(rq, I915_PRIORITY_MAX);
+
 	timeout = i915_wait_request(rq, flags, timeout);
 
 out:
-- 
2.11.0



More information about the Intel-gfx mailing list