Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip/armada-370-xp: Fix support for Multi-MSI interrupts

irq-armada-370-xp driver already sets MSI_FLAG_MULTI_PCI_MSI flag into
msi_domain_info structure. But allocated interrupt numbers for Multi-MSI
needs to be properly aligned otherwise devices send MSI interrupt with
wrong number.

Fix this issue by using function bitmap_find_free_region() instead of
bitmap_find_next_zero_area() to allocate aligned interrupt numbers.

Signed-off-by: Pali Rohár <pali@kernel.org>
Fixes: a71b9412c90c ("irqchip/armada-370-xp: Allow allocation of multiple MSIs")
Cc: stable@vger.kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211125130057.26705-2-pali@kernel.org

authored by

Pali Rohár and committed by
Marc Zyngier
d0a55350 ce20eff5

+6 -10
+6 -10
drivers/irqchip/irq-armada-370-xp.c
··· 232 232 int hwirq, i; 233 233 234 234 mutex_lock(&msi_used_lock); 235 - 236 - hwirq = bitmap_find_next_zero_area(msi_used, PCI_MSI_DOORBELL_NR, 237 - 0, nr_irqs, 0); 238 - if (hwirq >= PCI_MSI_DOORBELL_NR) { 239 - mutex_unlock(&msi_used_lock); 240 - return -ENOSPC; 241 - } 242 - 243 - bitmap_set(msi_used, hwirq, nr_irqs); 235 + hwirq = bitmap_find_free_region(msi_used, PCI_MSI_DOORBELL_NR, 236 + order_base_2(nr_irqs)); 244 237 mutex_unlock(&msi_used_lock); 238 + 239 + if (hwirq < 0) 240 + return -ENOSPC; 245 241 246 242 for (i = 0; i < nr_irqs; i++) { 247 243 irq_domain_set_info(domain, virq + i, hwirq + i, ··· 255 259 struct irq_data *d = irq_domain_get_irq_data(domain, virq); 256 260 257 261 mutex_lock(&msi_used_lock); 258 - bitmap_clear(msi_used, d->hwirq, nr_irqs); 262 + bitmap_release_region(msi_used, d->hwirq, order_base_2(nr_irqs)); 259 263 mutex_unlock(&msi_used_lock); 260 264 } 261 265