Skip to content

Commit 3a3ed34

Browse files
author
Myron Stowe
committed
PCI/MSI: Size device MSI domain with the maximum number of vectors
JIRA: https://issues.redhat.com/browse/RHEL-120705 Upstream Status: 9cc82d9 commit 9cc82d9 Author: Marc Zyngier <maz@kernel.org> Date: Tue Jun 3 15:18:01 2025 +0100 PCI/MSI: Size device MSI domain with the maximum number of vectors Zenghui reports that since 1396e89 ("genirq/msi: Move prepare() call to per-device allocation"), his Multi-MSI capable device isn't working anymore. This is a consequence of 15c72f8 ("PCI/MSI: Add support for per device MSI[X] domains"), which always creates a MSI domain of size 1, even in the presence of Multi-MSI. While this was somehow working until then, moving the .prepare() call ends up sizing the ITS table with a tiny value for this device, and making the endpoint driver unhappy. Instead, always create the domain and call the .prepare() helper with the maximum expected size. Fixes: 1396e89 ("genirq/msi: Move prepare() call to per-device allocation") Fixes: 15c72f8 ("PCI/MSI: Add support for per device MSI[X] domains") Reported-by: Zenghui Yu <yuzenghui@huawei.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Zenghui Yu <yuzenghui@huawei.com> Reviewed-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Link: https://lore.kernel.org/all/20250603141801.915305-1-maz@kernel.org Closes: https://lore.kernel.org/r/0b1d7aec-1eac-a9cd-502a-339e216e08a1@huawei.com Signed-off-by: Myron Stowe <mstowe@redhat.com>
1 parent 91c6b43 commit 3a3ed34

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

drivers/pci/msi/irqdomain.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ static bool pci_create_device_domain(struct pci_dev *pdev, const struct msi_doma
309309
/**
310310
* pci_setup_msi_device_domain - Setup a device MSI interrupt domain
311311
* @pdev: The PCI device to create the domain on
312+
* @hwsize: The maximum number of MSI vectors
312313
*
313314
* Return:
314315
* True when:
@@ -325,7 +326,7 @@ static bool pci_create_device_domain(struct pci_dev *pdev, const struct msi_doma
325326
* - The device is removed
326327
* - MSI is disabled and a MSI-X domain is created
327328
*/
328-
bool pci_setup_msi_device_domain(struct pci_dev *pdev)
329+
bool pci_setup_msi_device_domain(struct pci_dev *pdev, unsigned int hwsize)
329330
{
330331
if (WARN_ON_ONCE(pdev->msix_enabled))
331332
return false;
@@ -335,7 +336,7 @@ bool pci_setup_msi_device_domain(struct pci_dev *pdev)
335336
if (pci_match_device_domain(pdev, DOMAIN_BUS_PCI_DEVICE_MSIX))
336337
msi_remove_device_irq_domain(&pdev->dev, MSI_DEFAULT_DOMAIN);
337338

338-
return pci_create_device_domain(pdev, &pci_msi_template, 1);
339+
return pci_create_device_domain(pdev, &pci_msi_template, hwsize);
339340
}
340341

341342
/**

drivers/pci/msi/msi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,16 +439,16 @@ int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
439439
if (nvec < minvec)
440440
return -ENOSPC;
441441

442-
if (nvec > maxvec)
443-
nvec = maxvec;
444-
445442
rc = pci_setup_msi_context(dev);
446443
if (rc)
447444
return rc;
448445

449-
if (!pci_setup_msi_device_domain(dev))
446+
if (!pci_setup_msi_device_domain(dev, nvec))
450447
return -ENODEV;
451448

449+
if (nvec > maxvec)
450+
nvec = maxvec;
451+
452452
for (;;) {
453453
if (affd) {
454454
nvec = irq_calc_affinity_vectors(minvec, nvec, affd);

drivers/pci/msi/msi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ enum support_mode {
107107
};
108108

109109
bool pci_msi_domain_supports(struct pci_dev *dev, unsigned int feature_mask, enum support_mode mode);
110-
bool pci_setup_msi_device_domain(struct pci_dev *pdev);
110+
bool pci_setup_msi_device_domain(struct pci_dev *pdev, unsigned int hwsize);
111111
bool pci_setup_msix_device_domain(struct pci_dev *pdev, unsigned int hwsize);
112112

113113
/* Legacy (!IRQDOMAIN) fallbacks */

0 commit comments

Comments
 (0)