Skip to content

Commit 762d32e

Browse files
author
Myron Stowe
committed
PCI/MSI: Move descriptor counting on allocation fail to the legacy code
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2151246 Upstream Status: 60bf9b3 commit 60bf9b3 Author: Thomas Gleixner <tglx@linutronix.de> Date: Mon Dec 6 23:28:00 2021 +0100 PCI/MSI: Move descriptor counting on allocation fail to the legacy code The irqdomain code already returns the information. Move the loop to the legacy code. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Juergen Gross <jgross@suse.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20211206210225.101336873@linutronix.de Signed-off-by: Myron Stowe <mstowe@redhat.com>
1 parent 1bb5597 commit 762d32e

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

drivers/pci/msi/legacy.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,27 @@ void __weak arch_teardown_msi_irqs(struct pci_dev *dev)
5050
}
5151
}
5252

53+
static int pci_msi_setup_check_result(struct pci_dev *dev, int type, int ret)
54+
{
55+
struct msi_desc *entry;
56+
int avail = 0;
57+
58+
if (type != PCI_CAP_ID_MSIX || ret >= 0)
59+
return ret;
60+
61+
/* Scan the MSI descriptors for successfully allocated ones. */
62+
for_each_pci_msi_entry(entry, dev) {
63+
if (entry->irq != 0)
64+
avail++;
65+
}
66+
return avail ? avail : ret;
67+
}
68+
5369
int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
5470
{
55-
return arch_setup_msi_irqs(dev, nvec, type);
71+
int ret = arch_setup_msi_irqs(dev, nvec, type);
72+
73+
return pci_msi_setup_check_result(dev, type, ret);
5674
}
5775

5876
void pci_msi_legacy_teardown_msi_irqs(struct pci_dev *dev)

drivers/pci/msi/msi.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
606606

607607
ret = pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
608608
if (ret)
609-
goto out_avail;
609+
goto out_free;
610610

611611
/* Check if all MSI entries honor device restrictions */
612612
ret = msi_verify_entries(dev);
@@ -641,23 +641,6 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
641641
pcibios_free_irq(dev);
642642
return 0;
643643

644-
out_avail:
645-
if (ret < 0) {
646-
/*
647-
* If we had some success, report the number of IRQs
648-
* we succeeded in setting up.
649-
*/
650-
struct msi_desc *entry;
651-
int avail = 0;
652-
653-
for_each_pci_msi_entry(entry, dev) {
654-
if (entry->irq != 0)
655-
avail++;
656-
}
657-
if (avail != 0)
658-
ret = avail;
659-
}
660-
661644
out_free:
662645
free_msi_irqs(dev);
663646

0 commit comments

Comments
 (0)