Skip to content

Commit 7a82344

Browse files
committed
PCI/MSI: Provide MSI_FLAG_MSIX_CONTIGUOUS
Provide a domain info flag which makes the core code check for a contiguous MSI-X index on allocation. That's simpler than checking it at some other domain callback in architecture code. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Acked-by: Bjorn Helgaas <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 173ffad commit 7a82344

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

drivers/pci/msi/irqdomain.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,21 @@ static int pci_msi_domain_check_cap(struct irq_domain *domain,
8989
if (pci_msi_desc_is_multi_msi(desc) &&
9090
!(info->flags & MSI_FLAG_MULTI_PCI_MSI))
9191
return 1;
92-
else if (desc->pci.msi_attrib.is_msix && !(info->flags & MSI_FLAG_PCI_MSIX))
93-
return -ENOTSUPP;
9492

93+
if (desc->pci.msi_attrib.is_msix) {
94+
if (!(info->flags & MSI_FLAG_PCI_MSIX))
95+
return -ENOTSUPP;
96+
97+
if (info->flags & MSI_FLAG_MSIX_CONTIGUOUS) {
98+
unsigned int idx = 0;
99+
100+
/* Check for gaps in the entry indices */
101+
for_each_msi_entry(desc, dev) {
102+
if (desc->msi_index != idx++)
103+
return -ENOTSUPP;
104+
}
105+
}
106+
}
95107
return 0;
96108
}
97109

include/linux/msi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ enum {
362362
MSI_FLAG_LEVEL_CAPABLE = (1 << 6),
363363
/* Populate sysfs on alloc() and destroy it on free() */
364364
MSI_FLAG_DEV_SYSFS = (1 << 7),
365+
/* MSI-X entries must be contiguous */
366+
MSI_FLAG_MSIX_CONTIGUOUS = (1 << 8),
365367
};
366368

367369
int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask,

0 commit comments

Comments
 (0)