static ssize_t pp_ppx_counter_srcx_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos, u32 src_id) { struct mali_pp_core *pp_core = (struct mali_pp_core *)filp->private_data; 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_core_set_counter_src0(pp_core, (u32)val)) { return 0; } } else { if (MALI_TRUE != mali_pp_core_set_counter_src1(pp_core, (u32)val)) { return 0; } } *ppos += cnt; return cnt; }
int _mali_profiling_set_event(u32 counter_id, s32 event_id) { if (COUNTER_VP_C0 == counter_id) { struct mali_gp_core* gp_core = mali_gp_get_global_gp_core(); if (NULL != gp_core) { if (MALI_TRUE == mali_gp_core_set_counter_src0(gp_core, event_id)) { return 1; } } } if (COUNTER_VP_C1 == counter_id) { struct mali_gp_core* gp_core = mali_gp_get_global_gp_core(); if (NULL != gp_core) { if (MALI_TRUE == mali_gp_core_set_counter_src1(gp_core, event_id)) { return 1; } } } if (COUNTER_FP0_C0 <= counter_id && COUNTER_FP3_C1 >= counter_id) { u32 core_id = (counter_id - COUNTER_FP0_C0) >> 1; struct mali_pp_core* pp_core = mali_pp_get_global_pp_core(core_id); if (NULL != pp_core) { u32 counter_src = (counter_id - COUNTER_FP0_C0) & 1; if (0 == counter_src) { if (MALI_TRUE == mali_pp_core_set_counter_src0(pp_core, event_id)) { return 1; } } else { if (MALI_TRUE == mali_pp_core_set_counter_src1(pp_core, event_id)) { return 1; } } } }
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 ci; struct mali_cluster *cluster; 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; } ci = 0; cluster = mali_cluster_get_global_cluster(ci); while (NULL != cluster) { u32 gi = 0; struct mali_group *group = mali_cluster_get_group(cluster, gi); while (NULL != group) { 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_core_set_counter_src0(pp_core, (u32)val)) { return 0; } } else { if (MALI_TRUE != mali_pp_core_set_counter_src1(pp_core, (u32)val)) { return 0; } } } /* try next group */ gi++; group = mali_cluster_get_group(cluster, gi); } /* try next cluster */ ci++; cluster = mali_cluster_get_global_cluster(ci); } *ppos += cnt; return cnt; }