aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <thierry.reding@avionic-design.de>2013-08-09 16:27:08 -0400
committerJason Cooper <jason@lakedaemon.net>2013-08-12 11:26:58 -0400
commit0cbdcfcf427b63b9670e56760ef5e67cd7081b35 (patch)
tree941122e2248ac4b8dd107bc1702c83cbc0961166
parentebd97be635bff43239f391a49c78b98818c589fe (diff)
PCI: Introduce new MSI chip infrastructure
The new struct msi_chip is used to associated an MSI controller with a PCI bus. It is automatically handed down from the root to its children during bus enumeration. This patch provides default (weak) implementations for the architecture- specific MSI functions (arch_setup_msi_irq(), arch_teardown_msi_irq() and arch_msi_check_device()) which check if a PCI device's bus has an attached MSI chip and forward the call appropriately. Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Daniel Price <daniel.price@gmail.com> Tested-by: Thierry Reding <thierry.reding@gmail.com> Signed-off-by: Jason Cooper <jason@lakedaemon.net>
-rw-r--r--drivers/pci/msi.c27
-rw-r--r--drivers/pci/probe.c1
-rw-r--r--include/linux/msi.h11
-rw-r--r--include/linux/pci.h1
4 files changed, 38 insertions, 2 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 823c3861c4d8..2837285c4e83 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -32,16 +32,39 @@ static int pci_msi_enable = 1;
32 32
33int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) 33int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
34{ 34{
35 return -EINVAL; 35 struct msi_chip *chip = dev->bus->msi;
36 int err;
37
38 if (!chip || !chip->setup_irq)
39 return -EINVAL;
40
41 err = chip->setup_irq(chip, dev, desc);
42 if (err < 0)
43 return err;
44
45 irq_set_chip_data(desc->irq, chip);
46
47 return 0;
36} 48}
37 49
38void __weak arch_teardown_msi_irq(unsigned int irq) 50void __weak arch_teardown_msi_irq(unsigned int irq)
39{ 51{
52 struct msi_chip *chip = irq_get_chip_data(irq);
53
54 if (!chip || !chip->teardown_irq)
55 return;
56
57 chip->teardown_irq(chip, irq);
40} 58}
41 59
42int __weak arch_msi_check_device(struct pci_dev *dev, int nvec, int type) 60int __weak arch_msi_check_device(struct pci_dev *dev, int nvec, int type)
43{ 61{
44 return 0; 62 struct msi_chip *chip = dev->bus->msi;
63
64 if (!chip || !chip->check_device)
65 return 0;
66
67 return chip->check_device(chip, dev, nvec, type);
45} 68}
46 69
47int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) 70int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 46ada5c098eb..b8eaa8167849 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -666,6 +666,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
666 666
667 child->parent = parent; 667 child->parent = parent;
668 child->ops = parent->ops; 668 child->ops = parent->ops;
669 child->msi = parent->msi;
669 child->sysdata = parent->sysdata; 670 child->sysdata = parent->sysdata;
670 child->bus_flags = parent->bus_flags; 671 child->bus_flags = parent->bus_flags;
671 672
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 271dfd14a05f..090ddadbc838 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -65,4 +65,15 @@ void arch_restore_msi_irqs(struct pci_dev *dev, int irq);
65void default_teardown_msi_irqs(struct pci_dev *dev); 65void default_teardown_msi_irqs(struct pci_dev *dev);
66void default_restore_msi_irqs(struct pci_dev *dev, int irq); 66void default_restore_msi_irqs(struct pci_dev *dev, int irq);
67 67
68struct msi_chip {
69 struct module *owner;
70 struct device *dev;
71
72 int (*setup_irq)(struct msi_chip *chip, struct pci_dev *dev,
73 struct msi_desc *desc);
74 void (*teardown_irq)(struct msi_chip *chip, unsigned int irq);
75 int (*check_device)(struct msi_chip *chip, struct pci_dev *dev,
76 int nvec, int type);
77};
78
68#endif /* LINUX_MSI_H */ 79#endif /* LINUX_MSI_H */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 0fd1f1582fa1..4044e3c00609 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -433,6 +433,7 @@ struct pci_bus {
433 struct resource busn_res; /* bus numbers routed to this bus */ 433 struct resource busn_res; /* bus numbers routed to this bus */
434 434
435 struct pci_ops *ops; /* configuration access functions */ 435 struct pci_ops *ops; /* configuration access functions */
436 struct msi_chip *msi; /* MSI controller */
436 void *sysdata; /* hook for sys-specific extension */ 437 void *sysdata; /* hook for sys-specific extension */
437 struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */ 438 struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */
438 439