static ssize_t mcdi_profile_read(struct file *filp, char __user *userbuf, size_t count, loff_t *f_pos) { int i, len = 0; char *p = dbg_buf; unsigned int ratio_raw = 0; unsigned int ratio_int = 0; unsigned int ratio_fraction = 0; unsigned int ratio_dur = 0; struct { unsigned int sec[DISTRIBUTE_NUM]; unsigned int total; } cnt[2] = {0}; #ifdef MCDI_PWR_SEQ_PROF_BREAKDOWN struct mcdi_prof_breakdown *p_prof = (struct mcdi_prof_breakdown *)SYSRAM_PROF_PWR_SEQ_BK; unsigned int j; #endif mcdi_log( "mcdi cpu off : max_id = 0x%x, avg = %4dus, max = %5dus, cnt = %d\n", mcdi_read(CPU_OFF_LATENCY_REG(ID_OFS)), mcdi_read(CPU_OFF_LATENCY_REG(AVG_OFS)), mcdi_read(CPU_OFF_LATENCY_REG(MAX_OFS)), mcdi_read(CPU_OFF_LATENCY_REG(CNT_OFS))); mcdi_log( "mcdi cpu on : max_id = 0x%x, avg = %4dus, max = %5dus, cnt = %d\n", mcdi_read(CPU_ON_LATENCY_REG(ID_OFS)), mcdi_read(CPU_ON_LATENCY_REG(AVG_OFS)), mcdi_read(CPU_ON_LATENCY_REG(MAX_OFS)), mcdi_read(CPU_ON_LATENCY_REG(CNT_OFS))); mcdi_log( "mcdi cluster off: max_id = 0x%x, avg = %4dus, max = %5dus, cnt = %d\n", mcdi_read(Cluster_OFF_LATENCY_REG(ID_OFS)), mcdi_read(Cluster_OFF_LATENCY_REG(AVG_OFS)), mcdi_read(Cluster_OFF_LATENCY_REG(MAX_OFS)), mcdi_read(Cluster_OFF_LATENCY_REG(CNT_OFS))); mcdi_log( "mcdi cluster on : max_id = 0x%x, avg = %4dus, max = %5dus, cnt = %d\n", mcdi_read(Cluster_ON_LATENCY_REG(ID_OFS)), mcdi_read(Cluster_ON_LATENCY_REG(AVG_OFS)), mcdi_read(Cluster_ON_LATENCY_REG(MAX_OFS)), mcdi_read(Cluster_ON_LATENCY_REG(CNT_OFS))); mcdi_log("\n"); for (i = 0; i < DISTRIBUTE_NUM; i++) { cnt[0].sec[i] = mcdi_read(PROF_OFF_CNT_REG(i)); cnt[1].sec[i] = mcdi_read(PROF_ON_CNT_REG(i)); cnt[0].total += cnt[0].sec[i]; cnt[1].total += cnt[1].sec[i]; } cnt[0].total = cnt[0].total ? : 1; cnt[1].total = cnt[1].total ? : 1; for (i = 0; i < DISTRIBUTE_NUM; i++) mcdi_log("pwr off latency (section%d) : %2d%% (%d)\n", i, (100 * cnt[0].sec[i]) / cnt[0].total, cnt[0].sec[i]); for (i = 0; i < DISTRIBUTE_NUM; i++) mcdi_log("pwr on latency (section%d) : %2d%% (%d)\n", i, (100 * cnt[1].sec[i]) / cnt[1].total, cnt[1].sec[i]); ratio_dur = mcdi_read(SYSRAM_PROF_RARIO_DUR); if (ratio_dur == 0) ratio_dur = ~0; mcdi_log("\nOFF %% (cpu):\n"); for (i = 0; i < NF_CPU; i++) { ratio_raw = 100 * mcdi_read(PROF_CPU_RATIO_REG(i)); ratio_int = ratio_raw / ratio_dur; ratio_fraction = (1000 * (ratio_raw % ratio_dur)) / ratio_dur; mcdi_log("%d: %3u.%03u%% (%u)\n", i, ratio_int, ratio_fraction, ratio_raw/100); } mcdi_log("\nOFF %% (cluster):\n"); for (i = 0; i < NF_CLUSTER; i++) { ratio_raw = 100 * mcdi_read(PROF_CLUSTER_RATIO_REG(i)); ratio_int = ratio_raw / ratio_dur; ratio_fraction = (1000 * (ratio_raw % ratio_dur)) / ratio_dur; mcdi_log("%d: %3u.%03u%% (%u)\n", i, ratio_int, ratio_fraction, ratio_raw/100); } mcdi_log("\nprof cpu = %d, count = %d, state = %d, profile_state=%d\n", get_mcdi_profile_cpu(), get_mcdi_profile_cnt(), mcdi_mbox_read(MCDI_MBOX_PROF_CMD), profile_state); for (i = 0; i < (NF_MCDI_PROFILE - 1); i++) mcdi_log("%s: %u\n", prof_item[i], get_mcdi_profile_sum_us(i)); #ifdef MCDI_PWR_SEQ_PROF_BREAKDOWN mcdi_log("\npwr seq (us)\n"); for (j = 0; j < NF_CLUSTER; j++) { mcdi_log("\n---cluster %d---\n", j); for (i = 0; i < (MCDI_PROF_BK_NUM); i++) { mcdi_log("%s on, cnt : %u, %u\n", prof_pwr_seq_item[i], p_prof->onoff[0].item[i][j], p_prof->onoff[0].count[i][j]); } mcdi_log("\n"); for (i = 0; i < (MCDI_PROF_BK_NUM); i++) { mcdi_log("%s off, cnt : %u, %u\n", prof_pwr_seq_item[i], p_prof->onoff[1].item[i][j], p_prof->onoff[1].count[i][j]); } } #endif len = p - dbg_buf; return simple_read_from_buffer(userbuf, count, f_pos, dbg_buf, len); }