Skip to content

Commit

Permalink
Merge branch 'pci/msi'
Browse files Browse the repository at this point in the history
  - Avoid panic when drivers enable MSI/MSI-X twice (Tonghao Zhang)

* pci/msi:
  PCI/MSI: Warn and return error if driver enables MSI/MSI-X twice
  • Loading branch information
Bjorn Helgaas committed Oct 20, 2018
2 parents ee8360f + 4c1ef72 commit 0af6166
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/pci/msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,6 @@ static int __pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries,
}
}
}
WARN_ON(!!dev->msix_enabled);

/* Check whether driver already requested for MSI irq */
if (dev->msi_enabled) {
Expand Down Expand Up @@ -1028,8 +1027,6 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
if (!pci_msi_supported(dev, minvec))
return -EINVAL;

WARN_ON(!!dev->msi_enabled);

/* Check whether driver already requested MSI-X irqs */
if (dev->msix_enabled) {
pci_info(dev, "can't enable MSI (MSI-X already enabled)\n");
Expand All @@ -1039,6 +1036,9 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
if (maxvec < minvec)
return -ERANGE;

if (WARN_ON_ONCE(dev->msi_enabled))
return -EINVAL;

nvec = pci_msi_vec_count(dev);
if (nvec < 0)
return nvec;
Expand Down Expand Up @@ -1087,6 +1087,9 @@ static int __pci_enable_msix_range(struct pci_dev *dev,
if (maxvec < minvec)
return -ERANGE;

if (WARN_ON_ONCE(dev->msix_enabled))
return -EINVAL;

for (;;) {
if (affd) {
nvec = irq_calc_affinity_vectors(minvec, nvec, affd);
Expand Down

0 comments on commit 0af6166

Please sign in to comment.