diff --git a/drivers/thermal/cpu_budget_cooling.c b/drivers/thermal/cpu_budget_cooling.c index 2a2aad7..45b6bfa 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; @@ -160,6 +175,7 @@ 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; @@ -185,6 +201,14 @@ 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; + /* Depends on /drivers/thermal/sunxi-cpu-budget-cooling.c m_default_budgets_table */ +#ifdef CONFIG_ARCH_SUN8IW7 + if (cpu_budget_device->cpu_budget_state < 2 && (c0_takedown + c1_takedown) == 0) + { + c0_bringup = (c0_online < c0_max)?(c0_max - c0_online):0; + c1_bringup = (c1_online < c1_max)?(c1_max - c1_online):0; + } +#endif while(c1_takedown) { cpuid = get_any_online_cpu(&cpu_budget_device->cluster1_cpus); @@ -209,6 +233,30 @@ 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);