aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/pseries/msi.c
diff options
context:
space:
mode:
authorAlexander Gordeev <agordeev@redhat.com>2014-09-07 14:57:53 -0400
committerBjorn Helgaas <bhelgaas@google.com>2014-10-01 14:21:14 -0400
commit6b2fd7efeb888fa781c1f767de6c36497ac1596b (patch)
tree5c0034e0cd1db2e36e54140a6f1477948016bc0f /arch/powerpc/platforms/pseries/msi.c
parent52addcf9d6669fa439387610bc65c92fa0980cef (diff)
PCI/MSI/PPC: Remove arch_msi_check_device()
Move MSI checks from arch_msi_check_device() to arch_setup_msi_irqs(). This makes the code more compact and allows removing arch_msi_check_device() from generic MSI code. Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/platforms/pseries/msi.c')
-rw-r--r--arch/powerpc/platforms/pseries/msi.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/arch/powerpc/platforms/pseries/msi.c b/arch/powerpc/platforms/pseries/msi.c
index 18ff4626d74e..e68c196def1a 100644
--- a/arch/powerpc/platforms/pseries/msi.c
+++ b/arch/powerpc/platforms/pseries/msi.c
@@ -336,26 +336,6 @@ out:
336 return request; 336 return request;
337} 337}
338 338
339static int rtas_msi_check_device(struct pci_dev *pdev, int nvec, int type)
340{
341 int quota, rc;
342
343 if (type == PCI_CAP_ID_MSIX)
344 rc = check_req_msix(pdev, nvec);
345 else
346 rc = check_req_msi(pdev, nvec);
347
348 if (rc)
349 return rc;
350
351 quota = msi_quota_for_device(pdev, nvec);
352
353 if (quota && quota < nvec)
354 return quota;
355
356 return 0;
357}
358
359static int check_msix_entries(struct pci_dev *pdev) 339static int check_msix_entries(struct pci_dev *pdev)
360{ 340{
361 struct msi_desc *entry; 341 struct msi_desc *entry;
@@ -397,15 +377,24 @@ static void rtas_hack_32bit_msi_gen2(struct pci_dev *pdev)
397static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type) 377static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type)
398{ 378{
399 struct pci_dn *pdn; 379 struct pci_dn *pdn;
400 int hwirq, virq, i, rc; 380 int hwirq, virq, i, quota, rc;
401 struct msi_desc *entry; 381 struct msi_desc *entry;
402 struct msi_msg msg; 382 struct msi_msg msg;
403 int nvec = nvec_in; 383 int nvec = nvec_in;
404 int use_32bit_msi_hack = 0; 384 int use_32bit_msi_hack = 0;
405 385
406 pdn = pci_get_pdn(pdev); 386 if (type == PCI_CAP_ID_MSIX)
407 if (!pdn) 387 rc = check_req_msix(pdev, nvec);
408 return -ENODEV; 388 else
389 rc = check_req_msi(pdev, nvec);
390
391 if (rc)
392 return rc;
393
394 quota = msi_quota_for_device(pdev, nvec);
395
396 if (quota && quota < nvec)
397 return quota;
409 398
410 if (type == PCI_CAP_ID_MSIX && check_msix_entries(pdev)) 399 if (type == PCI_CAP_ID_MSIX && check_msix_entries(pdev))
411 return -EINVAL; 400 return -EINVAL;
@@ -416,12 +405,14 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type)
416 */ 405 */
417 if (type == PCI_CAP_ID_MSIX) { 406 if (type == PCI_CAP_ID_MSIX) {
418 int m = roundup_pow_of_two(nvec); 407 int m = roundup_pow_of_two(nvec);
419 int quota = msi_quota_for_device(pdev, m); 408 quota = msi_quota_for_device(pdev, m);
420 409
421 if (quota >= m) 410 if (quota >= m)
422 nvec = m; 411 nvec = m;
423 } 412 }
424 413
414 pdn = pci_get_pdn(pdev);
415
425 /* 416 /*
426 * Try the new more explicit firmware interface, if that fails fall 417 * Try the new more explicit firmware interface, if that fails fall
427 * back to the old interface. The old interface is known to never 418 * back to the old interface. The old interface is known to never
@@ -526,7 +517,6 @@ static int rtas_msi_init(void)
526 WARN_ON(ppc_md.setup_msi_irqs); 517 WARN_ON(ppc_md.setup_msi_irqs);
527 ppc_md.setup_msi_irqs = rtas_setup_msi_irqs; 518 ppc_md.setup_msi_irqs = rtas_setup_msi_irqs;
528 ppc_md.teardown_msi_irqs = rtas_teardown_msi_irqs; 519 ppc_md.teardown_msi_irqs = rtas_teardown_msi_irqs;
529 ppc_md.msi_check_device = rtas_msi_check_device;
530 520
531 WARN_ON(ppc_md.pci_irq_fixup); 521 WARN_ON(ppc_md.pci_irq_fixup);
532 ppc_md.pci_irq_fixup = rtas_msi_pci_irq_fixup; 522 ppc_md.pci_irq_fixup = rtas_msi_pci_irq_fixup;