Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] drm/i915/gt: Use spin_lock_irqsave() in interruptible context
@ 2025-01-16 10:40 Krzysztof Karas
  2025-01-16 11:22 ` Maciej Patelczyk
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Krzysztof Karas @ 2025-01-16 10:40 UTC (permalink / raw)
  To: intel-gfx, dri-devel; +Cc: Maciej Patelczyk, Tvrtko Ursulin

spin_lock/unlock() functions used in interrupt contexts could
result in a deadlock, as seen in GitLab issue #13399:
https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13399,
which occurs when interrupt comes in while holding a lock.

Try to remedy the problem by saving irq state before spin lock
acquisition.

v2: add irqs' state save/restore calls to all locks/unlocks in
 signal_irq_work() execution (Maciej)

v3: use with spin_lock_irqsave() in guc_lrc_desc_unpin() instead
 of other lock/unlock calls and add Fixes and Cc tags (Tvrtko);
 change title and commit message

Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Fixes: 2f2cc53b5fe7 ("drm/i915/guc: Close deregister-context race against CT-loss")
Cc: <stable@vger.kernel.org> # v6.9+
---
 drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index 12f1ba7ca9c1..29d9c81473cc 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -3433,10 +3433,10 @@ static inline int guc_lrc_desc_unpin(struct intel_context *ce)
 	 */
 	ret = deregister_context(ce, ce->guc_id.id);
 	if (ret) {
-		spin_lock(&ce->guc_state.lock);
+		spin_lock_irqsave(&ce->guc_state.lock, flags);
 		set_context_registered(ce);
 		clr_context_destroyed(ce);
-		spin_unlock(&ce->guc_state.lock);
+		spin_unlock_irqrestore(&ce->guc_state.lock, flags);
 		/*
 		 * As gt-pm is awake at function entry, intel_wakeref_put_async merely decrements
 		 * the wakeref immediately but per function spec usage call this after unlock.
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-02-13 18:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-16 10:40 [PATCH v3] drm/i915/gt: Use spin_lock_irqsave() in interruptible context Krzysztof Karas
2025-01-16 11:22 ` Maciej Patelczyk
2025-01-16 12:13 ` ✗ Fi.CI.SPARSE: warning for " Patchwork
2025-01-16 13:18 ` ✗ i915.CI.BAT: failure " Patchwork
2025-01-17 11:51   ` Krzysztof Karas
2025-01-20  9:25     ` Ravali, JupallyX
2025-01-20  9:20 ` ✓ i915.CI.BAT: success " Patchwork
2025-01-21  4:20 ` ✗ i915.CI.Full: failure " Patchwork
2025-01-31 10:40 ` ✓ i915.CI.BAT: success for drm/i915/gt: Use spin_lock_irqsave() in interruptible context (rev2) Patchwork
2025-01-31 12:52 ` ✓ i915.CI.Full: " Patchwork
2025-02-13 18:56 ` [PATCH v3] drm/i915/gt: Use spin_lock_irqsave() in interruptible context Andi Shyti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox