[PATCH] drm/i915: Prime the reset mutex inside the dma-fence critical section

Thomas Hellström thomas.hellstrom at linux.intel.com
Thu Jun 30 07:07:11 UTC 2022


The reset mutex should be safe to take inside a dma-fence critical
section. The annotation inside i915_request_wait_timeout() may
register the lock dependency in the opposite order.

Signed-off-by: Thomas Hellström <thomas.hellstrom at linux.intel.com>
---
 drivers/gpu/drm/i915/i915_request.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index 62fad16a55e8..4913ea6f787f 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -1953,6 +1953,7 @@ long i915_request_wait_timeout(struct i915_request *rq,
 	const int state = flags & I915_WAIT_INTERRUPTIBLE ?
 		TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE;
 	struct request_wait wait;
+	bool cookie;
 
 	might_sleep();
 	GEM_BUG_ON(timeout < 0);
@@ -1971,6 +1972,7 @@ long i915_request_wait_timeout(struct i915_request *rq,
 	 * serialise wait/reset with an explicit lock, we do want
 	 * lockdep to detect potential dependency cycles.
 	 */
+	cookie = dma_fence_begin_signalling();
 	mutex_acquire(&rq->engine->gt->reset.mutex.dep_map, 0, 0, _THIS_IP_);
 
 	/*
@@ -2063,6 +2065,7 @@ long i915_request_wait_timeout(struct i915_request *rq,
 
 out:
 	mutex_release(&rq->engine->gt->reset.mutex.dep_map, _THIS_IP_);
+	dma_fence_end_signalling(cookie);
 	trace_i915_request_wait_end(rq);
 	return timeout;
 }
-- 
2.34.3



More information about the Intel-gfx-trybot mailing list