Lines Matching defs:cluster

3  * arch/arm/common/mcpm_entry.c -- entry point for multi-cluster PM
24 * see Documentation/arch/arm/cluster-pm-race-avoidance.rst.
34 static void __mcpm_cpu_going_down(unsigned int cpu, unsigned int cluster)
36 mcpm_sync.clusters[cluster].cpus[cpu].cpu = CPU_GOING_DOWN;
37 sync_cache_w(&mcpm_sync.clusters[cluster].cpus[cpu].cpu);
42 * cluster can be torn down without disrupting this CPU.
47 static void __mcpm_cpu_down(unsigned int cpu, unsigned int cluster)
50 mcpm_sync.clusters[cluster].cpus[cpu].cpu = CPU_DOWN;
51 sync_cache_w(&mcpm_sync.clusters[cluster].cpus[cpu].cpu);
56 * __mcpm_outbound_leave_critical: Leave the cluster teardown critical section.
57 * @state: the final state of the cluster:
58 * CLUSTER_UP: no destructive teardown was done and the cluster has been
60 * CLUSTER_DOWN: the cluster has been torn-down, ready for power-off
63 static void __mcpm_outbound_leave_critical(unsigned int cluster, int state)
66 mcpm_sync.clusters[cluster].cluster = state;
67 sync_cache_w(&mcpm_sync.clusters[cluster].cluster);
72 * __mcpm_outbound_enter_critical: Enter the cluster teardown critical section.
78 * observed, or the cluster is already being set up;
80 * cluster.
82 static bool __mcpm_outbound_enter_critical(unsigned int cpu, unsigned int cluster)
85 struct mcpm_sync_struct *c = &mcpm_sync.clusters[cluster];
87 /* Warn inbound CPUs that the cluster is being torn down: */
88 c->cluster = CLUSTER_GOING_DOWN;
89 sync_cache_w(&c->cluster);
91 /* Back out if the inbound cluster is already in the critical region: */
98 * teardown is complete on each CPU before tearing down the cluster.
101 * shouldn't be taking the cluster down at all: abort in that case.
131 __mcpm_outbound_leave_critical(cluster, CLUSTER_UP);
135 static int __mcpm_cluster_state(unsigned int cluster)
137 sync_cache_r(&mcpm_sync.clusters[cluster].cluster);
138 return mcpm_sync.clusters[cluster].cluster;
143 void mcpm_set_entry_vector(unsigned cpu, unsigned cluster, void *ptr)
146 mcpm_entry_vectors[cluster][cpu] = val;
147 sync_cache_w(&mcpm_entry_vectors[cluster][cpu]);
152 void mcpm_set_early_poke(unsigned cpu, unsigned cluster,
155 unsigned long *poke = &mcpm_entry_early_pokes[cluster][cpu][0];
187 static inline bool mcpm_cluster_unused(unsigned int cluster)
191 cnt |= mcpm_cpu_use_count[cluster][i];
195 int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster)
200 pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
212 cpu_is_down = !mcpm_cpu_use_count[cluster][cpu];
213 cluster_is_down = mcpm_cluster_unused(cluster);
215 mcpm_cpu_use_count[cluster][cpu]++;
224 BUG_ON(mcpm_cpu_use_count[cluster][cpu] != 1 &&
225 mcpm_cpu_use_count[cluster][cpu] != 2);
228 ret = platform_ops->cluster_powerup(cluster);
230 ret = platform_ops->cpu_powerup(cpu, cluster);
241 unsigned int mpidr, cpu, cluster;
247 cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
248 pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
255 __mcpm_cpu_going_down(cpu, cluster);
257 BUG_ON(__mcpm_cluster_state(cluster) != CLUSTER_UP);
259 mcpm_cpu_use_count[cluster][cpu]--;
260 BUG_ON(mcpm_cpu_use_count[cluster][cpu] != 0 &&
261 mcpm_cpu_use_count[cluster][cpu] != 1);
262 cpu_going_down = !mcpm_cpu_use_count[cluster][cpu];
263 last_man = mcpm_cluster_unused(cluster);
265 if (last_man && __mcpm_outbound_enter_critical(cpu, cluster)) {
266 platform_ops->cpu_powerdown_prepare(cpu, cluster);
267 platform_ops->cluster_powerdown_prepare(cluster);
270 __mcpm_outbound_leave_critical(cluster, CLUSTER_DOWN);
273 platform_ops->cpu_powerdown_prepare(cpu, cluster);
286 __mcpm_cpu_down(cpu, cluster);
308 int mcpm_wait_for_cpu_powerdown(unsigned int cpu, unsigned int cluster)
315 ret = platform_ops->wait_for_powerdown(cpu, cluster);
317 pr_warn("%s: cpu %u, cluster %u failed to power down (%d)\n",
318 __func__, cpu, cluster, ret);
332 unsigned int cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
334 platform_ops->cpu_suspend_prepare(cpu, cluster);
342 unsigned int mpidr, cpu, cluster;
351 cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
355 cpu_was_down = !mcpm_cpu_use_count[cluster][cpu];
356 first_man = mcpm_cluster_unused(cluster);
359 platform_ops->cluster_is_up(cluster);
361 mcpm_cpu_use_count[cluster][cpu] = 1;
363 platform_ops->cpu_is_up(cpu, cluster);
378 unsigned int cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
381 mcpm_set_entry_vector(cpu, cluster, cpu_resume_no_hyp);
384 __mcpm_cpu_going_down(cpu, cluster);
385 BUG_ON(!__mcpm_outbound_enter_critical(cpu, cluster));
387 __mcpm_outbound_leave_critical(cluster, CLUSTER_DOWN);
388 __mcpm_cpu_down(cpu, cluster);
432 * Set initial CPU and cluster states.
433 * Only one cluster is assumed to be active at this point.
436 mcpm_sync.clusters[i].cluster = CLUSTER_DOWN;
447 mcpm_sync.clusters[this_cluster].cluster = CLUSTER_UP;