Skip to content

Commit 4d79a12

Browse files
illevirodrigovivi
authored andcommitted
drm/xe: Make irq enabled flag atomic
The irq.enabled flag was protected by a spin lock (irq.lock). By making it atomic we no longer need to wait for the spin lock in irq handlers. This will become especially useful for MSI-X irq handlers to prevent lock contention between different interrupts. Signed-off-by: Ilia Levi <[email protected]> Reviewed-by: Rodrigo Vivi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 3fcf68d commit 4d79a12

File tree

3 files changed

+9
-35
lines changed

3 files changed

+9
-35
lines changed

drivers/gpu/drm/xe/display/ext/i915_irq.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,7 @@ void gen2_irq_init(struct intel_uncore *uncore, struct i915_irq_regs regs,
5353

5454
bool intel_irqs_enabled(struct xe_device *xe)
5555
{
56-
/*
57-
* XXX: i915 has a racy handling of the irq.enabled, since it doesn't
58-
* lock its transitions. Because of that, the irq.enabled sometimes
59-
* is not read with the irq.lock in place.
60-
* However, the most critical cases like vblank and page flips are
61-
* properly using the locks.
62-
* We cannot take the lock in here or run any kind of assert because
63-
* of i915 inconsistency.
64-
* But at this point the xe irq is better protected against races,
65-
* although the full solution would be protecting the i915 side.
66-
*/
67-
return xe->irq.enabled;
56+
return atomic_read(&xe->irq.enabled);
6857
}
6958

7059
void intel_synchronize_irq(struct xe_device *xe)

drivers/gpu/drm/xe/xe_device_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ struct xe_device {
347347
spinlock_t lock;
348348

349349
/** @irq.enabled: interrupts enabled on this device */
350-
bool enabled;
350+
atomic_t enabled;
351351
} irq;
352352

353353
/** @ttm: ttm device */

drivers/gpu/drm/xe/xe_irq.c

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,8 @@ static irqreturn_t xelp_irq_handler(int irq, void *arg)
348348
unsigned long intr_dw[2];
349349
u32 identity[32];
350350

351-
spin_lock(&xe->irq.lock);
352-
if (!xe->irq.enabled) {
353-
spin_unlock(&xe->irq.lock);
351+
if (!atomic_read(&xe->irq.enabled))
354352
return IRQ_NONE;
355-
}
356-
spin_unlock(&xe->irq.lock);
357353

358354
master_ctl = xelp_intr_disable(xe);
359355
if (!master_ctl) {
@@ -417,12 +413,8 @@ static irqreturn_t dg1_irq_handler(int irq, void *arg)
417413

418414
/* TODO: This really shouldn't be copied+pasted */
419415

420-
spin_lock(&xe->irq.lock);
421-
if (!xe->irq.enabled) {
422-
spin_unlock(&xe->irq.lock);
416+
if (!atomic_read(&xe->irq.enabled))
423417
return IRQ_NONE;
424-
}
425-
spin_unlock(&xe->irq.lock);
426418

427419
master_tile_ctl = dg1_intr_disable(xe);
428420
if (!master_tile_ctl) {
@@ -644,12 +636,8 @@ static irqreturn_t vf_mem_irq_handler(int irq, void *arg)
644636
struct xe_tile *tile;
645637
unsigned int id;
646638

647-
spin_lock(&xe->irq.lock);
648-
if (!xe->irq.enabled) {
649-
spin_unlock(&xe->irq.lock);
639+
if (!atomic_read(&xe->irq.enabled))
650640
return IRQ_NONE;
651-
}
652-
spin_unlock(&xe->irq.lock);
653641

654642
for_each_tile(tile, xe, id)
655643
xe_memirq_handler(&tile->memirq);
@@ -674,10 +662,9 @@ static void irq_uninstall(void *arg)
674662
struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
675663
int irq;
676664

677-
if (!xe->irq.enabled)
665+
if (!atomic_xchg(&xe->irq.enabled, 0))
678666
return;
679667

680-
xe->irq.enabled = false;
681668
xe_irq_reset(xe);
682669

683670
irq = pci_irq_vector(pdev, 0);
@@ -724,7 +711,7 @@ int xe_irq_install(struct xe_device *xe)
724711
return err;
725712
}
726713

727-
xe->irq.enabled = true;
714+
atomic_set(&xe->irq.enabled, 1);
728715

729716
xe_irq_postinstall(xe);
730717

@@ -744,9 +731,7 @@ void xe_irq_suspend(struct xe_device *xe)
744731
{
745732
int irq = to_pci_dev(xe->drm.dev)->irq;
746733

747-
spin_lock_irq(&xe->irq.lock);
748-
xe->irq.enabled = false; /* no new irqs */
749-
spin_unlock_irq(&xe->irq.lock);
734+
atomic_set(&xe->irq.enabled, 0); /* no new irqs */
750735

751736
synchronize_irq(irq); /* flush irqs */
752737
xe_irq_reset(xe); /* turn irqs off */
@@ -762,7 +747,7 @@ void xe_irq_resume(struct xe_device *xe)
762747
* 1. no irq will arrive before the postinstall
763748
* 2. display is not yet resumed
764749
*/
765-
xe->irq.enabled = true;
750+
atomic_set(&xe->irq.enabled, 1);
766751
xe_irq_reset(xe);
767752
xe_irq_postinstall(xe); /* turn irqs on */
768753

0 commit comments

Comments
 (0)