* [PATCH 2/4] Cleanup pseries smp initialisation code
2007-02-08 7:33 [PATCH 1/4] Consolidate pseries platform header files into pseries.h Michael Ellerman
@ 2007-02-08 7:33 ` Michael Ellerman
2007-02-08 7:33 ` [PATCH 3/4] Cleanup pseries kexec code Michael Ellerman
2007-02-08 7:34 ` [PATCH 4/4] Move MPIC smp routines into mpic.c Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2007-02-08 7:33 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev
Move some extern declarations from setup.c into the new pseries.h.
While we're at it, provide dummy implementations for !SMP, to avoid
cluttering the C file with more #ifdefs.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/platforms/pseries/pseries.h | 8 ++++++++
arch/powerpc/platforms/pseries/setup.c | 6 ------
arch/powerpc/platforms/pseries/smp.c | 1 +
3 files changed, 9 insertions(+), 6 deletions(-)
Index: powerpc/arch/powerpc/platforms/pseries/pseries.h
===================================================================
--- powerpc.orig/arch/powerpc/platforms/pseries/pseries.h
+++ powerpc/arch/powerpc/platforms/pseries/pseries.h
@@ -17,4 +17,12 @@ struct pt_regs;
extern int pSeries_system_reset_exception(struct pt_regs *regs);
extern int pSeries_machine_check_exception(struct pt_regs *regs);
+#ifdef CONFIG_SMP
+extern void smp_init_pseries_mpic(void);
+extern void smp_init_pseries_xics(void);
+#else
+static inline smp_init_pseries_mpic(void) { };
+static inline smp_init_pseries_xics(void) { };
+#endif
+
#endif /* _PSERIES_PSERIES_H */
Index: powerpc/arch/powerpc/platforms/pseries/setup.c
===================================================================
--- powerpc.orig/arch/powerpc/platforms/pseries/setup.c
+++ powerpc/arch/powerpc/platforms/pseries/setup.c
@@ -77,8 +77,6 @@
#endif
/* move those away to a .h */
-extern void smp_init_pseries_mpic(void);
-extern void smp_init_pseries_xics(void);
extern void find_udbg_vterm(void);
int fwnmi_active; /* TRUE if an FWNMI handler is present */
@@ -272,18 +270,14 @@ static void __init pseries_discover_pic(
#ifdef CONFIG_KEXEC
ppc_md.kexec_cpu_down = pseries_kexec_cpu_down_mpic;
#endif
-#ifdef CONFIG_SMP
smp_init_pseries_mpic();
-#endif
return;
} else if (strstr(typep, "ppc-xicp")) {
ppc_md.init_IRQ = xics_init_IRQ;
#ifdef CONFIG_KEXEC
ppc_md.kexec_cpu_down = pseries_kexec_cpu_down_xics;
#endif
-#ifdef CONFIG_SMP
smp_init_pseries_xics();
-#endif
return;
}
}
Index: powerpc/arch/powerpc/platforms/pseries/smp.c
===================================================================
--- powerpc.orig/arch/powerpc/platforms/pseries/smp.c
+++ powerpc/arch/powerpc/platforms/pseries/smp.c
@@ -48,6 +48,7 @@
#include <asm/vdso_datapage.h>
#include "plpar_wrappers.h"
+#include "pseries.h"
#ifdef DEBUG
#include <asm/udbg.h>
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 3/4] Cleanup pseries kexec code
2007-02-08 7:33 [PATCH 1/4] Consolidate pseries platform header files into pseries.h Michael Ellerman
2007-02-08 7:33 ` [PATCH 2/4] Cleanup pseries smp initialisation code Michael Ellerman
@ 2007-02-08 7:33 ` Michael Ellerman
2007-02-08 7:34 ` [PATCH 4/4] Move MPIC smp routines into mpic.c Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2007-02-08 7:33 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev
Move all the pseries kexec code into one file, platforms/pseries/kexec.c
Provide helpers for setting up ppc_md.kexec_cpu_down, so that we don't
have to have #ifdef CONFIG_KEXEC in setup.c
Move the initialisation of the ppc_md kexec callbacks into an init routine.
This is well and truly early enough to cause no change in behaviour, we
can't kexec until userspace has given us a kernel to kexec into.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/platforms/pseries/Makefile | 1
arch/powerpc/platforms/pseries/kexec.c | 72 +++++++++++++++++++++++++++++++
arch/powerpc/platforms/pseries/pseries.h | 8 +++
arch/powerpc/platforms/pseries/setup.c | 50 ---------------------
4 files changed, 83 insertions(+), 48 deletions(-)
Index: powerpc/arch/powerpc/platforms/pseries/Makefile
===================================================================
--- powerpc.orig/arch/powerpc/platforms/pseries/Makefile
+++ powerpc/arch/powerpc/platforms/pseries/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_SMP) += smp.o
obj-$(CONFIG_XICS) += xics.o
obj-$(CONFIG_SCANLOG) += scanlog.o
obj-$(CONFIG_EEH) += eeh.o eeh_cache.o eeh_driver.o eeh_event.o
+obj-$(CONFIG_KEXEC) += kexec.o
obj-$(CONFIG_HOTPLUG_CPU) += hotplug-cpu.o
Index: powerpc/arch/powerpc/platforms/pseries/kexec.c
===================================================================
--- /dev/null
+++ powerpc/arch/powerpc/platforms/pseries/kexec.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2006 Michael Ellerman, IBM Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <asm/machdep.h>
+#include <asm/page.h>
+#include <asm/firmware.h>
+#include <asm/kexec.h>
+#include <asm/mpic.h>
+
+#include "pseries.h"
+#include "xics.h"
+#include "plpar_wrappers.h"
+
+static void pseries_kexec_cpu_down(int crash_shutdown, int secondary)
+{
+ /* Don't risk a hypervisor call if we're crashing */
+ if (firmware_has_feature(FW_FEATURE_SPLPAR) && !crash_shutdown) {
+ unsigned long addr;
+
+ addr = __pa(get_slb_shadow());
+ if (unregister_slb_shadow(hard_smp_processor_id(), addr))
+ printk("SLB shadow buffer deregistration of "
+ "cpu %u (hw_cpu_id %d) failed\n",
+ smp_processor_id(),
+ hard_smp_processor_id());
+
+ addr = __pa(get_lppaca());
+ if (unregister_vpa(hard_smp_processor_id(), addr)) {
+ printk("VPA deregistration of cpu %u (hw_cpu_id %d) "
+ "failed\n", smp_processor_id(),
+ hard_smp_processor_id());
+ }
+ }
+}
+
+static void pseries_kexec_cpu_down_mpic(int crash_shutdown, int secondary)
+{
+ pseries_kexec_cpu_down(crash_shutdown, secondary);
+ mpic_teardown_this_cpu(secondary);
+}
+
+void __init setup_kexec_cpu_down_mpic(void)
+{
+ ppc_md.kexec_cpu_down = pseries_kexec_cpu_down_mpic;
+}
+
+static void pseries_kexec_cpu_down_xics(int crash_shutdown, int secondary)
+{
+ pseries_kexec_cpu_down(crash_shutdown, secondary);
+ xics_teardown_cpu(secondary);
+}
+
+void __init setup_kexec_cpu_down_xics(void)
+{
+ ppc_md.kexec_cpu_down = pseries_kexec_cpu_down_xics;
+}
+
+static int __init pseries_kexec_setup(void)
+{
+ ppc_md.machine_kexec = default_machine_kexec;
+ ppc_md.machine_kexec_prepare = default_machine_kexec_prepare;
+ ppc_md.machine_crash_shutdown = default_machine_crash_shutdown;
+
+ return 0;
+}
+__initcall(pseries_kexec_setup);
Index: powerpc/arch/powerpc/platforms/pseries/pseries.h
===================================================================
--- powerpc.orig/arch/powerpc/platforms/pseries/pseries.h
+++ powerpc/arch/powerpc/platforms/pseries/pseries.h
@@ -25,4 +25,12 @@ static inline smp_init_pseries_mpic(void
static inline smp_init_pseries_xics(void) { };
#endif
+#ifdef CONFIG_KEXEC
+extern void setup_kexec_cpu_down_xics(void);
+extern void setup_kexec_cpu_down_mpic(void);
+#else
+static inline setup_kexec_cpu_down_xics(void) { };
+static inline setup_kexec_cpu_down_mpic(void) { };
+#endif
+
#endif /* _PSERIES_PSERIES_H */
Index: powerpc/arch/powerpc/platforms/pseries/setup.c
===================================================================
--- powerpc.orig/arch/powerpc/platforms/pseries/setup.c
+++ powerpc/arch/powerpc/platforms/pseries/setup.c
@@ -55,7 +55,6 @@
#include <asm/dma.h>
#include <asm/machdep.h>
#include <asm/irq.h>
-#include <asm/kexec.h>
#include <asm/time.h>
#include <asm/nvram.h>
#include "xics.h"
@@ -219,42 +218,6 @@ static void pseries_lpar_enable_pmcs(voi
get_lppaca()->pmcregs_in_use = 1;
}
-#ifdef CONFIG_KEXEC
-static void pseries_kexec_cpu_down(int crash_shutdown, int secondary)
-{
- /* Don't risk a hypervisor call if we're crashing */
- if (firmware_has_feature(FW_FEATURE_SPLPAR) && !crash_shutdown) {
- unsigned long addr;
-
- addr = __pa(get_slb_shadow());
- if (unregister_slb_shadow(hard_smp_processor_id(), addr))
- printk("SLB shadow buffer deregistration of "
- "cpu %u (hw_cpu_id %d) failed\n",
- smp_processor_id(),
- hard_smp_processor_id());
-
- addr = __pa(get_lppaca());
- if (unregister_vpa(hard_smp_processor_id(), addr)) {
- printk("VPA deregistration of cpu %u (hw_cpu_id %d) "
- "failed\n", smp_processor_id(),
- hard_smp_processor_id());
- }
- }
-}
-
-static void pseries_kexec_cpu_down_mpic(int crash_shutdown, int secondary)
-{
- pseries_kexec_cpu_down(crash_shutdown, secondary);
- mpic_teardown_this_cpu(secondary);
-}
-
-static void pseries_kexec_cpu_down_xics(int crash_shutdown, int secondary)
-{
- pseries_kexec_cpu_down(crash_shutdown, secondary);
- xics_teardown_cpu(secondary);
-}
-#endif /* CONFIG_KEXEC */
-
static void __init pseries_discover_pic(void)
{
struct device_node *np;
@@ -267,16 +230,12 @@ static void __init pseries_discover_pic(
pSeries_mpic_node = of_node_get(np);
ppc_md.init_IRQ = pseries_mpic_init_IRQ;
ppc_md.get_irq = mpic_get_irq;
-#ifdef CONFIG_KEXEC
- ppc_md.kexec_cpu_down = pseries_kexec_cpu_down_mpic;
-#endif
+ setup_kexec_cpu_down_mpic();
smp_init_pseries_mpic();
return;
} else if (strstr(typep, "ppc-xicp")) {
ppc_md.init_IRQ = xics_init_IRQ;
-#ifdef CONFIG_KEXEC
- ppc_md.kexec_cpu_down = pseries_kexec_cpu_down_xics;
-#endif
+ setup_kexec_cpu_down_xics();
smp_init_pseries_xics();
return;
}
@@ -548,9 +507,4 @@ define_machine(pseries) {
.check_legacy_ioport = pSeries_check_legacy_ioport,
.system_reset_exception = pSeries_system_reset_exception,
.machine_check_exception = pSeries_machine_check_exception,
-#ifdef CONFIG_KEXEC
- .machine_kexec = default_machine_kexec,
- .machine_kexec_prepare = default_machine_kexec_prepare,
- .machine_crash_shutdown = default_machine_crash_shutdown,
-#endif
};
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 4/4] Move MPIC smp routines into mpic.c
2007-02-08 7:33 [PATCH 1/4] Consolidate pseries platform header files into pseries.h Michael Ellerman
2007-02-08 7:33 ` [PATCH 2/4] Cleanup pseries smp initialisation code Michael Ellerman
2007-02-08 7:33 ` [PATCH 3/4] Cleanup pseries kexec code Michael Ellerman
@ 2007-02-08 7:34 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2007-02-08 7:34 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev
Move a couple of MPIC smp routines into mpic.c, they're inside an SMP
block in mpic.c - so they're still only built for SMP.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/kernel/smp.c | 23 -----------------------
arch/powerpc/sysdev/mpic.c | 21 +++++++++++++++++++++
2 files changed, 21 insertions(+), 23 deletions(-)
Index: powerpc/arch/powerpc/kernel/smp.c
===================================================================
--- powerpc.orig/arch/powerpc/kernel/smp.c
+++ powerpc/arch/powerpc/kernel/smp.c
@@ -78,29 +78,6 @@ int smt_enabled_at_boot = 1;
static void (*crash_ipi_function_ptr)(struct pt_regs *) = NULL;
-#ifdef CONFIG_MPIC
-int __init smp_mpic_probe(void)
-{
- int nr_cpus;
-
- DBG("smp_mpic_probe()...\n");
-
- nr_cpus = cpus_weight(cpu_possible_map);
-
- DBG("nr_cpus: %d\n", nr_cpus);
-
- if (nr_cpus > 1)
- mpic_request_ipis();
-
- return nr_cpus;
-}
-
-void __devinit smp_mpic_setup_cpu(int cpu)
-{
- mpic_setup_this_cpu();
-}
-#endif /* CONFIG_MPIC */
-
#ifdef CONFIG_PPC64
void __devinit smp_generic_kick_cpu(int nr)
{
Index: powerpc/arch/powerpc/sysdev/mpic.c
===================================================================
--- powerpc.orig/arch/powerpc/sysdev/mpic.c
+++ powerpc/arch/powerpc/sysdev/mpic.c
@@ -1375,4 +1375,25 @@ void smp_mpic_message_pass(int target, i
break;
}
}
+
+int __init smp_mpic_probe(void)
+{
+ int nr_cpus;
+
+ DBG("smp_mpic_probe()...\n");
+
+ nr_cpus = cpus_weight(cpu_possible_map);
+
+ DBG("nr_cpus: %d\n", nr_cpus);
+
+ if (nr_cpus > 1)
+ mpic_request_ipis();
+
+ return nr_cpus;
+}
+
+void __devinit smp_mpic_setup_cpu(int cpu)
+{
+ mpic_setup_this_cpu();
+}
#endif /* CONFIG_SMP */
^ permalink raw reply [flat|nested] 4+ messages in thread