samsung: cpupm: Add cpuhp_last_cpu mask to indecating last_cpu
authorYoungtae Lee <yt0729.lee@samsung.com>
Fri, 4 May 2018 06:26:16 +0000 (15:26 +0900)
committerlakkyung.jung <lakkyung.jung@samsung.com>
Mon, 23 Jul 2018 05:59:14 +0000 (14:59 +0900)
this mask shows cpus that should perform
the cluster power down sequence.

Change-Id: If41ecb630191674dc47995808c383688aa0d8d55
Signed-off-by: Youngtae Lee <yt0729.lee@samsung.com>
drivers/soc/samsung/exynos-cpupm.c
include/soc/samsung/exynos-cpupm.h

index 9588f912058a8154ec025290cf7123de2c5b1f01..c76c27d2f12a1263d54760a26646231d4214200d 100644 (file)
@@ -298,13 +298,25 @@ static void cluster_disable(unsigned int cpu_id)
 /******************************************************************************
  *                               CPU HOTPLUG                                  *
  ******************************************************************************/
+/* cpumask for indecating last cpu of a cluster */
+struct cpumask cpuhp_last_cpu;
+
+bool exynos_cpuhp_last_cpu(unsigned int cpu)
+{
+       return cpumask_test_cpu(cpu, &cpuhp_last_cpu);
+}
+
 static int cpuhp_cpupm_online(unsigned int cpu)
 {
        struct cpumask mask;
 
        cpumask_and(&mask, cpu_coregroup_mask(cpu), cpu_online_mask);
-       if (cpumask_weight(&mask) == 0)
+       if (cpumask_weight(&mask) == 0) {
                cluster_enable(cpu);
+               /* clear cpus of this cluster from cpuhp_last_cpu */
+               cpumask_andnot(&cpuhp_last_cpu,
+                       &cpuhp_last_cpu, cpu_coregroup_mask(cpu));
+       }
 
        cpu_enable(cpu);
 
@@ -318,8 +330,11 @@ static int cpuhp_cpupm_offline(unsigned int cpu)
        cpu_disable(cpu);
 
        cpumask_and(&mask, cpu_coregroup_mask(cpu), cpu_online_mask);
-       if (cpumask_weight(&mask) == 0)
+       if (cpumask_weight(&mask) == 0) {
+               /* set cpu cpuhp_last_cpu */
+               cpumask_set_cpu(cpu, &cpuhp_last_cpu);
                cluster_disable(cpu);
+       }
 
        return 0;
 }
index eb132497d34a93977202db6529fb2cb021d48b77..06292fc19ee19029f0082f8c8c9211a11d2ee0b8 100644 (file)
@@ -17,6 +17,10 @@ enum {
        POWERMODE_TYPE_SYSTEM,
 };
 
+extern void disable_power_mode(int cpu, int type);
+extern void enable_power_mode(int cpu, int type);
+extern bool exynos_cpuhp_last_cpu(unsigned int cpu);
+
 #ifdef CONFIG_CPU_IDLE
 void exynos_update_ip_idle_status(int index, int idle);
 int exynos_get_idle_ip_index(const char *name);