static ssize_t pp_all_counter_srcx_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos, u32 src_id) { char buf[64]; long val; int ret; u32 num_groups; int i; if (cnt >= sizeof(buf)) { return -EINVAL; } if (copy_from_user(&buf, ubuf, cnt)) { return -EFAULT; } buf[cnt] = 0; ret = strict_strtol(buf, 10, &val); if (ret < 0) { return ret; } if (val < 0) { /* any negative input will disable counter */ val = MALI_HW_CORE_NO_COUNTER; } num_groups = mali_group_get_glob_num_groups(); for (i = 0; i < num_groups; i++) { struct mali_group *group = mali_group_get_glob_group(i); struct mali_pp_core *pp_core = mali_group_get_pp_core(group); if (NULL != pp_core) { if (0 == src_id) { if (MALI_TRUE != mali_pp_job_set_pp_counter_src0((u32)val)) { return 0; } } else { if (MALI_TRUE != mali_pp_job_set_pp_counter_src1((u32)val)) { return 0; } } } } *ppos += cnt; return cnt; }
/** * Called by gator.ko to set HW counters * * @param counter_id The counter ID. * @param event_id Event ID that the counter should count (HW counter value from TRM). * * @return 1 on success, 0 on failure. */ int _mali_profiling_set_event(u32 counter_id, s32 event_id) { if (COUNTER_VP_0_C0 == counter_id) { if (MALI_TRUE == mali_gp_job_set_gp_counter_src0(event_id)) { return 1; } } if (COUNTER_VP_0_C1 == counter_id) { if (MALI_TRUE == mali_gp_job_set_gp_counter_src1(event_id)) { return 1; } } if (COUNTER_FP_0_C0 == counter_id) { if (MALI_TRUE == mali_pp_job_set_pp_counter_src0(event_id)) { return 1; } } if (COUNTER_FP_0_C1 == counter_id) { if (MALI_TRUE == mali_pp_job_set_pp_counter_src1(event_id)) { return 1; } } if (COUNTER_L2_0_C0 <= counter_id && COUNTER_L2_2_C1 >= counter_id) { u32 core_id = (counter_id - COUNTER_L2_0_C0) >> 1; struct mali_l2_cache_core* l2_cache_core = mali_l2_cache_core_get_glob_l2_core(core_id); if (NULL != l2_cache_core) { u32 counter_src = (counter_id - COUNTER_L2_0_C0) & 1; if (0 == counter_src) { if (MALI_TRUE == mali_l2_cache_core_set_counter_src0(l2_cache_core, event_id)) { return 1; } } else { if (MALI_TRUE == mali_l2_cache_core_set_counter_src1(l2_cache_core, event_id)) { return 1; } } } }
static ssize_t pp_ppx_counter_srcx_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos, u32 src_id) { char buf[64]; long val; int ret; if (cnt >= sizeof(buf)) { return -EINVAL; } if (copy_from_user(&buf, ubuf, cnt)) { return -EFAULT; } buf[cnt] = 0; ret = strict_strtol(buf, 10, &val); if (ret < 0) { return ret; } if (val < 0) { /* any negative input will disable counter */ val = MALI_HW_CORE_NO_COUNTER; } if (0 == src_id) { if (MALI_TRUE != mali_pp_job_set_pp_counter_src0((u32)val)) { return 0; } } else { if (MALI_TRUE != mali_pp_job_set_pp_counter_src1((u32)val)) { return 0; } } *ppos += cnt; return cnt; }