···6969 .startup_addr = omap5_secondary_startup,7070};71717272-static DEFINE_SPINLOCK(boot_lock);7373-7472void __iomem *omap4_get_scu_base(void)7573{7674 return cfg.scu_base;···171173 /* Enable ACR to allow for ICUALLU workaround */172174 omap5_secondary_harden_predictor();173175 }174174-175175- /*176176- * Synchronise with the boot thread.177177- */178178- spin_lock(&boot_lock);179179- spin_unlock(&boot_lock);180176}181177182178static int omap4_boot_secondary(unsigned int cpu, struct task_struct *idle)···178186 static struct clockdomain *cpu1_clkdm;179187 static bool booted;180188 static struct powerdomain *cpu1_pwrdm;181181-182182- /*183183- * Set synchronisation state between this boot processor184184- * and the secondary one185185- */186186- spin_lock(&boot_lock);187189188190 /*189191 * Update the AuxCoreBoot0 with boot state for secondary core.···251265 }252266253267 arch_send_wakeup_ipi_mask(cpumask_of(cpu));254254-255255- /*256256- * Now the secondary core is starting up let it run its257257- * calibrations, then wait for it to finish258258- */259259- spin_unlock(&boot_lock);260268261269 return 0;262270}
···11/*22- * linux/arch/arm/mach-realview/hotplug.c33- *42 * Copyright (C) 2002 ARM Ltd.53 * All Rights Reserved64 *75 * This program is free software; you can redistribute it and/or modify86 * it under the terms of the GNU General Public License version 2 as97 * published by the Free Software Foundation.88+ *99+ * This hotplug implementation is _specific_ to the situation found on1010+ * ARM development platforms where there is _no_ possibility of actually1111+ * taking a CPU offline, resetting it, or otherwise. Real platforms must1212+ * NOT copy this code.1013 */1114#include <linux/kernel.h>1215#include <linux/errno.h>1316#include <linux/smp.h>14171515-#include <asm/cp15.h>1618#include <asm/smp_plat.h>1919+#include <asm/cp15.h>17201818-static inline void cpu_enter_lowpower(void)2121+#include <plat/platsmp.h>2222+2323+static inline void versatile_immitation_enter_lowpower(unsigned int actrl_mask)1924{2025 unsigned int v;21262227 asm volatile(2323- " mcr p15, 0, %1, c7, c5, 0\n"2828+ "mcr p15, 0, %1, c7, c5, 0\n"2429 " mcr p15, 0, %1, c7, c10, 4\n"2530 /*2631 * Turn off coherency2732 */2833 " mrc p15, 0, %0, c1, c0, 1\n"2929- " bic %0, %0, #0x20\n"3434+ " bic %0, %0, %3\n"3035 " mcr p15, 0, %0, c1, c0, 1\n"3136 " mrc p15, 0, %0, c1, c0, 0\n"3237 " bic %0, %0, %2\n"3338 " mcr p15, 0, %0, c1, c0, 0\n"3439 : "=&r" (v)3535- : "r" (0), "Ir" (CR_C)4040+ : "r" (0), "Ir" (CR_C), "Ir" (actrl_mask)3641 : "cc");3742}38433939-static inline void cpu_leave_lowpower(void)4444+static inline void versatile_immitation_leave_lowpower(unsigned int actrl_mask)4045{4146 unsigned int v;42474343- asm volatile( "mrc p15, 0, %0, c1, c0, 0\n"4848+ asm volatile(4949+ "mrc p15, 0, %0, c1, c0, 0\n"4450 " orr %0, %0, %1\n"4551 " mcr p15, 0, %0, c1, c0, 0\n"4652 " mrc p15, 0, %0, c1, c0, 1\n"4747- " orr %0, %0, #0x20\n"5353+ " orr %0, %0, %2\n"4854 " mcr p15, 0, %0, c1, c0, 1\n"4955 : "=&r" (v)5050- : "Ir" (CR_C)5656+ : "Ir" (CR_C), "Ir" (actrl_mask)5157 : "cc");5258}53595454-static inline void platform_do_lowpower(unsigned int cpu, int *spurious)6060+static inline void versatile_immitation_do_lowpower(unsigned int cpu, int *spurious)5561{5662 /*5763 * there is no power-control hardware on this platform, so all5864 * we can do is put the core into WFI; this is safe as the calling5959- * code will have already disabled interrupts6565+ * code will have already disabled interrupts.6666+ *6767+ * This code should not be used outside Versatile platforms.6068 */6169 for (;;) {6262- /*6363- * here's the WFI6464- */6565- asm(".word 0xe320f003\n"6666- :6767- :6868- : "memory", "cc");7070+ wfi();69717070- if (pen_release == cpu_logical_map(cpu)) {7272+ if (versatile_cpu_release == cpu_logical_map(cpu)) {7173 /*7274 * OK, proper wakeup, we're done7375 */···8886}89879088/*9191- * platform-specific code to shutdown a CPU9292- *9393- * Called with IRQs disabled8989+ * platform-specific code to shutdown a CPU.9090+ * This code supports immitation-style CPU hotplug for Versatile/Realview/9191+ * Versatile Express platforms that are unable to do real CPU hotplug.9492 */9595-void realview_cpu_die(unsigned int cpu)9393+void versatile_immitation_cpu_die(unsigned int cpu, unsigned int actrl_mask)9694{9795 int spurious = 0;98969999- /*100100- * we're ready for shutdown now, so do it101101- */102102- cpu_enter_lowpower();103103- platform_do_lowpower(cpu, &spurious);104104-105105- /*106106- * bring this CPU back into the world of cache107107- * coherency, and then restore interrupts108108- */109109- cpu_leave_lowpower();9797+ versatile_immitation_enter_lowpower(actrl_mask);9898+ versatile_immitation_do_lowpower(cpu, &spurious);9999+ versatile_immitation_leave_lowpower(actrl_mask);110100111101 if (spurious)112102 pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious);
···11bool vexpress_smp_init_ops(void);2233extern const struct smp_operations vexpress_smp_dt_ops;44-55-extern void vexpress_cpu_die(unsigned int cpu);
-108
arch/arm/mach-vexpress/hotplug.c
···11-/*22- * linux/arch/arm/mach-realview/hotplug.c33- *44- * Copyright (C) 2002 ARM Ltd.55- * All Rights Reserved66- *77- * This program is free software; you can redistribute it and/or modify88- * it under the terms of the GNU General Public License version 2 as99- * published by the Free Software Foundation.1010- */1111-#include <linux/kernel.h>1212-#include <linux/errno.h>1313-#include <linux/smp.h>1414-1515-#include <asm/smp_plat.h>1616-#include <asm/cp15.h>1717-1818-#include "core.h"1919-2020-static inline void cpu_enter_lowpower(void)2121-{2222- unsigned int v;2323-2424- asm volatile(2525- "mcr p15, 0, %1, c7, c5, 0\n"2626- " mcr p15, 0, %1, c7, c10, 4\n"2727- /*2828- * Turn off coherency2929- */3030- " mrc p15, 0, %0, c1, c0, 1\n"3131- " bic %0, %0, %3\n"3232- " mcr p15, 0, %0, c1, c0, 1\n"3333- " mrc p15, 0, %0, c1, c0, 0\n"3434- " bic %0, %0, %2\n"3535- " mcr p15, 0, %0, c1, c0, 0\n"3636- : "=&r" (v)3737- : "r" (0), "Ir" (CR_C), "Ir" (0x40)3838- : "cc");3939-}4040-4141-static inline void cpu_leave_lowpower(void)4242-{4343- unsigned int v;4444-4545- asm volatile(4646- "mrc p15, 0, %0, c1, c0, 0\n"4747- " orr %0, %0, %1\n"4848- " mcr p15, 0, %0, c1, c0, 0\n"4949- " mrc p15, 0, %0, c1, c0, 1\n"5050- " orr %0, %0, %2\n"5151- " mcr p15, 0, %0, c1, c0, 1\n"5252- : "=&r" (v)5353- : "Ir" (CR_C), "Ir" (0x40)5454- : "cc");5555-}5656-5757-static inline void platform_do_lowpower(unsigned int cpu, int *spurious)5858-{5959- /*6060- * there is no power-control hardware on this platform, so all6161- * we can do is put the core into WFI; this is safe as the calling6262- * code will have already disabled interrupts6363- */6464- for (;;) {6565- wfi();6666-6767- if (pen_release == cpu_logical_map(cpu)) {6868- /*6969- * OK, proper wakeup, we're done7070- */7171- break;7272- }7373-7474- /*7575- * Getting here, means that we have come out of WFI without7676- * having been woken up - this shouldn't happen7777- *7878- * Just note it happening - when we're woken, we can report7979- * its occurrence.8080- */8181- (*spurious)++;8282- }8383-}8484-8585-/*8686- * platform-specific code to shutdown a CPU8787- *8888- * Called with IRQs disabled8989- */9090-void vexpress_cpu_die(unsigned int cpu)9191-{9292- int spurious = 0;9393-9494- /*9595- * we're ready for shutdown now, so do it9696- */9797- cpu_enter_lowpower();9898- platform_do_lowpower(cpu, &spurious);9999-100100- /*101101- * bring this CPU back into the world of cache102102- * coherency, and then restore interrupts103103- */104104- cpu_leave_lowpower();105105-106106- if (spurious)107107- pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious);108108-}
···88 * it under the terms of the GNU General Public License version 2 as99 * published by the Free Software Foundation.1010 */1111+extern volatile int versatile_cpu_release;11121213extern void versatile_secondary_startup(void);1314extern void versatile_secondary_init(unsigned int cpu);1415extern int versatile_boot_secondary(unsigned int cpu, struct task_struct *idle);1616+void versatile_immitation_cpu_die(unsigned int cpu, unsigned int actrl_mask);
+33-14
arch/arm/plat-versatile/platsmp.c
···77 * This program is free software; you can redistribute it and/or modify88 * it under the terms of the GNU General Public License version 2 as99 * published by the Free Software Foundation.1010+ *1111+ * This code is specific to the hardware found on ARM Realview and1212+ * Versatile Express platforms where the CPUs are unable to be individually1313+ * woken, and where there is no way to hot-unplug CPUs. Real platforms1414+ * should not copy this code.1015 */1116#include <linux/init.h>1217#include <linux/errno.h>···2621#include <plat/platsmp.h>27222823/*2929- * Write pen_release in a way that is guaranteed to be visible to all3030- * observers, irrespective of whether they're taking part in coherency2424+ * versatile_cpu_release controls the release of CPUs from the holding2525+ * pen in headsmp.S, which exists because we are not always able to2626+ * control the release of individual CPUs from the board firmware.2727+ * Production platforms do not need this.2828+ */2929+volatile int versatile_cpu_release = -1;3030+3131+/*3232+ * Write versatile_cpu_release in a way that is guaranteed to be visible to3333+ * all observers, irrespective of whether they're taking part in coherency3134 * or not. This is necessary for the hotplug code to work reliably.3235 */3333-static void write_pen_release(int val)3636+static void versatile_write_cpu_release(int val)3437{3535- pen_release = val;3838+ versatile_cpu_release = val;3639 smp_wmb();3737- sync_cache_w(&pen_release);4040+ sync_cache_w(&versatile_cpu_release);3841}39424040-static DEFINE_SPINLOCK(boot_lock);4343+/*4444+ * versatile_lock exists to avoid running the loops_per_jiffy delay loop4545+ * calibrations on the secondary CPU while the requesting CPU is using4646+ * the limited-bandwidth bus - which affects the calibration value.4747+ * Production platforms do not need this.4848+ */4949+static DEFINE_RAW_SPINLOCK(versatile_lock);41504251void versatile_secondary_init(unsigned int cpu)4352{···5940 * let the primary processor know we're out of the6041 * pen, then head off into the C entry point6142 */6262- write_pen_release(-1);4343+ versatile_write_cpu_release(-1);63446445 /*6546 * Synchronise with the boot thread.6647 */6767- spin_lock(&boot_lock);6868- spin_unlock(&boot_lock);4848+ raw_spin_lock(&versatile_lock);4949+ raw_spin_unlock(&versatile_lock);6950}70517152int versatile_boot_secondary(unsigned int cpu, struct task_struct *idle)···7657 * Set synchronisation state between this boot processor7758 * and the secondary one7859 */7979- spin_lock(&boot_lock);6060+ raw_spin_lock(&versatile_lock);80618162 /*8263 * This is really belt and braces; we hold unintended secondary···8465 * since we haven't sent them a soft interrupt, they shouldn't8566 * be there.8667 */8787- write_pen_release(cpu_logical_map(cpu));6868+ versatile_write_cpu_release(cpu_logical_map(cpu));88698970 /*9071 * Send the secondary CPU a soft interrupt, thereby causing···9677 timeout = jiffies + (1 * HZ);9778 while (time_before(jiffies, timeout)) {9879 smp_rmb();9999- if (pen_release == -1)8080+ if (versatile_cpu_release == -1)10081 break;1018210283 udelay(10);···10687 * now the secondary core is starting up let it run its10788 * calibrations, then wait for it to finish10889 */109109- spin_unlock(&boot_lock);9090+ raw_spin_unlock(&versatile_lock);11091111111- return pen_release != -1 ? -ENOSYS : 0;9292+ return versatile_cpu_release != -1 ? -ENOSYS : 0;11293}