Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Copyright 2006-2007, Michael Ellerman, IBM Corporation.
0004  */
0005 
0006 #include <linux/kernel.h>
0007 #include <linux/msi.h>
0008 #include <linux/pci.h>
0009 
0010 #include <asm/machdep.h>
0011 
0012 int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
0013 {
0014     struct pci_controller *phb = pci_bus_to_host(dev->bus);
0015 
0016     if (!phb->controller_ops.setup_msi_irqs ||
0017         !phb->controller_ops.teardown_msi_irqs) {
0018         pr_debug("msi: Platform doesn't provide MSI callbacks.\n");
0019         return -ENOSYS;
0020     }
0021 
0022     /* PowerPC doesn't support multiple MSI yet */
0023     if (type == PCI_CAP_ID_MSI && nvec > 1)
0024         return 1;
0025 
0026     return phb->controller_ops.setup_msi_irqs(dev, nvec, type);
0027 }
0028 
0029 void arch_teardown_msi_irqs(struct pci_dev *dev)
0030 {
0031     struct pci_controller *phb = pci_bus_to_host(dev->bus);
0032 
0033     /*
0034      * We can be called even when arch_setup_msi_irqs() returns -ENOSYS,
0035      * so check the pointer again.
0036      */
0037     if (phb->controller_ops.teardown_msi_irqs)
0038         phb->controller_ops.teardown_msi_irqs(dev);
0039 }