[PATCH v3 2/2] drm/i915: Fix potential irq lock inversion dependency of requests
Janusz Krzysztofik
janusz.krzysztofik at linux.intel.com
Wed Jul 19 14:25:21 UTC 2023
Potential IRQ lock inversion dependency among __i915_active_fence_set()
and signal_irq_work() was reported by CI pre-merge run for a patch that
closes a potential race between multiple threads trying to set an active
fence on a tracker.
Since we use request lock nesting inside __i915_active_fence_set(),
disable IRQs while locking requests also inside signal_irq_work() which
can be called from either hard or soft IRQs on different CPUs
concurrently.
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_breadcrumbs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
index ecc990ec1b952..c6feb8e17a5c5 100644
--- a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
+++ b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
@@ -245,15 +245,16 @@ static void signal_irq_work(struct irq_work *work)
struct i915_request *rq =
llist_entry(signal, typeof(*rq), signal_node);
struct list_head cb_list;
+ unsigned long int flags;
if (rq->engine->sched_engine->retire_inflight_request_prio)
rq->engine->sched_engine->retire_inflight_request_prio(rq);
- spin_lock(&rq->lock);
+ spin_lock_irqsave(&rq->lock, flags);
list_replace(&rq->fence.cb_list, &cb_list);
__dma_fence_signal__timestamp(&rq->fence, timestamp);
__dma_fence_signal__notify(&rq->fence, &cb_list);
- spin_unlock(&rq->lock);
+ spin_unlock_irqrestore(&rq->lock, flags);
i915_request_put(rq);
}
--
2.41.0
More information about the Intel-gfx-trybot
mailing list