blob: a5d25bebcab9b039c8a6fe38d605dfc07036ac98 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Michael Ellermandf87ef52007-05-08 12:58:34 +10002/*
3 * Copyright 2006-2007, Michael Ellerman, IBM Corporation.
Michael Ellermandf87ef52007-05-08 12:58:34 +10004 */
5
6#include <linux/kernel.h>
7#include <linux/msi.h>
Jesse Barnesceb93a92009-03-25 08:54:29 -07008#include <linux/pci.h>
Michael Ellermandf87ef52007-05-08 12:58:34 +10009
10#include <asm/machdep.h>
11
Alexander Gordeev6b2fd7ef2014-09-07 20:57:53 +020012int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
Michael Ellermandf87ef52007-05-08 12:58:34 +100013{
Daniel Axtense059b102015-04-14 14:27:54 +100014 struct pci_controller *phb = pci_bus_to_host(dev->bus);
15
Daniel Axtens1f88d582015-04-14 14:28:03 +100016 if (!phb->controller_ops.setup_msi_irqs ||
17 !phb->controller_ops.teardown_msi_irqs) {
Michael Ellermandf87ef52007-05-08 12:58:34 +100018 pr_debug("msi: Platform doesn't provide MSI callbacks.\n");
19 return -ENOSYS;
20 }
21
Matthew Wilcox1c8d7b02009-03-17 08:54:10 -040022 /* PowerPC doesn't support multiple MSI yet */
23 if (type == PCI_CAP_ID_MSI && nvec > 1)
24 return 1;
25
Daniel Axtens1f88d582015-04-14 14:28:03 +100026 return phb->controller_ops.setup_msi_irqs(dev, nvec, type);
Michael Ellermandf87ef52007-05-08 12:58:34 +100027}
28
29void arch_teardown_msi_irqs(struct pci_dev *dev)
30{
Daniel Axtense059b102015-04-14 14:27:54 +100031 struct pci_controller *phb = pci_bus_to_host(dev->bus);
32
Radu Rendec78e7b152018-11-27 22:20:48 -050033 /*
34 * We can be called even when arch_setup_msi_irqs() returns -ENOSYS,
35 * so check the pointer again.
36 */
37 if (phb->controller_ops.teardown_msi_irqs)
38 phb->controller_ops.teardown_msi_irqs(dev);
Michael Ellermandf87ef52007-05-08 12:58:34 +100039}