| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * linux/arch/arm/plat-versatile/platsmp.c |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2002 ARM Ltd. |
|---|
| 5 | 6 | * All Rights Reserved |
|---|
| 6 | 7 | * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 9 | | - * published by the Free Software Foundation. |
|---|
| 8 | + * This code is specific to the hardware found on ARM Realview and |
|---|
| 9 | + * Versatile Express platforms where the CPUs are unable to be individually |
|---|
| 10 | + * woken, and where there is no way to hot-unplug CPUs. Real platforms |
|---|
| 11 | + * should not copy this code. |
|---|
| 10 | 12 | */ |
|---|
| 11 | 13 | #include <linux/init.h> |
|---|
| 12 | 14 | #include <linux/errno.h> |
|---|
| .. | .. |
|---|
| 21 | 23 | #include <plat/platsmp.h> |
|---|
| 22 | 24 | |
|---|
| 23 | 25 | /* |
|---|
| 24 | | - * Write pen_release in a way that is guaranteed to be visible to all |
|---|
| 25 | | - * observers, irrespective of whether they're taking part in coherency |
|---|
| 26 | + * versatile_cpu_release controls the release of CPUs from the holding |
|---|
| 27 | + * pen in headsmp.S, which exists because we are not always able to |
|---|
| 28 | + * control the release of individual CPUs from the board firmware. |
|---|
| 29 | + * Production platforms do not need this. |
|---|
| 30 | + */ |
|---|
| 31 | +volatile int versatile_cpu_release = -1; |
|---|
| 32 | + |
|---|
| 33 | +/* |
|---|
| 34 | + * Write versatile_cpu_release in a way that is guaranteed to be visible to |
|---|
| 35 | + * all observers, irrespective of whether they're taking part in coherency |
|---|
| 26 | 36 | * or not. This is necessary for the hotplug code to work reliably. |
|---|
| 27 | 37 | */ |
|---|
| 28 | | -static void write_pen_release(int val) |
|---|
| 38 | +static void versatile_write_cpu_release(int val) |
|---|
| 29 | 39 | { |
|---|
| 30 | | - pen_release = val; |
|---|
| 40 | + versatile_cpu_release = val; |
|---|
| 31 | 41 | smp_wmb(); |
|---|
| 32 | | - sync_cache_w(&pen_release); |
|---|
| 42 | + sync_cache_w(&versatile_cpu_release); |
|---|
| 33 | 43 | } |
|---|
| 34 | 44 | |
|---|
| 35 | | -static DEFINE_RAW_SPINLOCK(boot_lock); |
|---|
| 45 | +/* |
|---|
| 46 | + * versatile_lock exists to avoid running the loops_per_jiffy delay loop |
|---|
| 47 | + * calibrations on the secondary CPU while the requesting CPU is using |
|---|
| 48 | + * the limited-bandwidth bus - which affects the calibration value. |
|---|
| 49 | + * Production platforms do not need this. |
|---|
| 50 | + */ |
|---|
| 51 | +static DEFINE_RAW_SPINLOCK(versatile_lock); |
|---|
| 36 | 52 | |
|---|
| 37 | 53 | void versatile_secondary_init(unsigned int cpu) |
|---|
| 38 | 54 | { |
|---|
| .. | .. |
|---|
| 40 | 56 | * let the primary processor know we're out of the |
|---|
| 41 | 57 | * pen, then head off into the C entry point |
|---|
| 42 | 58 | */ |
|---|
| 43 | | - write_pen_release(-1); |
|---|
| 59 | + versatile_write_cpu_release(-1); |
|---|
| 44 | 60 | |
|---|
| 45 | 61 | /* |
|---|
| 46 | 62 | * Synchronise with the boot thread. |
|---|
| 47 | 63 | */ |
|---|
| 48 | | - raw_spin_lock(&boot_lock); |
|---|
| 49 | | - raw_spin_unlock(&boot_lock); |
|---|
| 64 | + raw_spin_lock(&versatile_lock); |
|---|
| 65 | + raw_spin_unlock(&versatile_lock); |
|---|
| 50 | 66 | } |
|---|
| 51 | 67 | |
|---|
| 52 | 68 | int versatile_boot_secondary(unsigned int cpu, struct task_struct *idle) |
|---|
| .. | .. |
|---|
| 57 | 73 | * Set synchronisation state between this boot processor |
|---|
| 58 | 74 | * and the secondary one |
|---|
| 59 | 75 | */ |
|---|
| 60 | | - raw_spin_lock(&boot_lock); |
|---|
| 76 | + raw_spin_lock(&versatile_lock); |
|---|
| 61 | 77 | |
|---|
| 62 | 78 | /* |
|---|
| 63 | 79 | * This is really belt and braces; we hold unintended secondary |
|---|
| .. | .. |
|---|
| 65 | 81 | * since we haven't sent them a soft interrupt, they shouldn't |
|---|
| 66 | 82 | * be there. |
|---|
| 67 | 83 | */ |
|---|
| 68 | | - write_pen_release(cpu_logical_map(cpu)); |
|---|
| 84 | + versatile_write_cpu_release(cpu_logical_map(cpu)); |
|---|
| 69 | 85 | |
|---|
| 70 | 86 | /* |
|---|
| 71 | 87 | * Send the secondary CPU a soft interrupt, thereby causing |
|---|
| .. | .. |
|---|
| 77 | 93 | timeout = jiffies + (1 * HZ); |
|---|
| 78 | 94 | while (time_before(jiffies, timeout)) { |
|---|
| 79 | 95 | smp_rmb(); |
|---|
| 80 | | - if (pen_release == -1) |
|---|
| 96 | + if (versatile_cpu_release == -1) |
|---|
| 81 | 97 | break; |
|---|
| 82 | 98 | |
|---|
| 83 | 99 | udelay(10); |
|---|
| .. | .. |
|---|
| 87 | 103 | * now the secondary core is starting up let it run its |
|---|
| 88 | 104 | * calibrations, then wait for it to finish |
|---|
| 89 | 105 | */ |
|---|
| 90 | | - raw_spin_unlock(&boot_lock); |
|---|
| 106 | + raw_spin_unlock(&versatile_lock); |
|---|
| 91 | 107 | |
|---|
| 92 | | - return pen_release != -1 ? -ENOSYS : 0; |
|---|
| 108 | + return versatile_cpu_release != -1 ? -ENOSYS : 0; |
|---|
| 93 | 109 | } |
|---|