890cdcf
. which makes the code fit within the rest of the x86_ops functions.
890cdcf
890cdcf
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
890cdcf
[v1: Changed x86_apic -> x86_ioapic per Yinghai Lu <yinghai@kernel.org> suggestion]
890cdcf
Acked-by: Suresh Siddha <suresh.b.siddha@intel.com>
890cdcf
---
890cdcf
 arch/x86/include/asm/io_apic.h  |   40 +++++++++++++++++++++--------
890cdcf
 arch/x86/include/asm/x86_init.h |    8 ++++++
890cdcf
 arch/x86/kernel/apic/io_apic.c  |   54 ++++----------------------------------
890cdcf
 arch/x86/kernel/setup.c         |    2 +-
890cdcf
 arch/x86/kernel/x86_init.c      |    8 ++++++
890cdcf
 5 files changed, 52 insertions(+), 60 deletions(-)
890cdcf
890cdcf
diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
890cdcf
index 190d8c2..ba1b11a 100644
890cdcf
--- a/arch/x86/include/asm/io_apic.h
890cdcf
+++ b/arch/x86/include/asm/io_apic.h
890cdcf
@@ -5,6 +5,7 @@
890cdcf
 #include <asm/mpspec.h>
890cdcf
 #include <asm/apicdef.h>
890cdcf
 #include <asm/irq_vectors.h>
890cdcf
+#include <asm/x86_init.h>
890cdcf
 
890cdcf
 /*
890cdcf
  * Intel IO-APIC support for SMP and UP systems.
890cdcf
@@ -21,15 +22,6 @@
890cdcf
 #define IO_APIC_REDIR_LEVEL_TRIGGER	(1 << 15)
890cdcf
 #define IO_APIC_REDIR_MASKED		(1 << 16)
890cdcf
 
890cdcf
-struct io_apic_ops {
890cdcf
-	void (*init)(void);
890cdcf
-	unsigned int (*read)(unsigned int apic, unsigned int reg);
890cdcf
-	void (*write)(unsigned int apic, unsigned int reg, unsigned int value);
890cdcf
-	void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
890cdcf
-};
890cdcf
-
890cdcf
-void __init set_io_apic_ops(const struct io_apic_ops *);
890cdcf
-
890cdcf
 /*
890cdcf
  * The structure of the IO-APIC:
890cdcf
  */
890cdcf
@@ -156,7 +148,6 @@ struct io_apic_irq_attr;
890cdcf
 extern int io_apic_set_pci_routing(struct device *dev, int irq,
890cdcf
 		 struct io_apic_irq_attr *irq_attr);
890cdcf
 void setup_IO_APIC_irq_extra(u32 gsi);
890cdcf
-extern void ioapic_and_gsi_init(void);
890cdcf
 extern void ioapic_insert_resources(void);
890cdcf
 
890cdcf
 int io_apic_setup_irq_pin_once(unsigned int irq, int node, struct io_apic_irq_attr *attr);
890cdcf
@@ -185,12 +176,35 @@ extern void mp_save_irq(struct mpc_intsrc *m);
890cdcf
 
890cdcf
 extern void disable_ioapic_support(void);
890cdcf
 
890cdcf
+
890cdcf
+void __init native_ioapic_init_mappings(void);
890cdcf
+unsigned int native_ioapic_read(unsigned int apic, unsigned int reg);
890cdcf
+void native_ioapic_write(unsigned int apic, unsigned int reg,
890cdcf
+			 unsigned int val);
890cdcf
+void native_ioapic_modify(unsigned int apic, unsigned int reg,
890cdcf
+			  unsigned int val);
890cdcf
+
890cdcf
+static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
890cdcf
+{
890cdcf
+	return x86_ioapic.read(apic, reg);
890cdcf
+}
890cdcf
+
890cdcf
+static inline void io_apic_write(unsigned int apic, unsigned int reg,
890cdcf
+				 unsigned int value)
890cdcf
+{
890cdcf
+	x86_ioapic.write(apic, reg, value);
890cdcf
+}
890cdcf
+
890cdcf
+static inline void io_apic_modify(unsigned int apic, unsigned int reg,
890cdcf
+				  unsigned int value)
890cdcf
+{
890cdcf
+	x86_ioapic.modify(apic, reg, value);
890cdcf
+}
890cdcf
 #else  /* !CONFIG_X86_IO_APIC */
890cdcf
 
890cdcf
 #define io_apic_assign_pci_irqs 0
890cdcf
 #define setup_ioapic_ids_from_mpc x86_init_noop
890cdcf
 static const int timer_through_8259 = 0;
890cdcf
-static inline void ioapic_and_gsi_init(void) { }
890cdcf
 static inline void ioapic_insert_resources(void) { }
890cdcf
 #define gsi_top (NR_IRQS_LEGACY)
890cdcf
 static inline int mp_find_ioapic(u32 gsi) { return 0; }
890cdcf
@@ -212,6 +226,10 @@ static inline int restore_ioapic_entries(void)
890cdcf
 
890cdcf
 static inline void mp_save_irq(struct mpc_intsrc *m) { };
890cdcf
 static inline void disable_ioapic_support(void) { }
890cdcf
+#define native_ioapic_init_mappings NULL
890cdcf
+#define native_ioapic_read NULL
890cdcf
+#define native_ioapic_write NULL
890cdcf
+#define native_ioapic_modify NULL
890cdcf
 #endif
890cdcf
 
890cdcf
 #endif /* _ASM_X86_IO_APIC_H */
890cdcf
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
890cdcf
index 517d476..a3730cc 100644
890cdcf
--- a/arch/x86/include/asm/x86_init.h
890cdcf
+++ b/arch/x86/include/asm/x86_init.h
890cdcf
@@ -182,10 +182,18 @@ struct x86_msi_ops {
890cdcf
 	void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
890cdcf
 };
890cdcf
 
890cdcf
+struct x86_ioapic_ops {
890cdcf
+	void (*init)(void);
890cdcf
+	unsigned int (*read)(unsigned int apic, unsigned int reg);
890cdcf
+	void (*write)(unsigned int apic, unsigned int reg, unsigned int value);
890cdcf
+	void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
890cdcf
+};
890cdcf
+
890cdcf
 extern struct x86_init_ops x86_init;
890cdcf
 extern struct x86_cpuinit_ops x86_cpuinit;
890cdcf
 extern struct x86_platform_ops x86_platform;
890cdcf
 extern struct x86_msi_ops x86_msi;
890cdcf
+extern struct x86_ioapic_ops x86_ioapic;
890cdcf
 
890cdcf
 extern void x86_init_noop(void);
890cdcf
 extern void x86_init_uint_noop(unsigned int unused);
890cdcf
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
890cdcf
index bf120234..9a15d4b 100644
890cdcf
--- a/arch/x86/kernel/apic/io_apic.c
890cdcf
+++ b/arch/x86/kernel/apic/io_apic.c
890cdcf
@@ -67,25 +67,6 @@
890cdcf
 #define for_each_irq_pin(entry, head) \
890cdcf
 	for (entry = head; entry; entry = entry->next)
890cdcf
 
890cdcf
-static void __init __ioapic_init_mappings(void);
890cdcf
-static unsigned int __io_apic_read(unsigned int apic, unsigned int reg);
890cdcf
-static void __io_apic_write(unsigned int apic, unsigned int reg,
890cdcf
-			    unsigned int val);
890cdcf
-static void __io_apic_modify(unsigned int apic, unsigned int reg,
890cdcf
-			     unsigned int val);
890cdcf
-
890cdcf
-static struct io_apic_ops io_apic_ops = {
890cdcf
-	.init = __ioapic_init_mappings,
890cdcf
-	.read = __io_apic_read,
890cdcf
-	.write = __io_apic_write,
890cdcf
-	.modify = __io_apic_modify,
890cdcf
-};
890cdcf
-
890cdcf
-void __init set_io_apic_ops(const struct io_apic_ops *ops)
890cdcf
-{
890cdcf
-	io_apic_ops = *ops;
890cdcf
-}
890cdcf
-
890cdcf
 /*
890cdcf
  *      Is the SiS APIC rmw bug present ?
890cdcf
  *      -1 = don't know, 0 = no, 1 = yes
890cdcf
@@ -313,24 +294,6 @@ static void free_irq_at(unsigned int at, struct irq_cfg *cfg)
890cdcf
 	irq_free_desc(at);
890cdcf
 }
890cdcf
 
890cdcf
-static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
890cdcf
-{
890cdcf
-	return io_apic_ops.read(apic, reg);
890cdcf
-}
890cdcf
-
890cdcf
-static inline void io_apic_write(unsigned int apic, unsigned int reg,
890cdcf
-				 unsigned int value)
890cdcf
-{
890cdcf
-	io_apic_ops.write(apic, reg, value);
890cdcf
-}
890cdcf
-
890cdcf
-static inline void io_apic_modify(unsigned int apic, unsigned int reg,
890cdcf
-				  unsigned int value)
890cdcf
-{
890cdcf
-	io_apic_ops.modify(apic, reg, value);
890cdcf
-}
890cdcf
-
890cdcf
-
890cdcf
 struct io_apic {
890cdcf
 	unsigned int index;
890cdcf
 	unsigned int unused[3];
890cdcf
@@ -351,15 +314,15 @@ static inline void io_apic_eoi(unsigned int apic, unsigned int vector)
890cdcf
 	writel(vector, &io_apic->eoi);
890cdcf
 }
890cdcf
 
890cdcf
-static unsigned int __io_apic_read(unsigned int apic, unsigned int reg)
890cdcf
+unsigned int native_ioapic_read(unsigned int apic, unsigned int reg)
890cdcf
 {
890cdcf
 	struct io_apic __iomem *io_apic = io_apic_base(apic);
890cdcf
 	writel(reg, &io_apic->index);
890cdcf
 	return readl(&io_apic->data);
890cdcf
 }
890cdcf
 
890cdcf
-static void __io_apic_write(unsigned int apic, unsigned int reg,
890cdcf
-			    unsigned int value)
890cdcf
+void native_ioapic_write(unsigned int apic, unsigned int reg,
890cdcf
+			 unsigned int value)
890cdcf
 {
890cdcf
 	struct io_apic __iomem *io_apic = io_apic_base(apic);
890cdcf
 	writel(reg, &io_apic->index);
890cdcf
@@ -372,8 +335,8 @@ static void __io_apic_write(unsigned int apic, unsigned int reg,
890cdcf
  *
890cdcf
  * Older SiS APIC requires we rewrite the index register
890cdcf
  */
890cdcf
-static void __io_apic_modify(unsigned int apic, unsigned int reg,
890cdcf
-			     unsigned int value)
890cdcf
+void native_ioapic_modify(unsigned int apic, unsigned int reg,
890cdcf
+			  unsigned int value)
890cdcf
 {
890cdcf
 	struct io_apic __iomem *io_apic = io_apic_base(apic);
890cdcf
 
890cdcf
@@ -3910,12 +3873,7 @@ static struct resource * __init ioapic_setup_resources(int nr_ioapics)
890cdcf
 	return res;
890cdcf
 }
890cdcf
 
890cdcf
-void __init ioapic_and_gsi_init(void)
890cdcf
-{
890cdcf
-	io_apic_ops.init();
890cdcf
-}
890cdcf
-
890cdcf
-static void __init __ioapic_init_mappings(void)
890cdcf
+void __init native_ioapic_init_mappings(void)
890cdcf
 {
890cdcf
 	unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0;
890cdcf
 	struct resource *ioapic_res;
890cdcf
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
890cdcf
index d7d5099..7eaef1a 100644
890cdcf
--- a/arch/x86/kernel/setup.c
890cdcf
+++ b/arch/x86/kernel/setup.c
890cdcf
@@ -1016,7 +1016,7 @@ void __init setup_arch(char **cmdline_p)
890cdcf
 	init_cpu_to_node();
890cdcf
 
890cdcf
 	init_apic_mappings();
890cdcf
-	ioapic_and_gsi_init();
890cdcf
+	x86_ioapic.init();
890cdcf
 
890cdcf
 	kvm_guest_init();
890cdcf
 
890cdcf
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
890cdcf
index 947a06c..df870d3 100644
890cdcf
--- a/arch/x86/kernel/x86_init.c
890cdcf
+++ b/arch/x86/kernel/x86_init.c
890cdcf
@@ -18,6 +18,7 @@
890cdcf
 #include <asm/e820.h>
890cdcf
 #include <asm/time.h>
890cdcf
 #include <asm/irq.h>
890cdcf
+#include <asm/io_apic.h>
890cdcf
 #include <asm/pat.h>
890cdcf
 #include <asm/tsc.h>
890cdcf
 #include <asm/iommu.h>
890cdcf
@@ -117,3 +118,10 @@ struct x86_msi_ops x86_msi = {
890cdcf
 	.teardown_msi_irqs = default_teardown_msi_irqs,
890cdcf
 	.restore_msi_irqs = default_restore_msi_irqs,
890cdcf
 };
890cdcf
+
890cdcf
+struct x86_ioapic_ops x86_ioapic = {
890cdcf
+	.init = native_ioapic_init_mappings,
890cdcf
+	.read = native_ioapic_read,
890cdcf
+	.write = native_ioapic_write,
890cdcf
+	.modify = native_ioapic_modify,
890cdcf
+};
890cdcf
-- 
890cdcf
1.7.7.5
890cdcf