aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/include
diff options
context:
space:
mode:
authorNicolas Pitre <nicolas.pitre@linaro.org>2015-03-11 18:16:13 -0400
committerOlof Johansson <olof@lixom.net>2015-04-03 15:52:46 -0400
commitd3a875444ad8d5e64c5a932361ca579312e49801 (patch)
tree88910c6b2e5b8f35541fbc57a975197981ea8113 /arch/arm/include
parent824f25c1ccded5de2d3e18268b91cddccdad3868 (diff)
ARM: MCPM: move the algorithmic complexity to the core code
All backends are reimplementing a variation of the same CPU reference count handling. They are also responsible for driving the MCPM special low-level locking. This is needless duplication, involving algorithmic requirements that are not necessarily obvious to the uninitiated. And from past code review experience, those were all initially implemented badly. After 3 years, it is time to refactor as much common code to the core MCPM facility to make the backends as simple as possible. To avoid a flag day, the new scheme is introduced in parallel to the existing backend interface. When all backends are converted over, the compatibility interface could be removed. The new MCPM backend interface implements simpler methods addressing very platform specific tasks performed under lock protection while keeping the algorithmic complexity and race avoidance local to the core code. Signed-off-by: Nicolas Pitre <nico@linaro.org> Tested-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'arch/arm/include')
-rw-r--r--arch/arm/include/asm/mcpm.h65
1 files changed, 63 insertions, 2 deletions
diff --git a/arch/arm/include/asm/mcpm.h b/arch/arm/include/asm/mcpm.h
index 3446f6a1d9fa..50b378f59e08 100644
--- a/arch/arm/include/asm/mcpm.h
+++ b/arch/arm/include/asm/mcpm.h
@@ -171,12 +171,73 @@ void mcpm_cpu_suspend(u64 expected_residency);
171int mcpm_cpu_powered_up(void); 171int mcpm_cpu_powered_up(void);
172 172
173/* 173/*
174 * Platform specific methods used in the implementation of the above API. 174 * Platform specific callbacks used in the implementation of the above API.
175 *
176 * cpu_powerup:
177 * Make given CPU runable. Called with MCPM lock held and IRQs disabled.
178 * The given cluster is assumed to be set up (cluster_powerup would have
179 * been called beforehand). Must return 0 for success or negative error code.
180 *
181 * cluster_powerup:
182 * Set up power for given cluster. Called with MCPM lock held and IRQs
183 * disabled. Called before first cpu_powerup when cluster is down. Must
184 * return 0 for success or negative error code.
185 *
186 * cpu_suspend_prepare:
187 * Special suspend configuration. Called on target CPU with MCPM lock held
188 * and IRQs disabled. This callback is optional. If provided, it is called
189 * before cpu_powerdown_prepare.
190 *
191 * cpu_powerdown_prepare:
192 * Configure given CPU for power down. Called on target CPU with MCPM lock
193 * held and IRQs disabled. Power down must be effective only at the next WFI instruction.
194 *
195 * cluster_powerdown_prepare:
196 * Configure given cluster for power down. Called on one CPU from target
197 * cluster with MCPM lock held and IRQs disabled. A cpu_powerdown_prepare
198 * for each CPU in the cluster has happened when this occurs.
199 *
200 * cpu_cache_disable:
201 * Clean and disable CPU level cache for the calling CPU. Called on with IRQs
202 * disabled only. The CPU is no longer cache coherent with the rest of the
203 * system when this returns.
204 *
205 * cluster_cache_disable:
206 * Clean and disable the cluster wide cache as well as the CPU level cache
207 * for the calling CPU. No call to cpu_cache_disable will happen for this
208 * CPU. Called with IRQs disabled and only when all the other CPUs are done
209 * with their own cpu_cache_disable. The cluster is no longer cache coherent
210 * with the rest of the system when this returns.
211 *
212 * cpu_is_up:
213 * Called on given CPU after it has been powered up or resumed. The MCPM lock
214 * is held and IRQs disabled. This callback is optional.
215 *
216 * cluster_is_up:
217 * Called by the first CPU to be powered up or resumed in given cluster.
218 * The MCPM lock is held and IRQs disabled. This callback is optional. If
219 * provided, it is called before cpu_is_up for that CPU.
220 *
221 * wait_for_powerdown:
222 * Wait until given CPU is powered down. This is called in sleeping context.
223 * Some reasonable timeout must be considered. Must return 0 for success or
224 * negative error code.
175 */ 225 */
176struct mcpm_platform_ops { 226struct mcpm_platform_ops {
227 int (*cpu_powerup)(unsigned int cpu, unsigned int cluster);
228 int (*cluster_powerup)(unsigned int cluster);
229 void (*cpu_suspend_prepare)(unsigned int cpu, unsigned int cluster);
230 void (*cpu_powerdown_prepare)(unsigned int cpu, unsigned int cluster);
231 void (*cluster_powerdown_prepare)(unsigned int cluster);
232 void (*cpu_cache_disable)(void);
233 void (*cluster_cache_disable)(void);
234 void (*cpu_is_up)(unsigned int cpu, unsigned int cluster);
235 void (*cluster_is_up)(unsigned int cluster);
236 int (*wait_for_powerdown)(unsigned int cpu, unsigned int cluster);
237
238 /* deprecated callbacks */
177 int (*power_up)(unsigned int cpu, unsigned int cluster); 239 int (*power_up)(unsigned int cpu, unsigned int cluster);
178 void (*power_down)(void); 240 void (*power_down)(void);
179 int (*wait_for_powerdown)(unsigned int cpu, unsigned int cluster);
180 void (*suspend)(u64); 241 void (*suspend)(u64);
181 void (*powered_up)(void); 242 void (*powered_up)(void);
182}; 243};