soc: samsung: cpupm: introduce virtual cluster info
authorJohnlay Park <jonglae.park@samsung.com>
Fri, 8 Jun 2018 14:45:20 +0000 (23:45 +0900)
committerlakkyung.jung <lakkyung.jung@samsung.com>
Mon, 23 Jul 2018 05:58:41 +0000 (14:58 +0900)
to abstract the CPU topology

Change-Id: I4e13b6a45059743ceab143ba95826a35670b5357
Signed-off-by: Johnlay Park <jonglae.park@samsung.com>
drivers/soc/samsung/exynos-cpupm.c

index 3754df21b463daf8953996faf8893e292f18daed..4c7e34024251acde293ccdab71369ae7034f664b 100644 (file)
@@ -280,14 +280,17 @@ static void cpu_disable(unsigned int cpu)
        cal_cpu_disable(cpu);
 }
 
-static void cluster_enable(unsigned int cluster_id)
+static DEFINE_PER_CPU(int, vcluster_id);
+static void cluster_enable(unsigned int cpu_id)
 {
+       unsigned int cluster_id = per_cpu(vcluster_id, cpu_id);;
        cal_cluster_enable(cluster_id);
        big_reset_control(1);
 }
 
-static void cluster_disable(unsigned int cluster_id)
+static void cluster_disable(unsigned int cpu_id)
 {
+       unsigned int cluster_id = per_cpu(vcluster_id, cpu_id);
        big_reset_control(0);
        cal_cluster_disable(cluster_id);
 }
@@ -301,7 +304,7 @@ static int cpuhp_cpupm_online(unsigned int cpu)
 
        cpumask_and(&mask, cpu_coregroup_mask(cpu), cpu_online_mask);
        if (cpumask_weight(&mask) == 0)
-               cluster_enable(cpu_topology[cpu].cluster_id);
+               cluster_enable(cpu);
 
        cpu_enable(cpu);
 
@@ -316,7 +319,7 @@ static int cpuhp_cpupm_offline(unsigned int cpu)
 
        cpumask_and(&mask, cpu_coregroup_mask(cpu), cpu_online_mask);
        if (cpumask_weight(&mask) == 0)
-               cluster_disable(cpu_topology[cpu].cluster_id);
+               cluster_disable(cpu);
 
        return 0;
 }
@@ -599,7 +602,7 @@ static int try_to_enter_power_mode(int cpu, struct power_mode *mode)
         */
        switch (mode->type) {
        case POWERMODE_TYPE_CLUSTER:
-               cluster_disable(cpu_topology[cpu].cluster_id);
+               cluster_disable(cpu);
                break;
        case POWERMODE_TYPE_SYSTEM:
                if (unlikely(exynos_system_idle_enter()))
@@ -634,7 +637,7 @@ static void exit_mode(int cpu, struct power_mode *mode, int cancel)
 
        switch (mode->type) {
        case POWERMODE_TYPE_CLUSTER:
-               cluster_enable(cpu_topology[cpu].cluster_id);
+               cluster_enable(cpu);
                break;
        case POWERMODE_TYPE_SYSTEM:
                exynos_system_idle_exit(cancel);
@@ -869,6 +872,32 @@ static int __init cpu_power_mode_init(void)
        if (attr_count)
                cpupm_sysfs_node_init(attr_count);
 
+       dn = of_find_node_by_path("/cpupm/vcpu_topology");
+       if (dn){
+               int i, cluster_cnt = 0;
+               of_property_read_u32(dn, "vcluster_cnt", &cluster_cnt);
+
+               pr_info("%s:Virtual Cluster Info\n", __func__);
+               for (i = 0 ; i < cluster_cnt ; i++) {
+                       int cpu;
+                       char name[20];
+                       struct cpumask sibling;
+                       snprintf(name, sizeof(name), "vcluster%d_sibling", i);
+                       if (!of_property_read_string(dn, name, &buf)) {
+                               cpulist_parse(buf, &sibling);
+
+                               pr_info("Cluster%d : ", i);
+                               for_each_cpu(cpu, &sibling) {
+                                       per_cpu(vcluster_id, cpu) = i;
+                                       pr_info("%d ", cpu);
+                               }
+                               pr_info("\n");
+                       }
+               }
+       }else {
+               pr_info("No Virtual Cluster Info\n");
+       }
+
        return 0;
 }