aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2017-03-22 14:01:48 -0400
committerTony Lindgren <tony@atomide.com>2017-03-27 13:10:42 -0400
commit351b7c490700747d1dba1b0a10fbfe3448d11c35 (patch)
tree7f09cc2e3a85b88da50a3f83d9a53a71f0cc41ce
parent9bcf53f34a2c1cebc45cc12e273dcd5f51fbc099 (diff)
ARM: omap2+: Revert omap-smp.c changes resetting CPU1 during boot
Commit 3251885285e1 ("ARM: OMAP4+: Reset CPU1 properly for kexec") started unconditionally resetting CPU1 because of a kexec boot issue I was seeing earlier on omap4 when doing kexec boot between two different kernel versions. This caused issues on some systems. We should only reset CPU1 as a last resort option, and try to avoid it where possible. Doing an unconditional CPU1 reset causes issues for example when booting a bootloader configured secure OS running on CPU1 as reported by Andrew F. Davis <afd@ti.com>. We can't completely remove the reset of CPU1 as it would break kexec booting from older kernels. But we can limit the CPU1 reset to cases where CPU1 is wrongly parked within the memory area used by the booting kernel. Then later on we can add support for parking CPU1 for kexec out of the SDRAM back to bootrom. So let's first fix the regression reported by Andrew by making CPU1 reset conditional. To do this, we need to: 1. Save configured AUX_CORE_BOOT_1 for later 2. Modify AUX_CORE_BOOT_0 reading code to for HS SoCs to return the whole register instead of the CPU mask 3. Check if CPU1 is wrongly parked into the booting kernel by the previous kernel and reset if needed Fixes: 3251885285e1 ("ARM: OMAP4+: Reset CPU1 properly for kexec") Reported-by: Andrew F. Davis <afd@ti.com> Cc: Andrew F. Davis <afd@ti.com> Cc: Keerthy <j-keerthy@ti.com> Cc: Russell King <rmk+kernel@armlinux.org.uk> Cc: Santosh Shilimkar <ssantosh@kernel.org> Cc: Tero Kristo <t-kristo@ti.com> Tested-by: Keerthy <j-keerthy@ti.com> Tested-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--arch/arm/mach-omap2/common.h1
-rw-r--r--arch/arm/mach-omap2/omap-hotplug.c2
-rw-r--r--arch/arm/mach-omap2/omap-mpuss-lowpower.c22
-rw-r--r--arch/arm/mach-omap2/omap-smc.S1
-rw-r--r--arch/arm/mach-omap2/omap-smp.c90
5 files changed, 96 insertions, 20 deletions
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index c4f2ace91ea2..3089d3bfa19b 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -270,6 +270,7 @@ extern const struct smp_operations omap4_smp_ops;
270extern int omap4_mpuss_init(void); 270extern int omap4_mpuss_init(void);
271extern int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state); 271extern int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state);
272extern int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state); 272extern int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state);
273extern u32 omap4_get_cpu1_ns_pa_addr(void);
273#else 274#else
274static inline int omap4_enter_lowpower(unsigned int cpu, 275static inline int omap4_enter_lowpower(unsigned int cpu,
275 unsigned int power_state) 276 unsigned int power_state)
diff --git a/arch/arm/mach-omap2/omap-hotplug.c b/arch/arm/mach-omap2/omap-hotplug.c
index d3fb5661bb5d..433db6d0b073 100644
--- a/arch/arm/mach-omap2/omap-hotplug.c
+++ b/arch/arm/mach-omap2/omap-hotplug.c
@@ -50,7 +50,7 @@ void omap4_cpu_die(unsigned int cpu)
50 omap4_hotplug_cpu(cpu, PWRDM_POWER_OFF); 50 omap4_hotplug_cpu(cpu, PWRDM_POWER_OFF);
51 51
52 if (omap_secure_apis_support()) 52 if (omap_secure_apis_support())
53 boot_cpu = omap_read_auxcoreboot0(); 53 boot_cpu = omap_read_auxcoreboot0() >> 9;
54 else 54 else
55 boot_cpu = 55 boot_cpu =
56 readl_relaxed(base + OMAP_AUX_CORE_BOOT_0) >> 5; 56 readl_relaxed(base + OMAP_AUX_CORE_BOOT_0) >> 5;
diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
index 113ab2dd2ee9..03ec6d307c82 100644
--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
@@ -64,6 +64,7 @@
64#include "prm-regbits-44xx.h" 64#include "prm-regbits-44xx.h"
65 65
66static void __iomem *sar_base; 66static void __iomem *sar_base;
67static u32 old_cpu1_ns_pa_addr;
67 68
68#if defined(CONFIG_PM) && defined(CONFIG_SMP) 69#if defined(CONFIG_PM) && defined(CONFIG_SMP)
69 70
@@ -212,6 +213,11 @@ static void __init save_l2x0_context(void)
212{} 213{}
213#endif 214#endif
214 215
216u32 omap4_get_cpu1_ns_pa_addr(void)
217{
218 return old_cpu1_ns_pa_addr;
219}
220
215/** 221/**
216 * omap4_enter_lowpower: OMAP4 MPUSS Low Power Entry Function 222 * omap4_enter_lowpower: OMAP4 MPUSS Low Power Entry Function
217 * The purpose of this function is to manage low power programming 223 * The purpose of this function is to manage low power programming
@@ -460,22 +466,30 @@ int __init omap4_mpuss_init(void)
460void __init omap4_mpuss_early_init(void) 466void __init omap4_mpuss_early_init(void)
461{ 467{
462 unsigned long startup_pa; 468 unsigned long startup_pa;
469 void __iomem *ns_pa_addr;
463 470
464 if (!(cpu_is_omap44xx() || soc_is_omap54xx())) 471 if (!(soc_is_omap44xx() || soc_is_omap54xx()))
465 return; 472 return;
466 473
467 sar_base = omap4_get_sar_ram_base(); 474 sar_base = omap4_get_sar_ram_base();
468 475
469 if (cpu_is_omap443x()) 476 /* Save old NS_PA_ADDR for validity checks later on */
477 if (soc_is_omap44xx())
478 ns_pa_addr = sar_base + CPU1_WAKEUP_NS_PA_ADDR_OFFSET;
479 else
480 ns_pa_addr = sar_base + OMAP5_CPU1_WAKEUP_NS_PA_ADDR_OFFSET;
481 old_cpu1_ns_pa_addr = readl_relaxed(ns_pa_addr);
482
483 if (soc_is_omap443x())
470 startup_pa = __pa_symbol(omap4_secondary_startup); 484 startup_pa = __pa_symbol(omap4_secondary_startup);
471 else if (cpu_is_omap446x()) 485 else if (soc_is_omap446x())
472 startup_pa = __pa_symbol(omap4460_secondary_startup); 486 startup_pa = __pa_symbol(omap4460_secondary_startup);
473 else if ((__boot_cpu_mode & MODE_MASK) == HYP_MODE) 487 else if ((__boot_cpu_mode & MODE_MASK) == HYP_MODE)
474 startup_pa = __pa_symbol(omap5_secondary_hyp_startup); 488 startup_pa = __pa_symbol(omap5_secondary_hyp_startup);
475 else 489 else
476 startup_pa = __pa_symbol(omap5_secondary_startup); 490 startup_pa = __pa_symbol(omap5_secondary_startup);
477 491
478 if (cpu_is_omap44xx()) 492 if (soc_is_omap44xx())
479 writel_relaxed(startup_pa, sar_base + 493 writel_relaxed(startup_pa, sar_base +
480 CPU1_WAKEUP_NS_PA_ADDR_OFFSET); 494 CPU1_WAKEUP_NS_PA_ADDR_OFFSET);
481 else 495 else
diff --git a/arch/arm/mach-omap2/omap-smc.S b/arch/arm/mach-omap2/omap-smc.S
index fd90125bffc7..72506e6cf9e7 100644
--- a/arch/arm/mach-omap2/omap-smc.S
+++ b/arch/arm/mach-omap2/omap-smc.S
@@ -94,6 +94,5 @@ ENTRY(omap_read_auxcoreboot0)
94 ldr r12, =0x103 94 ldr r12, =0x103
95 dsb 95 dsb
96 smc #0 96 smc #0
97 mov r0, r0, lsr #9
98 ldmfd sp!, {r2-r12, pc} 97 ldmfd sp!, {r2-r12, pc}
99ENDPROC(omap_read_auxcoreboot0) 98ENDPROC(omap_read_auxcoreboot0)
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index 003353b0b794..3faf454ba487 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -21,6 +21,7 @@
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/irqchip/arm-gic.h> 22#include <linux/irqchip/arm-gic.h>
23 23
24#include <asm/sections.h>
24#include <asm/smp_scu.h> 25#include <asm/smp_scu.h>
25#include <asm/virt.h> 26#include <asm/virt.h>
26 27
@@ -40,10 +41,14 @@
40 41
41#define OMAP5_CORE_COUNT 0x2 42#define OMAP5_CORE_COUNT 0x2
42 43
44#define AUX_CORE_BOOT0_GP_RELEASE 0x020
45#define AUX_CORE_BOOT0_HS_RELEASE 0x200
46
43struct omap_smp_config { 47struct omap_smp_config {
44 unsigned long cpu1_rstctrl_pa; 48 unsigned long cpu1_rstctrl_pa;
45 void __iomem *cpu1_rstctrl_va; 49 void __iomem *cpu1_rstctrl_va;
46 void __iomem *scu_base; 50 void __iomem *scu_base;
51 void __iomem *wakeupgen_base;
47 void *startup_addr; 52 void *startup_addr;
48}; 53};
49 54
@@ -140,7 +145,6 @@ static int omap4_boot_secondary(unsigned int cpu, struct task_struct *idle)
140 static struct clockdomain *cpu1_clkdm; 145 static struct clockdomain *cpu1_clkdm;
141 static bool booted; 146 static bool booted;
142 static struct powerdomain *cpu1_pwrdm; 147 static struct powerdomain *cpu1_pwrdm;
143 void __iomem *base = omap_get_wakeupgen_base();
144 148
145 /* 149 /*
146 * Set synchronisation state between this boot processor 150 * Set synchronisation state between this boot processor
@@ -155,9 +159,11 @@ static int omap4_boot_secondary(unsigned int cpu, struct task_struct *idle)
155 * A barrier is added to ensure that write buffer is drained 159 * A barrier is added to ensure that write buffer is drained
156 */ 160 */
157 if (omap_secure_apis_support()) 161 if (omap_secure_apis_support())
158 omap_modify_auxcoreboot0(0x200, 0xfffffdff); 162 omap_modify_auxcoreboot0(AUX_CORE_BOOT0_HS_RELEASE,
163 0xfffffdff);
159 else 164 else
160 writel_relaxed(0x20, base + OMAP_AUX_CORE_BOOT_0); 165 writel_relaxed(AUX_CORE_BOOT0_GP_RELEASE,
166 cfg.wakeupgen_base + OMAP_AUX_CORE_BOOT_0);
161 167
162 if (!cpu1_clkdm && !cpu1_pwrdm) { 168 if (!cpu1_clkdm && !cpu1_pwrdm) {
163 cpu1_clkdm = clkdm_lookup("mpu1_clkdm"); 169 cpu1_clkdm = clkdm_lookup("mpu1_clkdm");
@@ -261,9 +267,72 @@ static void __init omap4_smp_init_cpus(void)
261 set_cpu_possible(i, true); 267 set_cpu_possible(i, true);
262} 268}
263 269
270/*
271 * For now, just make sure the start-up address is not within the booting
272 * kernel space as that means we just overwrote whatever secondary_startup()
273 * code there was.
274 */
275static bool __init omap4_smp_cpu1_startup_valid(unsigned long addr)
276{
277 if ((addr >= __pa(PAGE_OFFSET)) && (addr <= __pa(__bss_start)))
278 return false;
279
280 return true;
281}
282
283/*
284 * We may need to reset CPU1 before configuring, otherwise kexec boot can end
285 * up trying to use old kernel startup address or suspend-resume will
286 * occasionally fail to bring up CPU1 on 4430 if CPU1 fails to enter deeper
287 * idle states.
288 */
289static void __init omap4_smp_maybe_reset_cpu1(struct omap_smp_config *c)
290{
291 unsigned long cpu1_startup_pa, cpu1_ns_pa_addr;
292 bool needs_reset = false;
293 u32 released;
294
295 if (omap_secure_apis_support())
296 released = omap_read_auxcoreboot0() & AUX_CORE_BOOT0_HS_RELEASE;
297 else
298 released = readl_relaxed(cfg.wakeupgen_base +
299 OMAP_AUX_CORE_BOOT_0) &
300 AUX_CORE_BOOT0_GP_RELEASE;
301 if (released) {
302 pr_warn("smp: CPU1 not parked?\n");
303
304 return;
305 }
306
307 cpu1_startup_pa = readl_relaxed(cfg.wakeupgen_base +
308 OMAP_AUX_CORE_BOOT_1);
309 cpu1_ns_pa_addr = omap4_get_cpu1_ns_pa_addr();
310
311 /* Did the configured secondary_startup() get overwritten? */
312 if (!omap4_smp_cpu1_startup_valid(cpu1_startup_pa))
313 needs_reset = true;
314
315 /*
316 * If omap4 or 5 has NS_PA_ADDR configured, CPU1 may be in a
317 * deeper idle state in WFI and will wake to an invalid address.
318 */
319 if ((soc_is_omap44xx() || soc_is_omap54xx()) &&
320 !omap4_smp_cpu1_startup_valid(cpu1_ns_pa_addr))
321 needs_reset = true;
322
323 if (!needs_reset || !c->cpu1_rstctrl_va)
324 return;
325
326 pr_info("smp: CPU1 parked within kernel, needs reset (0x%lx 0x%lx)\n",
327 cpu1_startup_pa, cpu1_ns_pa_addr);
328
329 writel_relaxed(1, c->cpu1_rstctrl_va);
330 readl_relaxed(c->cpu1_rstctrl_va);
331 writel_relaxed(0, c->cpu1_rstctrl_va);
332}
333
264static void __init omap4_smp_prepare_cpus(unsigned int max_cpus) 334static void __init omap4_smp_prepare_cpus(unsigned int max_cpus)
265{ 335{
266 void __iomem *base = omap_get_wakeupgen_base();
267 const struct omap_smp_config *c = NULL; 336 const struct omap_smp_config *c = NULL;
268 337
269 if (soc_is_omap443x()) 338 if (soc_is_omap443x())
@@ -281,6 +350,7 @@ static void __init omap4_smp_prepare_cpus(unsigned int max_cpus)
281 /* Must preserve cfg.scu_base set earlier */ 350 /* Must preserve cfg.scu_base set earlier */
282 cfg.cpu1_rstctrl_pa = c->cpu1_rstctrl_pa; 351 cfg.cpu1_rstctrl_pa = c->cpu1_rstctrl_pa;
283 cfg.startup_addr = c->startup_addr; 352 cfg.startup_addr = c->startup_addr;
353 cfg.wakeupgen_base = omap_get_wakeupgen_base();
284 354
285 if (soc_is_dra74x() || soc_is_omap54xx()) { 355 if (soc_is_dra74x() || soc_is_omap54xx()) {
286 if ((__boot_cpu_mode & MODE_MASK) == HYP_MODE) 356 if ((__boot_cpu_mode & MODE_MASK) == HYP_MODE)
@@ -299,15 +369,7 @@ static void __init omap4_smp_prepare_cpus(unsigned int max_cpus)
299 if (cfg.scu_base) 369 if (cfg.scu_base)
300 scu_enable(cfg.scu_base); 370 scu_enable(cfg.scu_base);
301 371
302 /* 372 omap4_smp_maybe_reset_cpu1(&cfg);
303 * Reset CPU1 before configuring, otherwise kexec will
304 * end up trying to use old kernel startup address.
305 */
306 if (cfg.cpu1_rstctrl_va) {
307 writel_relaxed(1, cfg.cpu1_rstctrl_va);
308 readl_relaxed(cfg.cpu1_rstctrl_va);
309 writel_relaxed(0, cfg.cpu1_rstctrl_va);
310 }
311 373
312 /* 374 /*
313 * Write the address of secondary startup routine into the 375 * Write the address of secondary startup routine into the
@@ -319,7 +381,7 @@ static void __init omap4_smp_prepare_cpus(unsigned int max_cpus)
319 omap_auxcoreboot_addr(__pa_symbol(cfg.startup_addr)); 381 omap_auxcoreboot_addr(__pa_symbol(cfg.startup_addr));
320 else 382 else
321 writel_relaxed(__pa_symbol(cfg.startup_addr), 383 writel_relaxed(__pa_symbol(cfg.startup_addr),
322 base + OMAP_AUX_CORE_BOOT_1); 384 cfg.wakeupgen_base + OMAP_AUX_CORE_BOOT_1);
323} 385}
324 386
325const struct smp_operations omap4_smp_ops __initconst = { 387const struct smp_operations omap4_smp_ops __initconst = {