Skip to content

Commit 1b02865

Browse files
Bixuan Cuismb49
authored andcommitted
genirq/msi: Ensure deactivation on teardown
BugLink: https://bugs.launchpad.net/bugs/1944202 commit dbbc935 upstream. 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 <cuibixuan@huawei.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210518033117.78104-1-cuibixuan@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
1 parent 3da3d48 commit 1b02865

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

kernel/irq/msi.c

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

479479
cleanup:
480-
for_each_msi_vector(desc, i, dev) {
481-
irq_data = irq_domain_get_irq_data(domain, i);
482-
if (irqd_is_activated(irq_data))
483-
irq_domain_deactivate_irq(irq_data);
484-
}
485480
msi_domain_free_irqs(domain, dev);
486481
return ret;
487482
}
@@ -494,7 +489,15 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
494489
*/
495490
void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev)
496491
{
492+
struct irq_data *irq_data;
497493
struct msi_desc *desc;
494+
int i;
495+
496+
for_each_msi_vector(desc, i, dev) {
497+
irq_data = irq_domain_get_irq_data(domain, i);
498+
if (irqd_is_activated(irq_data))
499+
irq_domain_deactivate_irq(irq_data);
500+
}
498501

499502
for_each_msi_entry(desc, dev) {
500503
/*

0 commit comments

Comments
 (0)