hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/arch/arm/plat-versatile/platsmp.c
....@@ -1,12 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/arch/arm/plat-versatile/platsmp.c
34 *
45 * Copyright (C) 2002 ARM Ltd.
56 * All Rights Reserved
67 *
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.
1012 */
1113 #include <linux/init.h>
1214 #include <linux/errno.h>
....@@ -21,18 +23,32 @@
2123 #include <plat/platsmp.h>
2224
2325 /*
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
2636 * or not. This is necessary for the hotplug code to work reliably.
2737 */
28
-static void write_pen_release(int val)
38
+static void versatile_write_cpu_release(int val)
2939 {
30
- pen_release = val;
40
+ versatile_cpu_release = val;
3141 smp_wmb();
32
- sync_cache_w(&pen_release);
42
+ sync_cache_w(&versatile_cpu_release);
3343 }
3444
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);
3652
3753 void versatile_secondary_init(unsigned int cpu)
3854 {
....@@ -40,13 +56,13 @@
4056 * let the primary processor know we're out of the
4157 * pen, then head off into the C entry point
4258 */
43
- write_pen_release(-1);
59
+ versatile_write_cpu_release(-1);
4460
4561 /*
4662 * Synchronise with the boot thread.
4763 */
48
- raw_spin_lock(&boot_lock);
49
- raw_spin_unlock(&boot_lock);
64
+ raw_spin_lock(&versatile_lock);
65
+ raw_spin_unlock(&versatile_lock);
5066 }
5167
5268 int versatile_boot_secondary(unsigned int cpu, struct task_struct *idle)
....@@ -57,7 +73,7 @@
5773 * Set synchronisation state between this boot processor
5874 * and the secondary one
5975 */
60
- raw_spin_lock(&boot_lock);
76
+ raw_spin_lock(&versatile_lock);
6177
6278 /*
6379 * This is really belt and braces; we hold unintended secondary
....@@ -65,7 +81,7 @@
6581 * since we haven't sent them a soft interrupt, they shouldn't
6682 * be there.
6783 */
68
- write_pen_release(cpu_logical_map(cpu));
84
+ versatile_write_cpu_release(cpu_logical_map(cpu));
6985
7086 /*
7187 * Send the secondary CPU a soft interrupt, thereby causing
....@@ -77,7 +93,7 @@
7793 timeout = jiffies + (1 * HZ);
7894 while (time_before(jiffies, timeout)) {
7995 smp_rmb();
80
- if (pen_release == -1)
96
+ if (versatile_cpu_release == -1)
8197 break;
8298
8399 udelay(10);
....@@ -87,7 +103,7 @@
87103 * now the secondary core is starting up let it run its
88104 * calibrations, then wait for it to finish
89105 */
90
- raw_spin_unlock(&boot_lock);
106
+ raw_spin_unlock(&versatile_lock);
91107
92
- return pen_release != -1 ? -ENOSYS : 0;
108
+ return versatile_cpu_release != -1 ? -ENOSYS : 0;
93109 }