1 From d9a056919c4fa46cd9e094f969032bd4e15bffef Mon Sep 17 00:00:00 2001
2 From: Ralf Baechle <ralf@linux-mips.org>
3 Date: Sat, 28 May 2011 15:27:59 +0100
4 Subject: [PATCH] MIPS: Malta: Fix crash SMP kernel on non-CMP systems.
6 Since 6be63bbbdab66b9185dc6f67c8b1bacb6f37f946 (lmo) rsp.
7 af3a1f6f4813907e143f87030cde67a9971db533 (kernel.org) the Malta code does
8 no longer probe for presence of GCMP if CMP is not configured. This means
9 that the variable gcmp_present well be left at its default value of -1
10 which normally is meant to indicate that GCMP has not yet been mmapped.
11 This non-zero value is now interpreted as GCMP being present resulting
12 in a write attempt to a GCMP register resulting in a crash.
14 Reported and a build fix on top of my fix by Rob Landley <rob@landley.net>.
16 Reported-by: Rob Landley <rob@landley.net>
17 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
18 Patchwork: https://patchwork.linux-mips.org/patch/2413/
19 (cherry picked from commit c3ddf592134eaab38d051b2e7b23e81201ae423a)
21 arch/mips/include/asm/smp-ops.h | 41 +++++++++++++++++++++++++++--
22 arch/mips/mipssim/sim_setup.c | 17 ++++++------
23 arch/mips/mti-malta/malta-init.c | 14 +++++-----
24 arch/mips/pmc-sierra/msp71xx/msp_setup.c | 8 ++---
25 4 files changed, 56 insertions(+), 24 deletions(-)
27 diff --git a/arch/mips/include/asm/smp-ops.h b/arch/mips/include/asm/smp-ops.h
28 index 9e09af3..48b03ff 100644
29 --- a/arch/mips/include/asm/smp-ops.h
30 +++ b/arch/mips/include/asm/smp-ops.h
31 @@ -56,8 +56,43 @@ static inline void register_smp_ops(struct plat_smp_ops *ops)
33 #endif /* !CONFIG_SMP */
35 -extern struct plat_smp_ops up_smp_ops;
36 -extern struct plat_smp_ops cmp_smp_ops;
37 -extern struct plat_smp_ops vsmp_smp_ops;
38 +static inline int register_up_smp_ops(void)
41 + extern struct plat_smp_ops up_smp_ops;
43 + register_smp_ops(&up_smp_ops);
51 +static inline int register_cmp_smp_ops(void)
53 +#ifdef CONFIG_MIPS_CMP
54 + extern struct plat_smp_ops cmp_smp_ops;
56 + register_smp_ops(&cmp_smp_ops);
64 +static inline int register_vsmp_smp_ops(void)
66 +#ifdef CONFIG_MIPS_MT_SMP
67 + extern struct plat_smp_ops vsmp_smp_ops;
69 + register_smp_ops(&vsmp_smp_ops);
77 #endif /* __ASM_SMP_OPS_H */
78 diff --git a/arch/mips/mipssim/sim_setup.c b/arch/mips/mipssim/sim_setup.c
79 index 55f22a3..1970069 100644
80 --- a/arch/mips/mipssim/sim_setup.c
81 +++ b/arch/mips/mipssim/sim_setup.c
82 @@ -59,18 +59,17 @@ void __init prom_init(void)
86 -#ifdef CONFIG_MIPS_MT_SMP
88 - register_smp_ops(&vsmp_smp_ops);
90 - register_smp_ops(&up_smp_ops);
92 + if (cpu_has_mipsmt) {
93 + if (!register_vsmp_smp_ops())
96 #ifdef CONFIG_MIPS_MT_SMTC
98 register_smp_ops(&ssmtc_smp_ops);
100 - register_smp_ops(&up_smp_ops);
105 + register_up_smp_ops();
108 static void __init serial_init(void)
109 diff --git a/arch/mips/mti-malta/malta-init.c b/arch/mips/mti-malta/malta-init.c
110 index 31180c3..4b988b9 100644
111 --- a/arch/mips/mti-malta/malta-init.c
112 +++ b/arch/mips/mti-malta/malta-init.c
115 #include <asm/system.h>
116 #include <asm/cacheflush.h>
117 +#include <asm/smp-ops.h>
118 #include <asm/traps.h>
120 #include <asm/gcmpregs.h>
121 @@ -358,15 +359,14 @@ void __init prom_init(void)
122 #ifdef CONFIG_SERIAL_8250_CONSOLE
125 -#ifdef CONFIG_MIPS_CMP
126 /* Early detection of CMP support */
127 if (gcmp_probe(GCMP_BASE_ADDR, GCMP_ADDRSPACE_SZ))
128 - register_smp_ops(&cmp_smp_ops);
131 -#ifdef CONFIG_MIPS_MT_SMP
132 - register_smp_ops(&vsmp_smp_ops);
134 + if (!register_cmp_smp_ops())
137 + if (!register_vsmp_smp_ops())
140 #ifdef CONFIG_MIPS_MT_SMTC
141 register_smp_ops(&msmtc_smp_ops);
143 diff --git a/arch/mips/pmc-sierra/msp71xx/msp_setup.c b/arch/mips/pmc-sierra/msp71xx/msp_setup.c
144 index 2413ea6..0abfbe0 100644
145 --- a/arch/mips/pmc-sierra/msp71xx/msp_setup.c
146 +++ b/arch/mips/pmc-sierra/msp71xx/msp_setup.c
147 @@ -228,13 +228,11 @@ void __init prom_init(void)
151 -#ifdef CONFIG_MIPS_MT_SMP
152 - register_smp_ops(&vsmp_smp_ops);
155 + if (register_vsmp_smp_ops()) {
156 #ifdef CONFIG_MIPS_MT_SMTC
157 - register_smp_ops(&msp_smtc_smp_ops);
158 + register_smp_ops(&msp_smtc_smp_ops);
162 #ifdef CONFIG_PMCTWILED