static ssize_t gp_all_counter_srcx_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *gpos, 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_gp_core *gp_core = mali_group_get_gp_core(group); if (NULL != gp_core) { if (0 == src_id) { if (MALI_TRUE != mali_gp_job_set_gp_counter_src0((u32)val)) { return 0; } } else { if (MALI_TRUE != mali_gp_job_set_gp_counter_src1((u32)val)) { return 0; } } } } *gpos += cnt; return cnt; }
_mali_osk_errcode_t mali_gp_scheduler_initialize(void) { u32 i; _MALI_OSK_INIT_LIST_HEAD(&job_queue); gp_scheduler_lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ORDERED | _MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_SCHEDULER); gp_scheduler_working_wait_queue = _mali_osk_wait_queue_init(); if (NULL == gp_scheduler_lock) { return _MALI_OSK_ERR_NOMEM; } if (NULL == gp_scheduler_working_wait_queue) { _mali_osk_lock_term(gp_scheduler_lock); return _MALI_OSK_ERR_NOMEM; } /* Find all the available GP cores */ for (i = 0; i < mali_cluster_get_glob_num_clusters(); i++) { u32 group_id = 0; struct mali_cluster *curr_cluster = mali_cluster_get_global_cluster(i); struct mali_group *group = mali_cluster_get_group(curr_cluster, group_id); while (NULL != group) { struct mali_gp_core *gp_core = mali_group_get_gp_core(group); if (NULL != gp_core) { if (0 == gp_version) { /* Retrieve GP version */ gp_version = mali_gp_core_get_version(gp_core); } slot.group = group; slot.state = MALI_GP_SLOT_STATE_IDLE; break; /* There are only one GP, no point in looking for more */ } group_id++; group = mali_cluster_get_group(curr_cluster, group_id); } } return _MALI_OSK_ERR_OK; }
_mali_osk_errcode_t mali_gp_scheduler_initialize(void) { u32 num_groups; u32 i; _mali_osk_errcode_t ret = _MALI_OSK_ERR_OK; #if defined(MALI_UPPER_HALF_SCHEDULING) gp_scheduler_lock = _mali_osk_spinlock_irq_init(_MALI_OSK_LOCKFLAG_ORDERED, _MALI_OSK_LOCK_ORDER_SCHEDULER); #else gp_scheduler_lock = _mali_osk_spinlock_init(_MALI_OSK_LOCKFLAG_ORDERED, _MALI_OSK_LOCK_ORDER_SCHEDULER); #endif /* defined(MALI_UPPER_HALF_SCHEDULING) */ if (NULL == gp_scheduler_lock) { ret = _MALI_OSK_ERR_NOMEM; goto cleanup; } gp_scheduler_working_wait_queue = _mali_osk_wait_queue_init(); if (NULL == gp_scheduler_working_wait_queue) { ret = _MALI_OSK_ERR_NOMEM; goto cleanup; } /* Find all the available GP cores */ 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); MALI_DEBUG_ASSERT(NULL != group); if (NULL != group) { struct mali_gp_core *gp_core = mali_group_get_gp_core(group); if (NULL != gp_core) { if (0 == gp_version) { /* Retrieve GP version */ gp_version = mali_gp_core_get_version(gp_core); } slot.group = group; slot.state = MALI_GP_SLOT_STATE_IDLE; break; /* There is only one GP, no point in looking for more */ } } else { ret = _MALI_OSK_ERR_ITEM_NOT_FOUND; goto cleanup; } } return _MALI_OSK_ERR_OK; cleanup: if (NULL != gp_scheduler_working_wait_queue) { _mali_osk_wait_queue_term(gp_scheduler_working_wait_queue); gp_scheduler_working_wait_queue = NULL; } if (NULL != gp_scheduler_lock) { #if defined(MALI_UPPER_HALF_SCHEDULING) _mali_osk_spinlock_irq_term(gp_scheduler_lock); #else _mali_osk_spinlock_term(gp_scheduler_lock); #endif /* defined(MALI_UPPER_HALF_SCHEDULING) */ gp_scheduler_lock = NULL; } return ret; }
static ssize_t gp_all_counter_srcx_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *gpos, 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_gp_core *gp_core = mali_group_get_gp_core(group); if (NULL != gp_core) { if (0 == src_id) { if (MALI_TRUE != mali_gp_core_set_counter_src0(gp_core, (u32)val)) { return 0; } } else { if (MALI_TRUE != mali_gp_core_set_counter_src1(gp_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); } *gpos += cnt; return cnt; }
int mali_sysfs_register(struct mali_dev *device, dev_t dev, const char *mali_dev_name) { int err = 0; device->mali_class = class_create(THIS_MODULE, mali_dev_name); if (IS_ERR(device->mali_class)) { err = PTR_ERR(device->mali_class); goto init_class_err; } mali_device = device_create(device->mali_class, NULL, dev, NULL, mali_dev_name); if (IS_ERR(mali_device)) { err = PTR_ERR(mali_device); goto init_mdev_err; } mali_debugfs_dir = debugfs_create_dir(mali_dev_name, NULL); if(ERR_PTR(-ENODEV) == mali_debugfs_dir) { /* Debugfs not supported. */ mali_debugfs_dir = NULL; } else { if(NULL != mali_debugfs_dir) { /* Debugfs directory created successfully; create files now */ struct dentry *mali_power_dir; struct dentry *mali_gp_dir; struct dentry *mali_pp_dir; struct dentry *mali_l2_dir; #if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED struct dentry *mali_profiling_dir; #endif mali_power_dir = debugfs_create_dir("power", mali_debugfs_dir); if (mali_power_dir != NULL) { debugfs_create_file("power_events", 0400, mali_power_dir, NULL, &power_events_fops); } mali_gp_dir = debugfs_create_dir("gp", mali_debugfs_dir); if (mali_gp_dir != NULL) { struct dentry *mali_gp_all_dir; u32 ci; struct mali_cluster *cluster; mali_gp_all_dir = debugfs_create_dir("all", mali_gp_dir); if (mali_gp_all_dir != NULL) { debugfs_create_file("counter_src0", 0400, mali_gp_all_dir, NULL, &gp_all_counter_src0_fops); debugfs_create_file("counter_src1", 0400, mali_gp_all_dir, NULL, &gp_all_counter_src1_fops); } 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_gp_core *gp_core = mali_group_get_gp_core(group); if (NULL != gp_core) { struct dentry *mali_gp_gpx_dir; mali_gp_gpx_dir = debugfs_create_dir("gp0", mali_gp_dir); if (NULL != mali_gp_gpx_dir) { debugfs_create_file("counter_src0", 0600, mali_gp_gpx_dir, gp_core, &gp_gpx_counter_src0_fops); debugfs_create_file("counter_src1", 0600, mali_gp_gpx_dir, gp_core, &gp_gpx_counter_src1_fops); } break; /* no need to look for any other GP cores */ } /* try next group */ gi++; group = mali_cluster_get_group(cluster, gi); } /* try next cluster */ ci++; cluster = mali_cluster_get_global_cluster(ci); } } mali_pp_dir = debugfs_create_dir("pp", mali_debugfs_dir); if (mali_pp_dir != NULL) { struct dentry *mali_pp_all_dir; u32 ci; struct mali_cluster *cluster; mali_pp_all_dir = debugfs_create_dir("all", mali_pp_dir); if (mali_pp_all_dir != NULL) { debugfs_create_file("counter_src0", 0400, mali_pp_all_dir, NULL, &pp_all_counter_src0_fops); debugfs_create_file("counter_src1", 0400, mali_pp_all_dir, NULL, &pp_all_counter_src1_fops); } 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) { char buf[16]; struct dentry *mali_pp_ppx_dir; _mali_osk_snprintf(buf, sizeof(buf), "pp%u", mali_pp_core_get_id(pp_core)); mali_pp_ppx_dir = debugfs_create_dir(buf, mali_pp_dir); if (NULL != mali_pp_ppx_dir) { debugfs_create_file("counter_src0", 0600, mali_pp_ppx_dir, pp_core, &pp_ppx_counter_src0_fops); debugfs_create_file("counter_src1", 0600, mali_pp_ppx_dir, pp_core, &pp_ppx_counter_src1_fops); } } /* try next group */ gi++; group = mali_cluster_get_group(cluster, gi); } /* try next cluster */ ci++; cluster = mali_cluster_get_global_cluster(ci); } } mali_l2_dir = debugfs_create_dir("l2", mali_debugfs_dir); if (mali_l2_dir != NULL) { struct dentry *mali_l2_all_dir; u32 l2_id; struct mali_l2_cache_core *l2_cache; mali_l2_all_dir = debugfs_create_dir("all", mali_l2_dir); if (mali_l2_all_dir != NULL) { debugfs_create_file("counter_src0", 0400, mali_l2_all_dir, NULL, &l2_all_counter_src0_fops); debugfs_create_file("counter_src1", 0400, mali_l2_all_dir, NULL, &l2_all_counter_src1_fops); } l2_id = 0; l2_cache = mali_l2_cache_core_get_glob_l2_core(l2_id); while (NULL != l2_cache) { char buf[16]; struct dentry *mali_l2_l2x_dir; _mali_osk_snprintf(buf, sizeof(buf), "l2%u", l2_id); mali_l2_l2x_dir = debugfs_create_dir(buf, mali_l2_dir); if (NULL != mali_l2_l2x_dir) { debugfs_create_file("counter_src0", 0600, mali_l2_l2x_dir, l2_cache, &l2_l2x_counter_src0_fops); debugfs_create_file("counter_src1", 0600, mali_l2_l2x_dir, l2_cache, &l2_l2x_counter_src1_fops); } /* try next L2 */ l2_id++; l2_cache = mali_l2_cache_core_get_glob_l2_core(l2_id); } } debugfs_create_file("memory_usage", 0400, mali_debugfs_dir, NULL, &memory_usage_fops); #if MALI_INTERNAL_TIMELINE_PROFILING_ENABLED mali_profiling_dir = debugfs_create_dir("profiling", mali_debugfs_dir); if (mali_profiling_dir != NULL) { struct dentry *mali_profiling_proc_dir = debugfs_create_dir("proc", mali_profiling_dir); if (mali_profiling_proc_dir != NULL) { struct dentry *mali_profiling_proc_default_dir = debugfs_create_dir("default", mali_profiling_proc_dir); if (mali_profiling_proc_default_dir != NULL) { debugfs_create_file("enable", 0600, mali_profiling_proc_default_dir, (void*)_MALI_UK_USER_SETTING_SW_EVENTS_ENABLE, &user_settings_fops); } } debugfs_create_file("record", 0600, mali_profiling_dir, NULL, &profiling_record_fops); debugfs_create_file("events", 0400, mali_profiling_dir, NULL, &profiling_events_fops); } #endif #if MALI_STATE_TRACKING debugfs_create_file("state_dump", 0400, mali_debugfs_dir, NULL, &mali_seq_internal_state_fops); #endif if (mali_sysfs_user_settings_register()) { /* Failed to create the debugfs entries for the user settings DB. */ MALI_DEBUG_PRINT(2, ("Failed to create user setting debugfs files. Ignoring...\n")); } } } /* Success! */ return 0; /* Error handling */ init_mdev_err: class_destroy(device->mali_class); init_class_err: return err; }