build/patch/kernel/sun8i-default/sun8i-simple-cpu-corekeeper.patch.disabled

98 lines
3.4 KiB
Text
Raw Normal View History

diff --git a/drivers/thermal/cpu_budget_cooling.c b/drivers/thermal/cpu_budget_cooling.c
2016-05-16 20:00:07 +03:00
index 2a2aad7..94cb784 100755
--- a/drivers/thermal/cpu_budget_cooling.c
+++ b/drivers/thermal/cpu_budget_cooling.c
@@ -124,6 +124,21 @@ static int get_any_online_cpu(const cpumask_t *mask)
}
return lastcpu;
}
+static int get_any_offline_cpu(const cpumask_t *mask)
+{
+ int cpu,lastcpu=0xffff;
+
+ for_each_cpu(cpu, mask) {
+ if (cpu_is_offline(cpu))
+ {
+ if(lastcpu == 0xffff)
+ lastcpu = cpu;
+ else if(cpu >lastcpu)
+ lastcpu = cpu;
+ }
+ }
+ return lastcpu;
+}
static int get_online_cpu(const cpumask_t *mask)
{
int cpu,num =0;
@@ -151,6 +166,7 @@ EXPORT_SYMBOL(register_budget_cooling_notifier);
#ifdef CONFIG_CPU_FREQ_GOV_AUTO_HOTPLUG_ROOMAGE
extern int autohotplug_update_room(unsigned int c0min,unsigned int c1min,unsigned int c0max,unsigned int c1max);
#endif
+static int old_cooling_state = 0;
int cpu_budget_update_state(struct cpu_budget_cooling_device *cpu_budget_device)
{
int ret = 0;
@@ -160,10 +176,12 @@ int cpu_budget_update_state(struct cpu_budget_cooling_device *cpu_budget_device)
unsigned int c0_online=0,c1_online=0;
unsigned int c0_takedown=0,c1_takedown=0;
unsigned int c0_max,c1_max,c0_min,c1_min;
+ unsigned int c0_bringup=0,c1_bringup=0;
#endif
struct cpumask *cluster0_cpus = &cpu_budget_device->cluster0_cpus;
struct cpumask *cluster1_cpus = &cpu_budget_device->cluster1_cpus;
struct cpufreq_policy policy;
+ int cooling_state = cpu_budget_device->cpu_budget_state;
ret = 0;
#ifdef CONFIG_HOTPLUG_CPU
2016-05-16 20:00:07 +03:00
@@ -185,6 +203,22 @@ int cpu_budget_update_state(struct cpu_budget_cooling_device *cpu_budget_device)
c0_max:cpu_budget_device->cluster0_num_floor;
c0_takedown = (c0_online > c0_max)?(c0_online - c0_max):0;
c1_takedown = (c1_online > c1_max)?(c1_online - c1_max):0;
+#ifdef CONFIG_ARCH_SUN8IW7
+ if ((cooling_state < old_cooling_state) && (c0_takedown + c1_takedown == 0))
+ {
+ pr_info("CPU Budget:plugging cores, old state %d, new state %d\n",old_cooling_state,cooling_state);
+ switch (cooling_state)
+ {
+ case 2:
+ case 1:
+ case 0:
+ c0_bringup = (c0_online < c0_max) ? c0_max - c0_online : 0;
+ c1_bringup = (c1_online < c1_max) ? c1_max - c1_online : 0;
+ break;
+ }
+ }
+ old_cooling_state = cooling_state;
+#endif
while(c1_takedown)
{
cpuid = get_any_online_cpu(&cpu_budget_device->cluster1_cpus);
2016-05-16 20:00:07 +03:00
@@ -209,6 +243,26 @@ int cpu_budget_update_state(struct cpu_budget_cooling_device *cpu_budget_device)
}
c0_takedown--;
}
+ while(c0_bringup)
+ {
+ cpuid = get_any_offline_cpu(&cpu_budget_device->cluster0_cpus);
+ if (cpuid < nr_cpu_ids)
+ {
+ pr_info("CPU Budget:Try to up cpu %d, cluster0 online %d, limit %d\n",cpuid,c0_online,cpu_budget_device->cluster0_num_limit);
+ ret = work_on_cpu(BOOT_CPU,(long(*)(void *))cpu_up,(void *)cpuid);
+ }
+ c0_bringup--;
+ }
+ while(c1_bringup)
+ {
+ cpuid = get_any_offline_cpu(&cpu_budget_device->cluster1_cpus);
+ if (cpuid < nr_cpu_ids)
+ {
+ pr_info("CPU Budget:Try to up cpu %d, cluster1 online %d, limit %d\n",cpuid,c1_online,cpu_budget_device->cluster1_num_limit);
+ ret = work_on_cpu(BOOT_CPU,(long(*)(void *))cpu_up,(void *)cpuid);
+ }
+ c1_bringup--;
+ }
#endif
#ifdef CONFIG_CPU_FREQ_GOV_AUTO_HOTPLUG_ROOMAGE
autohotplug_update_room(c0_min,c1_min,c0_max,c1_max);