_mali_osk_errcode_t _mali_internal_profiling_start(u32 * limit) { _mali_osk_errcode_t ret; mali_profiling_entry *new_profile_entries; _mali_osk_mutex_wait(lock); if (MALI_PROFILING_STATE_RUNNING == prof_state) { _mali_osk_mutex_signal(lock); return _MALI_OSK_ERR_BUSY; } new_profile_entries = _mali_osk_valloc(*limit * sizeof(mali_profiling_entry)); if (NULL == new_profile_entries) { _mali_osk_vfree(new_profile_entries); return _MALI_OSK_ERR_NOMEM; } if (MALI_PROFILING_MAX_BUFFER_ENTRIES < *limit) { *limit = MALI_PROFILING_MAX_BUFFER_ENTRIES; } profile_mask = 1; while (profile_mask <= *limit) { profile_mask <<= 1; } profile_mask >>= 1; *limit = profile_mask; profile_mask--; /* turns the power of two into a mask of one less */ if (MALI_PROFILING_STATE_IDLE != prof_state) { _mali_osk_mutex_signal(lock); _mali_osk_vfree(new_profile_entries); return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */ } profile_entries = new_profile_entries; ret = _mali_timestamp_reset(); if (_MALI_OSK_ERR_OK == ret) { prof_state = MALI_PROFILING_STATE_RUNNING; } else { _mali_osk_vfree(profile_entries); profile_entries = NULL; } register_trace_mali_timeline_event(probe_mali_timeline_event, NULL); _mali_osk_mutex_signal(lock); return ret; }
inline _mali_osk_errcode_t _mali_osk_profiling_start(u32 * limit) { _mali_osk_errcode_t ret; mali_profiling_entry *new_profile_entries = _mali_osk_valloc(*limit * sizeof(mali_profiling_entry)); if(NULL == new_profile_entries) { return _MALI_OSK_ERR_NOMEM; } _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW); if (prof_state != MALI_PROFILING_STATE_IDLE) { _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); _mali_osk_vfree(new_profile_entries); return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */ } if (*limit > MALI_PROFILING_MAX_BUFFER_ENTRIES) { *limit = MALI_PROFILING_MAX_BUFFER_ENTRIES; } profile_entries = new_profile_entries; profile_entry_count = *limit; ret = _mali_timestamp_reset(); if (ret == _MALI_OSK_ERR_OK) { prof_state = MALI_PROFILING_STATE_RUNNING; } else { _mali_osk_vfree(profile_entries); profile_entries = NULL; } _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); return ret; }
int mem_dump_mmu_page_table_wrapper(struct mali_session_data *session_data, _mali_uk_dump_mmu_page_table_s __user * uargs) { _mali_uk_dump_mmu_page_table_s kargs; _mali_osk_errcode_t err; void *buffer; int rc = -EFAULT; /* validate input */ MALI_CHECK_NON_NULL(uargs, -EINVAL); /* the session_data pointer was validated by caller */ kargs.buffer = NULL; /* get location of user buffer */ if (0 != get_user(buffer, &uargs->buffer)) goto err_exit; /* get size of mmu page table info buffer from user space */ if ( 0 != get_user(kargs.size, &uargs->size) ) goto err_exit; /* verify we can access the whole of the user buffer */ if (!access_ok(VERIFY_WRITE, buffer, kargs.size)) goto err_exit; /* allocate temporary buffer (kernel side) to store mmu page table info */ MALI_CHECK(kargs.size > 0, -ENOMEM); kargs.buffer = _mali_osk_valloc(kargs.size); if (NULL == kargs.buffer) { rc = -ENOMEM; goto err_exit; } kargs.ctx = session_data; err = _mali_ukk_dump_mmu_page_table(&kargs); if (_MALI_OSK_ERR_OK != err) { rc = map_errcode(err); goto err_exit; } /* copy mmu page table info back to user space and update pointers */ if (0 != copy_to_user(uargs->buffer, kargs.buffer, kargs.size) ) goto err_exit; if (0 != put_user((kargs.register_writes - (u32 *)kargs.buffer) + (u32 *)uargs->buffer, &uargs->register_writes)) goto err_exit; if (0 != put_user((kargs.page_table_dump - (u32 *)kargs.buffer) + (u32 *)uargs->buffer, &uargs->page_table_dump)) goto err_exit; if (0 != put_user(kargs.register_writes_size, &uargs->register_writes_size)) goto err_exit; if (0 != put_user(kargs.page_table_dump_size, &uargs->page_table_dump_size)) goto err_exit; rc = 0; err_exit: if (kargs.buffer) _mali_osk_vfree(kargs.buffer); return rc; }
int mem_dump_mmu_page_table_wrapper(struct mali_session_data *session_data, _mali_uk_dump_mmu_page_table_s __user * uargs) { _mali_uk_dump_mmu_page_table_s kargs; _mali_osk_errcode_t err; void *buffer; int rc = -EFAULT; MALI_CHECK_NON_NULL(uargs, -EINVAL); kargs.buffer = NULL; if (0 != get_user(buffer, &uargs->buffer)) goto err_exit; if ( 0 != get_user(kargs.size, &uargs->size) ) goto err_exit; if (!access_ok(VERIFY_WRITE, buffer, kargs.size)) goto err_exit; kargs.buffer = _mali_osk_valloc(kargs.size); if (NULL == kargs.buffer) { rc = -ENOMEM; goto err_exit; } kargs.ctx = session_data; err = _mali_ukk_dump_mmu_page_table(&kargs); if (_MALI_OSK_ERR_OK != err) { rc = map_errcode(err); goto err_exit; } if (0 != copy_to_user(uargs->buffer, kargs.buffer, kargs.size) ) goto err_exit; if (0 != put_user((kargs.register_writes - (u32 *)kargs.buffer) + (u32 *)uargs->buffer, &uargs->register_writes)) goto err_exit; if (0 != put_user((kargs.page_table_dump - (u32 *)kargs.buffer) + (u32 *)uargs->buffer, &uargs->page_table_dump)) goto err_exit; if (0 != put_user(kargs.register_writes_size, &uargs->register_writes_size)) goto err_exit; if (0 != put_user(kargs.page_table_dump_size, &uargs->page_table_dump_size)) goto err_exit; rc = 0; err_exit: if (kargs.buffer) _mali_osk_vfree(kargs.buffer); return rc; }
void _mali_internal_profiling_term(void) { u32 count; /* Ensure profiling is stopped */ _mali_internal_profiling_stop(&count); prof_state = MALI_PROFILING_STATE_UNINITIALIZED; if (NULL != profile_entries) { _mali_osk_vfree(profile_entries); profile_entries = NULL; } if (NULL != lock) { _mali_osk_mutex_term(lock); lock = NULL; } }
_mali_osk_errcode_t _mali_internal_profiling_clear(void) { _mali_osk_mutex_wait(lock); if (MALI_PROFILING_STATE_RETURN != prof_state) { _mali_osk_mutex_signal(lock); return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */ } prof_state = MALI_PROFILING_STATE_IDLE; profile_mask = 0; _mali_osk_atomic_init(&profile_insert_index, 0); if (NULL != profile_entries) { _mali_osk_vfree(profile_entries); profile_entries = NULL; } _mali_osk_mutex_signal(lock); return _MALI_OSK_ERR_OK; }
void _mali_osk_profiling_term(void) { prof_state = MALI_PROFILING_STATE_UNINITIALIZED; /* wait for all elements to be completely inserted into array */ while (_mali_osk_atomic_read(&profile_insert_index) != _mali_osk_atomic_read(&profile_entries_written)) { /* do nothing */; } if (NULL != profile_entries) { _mali_osk_vfree(profile_entries); profile_entries = NULL; } if (NULL != lock) { _mali_osk_lock_term(lock); lock = NULL; } }
inline _mali_osk_errcode_t _mali_osk_profiling_clear(void) { _mali_osk_lock_wait(lock, _MALI_OSK_LOCKMODE_RW); if (prof_state != MALI_PROFILING_STATE_RETURN) { _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); return _MALI_OSK_ERR_INVALID_ARGS; /* invalid to call this function in this state */ } prof_state = MALI_PROFILING_STATE_IDLE; profile_entry_count = 0; _mali_osk_atomic_init(&profile_insert_index, 0); _mali_osk_atomic_init(&profile_entries_written, 0); if (NULL != profile_entries) { _mali_osk_vfree(profile_entries); profile_entries = NULL; } _mali_osk_lock_signal(lock, _MALI_OSK_LOCKMODE_RW); return _MALI_OSK_ERR_OK; }