static void pwrctrl_dfs_mgrmsg_task(void) { int cur_profile = 0; unsigned int flowctrl_cpuload = 0; PWRCTRLFUNCPTR pRoutine = NULL; struct cpufreq_msg task_msg = {0,0,0,0}; g_stDfsCpuControl.ulStartTime = bsp_get_slice_value(); /* coverity[INFINITE_LOOP] */ /* coverity[no_escape] */ for (;;) { if (NULL != g_sem_calccpu_flag) { semTake(g_sem_calccpu_flag, DFS_WAIT_FOREVER); /*调用ttf回调函数*/ if ((NULL != FlowCtrlCallBack) && (g_flowctrl_in_interr_times >= 200)) { flowctrl_cpuload = cpufreq_calccpu_cpuload(); pRoutine = FlowCtrlCallBack; (void)(*pRoutine)(flowctrl_cpuload); } } else { taskDelay((int)g_stDfsCpuConfigInfo.ulTimerLen); g_calccpu_load_result = cpufreq_calccpu_result(&g_next_freq); } if (!g_cpufreq_lock_status_flag) { continue; } cur_profile = pwrctrl_dfs_get_profile(); cpufreq_assistant_regulate_ddr(cur_profile); if (DFS_PROFILE_NOCHANGE != g_calccpu_load_result) { if (g_icc_run_flag == 1) { task_msg.msg_type = CPUFREQ_ADJUST_FREQ; task_msg.source = CPUFREQ_CCORE; task_msg.content = g_calccpu_load_result; if (DFS_PROFILE_UP_TARGET == g_calccpu_load_result) { cur_profile = DC_RESV; } else if ((u32)cur_profile == CPUFREQ_MIN_PROFILE_LIMIT) { continue; } task_msg.profile = (unsigned int)cur_profile - 1; balong_cpufreq_icc_send(&task_msg); } else if (g_icc_run_flag == 2) { cpufreq_excute_result_cpu(g_calccpu_load_result, g_next_freq); } } } }
/* * 变为两个函数,一个计算占用率,并返回要之后要如何操作 * 一个根据返回完成接下来的操作 */ void balong_dbs_check_cpu(void) { u32 result = 2; u32 nextfreq = 0; struct cpu_dbs_info_s *dbs_info = &per_cpu(g_acpu_dbs_info, 0); struct cpufreq_policy *policy; policy = dbs_info->cur_policy; if (!g_cpufreq_lock_status_flag) { return; } result = cpufreq_calccpu_result(&nextfreq); if (result != DFS_PROFILE_NOCHANGE) { if (g_icc_run_flag) { __cpufreq_driver_target(policy, nextfreq, result); } } }