void mali_mem_descriptor_destroy(mali_mem_allocation *descriptor) { MALI_DEBUG_ASSERT(MALI_MEM_ALLOCATION_VALID_MAGIC == descriptor->magic); MALI_DEBUG_CODE(descriptor->magic = MALI_MEM_ALLOCATION_FREED_MAGIC); kfree(descriptor); }
/* Prepare memory descriptor */ static mali_mem_allocation *mali_mem_allocation_struct_create(struct mali_session_data *session) { mali_mem_allocation *mali_allocation; /* Allocate memory */ mali_allocation = (mali_mem_allocation *)kzalloc(sizeof(mali_mem_allocation), GFP_KERNEL); if (NULL == mali_allocation) { MALI_DEBUG_PRINT(1, ("mali_mem_allocation_struct_create: descriptor was NULL\n")); return NULL; } MALI_DEBUG_CODE(mali_allocation->magic = MALI_MEM_ALLOCATION_VALID_MAGIC); /* do init */ mali_allocation->flags = 0; mali_allocation->session = session; INIT_LIST_HEAD(&mali_allocation->list); kref_init(&mali_allocation->ref); /** *add to session list */ mutex_lock(&session->allocation_mgr.list_mutex); list_add_tail(&mali_allocation->list, &session->allocation_mgr.head); session->allocation_mgr.mali_allocation_nr++; mutex_unlock(&session->allocation_mgr.list_mutex); return mali_allocation; }
MALI_STATIC_INLINE void mali_pp_scheduler_unlock(void) { MALI_DEBUG_PRINT(5, ("Mali PP scheduler: Releasing PP scheduler lock\n")); MALI_DEBUG_ASSERT(_mali_osk_get_tid() == pp_scheduler_lock_owner); MALI_DEBUG_CODE(pp_scheduler_lock_owner = 0); _mali_osk_lock_signal(pp_scheduler_lock, _MALI_OSK_LOCKMODE_RW); }
MALI_STATIC_INLINE void mali_soft_job_system_unlock(struct mali_soft_job_system *system) { MALI_DEBUG_ASSERT_POINTER(system); MALI_DEBUG_PRINT(5, ("Mali Soft Job: releasing soft system %p lock\n", system)); MALI_DEBUG_ASSERT(_mali_osk_get_tid() == system->lock_owner); MALI_DEBUG_CODE(system->lock_owner = 0); _mali_osk_spinlock_irq_unlock(system->lock); }
MALI_STATIC_INLINE void mali_soft_job_system_lock(struct mali_soft_job_system *system) { MALI_DEBUG_ASSERT_POINTER(system); _mali_osk_spinlock_irq_lock(system->lock); MALI_DEBUG_PRINT(5, ("Mali Soft Job: soft system %p lock taken\n", system)); MALI_DEBUG_ASSERT(0 == system->lock_owner); MALI_DEBUG_CODE(system->lock_owner = _mali_osk_get_tid()); }
MALI_STATIC_INLINE void mali_pp_scheduler_lock(void) { if(_MALI_OSK_ERR_OK != _mali_osk_lock_wait(pp_scheduler_lock, _MALI_OSK_LOCKMODE_RW)) { /* Non-interruptable lock failed: this should never happen. */ MALI_DEBUG_ASSERT(0); } MALI_DEBUG_PRINT(5, ("Mali PP scheduler: PP scheduler lock taken\n")); MALI_DEBUG_ASSERT(0 == pp_scheduler_lock_owner); MALI_DEBUG_CODE(pp_scheduler_lock_owner = _mali_osk_get_tid()); }
/* Prepare memory descriptor */ mali_mem_allocation *mali_mem_descriptor_create(struct mali_session_data *session, mali_mem_type type) { mali_mem_allocation *descriptor; descriptor = (mali_mem_allocation *)kzalloc(sizeof(mali_mem_allocation), GFP_KERNEL); if (NULL == descriptor) { MALI_DEBUG_PRINT(3, ("mali_ukk_mem_mmap: descriptor was NULL\n")); return NULL; } MALI_DEBUG_CODE(descriptor->magic = MALI_MEM_ALLOCATION_VALID_MAGIC); descriptor->flags = 0; descriptor->type = type; descriptor->session = session; return descriptor; }