Commit 4287d824 authored by Thomas Petazzoni's avatar Thomas Petazzoni Committed by Jason Cooper

PCI: use weak functions for MSI arch-specific functions

Until now, the MSI architecture-specific functions could be overloaded
using a fairly complex set of #define and compile-time
conditionals. In order to prepare for the introduction of the msi_chip
infrastructure, it is desirable to switch all those functions to use
the 'weak' mechanism. This commit converts all the architectures that
were overidding those MSI functions to use the new strategy.

Note that we keep two separate, non-weak, functions
default_teardown_msi_irqs() and default_restore_msi_irqs() for the
default behavior of the arch_teardown_msi_irqs() and
arch_restore_msi_irqs(), as the default behavior is needed by x86 PCI
code.
Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Acked-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tested-by: default avatarDaniel Price <daniel.price@gmail.com>
Tested-by: default avatarThierry Reding <thierry.reding@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: David S. Miller <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: default avatarJason Cooper <jason@lakedaemon.net>
parent ad81f054
...@@ -136,11 +136,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) ...@@ -136,11 +136,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
return channel ? 15 : 14; return channel ? 15 : 14;
} }
#ifdef CONFIG_CPU_CAVIUM_OCTEON
/* MSI arch hook for OCTEON */
#define arch_setup_msi_irqs arch_setup_msi_irqs
#endif
extern char * (*pcibios_plat_setup)(char *str); extern char * (*pcibios_plat_setup)(char *str);
#ifdef CONFIG_OF #ifdef CONFIG_OF
......
...@@ -113,11 +113,6 @@ extern int pci_domain_nr(struct pci_bus *bus); ...@@ -113,11 +113,6 @@ extern int pci_domain_nr(struct pci_bus *bus);
/* Decide whether to display the domain number in /proc */ /* Decide whether to display the domain number in /proc */
extern int pci_proc_domain(struct pci_bus *bus); extern int pci_proc_domain(struct pci_bus *bus);
/* MSI arch hooks */
#define arch_setup_msi_irqs arch_setup_msi_irqs
#define arch_teardown_msi_irqs arch_teardown_msi_irqs
#define arch_msi_check_device arch_msi_check_device
struct vm_area_struct; struct vm_area_struct;
/* Map a range of PCI memory or I/O space for a device into user space */ /* Map a range of PCI memory or I/O space for a device into user space */
int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma, int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
......
...@@ -21,10 +21,6 @@ void pci_iounmap(struct pci_dev *, void __iomem *); ...@@ -21,10 +21,6 @@ void pci_iounmap(struct pci_dev *, void __iomem *);
int pci_domain_nr(struct pci_bus *); int pci_domain_nr(struct pci_bus *);
int pci_proc_domain(struct pci_bus *); int pci_proc_domain(struct pci_bus *);
/* MSI arch hooks */
#define arch_setup_msi_irqs arch_setup_msi_irqs
#define arch_teardown_msi_irqs arch_teardown_msi_irqs
#define ZPCI_BUS_NR 0 /* default bus number */ #define ZPCI_BUS_NR 0 /* default bus number */
#define ZPCI_DEVFN 0 /* default device number */ #define ZPCI_DEVFN 0 /* default device number */
......
...@@ -100,29 +100,6 @@ static inline void early_quirks(void) { } ...@@ -100,29 +100,6 @@ static inline void early_quirks(void) { }
extern void pci_iommu_alloc(void); extern void pci_iommu_alloc(void);
#ifdef CONFIG_PCI_MSI #ifdef CONFIG_PCI_MSI
/* MSI arch specific hooks */
static inline int x86_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
return x86_msi.setup_msi_irqs(dev, nvec, type);
}
static inline void x86_teardown_msi_irqs(struct pci_dev *dev)
{
x86_msi.teardown_msi_irqs(dev);
}
static inline void x86_teardown_msi_irq(unsigned int irq)
{
x86_msi.teardown_msi_irq(irq);
}
static inline void x86_restore_msi_irqs(struct pci_dev *dev, int irq)
{
x86_msi.restore_msi_irqs(dev, irq);
}
#define arch_setup_msi_irqs x86_setup_msi_irqs
#define arch_teardown_msi_irqs x86_teardown_msi_irqs
#define arch_teardown_msi_irq x86_teardown_msi_irq
#define arch_restore_msi_irqs x86_restore_msi_irqs
/* implemented in arch/x86/kernel/apic/io_apic. */ /* implemented in arch/x86/kernel/apic/io_apic. */
struct msi_desc; struct msi_desc;
int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
...@@ -130,16 +107,9 @@ void native_teardown_msi_irq(unsigned int irq); ...@@ -130,16 +107,9 @@ void native_teardown_msi_irq(unsigned int irq);
void native_restore_msi_irqs(struct pci_dev *dev, int irq); void native_restore_msi_irqs(struct pci_dev *dev, int irq);
int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc,
unsigned int irq_base, unsigned int irq_offset); unsigned int irq_base, unsigned int irq_offset);
/* default to the implementation in drivers/lib/msi.c */
#define HAVE_DEFAULT_MSI_TEARDOWN_IRQS
#define HAVE_DEFAULT_MSI_RESTORE_IRQS
void default_teardown_msi_irqs(struct pci_dev *dev);
void default_restore_msi_irqs(struct pci_dev *dev, int irq);
#else #else
#define native_setup_msi_irqs NULL #define native_setup_msi_irqs NULL
#define native_teardown_msi_irq NULL #define native_teardown_msi_irq NULL
#define default_teardown_msi_irqs NULL
#define default_restore_msi_irqs NULL
#endif #endif
#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys) #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
......
...@@ -107,6 +107,8 @@ struct x86_platform_ops x86_platform = { ...@@ -107,6 +107,8 @@ struct x86_platform_ops x86_platform = {
}; };
EXPORT_SYMBOL_GPL(x86_platform); EXPORT_SYMBOL_GPL(x86_platform);
#if defined(CONFIG_PCI_MSI)
struct x86_msi_ops x86_msi = { struct x86_msi_ops x86_msi = {
.setup_msi_irqs = native_setup_msi_irqs, .setup_msi_irqs = native_setup_msi_irqs,
.compose_msi_msg = native_compose_msi_msg, .compose_msi_msg = native_compose_msi_msg,
...@@ -116,6 +118,28 @@ struct x86_msi_ops x86_msi = { ...@@ -116,6 +118,28 @@ struct x86_msi_ops x86_msi = {
.setup_hpet_msi = default_setup_hpet_msi, .setup_hpet_msi = default_setup_hpet_msi,
}; };
/* MSI arch specific hooks */
int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
return x86_msi.setup_msi_irqs(dev, nvec, type);
}
void arch_teardown_msi_irqs(struct pci_dev *dev)
{
x86_msi.teardown_msi_irqs(dev);
}
void arch_teardown_msi_irq(unsigned int irq)
{
x86_msi.teardown_msi_irq(irq);
}
void arch_restore_msi_irqs(struct pci_dev *dev, int irq)
{
x86_msi.restore_msi_irqs(dev, irq);
}
#endif
struct x86_io_apic_ops x86_io_apic_ops = { struct x86_io_apic_ops x86_io_apic_ops = {
.init = native_io_apic_init_mappings, .init = native_io_apic_init_mappings,
.read = native_io_apic_read, .read = native_io_apic_read,
......
...@@ -30,20 +30,21 @@ static int pci_msi_enable = 1; ...@@ -30,20 +30,21 @@ static int pci_msi_enable = 1;
/* Arch hooks */ /* Arch hooks */
#ifndef arch_msi_check_device int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
int arch_msi_check_device(struct pci_dev *dev, int nvec, int type)
{ {
return 0; return -EINVAL;
} }
#endif
#ifndef arch_setup_msi_irqs void __weak arch_teardown_msi_irq(unsigned int irq)
# define arch_setup_msi_irqs default_setup_msi_irqs {
# define HAVE_DEFAULT_MSI_SETUP_IRQS }
#endif
#ifdef HAVE_DEFAULT_MSI_SETUP_IRQS int __weak arch_msi_check_device(struct pci_dev *dev, int nvec, int type)
int default_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) {
return 0;
}
int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{ {
struct msi_desc *entry; struct msi_desc *entry;
int ret; int ret;
...@@ -65,14 +66,11 @@ int default_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) ...@@ -65,14 +66,11 @@ int default_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
return 0; return 0;
} }
#endif
#ifndef arch_teardown_msi_irqs
# define arch_teardown_msi_irqs default_teardown_msi_irqs
# define HAVE_DEFAULT_MSI_TEARDOWN_IRQS
#endif
#ifdef HAVE_DEFAULT_MSI_TEARDOWN_IRQS /*
* We have a default implementation available as a separate non-weak
* function, as it is used by the Xen x86 PCI code
*/
void default_teardown_msi_irqs(struct pci_dev *dev) void default_teardown_msi_irqs(struct pci_dev *dev)
{ {
struct msi_desc *entry; struct msi_desc *entry;
...@@ -89,14 +87,12 @@ void default_teardown_msi_irqs(struct pci_dev *dev) ...@@ -89,14 +87,12 @@ void default_teardown_msi_irqs(struct pci_dev *dev)
arch_teardown_msi_irq(entry->irq + i); arch_teardown_msi_irq(entry->irq + i);
} }
} }
#endif
#ifndef arch_restore_msi_irqs void __weak arch_teardown_msi_irqs(struct pci_dev *dev)
# define arch_restore_msi_irqs default_restore_msi_irqs {
# define HAVE_DEFAULT_MSI_RESTORE_IRQS return default_teardown_msi_irqs(dev);
#endif }
#ifdef HAVE_DEFAULT_MSI_RESTORE_IRQS
void default_restore_msi_irqs(struct pci_dev *dev, int irq) void default_restore_msi_irqs(struct pci_dev *dev, int irq)
{ {
struct msi_desc *entry; struct msi_desc *entry;
...@@ -114,7 +110,11 @@ void default_restore_msi_irqs(struct pci_dev *dev, int irq) ...@@ -114,7 +110,11 @@ void default_restore_msi_irqs(struct pci_dev *dev, int irq)
if (entry) if (entry)
write_msi_msg(irq, &entry->msg); write_msi_msg(irq, &entry->msg);
} }
#endif
void __weak arch_restore_msi_irqs(struct pci_dev *dev, int irq)
{
return default_restore_msi_irqs(dev, irq);
}
static void msi_set_enable(struct pci_dev *dev, int enable) static void msi_set_enable(struct pci_dev *dev, int enable)
{ {
......
...@@ -51,12 +51,18 @@ struct msi_desc { ...@@ -51,12 +51,18 @@ struct msi_desc {
}; };
/* /*
* The arch hook for setup up msi irqs * The arch hooks to setup up msi irqs. Those functions are
* implemented as weak symbols so that they /can/ be overriden by
* architecture specific code if needed.
*/ */
int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc); int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc);
void arch_teardown_msi_irq(unsigned int irq); void arch_teardown_msi_irq(unsigned int irq);
int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
void arch_teardown_msi_irqs(struct pci_dev *dev); void arch_teardown_msi_irqs(struct pci_dev *dev);
int arch_msi_check_device(struct pci_dev* dev, int nvec, int type); int arch_msi_check_device(struct pci_dev* dev, int nvec, int type);
void arch_restore_msi_irqs(struct pci_dev *dev, int irq);
void default_teardown_msi_irqs(struct pci_dev *dev);
void default_restore_msi_irqs(struct pci_dev *dev, int irq);
#endif /* LINUX_MSI_H */ #endif /* LINUX_MSI_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment