[PATCH 5.10-rt+] drm/i915/gt: transform irq_disable into local_lock.

From: Joe Korty
Date: Thu Oct 07 2021 - 12:59:49 EST


Convert IRQ blocking in intel_breadcrumbs_park() to a local lock.

Affects 5.10-rt and all later releases, up to and including when
rt was merged into mainline.

This problem has been reported in two other linux-rt-users postings,

[PREEMPT_RT] i915: fix PREEMPT_RT locking splats (Clark Williams)
[linux-5.12.y-rt] drm/i915/gt: Fix a lockdep warning with interrupts enabled (Jun Miao)

Neither of these submit the obvious solution, nor,
AFAICT, has either yet been acted on. So I muddy the
waters further by submitting this, a third fix.

Signed-off-by: Joe Korty <joe.korty@xxxxxxxxxxxxxxxxx>
Tested-by: Joe Korty <joe.korty@xxxxxxxxxxxxxxxxx>

Index: b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
===================================================================
--- a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
+++ b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
@@ -34,6 +34,16 @@
#include "intel_gt_pm.h"
#include "intel_gt_requests.h"

+#include <linux/local_lock.h>
+
+struct event_lock {
+ local_lock_t l;
+};
+
+static DEFINE_PER_CPU(struct event_lock, event_lock) = {
+ .l = INIT_LOCAL_LOCK(l),
+};
+
static bool irq_enable(struct intel_engine_cs *engine)
{
if (!engine->irq_enable)
@@ -342,9 +352,9 @@ void intel_breadcrumbs_park(struct intel
/* Kick the work once more to drain the signalers */
irq_work_sync(&b->irq_work);
while (unlikely(READ_ONCE(b->irq_armed))) {
- local_irq_disable();
+ local_lock_irq(&event_lock.l);
signal_irq_work(&b->irq_work);
- local_irq_enable();
+ local_unlock_irq(&event_lock.l);
cond_resched();
}
GEM_BUG_ON(!list_empty(&b->signalers));