irqchip: gic: Perform the gic_secondary_init() call via CPU notifier

All the calls to gic_secondary_init() pass 0 as the first argument.
Since this function is called on each CPU when starting, it can be done
in a platform-independent way via a CPU notifier registered by the GIC
code.

Signed-off-by: Catalin Marinas <[email protected]>
Acked-by: Stephen Warren <[email protected]>
Acked-by: Viresh Kumar <[email protected]>
Acked-by: Santosh Shilimkar <[email protected]>
Acked-by: Rob Herring <[email protected]>
Acked-by: Simon Horman <[email protected]>
Tested-by: Simon Horman <[email protected]>
Acked-by: Srinidhi Kasagar <[email protected]>
Tested-by: Dinh Nguyen <[email protected]>
Acked-by: Nicolas Pitre <[email protected]>
Tested-by: Marc Zyngier <[email protected]>
Cc: Russell King <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Kukjin Kim <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: David Brown <[email protected]>
Cc: Bryan Huntsman <[email protected]>
Cc: Tony Lindgren <[email protected]>
Cc: Magnus Damm <[email protected]>
Cc: Shiraz Hashim <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Kukjin Kim <[email protected]>
Cc: Barry Song <[email protected]>
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 974f77c..add1fd8 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -28,6 +28,7 @@
 #include <linux/module.h>
 #include <linux/list.h>
 #include <linux/smp.h>
+#include <linux/cpu.h>
 #include <linux/cpu_pm.h>
 #include <linux/cpumask.h>
 #include <linux/io.h>
@@ -699,6 +700,25 @@
 	return 0;
 }
 
+#ifdef CONFIG_SMP
+static int __cpuinit gic_secondary_init(struct notifier_block *nfb,
+					unsigned long action, void *hcpu)
+{
+	if (action == CPU_STARTING)
+		gic_cpu_init(&gic_data[0]);
+	return NOTIFY_OK;
+}
+
+/*
+ * Notifier for enabling the GIC CPU interface. Set an arbitrarily high
+ * priority because the GIC needs to be up before the ARM generic timers.
+ */
+static struct notifier_block __cpuinitdata gic_cpu_notifier = {
+	.notifier_call = gic_secondary_init,
+	.priority = 100,
+};
+#endif
+
 const struct irq_domain_ops gic_irq_domain_ops = {
 	.map = gic_irq_domain_map,
 	.xlate = gic_irq_domain_xlate,
@@ -789,6 +809,7 @@
 
 #ifdef CONFIG_SMP
 	set_smp_cross_call(gic_raise_softirq);
+	register_cpu_notifier(&gic_cpu_notifier);
 #endif
 
 	set_handle_irq(gic_handle_irq);
@@ -799,13 +820,6 @@
 	gic_pm_init(gic);
 }
 
-void __cpuinit gic_secondary_init(unsigned int gic_nr)
-{
-	BUG_ON(gic_nr >= MAX_GIC_NR);
-
-	gic_cpu_init(&gic_data[gic_nr]);
-}
-
 #ifdef CONFIG_OF
 static int gic_cnt __initdata = 0;