_mali_osk_errcode_t _mali_ukk_release_ump_mem(_mali_uk_release_ump_mem_s *args) { mali_mem_allocation * descriptor; struct mali_session_data *session; MALI_DEBUG_ASSERT_POINTER(args); MALI_CHECK_NON_NULL(args->ctx, _MALI_OSK_ERR_INVALID_ARGS); session = (struct mali_session_data *)args->ctx; MALI_CHECK_NON_NULL(session, _MALI_OSK_ERR_INVALID_ARGS); if (_MALI_OSK_ERR_OK != mali_descriptor_mapping_get(session->descriptor_mapping, args->cookie, (void**)&descriptor)) { MALI_DEBUG_PRINT(1, ("Invalid memory descriptor %d used to release ump memory\n", args->cookie)); MALI_ERROR(_MALI_OSK_ERR_FAULT); } descriptor = mali_descriptor_mapping_free(session->descriptor_mapping, args->cookie); if (NULL != descriptor) { _mali_osk_mutex_wait(session->memory_lock); mali_mem_ump_release(descriptor); _mali_osk_mutex_signal(session->memory_lock); mali_mem_descriptor_destroy(descriptor); } MALI_SUCCESS; }
static void mali_mem_vma_close(struct vm_area_struct *vma) { mali_mem_allocation *descriptor; struct mali_session_data *session; mali_mem_virt_cpu_mapping *mapping; MALI_DEBUG_PRINT(3, ("Close called on vma %p\n", vma)); descriptor = (mali_mem_allocation *)vma->vm_private_data; BUG_ON(!descriptor); MALI_DEBUG_ASSERT(MALI_MEM_ALLOCATION_VALID_MAGIC == descriptor->magic); mapping = &descriptor->cpu_mapping; BUG_ON(0 == mapping->ref); mapping->ref--; if (0 != mapping->ref) { MALI_DEBUG_PRINT(3, ("Ignoring this close, %d references still exists\n", mapping->ref)); return; } session = descriptor->session; mali_descriptor_mapping_free(session->descriptor_mapping, descriptor->id); _mali_osk_mutex_wait(session->memory_lock); mali_mem_release(descriptor); _mali_osk_mutex_signal(session->memory_lock); mali_mem_descriptor_destroy(descriptor); }