aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/common
diff options
context:
space:
mode:
authorNicolas Pitre <nicolas.pitre@linaro.org>2012-04-12 02:45:22 -0400
committerNicolas Pitre <nicolas.pitre@linaro.org>2013-04-24 10:36:59 -0400
commite8db288e05e588ad3f416b3a24354d60d02f35f2 (patch)
tree97a3ed1fa4e59d45ebc41d48b07d7c61fcff9ffc /arch/arm/common
parent0c91e7e07ebf08092bf8e28d8cd8d420732fc716 (diff)
ARM: multi-cluster PM: secondary kernel entry code
CPUs in cluster based systems, such as big.LITTLE, have special needs when entering the kernel due to a hotplug event, or when resuming from a deep sleep mode. This is vectorized so multiple CPUs can enter the kernel in parallel without serialization. The mcpm prefix stands for "multi cluster power management", however this is usable on single cluster systems as well. Only the basic structure is introduced here. This will be extended with later patches. In order not to complexify things more than they currently have to, the planned work to make runtime adjusted MPIDR based indexing and dynamic memory allocation for cluster states is postponed to a later cycle. The MAX_NR_CLUSTERS and MAX_CPUS_PER_CLUSTER static definitions should be sufficient for those systems expected to be available in the near future. Signed-off-by: Nicolas Pitre <nico@linaro.org> Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Reviewed-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm/common')
-rw-r--r--arch/arm/common/Makefile1
-rw-r--r--arch/arm/common/mcpm_entry.c22
-rw-r--r--arch/arm/common/mcpm_head.S86
3 files changed, 109 insertions, 0 deletions
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index dc8dd0de5c0f..b070671033ae 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o
11obj-$(CONFIG_SHARP_SCOOP) += scoop.o 11obj-$(CONFIG_SHARP_SCOOP) += scoop.o
12obj-$(CONFIG_PCI_HOST_ITE8152) += it8152.o 12obj-$(CONFIG_PCI_HOST_ITE8152) += it8152.o
13obj-$(CONFIG_ARM_TIMER_SP804) += timer-sp.o 13obj-$(CONFIG_ARM_TIMER_SP804) += timer-sp.o
14obj-$(CONFIG_MCPM) += mcpm_head.o mcpm_entry.o
diff --git a/arch/arm/common/mcpm_entry.c b/arch/arm/common/mcpm_entry.c
new file mode 100644
index 000000000000..7cbf70051ea7
--- /dev/null
+++ b/arch/arm/common/mcpm_entry.c
@@ -0,0 +1,22 @@
1/*
2 * arch/arm/common/mcpm_entry.c -- entry point for multi-cluster PM
3 *
4 * Created by: Nicolas Pitre, March 2012
5 * Copyright: (C) 2012-2013 Linaro Limited
6 *
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.
10 */
11
12#include <asm/mcpm.h>
13#include <asm/cacheflush.h>
14
15extern unsigned long mcpm_entry_vectors[MAX_NR_CLUSTERS][MAX_CPUS_PER_CLUSTER];
16
17void mcpm_set_entry_vector(unsigned cpu, unsigned cluster, void *ptr)
18{
19 unsigned long val = ptr ? virt_to_phys(ptr) : 0;
20 mcpm_entry_vectors[cluster][cpu] = val;
21 sync_cache_w(&mcpm_entry_vectors[cluster][cpu]);
22}
diff --git a/arch/arm/common/mcpm_head.S b/arch/arm/common/mcpm_head.S
new file mode 100644
index 000000000000..68c9903075a9
--- /dev/null
+++ b/arch/arm/common/mcpm_head.S
@@ -0,0 +1,86 @@
1/*
2 * arch/arm/common/mcpm_head.S -- kernel entry point for multi-cluster PM
3 *
4 * Created by: Nicolas Pitre, March 2012
5 * Copyright: (C) 2012-2013 Linaro Limited
6 *
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.
10 */
11
12#include <linux/linkage.h>
13#include <asm/mcpm.h>
14
15 .macro pr_dbg string
16#if defined(CONFIG_DEBUG_LL) && defined(DEBUG)
17 b 1901f
181902: .asciz "CPU"
191903: .asciz " cluster"
201904: .asciz ": \string"
21 .align
221901: adr r0, 1902b
23 bl printascii
24 mov r0, r9
25 bl printhex8
26 adr r0, 1903b
27 bl printascii
28 mov r0, r10
29 bl printhex8
30 adr r0, 1904b
31 bl printascii
32#endif
33 .endm
34
35 .arm
36 .align
37
38ENTRY(mcpm_entry_point)
39
40 THUMB( adr r12, BSYM(1f) )
41 THUMB( bx r12 )
42 THUMB( .thumb )
431:
44 mrc p15, 0, r0, c0, c0, 5 @ MPIDR
45 ubfx r9, r0, #0, #8 @ r9 = cpu
46 ubfx r10, r0, #8, #8 @ r10 = cluster
47 mov r3, #MAX_CPUS_PER_CLUSTER
48 mla r4, r3, r10, r9 @ r4 = canonical CPU index
49 cmp r4, #(MAX_CPUS_PER_CLUSTER * MAX_NR_CLUSTERS)
50 blo 2f
51
52 /* We didn't expect this CPU. Try to cheaply make it quiet. */
531: wfi
54 wfe
55 b 1b
56
572: pr_dbg "kernel mcpm_entry_point\n"
58
59 /*
60 * MMU is off so we need to get to mcpm_entry_vectors in a
61 * position independent way.
62 */
63 adr r5, 3f
64 ldr r6, [r5]
65 add r6, r5, r6 @ r6 = mcpm_entry_vectors
66
67mcpm_entry_gated:
68 ldr r5, [r6, r4, lsl #2] @ r5 = CPU entry vector
69 cmp r5, #0
70 wfeeq
71 beq mcpm_entry_gated
72 pr_dbg "released\n"
73 bx r5
74
75 .align 2
76
773: .word mcpm_entry_vectors - .
78
79ENDPROC(mcpm_entry_point)
80
81 .bss
82 .align 5
83
84 .type mcpm_entry_vectors, #object
85ENTRY(mcpm_entry_vectors)
86 .space 4 * MAX_NR_CLUSTERS * MAX_CPUS_PER_CLUSTER