msi.c 989 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright 2006-2007, Michael Ellerman, IBM Corporation.
  4. */
  5. #include <linux/kernel.h>
  6. #include <linux/msi.h>
  7. #include <linux/pci.h>
  8. #include <asm/machdep.h>
  9. int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
  10. {
  11. struct pci_controller *phb = pci_bus_to_host(dev->bus);
  12. if (!phb->controller_ops.setup_msi_irqs ||
  13. !phb->controller_ops.teardown_msi_irqs) {
  14. pr_debug("msi: Platform doesn't provide MSI callbacks.\n");
  15. return -ENOSYS;
  16. }
  17. /* PowerPC doesn't support multiple MSI yet */
  18. if (type == PCI_CAP_ID_MSI && nvec > 1)
  19. return 1;
  20. return phb->controller_ops.setup_msi_irqs(dev, nvec, type);
  21. }
  22. void arch_teardown_msi_irqs(struct pci_dev *dev)
  23. {
  24. struct pci_controller *phb = pci_bus_to_host(dev->bus);
  25. /*
  26. * We can be called even when arch_setup_msi_irqs() returns -ENOSYS,
  27. * so check the pointer again.
  28. */
  29. if (phb->controller_ops.teardown_msi_irqs)
  30. phb->controller_ops.teardown_msi_irqs(dev);
  31. }