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

PCI/MSI: Provide prepare_desc() MSI domain op

The setup of MSI descriptors for PCI/MSI-X interrupts depends partially on
the MSI index for which the descriptor is initialized.

Dynamic MSI-X vector allocation post MSI-X enablement allows to allocate
vectors at a given index or at any free index in the available table
range. The latter requires that the descriptor is initialized after the
MSI core has chosen an index.

Implement the prepare_desc() op in the PCI/MSI-X specific msi_domain_ops
which is invoked before the core interrupt descriptor and the associated
Linux interrupt number is allocated.

That callback is also provided for the upcoming PCI/IMS implementations so
the implementation specific interrupt domain can do their domain specific
initialization of the MSI descriptors.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221124232326.673658806@linutronix.de

+9
+9
drivers/pci/msi/irqdomain.c
··· 202 202 pci_msix_unmask(irq_data_get_msi_desc(data)); 203 203 } 204 204 205 + static void pci_msix_prepare_desc(struct irq_domain *domain, msi_alloc_info_t *arg, 206 + struct msi_desc *desc) 207 + { 208 + /* Don't fiddle with preallocated MSI descriptors */ 209 + if (!desc->pci.mask_base) 210 + msix_prepare_msi_desc(to_pci_dev(desc->dev), desc); 211 + } 212 + 205 213 static const struct msi_domain_template pci_msix_template = { 206 214 .chip = { 207 215 .name = "PCI-MSIX", ··· 220 212 }, 221 213 222 214 .ops = { 215 + .prepare_desc = pci_msix_prepare_desc, 223 216 .set_desc = pci_device_domain_set_desc, 224 217 }, 225 218