Skip to content

Commit dbbc935

Browse files
Bixuan CuiKAGA-KOKO
authored andcommitted
genirq/msi: Ensure deactivation on teardown
msi_domain_alloc_irqs() invokes irq_domain_activate_irq(), but msi_domain_free_irqs() does not enforce deactivation before tearing down the interrupts. This happens when PCI/MSI interrupts are set up and never used before being torn down again, e.g. in error handling pathes. The only place which cleans that up is the error handling path in msi_domain_alloc_irqs(). Move the cleanup from msi_domain_alloc_irqs() into msi_domain_free_irqs() to cure that. Fixes: f3b0946 ("genirq/msi: Make sure PCI MSIs are activated early") Signed-off-by: Bixuan Cui <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent b9cc7d8 commit dbbc935

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

kernel/irq/msi.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,6 @@ int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
476476
return 0;
477477

478478
cleanup:
479-
for_each_msi_vector(desc, i, dev) {
480-
irq_data = irq_domain_get_irq_data(domain, i);
481-
if (irqd_is_activated(irq_data))
482-
irq_domain_deactivate_irq(irq_data);
483-
}
484479
msi_domain_free_irqs(domain, dev);
485480
return ret;
486481
}
@@ -505,7 +500,15 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
505500

506501
void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev)
507502
{
503+
struct irq_data *irq_data;
508504
struct msi_desc *desc;
505+
int i;
506+
507+
for_each_msi_vector(desc, i, dev) {
508+
irq_data = irq_domain_get_irq_data(domain, i);
509+
if (irqd_is_activated(irq_data))
510+
irq_domain_deactivate_irq(irq_data);
511+
}
509512

510513
for_each_msi_entry(desc, dev) {
511514
/*

0 commit comments

Comments
 (0)