Commit 6071ed04 authored by Michael Ellerman's avatar Michael Ellerman Committed by Benjamin Herrenschmidt

powerpc/pseries: Return the number of MSIs we could allocate

If we can't allocate the requested number of MSIs, we can still tell the
generic code how many we were able to allocate. That can then be passed
onto the driver, allowing it to request that many in future, and
probably succeeed.
Signed-off-by: default avatarMichael Ellerman <michael@ellerman.id.au>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 649781f8
...@@ -71,11 +71,13 @@ static int rtas_change_msi(struct pci_dn *pdn, u32 func, u32 num_irqs) ...@@ -71,11 +71,13 @@ static int rtas_change_msi(struct pci_dn *pdn, u32 func, u32 num_irqs)
} while (rtas_busy_delay(rc)); } while (rtas_busy_delay(rc));
/* /*
* If the RTAS call succeeded, check the number of irqs is actually * If the RTAS call succeeded, return the number of irqs allocated.
* what we asked for. If not, return an error. * If not, make sure we return a negative error code.
*/ */
if (rc == 0 && rtas_ret[0] != num_irqs) if (rc == 0)
rc = -ENOSPC; rc = rtas_ret[0];
else if (rc > 0)
rc = -rc;
pr_debug("rtas_msi: ibm,change_msi(func=%d,num=%d), got %d rc = %d\n", pr_debug("rtas_msi: ibm,change_msi(func=%d,num=%d), got %d rc = %d\n",
func, num_irqs, rtas_ret[0], rc); func, num_irqs, rtas_ret[0], rc);
...@@ -91,7 +93,7 @@ static void rtas_disable_msi(struct pci_dev *pdev) ...@@ -91,7 +93,7 @@ static void rtas_disable_msi(struct pci_dev *pdev)
if (!pdn) if (!pdn)
return; return;
if (rtas_change_msi(pdn, RTAS_CHANGE_FN, 0)) if (rtas_change_msi(pdn, RTAS_CHANGE_FN, 0) != 0)
pr_debug("rtas_msi: Setting MSIs to 0 failed!\n"); pr_debug("rtas_msi: Setting MSIs to 0 failed!\n");
} }
...@@ -195,14 +197,14 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) ...@@ -195,14 +197,14 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
if (type == PCI_CAP_ID_MSI) { if (type == PCI_CAP_ID_MSI) {
rc = rtas_change_msi(pdn, RTAS_CHANGE_MSI_FN, nvec); rc = rtas_change_msi(pdn, RTAS_CHANGE_MSI_FN, nvec);
if (rc) { if (rc < 0) {
pr_debug("rtas_msi: trying the old firmware call.\n"); pr_debug("rtas_msi: trying the old firmware call.\n");
rc = rtas_change_msi(pdn, RTAS_CHANGE_FN, nvec); rc = rtas_change_msi(pdn, RTAS_CHANGE_FN, nvec);
} }
} else } else
rc = rtas_change_msi(pdn, RTAS_CHANGE_MSIX_FN, nvec); rc = rtas_change_msi(pdn, RTAS_CHANGE_MSIX_FN, nvec);
if (rc) { if (rc != nvec) {
pr_debug("rtas_msi: rtas_change_msi() failed\n"); pr_debug("rtas_msi: rtas_change_msi() failed\n");
return rc; return rc;
} }
......
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