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 --- a/arch/mips/include/asm/smp-ops.h
28 +++ b/arch/mips/include/asm/smp-ops.h
29 @@ -56,8 +56,43 @@ static inline void register_smp_ops(stru
31 #endif /* !CONFIG_SMP */
33 -extern struct plat_smp_ops up_smp_ops;
34 -extern struct plat_smp_ops cmp_smp_ops;
35 -extern struct plat_smp_ops vsmp_smp_ops;
36 +static inline int register_up_smp_ops(void)
39 + extern struct plat_smp_ops up_smp_ops;
41 + register_smp_ops(&up_smp_ops);
49 +static inline int register_cmp_smp_ops(void)
51 +#ifdef CONFIG_MIPS_CMP
52 + extern struct plat_smp_ops cmp_smp_ops;
54 + register_smp_ops(&cmp_smp_ops);
62 +static inline int register_vsmp_smp_ops(void)
64 +#ifdef CONFIG_MIPS_MT_SMP
65 + extern struct plat_smp_ops vsmp_smp_ops;
67 + register_smp_ops(&vsmp_smp_ops);
75 #endif /* __ASM_SMP_OPS_H */
76 --- a/arch/mips/mipssim/sim_setup.c
77 +++ b/arch/mips/mipssim/sim_setup.c
78 @@ -59,18 +59,17 @@ void __init prom_init(void)
82 -#ifdef CONFIG_MIPS_MT_SMP
84 - register_smp_ops(&vsmp_smp_ops);
86 - register_smp_ops(&up_smp_ops);
88 + if (cpu_has_mipsmt) {
89 + if (!register_vsmp_smp_ops())
92 #ifdef CONFIG_MIPS_MT_SMTC
94 register_smp_ops(&ssmtc_smp_ops);
96 - register_smp_ops(&up_smp_ops);
101 + register_up_smp_ops();
104 static void __init serial_init(void)
105 --- a/arch/mips/mti-malta/malta-init.c
106 +++ b/arch/mips/mti-malta/malta-init.c
109 #include <asm/system.h>
110 #include <asm/cacheflush.h>
111 +#include <asm/smp-ops.h>
112 #include <asm/traps.h>
114 #include <asm/gcmpregs.h>
115 @@ -358,15 +359,14 @@ void __init prom_init(void)
116 #ifdef CONFIG_SERIAL_8250_CONSOLE
119 -#ifdef CONFIG_MIPS_CMP
120 /* Early detection of CMP support */
121 if (gcmp_probe(GCMP_BASE_ADDR, GCMP_ADDRSPACE_SZ))
122 - register_smp_ops(&cmp_smp_ops);
125 -#ifdef CONFIG_MIPS_MT_SMP
126 - register_smp_ops(&vsmp_smp_ops);
128 + if (!register_cmp_smp_ops())
131 + if (!register_vsmp_smp_ops())
134 #ifdef CONFIG_MIPS_MT_SMTC
135 register_smp_ops(&msmtc_smp_ops);
137 --- a/arch/mips/pmc-sierra/msp71xx/msp_setup.c
138 +++ b/arch/mips/pmc-sierra/msp71xx/msp_setup.c
139 @@ -228,13 +228,11 @@ void __init prom_init(void)
143 -#ifdef CONFIG_MIPS_MT_SMP
144 - register_smp_ops(&vsmp_smp_ops);
147 + if (register_vsmp_smp_ops()) {
148 #ifdef CONFIG_MIPS_MT_SMTC
149 - register_smp_ops(&msp_smtc_smp_ops);
150 + register_smp_ops(&msp_smtc_smp_ops);
154 #ifdef CONFIG_PMCTWILED