void mtk_hotplug_mechanism_thermal_protect(int limited_cpus) { int i; HOTPLUG_INFO("mtk_hotplug_mechanism_thermal_protect: %d\n", limited_cpus); if ((limited_cpus < 1 ) || (limited_cpus > g_max_cpus)) return; mutex_lock(&g_mtk_hotplug_mechanism_lock); g_limited_cpus = limited_cpus; if (g_limited_cpus == 1) { disable_hotplug_policy(true, g_limited_cpus); } else { disable_hotplug_policy(false, g_limited_cpus); } for (i = g_limited_cpus; i < g_max_cpus; ++i) cpu_down(i); mutex_unlock(&g_mtk_hotplug_mechanism_lock); }
void factory_cpus_idle_test(void) { int cpu = 0; int i = 0; unsigned char name[10] = {'\0'}; struct task_struct *thread[nr_cpu_ids]; #ifdef CONFIG_SMP int ret = 0; #endif spin_lock(&factory_lock); cpu = smp_processor_id(); spin_unlock(&factory_lock); dcm_info("[%s]: it's cpu%d, num_online_cpus=%d\n", __func__, cpu, num_online_cpus()); #ifdef CONFIG_SMP mutex_lock(&ftm_cpu_prepare); disable_hotplug_policy(true, nr_cpu_ids); for (i = 1; i < nr_cpu_ids; i++) { ret = cpu_up(i); dcm_info("[%s]cpu_up(cpu%d) return %d, cpu1_killed=%u\n", __func__, i, ret, cpu1_killed); } mutex_unlock(&ftm_cpu_prepare); #endif mtk_wdt_disable(); // disable watch dog // turn off backlight #if defined(CONFIG_MTK_LEDS) mt65xx_leds_brightness_set(MT65XX_LED_TYPE_LCD, 0); #endif for (i = nr_cpu_ids-1; i >= 0; i--) { cpuid[i] = i; init_completion(&each_thread_done[i]); sprintf(name, "idle-%d", i); thread[i] = kthread_create(cpu_enter_wfi[i], &cpuid[i], name); if (IS_ERR(thread[i])) { int ret = PTR_ERR(thread[i]); thread[i] = NULL; dcm_info("[%s]: kthread_create %s fail(%d)\n", __func__, name, ret); return; } dcm_info("[%s]: kthread_create %s done\n", __func__, name); kthread_bind(thread[i], i); dcm_info("[%s]: kthread_bind %s done\n", __func__, name); wake_up_process(thread[i]); dcm_info("[%s]: wake_up_process %s done\n", __func__, name); wait_for_completion(&each_thread_done[i]); } dcm_info("[%s]: cpu%d starts to complete_all all_threads_done\n", __func__, cpu); complete_all(&all_threads_done); }
void factory_cpu0_idle_test(void) { int cpu = 0; #ifdef CONFIG_SMP int i = 0; int ret = 0; int cpu_pwrdn_flag[nr_cpu_ids]; #endif spin_lock(&factory_lock); cpu = smp_processor_id(); spin_unlock(&factory_lock); printk("[%s]it's cpu%d\n", __func__, cpu); #ifdef CONFIG_SMP mutex_lock(&ftm_cpu_prepare); disable_hotplug_policy(true, nr_cpu_ids); memset(cpu_pwrdn_flag, 0, nr_cpu_ids * sizeof(int)); for (i = 1; i < nr_cpu_ids; i++) { if (cpu_online(i)) { cpu_pwrdn_flag[i] = 1; ret = cpu_down(i); dcm_info("[%s]cpu_down(cpu%d) return %d, cpu1_killed=%u\n", __func__, i, ret, cpu1_killed); } else { dcm_info("[%s]no need to power down cpu%d\n", __func__, i); } } mutex_unlock(&ftm_cpu_prepare); #endif #ifdef CONFIG_LOCAL_WDT mpcore_wk_wdt_stop(); #endif mtk_wdt_disable(); // disable watch dog //this should be set by low power requirement. #ifdef IDLE_LOW_POWER_TEST enable_low_power_settings(); #endif local_irq_disable(); go_to_idle(); local_irq_enable(); #ifdef IDLE_LOW_POWER_TEST disable_low_power_settings(); #endif #ifdef CONFIG_SMP mutex_lock(&ftm_cpu_prepare); for (i = 1; i < nr_cpu_ids; i++) { if (cpu_pwrdn_flag[i] == 1) { ret = cpu_up(i); dcm_info("[%s]cpu_up(cpu%d) return %d, cpu1_killed=%u\n", __func__, i, ret, cpu1_killed); } else { dcm_info("[%s]no need to power up cpu%d\n", __func__, i); } } disable_hotplug_policy(false, nr_cpu_ids); mutex_unlock(&ftm_cpu_prepare); #endif }