static void calculate_gpu_utilization(void* arg) { u64 time_now; u64 time_period; u32 leading_zeroes; u32 shift_val; u32 work_normalized; u32 period_normalized; u32 utilization; _mali_osk_lock_wait(time_data_lock, _MALI_OSK_LOCKMODE_RW); if (accumulated_work_time == 0 && work_start_time == 0) { /* Don't reschedule timer, this will be started if new work arrives */ timer_running = MALI_FALSE; _mali_osk_lock_signal(time_data_lock, _MALI_OSK_LOCKMODE_RW); /* No work done for this period, report zero usage */ mali_gpu_utilization_handler(0); return; } time_now = _mali_osk_time_get_ns(); time_period = time_now - period_start_time; /* If we are currently busy, update working period up to now */ if (work_start_time != 0) { accumulated_work_time += (time_now - work_start_time); work_start_time = time_now; } /* * We have two 64-bit values, a dividend and a divisor. * To avoid dependencies to a 64-bit divider, we shift down the two values * equally first. * We shift the dividend up and possibly the divisor down, making the result X in 256. */ /* Shift the 64-bit values down so they fit inside a 32-bit integer */ leading_zeroes = _mali_osk_clz((u32)(time_period >> 32)); shift_val = 32 - leading_zeroes; work_normalized = (u32)(accumulated_work_time >> shift_val); period_normalized = (u32)(time_period >> shift_val); /* * Now, we should report the usage in parts of 256 * this means we must shift up the dividend or down the divisor by 8 * (we could do a combination, but we just use one for simplicity, * but the end result should be good enough anyway) */ if (period_normalized > 0x00FFFFFF) { /* The divisor is so big that it is safe to shift it down */ period_normalized >>= 8; }
/***************************************************************************** function name : mali_gpu_utilization_proc description : mali_gpu_utilization_proc input vars : void output vars : NA return value : void calls : NA called : os history : 1.data : 20/11/2013 modify : new *****************************************************************************/ static void mali_gpu_utilization_proc(struct mali_gpu_utilization_data *data) { static int count = 0; /*Just lock the gpu for the first 40 seconds after power up, this function be called every 50ns, 40s = 50ns * 800*/ if(800 == count) { MALI_DEBUG_PRINT(2,("set the gpu min_freq to 160M after about 40 seconds\n")); pmqos_gpu_dfs_limit_min(0); count++; } mali_gpu_utilization_handler(data->utilization_gpu); if(count < 800) { count++; } }
/***************************************************************************** function name : mali_gpu_utilization_proc description : mali_gpu_utilization_proc input vars : void output vars : NA return value : void calls : NA called : os history : 1.data : 20/11/2013 author : C66698 modify : new *****************************************************************************/ static void mali_gpu_utilization_proc(struct mali_gpu_utilization_data *data) { mali_gpu_utilization_handler(data->utilization_gpu); }