Commit 27e20603 authored by Alexander Gordeev's avatar Alexander Gordeev Committed by Bjorn Helgaas

PCI/MSI: Move D0 check into pci_msi_check_device()

Both callers of pci_msi_check_device() check that the device is in D0
state, so move the check from the callers into pci_msi_check_device()
itself.

In pci_enable_msi_range(), note that pci_msi_check_device() never returns a
positive value any more, so the loop that called it until it returns zero
or negative is no longer necessary.

[bhelgaas: changelog, split to separate patch]
Signed-off-by: default avatarAlexander Gordeev <agordeev@redhat.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent ad975eba
...@@ -810,7 +810,10 @@ static int pci_msi_check_device(struct pci_dev *dev, int nvec) ...@@ -810,7 +810,10 @@ static int pci_msi_check_device(struct pci_dev *dev, int nvec)
struct pci_bus *bus; struct pci_bus *bus;
/* MSI must be globally enabled and supported by the device */ /* MSI must be globally enabled and supported by the device */
if (!pci_msi_enable || !dev || dev->no_msi) if (!pci_msi_enable)
return -EINVAL;
if (!dev || dev->no_msi || dev->current_state != PCI_D0)
return -EINVAL; return -EINVAL;
/* /*
...@@ -934,13 +937,13 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec) ...@@ -934,13 +937,13 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
int status, nr_entries; int status, nr_entries;
int i, j; int i, j;
if (!entries || !dev->msix_cap || dev->current_state != PCI_D0)
return -EINVAL;
status = pci_msi_check_device(dev, nvec); status = pci_msi_check_device(dev, nvec);
if (status) if (status)
return status; return status;
if (!entries)
return -EINVAL;
nr_entries = pci_msix_vec_count(dev); nr_entries = pci_msix_vec_count(dev);
if (nr_entries < 0) if (nr_entries < 0)
return nr_entries; return nr_entries;
...@@ -1047,8 +1050,9 @@ int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) ...@@ -1047,8 +1050,9 @@ int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec)
int nvec; int nvec;
int rc; int rc;
if (dev->current_state != PCI_D0) rc = pci_msi_check_device(dev, minvec);
return -EINVAL; if (rc)
return rc;
WARN_ON(!!dev->msi_enabled); WARN_ON(!!dev->msi_enabled);
...@@ -1070,17 +1074,6 @@ int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) ...@@ -1070,17 +1074,6 @@ int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec)
else if (nvec > maxvec) else if (nvec > maxvec)
nvec = maxvec; nvec = maxvec;
do {
rc = pci_msi_check_device(dev, nvec);
if (rc < 0) {
return rc;
} else if (rc > 0) {
if (rc < minvec)
return -ENOSPC;
nvec = rc;
}
} while (rc);
do { do {
rc = msi_capability_init(dev, nvec); rc = msi_capability_init(dev, nvec);
if (rc < 0) { if (rc < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment