summaryrefslogtreecommitdiff
path: root/drivers/pci/msi
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2022-11-11 16:54:15 +0300
committerThomas Gleixner <tglx@linutronix.de>2022-11-17 17:15:18 +0300
commitfe97f59a78fefda6c4a8c8ee6a070b1f769fc801 (patch)
tree2519e100a301b64631efc9cd063656d669ebea61 /drivers/pci/msi
parentfd19ce77993a49f3afc56bb4cae7eafb1ec69e0c (diff)
downloadlinux-fe97f59a78fefda6c4a8c8ee6a070b1f769fc801.tar.xz
PCI/MSI: Check for MSI enabled in __pci_msix_enable()
PCI/MSI and PCI/MSI-X are mutually exclusive, but the MSI-X enable code lacks a check for already enabled MSI. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Ashok Raj <ashok.raj@intel.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://lore.kernel.org/r/20221111122013.653556720@linutronix.de
Diffstat (limited to 'drivers/pci/msi')
-rw-r--r--drivers/pci/msi/msi.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index fdd2ec09651e..160af9f01669 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -935,6 +935,11 @@ static int __pci_enable_msix_range(struct pci_dev *dev,
if (maxvec < minvec)
return -ERANGE;
+ if (dev->msi_enabled) {
+ pci_info(dev, "can't enable MSI-X (MSI already enabled)\n");
+ return -EINVAL;
+ }
+
if (WARN_ON_ONCE(dev->msix_enabled))
return -EINVAL;