void malipmm_kernel_subsystem_terminate( mali_kernel_subsystem_identifier id ) { /* Check this is the right system */ MALI_DEBUG_ASSERT( id == mali_subsystem_pmm_id ); MALI_DEBUG_ASSERT_POINTER(pmm_state); if( pmm_state ) { _mali_osk_resource_type_t t = PMU; #if PMM_OS_TEST power_test_end(); #endif /* Get the lock so we can shutdown */ MALI_PMM_LOCK(pmm_state); pmm_state->status = MALI_PMM_STATUS_OFF; MALI_PMM_UNLOCK(pmm_state); pmm_policy_term(pmm_state); _mali_osk_irq_term( pmm_state->irq ); #ifdef CONFIG_SMP _mali_osk_lock_term(mali_pmm_lock); #endif /* CONFIG_SMP */ _mali_osk_notification_queue_term( pmm_state->queue ); _mali_osk_notification_queue_term( pmm_state->iqueue ); if( pmm_state->pmu_initialized ) mali_platform_deinit(&t); _mali_osk_atomic_term( &(pmm_state->messages_queued) ); MALI_PMM_LOCK_TERM(pmm_state); _mali_osk_free(pmm_state); pmm_state = NULL; } MALIPMM_DEBUG_PRINT( ("PMM: subsystem terminated\n") ); }
void mali_pp_delete(struct mali_pp_core *core) { u32 i; MALI_DEBUG_ASSERT_POINTER(core); _mali_osk_irq_term(core->irq); mali_hw_core_delete(&core->hw_core); /* Remove core from global list */ for (i = 0; i < mali_global_num_pp_cores; i++) { if (mali_global_pp_cores[i] == core) { mali_global_pp_cores[i] = NULL; mali_global_num_pp_cores--; if (i != mali_global_num_pp_cores) { /* We removed a PP core from the middle of the array -- move the last * PP core to the current position to close the gap */ mali_global_pp_cores[i] = mali_global_pp_cores[mali_global_num_pp_cores]; mali_global_pp_cores[mali_global_num_pp_cores] = NULL; } break; } } _mali_osk_free(core); }
void mali_mmu_delete(struct mali_mmu_core *mmu) { mali_mmu_raw_reset(mmu); _mali_osk_irq_term(mmu->irq); mali_hw_core_delete(&mmu->hw_core); _mali_osk_free(mmu); }
void mali_gp_delete(struct mali_gp_core *core) { MALI_DEBUG_ASSERT_POINTER(core); _mali_osk_irq_term(core->irq); mali_hw_core_delete(&core->hw_core); mali_global_gp_core = NULL; _mali_osk_free(core); }
void mali_mmu_delete(struct mali_mmu_core *mmu) { if (NULL != mmu->irq) { _mali_osk_irq_term(mmu->irq); } mali_hw_core_delete(&mmu->hw_core); _mali_osk_free(mmu); }
void mali_pm_terminate(void) { mali_platform_deinit(); _mali_osk_irq_term(wq_irq); _mali_osk_timer_del(idle_timer); _mali_osk_timer_term(idle_timer); _mali_osk_lock_term(mali_pm_lock_execute_state_change); _mali_osk_lock_term(mali_pm_lock_set_next_state); _mali_osk_lock_term(mali_pm_lock_set_core_states); }
_mali_osk_errcode_t mali_pm_initialize(void) { mali_pm_lock_execute_state_change = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ORDERED | _MALI_OSK_LOCKFLAG_ORDERED |_MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_PM_EXECUTE); if (NULL != mali_pm_lock_execute_state_change ) { mali_pm_lock_set_next_state = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ONELOCK| _MALI_OSK_LOCKFLAG_SPINLOCK_IRQ |_MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_LAST); if (NULL != mali_pm_lock_set_next_state) { mali_pm_lock_set_core_states = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_ORDERED | _MALI_OSK_LOCKFLAG_NONINTERRUPTABLE, 0, _MALI_OSK_LOCK_ORDER_PM_CORE_STATE); if (NULL != mali_pm_lock_set_core_states) { idle_timer = _mali_osk_timer_init(); if (NULL != idle_timer) { wq_irq = _mali_osk_irq_init(_MALI_OSK_IRQ_NUMBER_PMM, mali_pm_upper_half, mali_pm_bottom_half, NULL, NULL, (void *)NULL, "Mali PM deferred work"); if (NULL != wq_irq) { if (_MALI_OSK_ERR_OK == mali_platform_init()) { #if MALI_PMM_RUNTIME_JOB_CONTROL_ON _mali_osk_pm_dev_enable(); mali_pm_powerup(); #endif return _MALI_OSK_ERR_OK; } _mali_osk_irq_term(wq_irq); } _mali_osk_timer_del(idle_timer); _mali_osk_timer_term(idle_timer); } _mali_osk_lock_term(mali_pm_lock_set_core_states); } _mali_osk_lock_term(mali_pm_lock_set_next_state); } _mali_osk_lock_term(mali_pm_lock_execute_state_change); } return _MALI_OSK_ERR_FAULT; }
void malipmm_kernel_subsystem_terminate( mali_kernel_subsystem_identifier id ) { /* Check this is the right system */ MALI_DEBUG_ASSERT( id == mali_subsystem_pmm_id ); MALI_DEBUG_ASSERT_POINTER(pmm_state); if( pmm_state ) { #if PMM_OS_TEST power_test_end(); #endif /* Get the lock so we can shutdown */ MALI_PMM_LOCK(pmm_state); #if MALI_STATE_TRACKING pmm_state->mali_pmm_lock_acquired = 1; #endif /* MALI_STATE_TRACKING */ pmm_state->status = MALI_PMM_STATUS_OFF; #if MALI_STATE_TRACKING pmm_state->mali_pmm_lock_acquired = 0; #endif /* MALI_STATE_TRACKING */ MALI_PMM_UNLOCK(pmm_state); _mali_osk_pmm_ospmm_cleanup(); pmm_policy_term(pmm_state); _mali_osk_irq_term( pmm_state->irq ); _mali_osk_notification_queue_term( pmm_state->queue ); _mali_osk_notification_queue_term( pmm_state->iqueue ); if (pmm_state->cores_registered) malipmm_powerdown(pmm_state->cores_registered,MALI_POWER_MODE_LIGHT_SLEEP); #if USING_MALI_PMU if( pmm_state->pmu_initialized ) { _mali_osk_resource_type_t t = PMU; mali_pmm_pmu_deinit(&t); } #endif /* USING_MALI_PMU */ _mali_osk_atomic_term( &(pmm_state->messages_queued) ); MALI_PMM_LOCK_TERM(pmm_state); _mali_osk_free(pmm_state); pmm_state = NULL; } MALIPMM_DEBUG_PRINT( ("PMM: subsystem terminated\n") ); }
void mali_pp_delete(struct mali_pp_core *core) { u32 i; MALI_DEBUG_ASSERT_POINTER(core); _mali_osk_irq_term(core->irq); mali_hw_core_delete(&core->hw_core); /* Remove core from global list */ for (i = 0; i < MALI_MAX_NUMBER_OF_PP_CORES; i++) { if (mali_global_pp_cores[i] == core) { mali_global_pp_cores[i] = NULL; mali_global_num_pp_cores--; break; } } _mali_osk_free(core); }
void mali_pp_delete(struct mali_pp_core *core) { u32 i; MALI_DEBUG_ASSERT_POINTER(core); _mali_osk_timer_term(core->timeout_timer); _mali_osk_irq_term(core->irq); mali_hw_core_delete(&core->hw_core); for (i = 0; i < mali_global_num_pp_cores; i++) { if (mali_global_pp_cores[i] == core) { mali_global_pp_cores[i] = NULL; mali_global_num_pp_cores--; break; } } _mali_osk_free(core); }
_mali_osk_errcode_t malipmm_create(_mali_osk_resource_t *resource) { /* Create PMM state memory */ MALI_DEBUG_ASSERT( pmm_state == NULL ); pmm_state = (_mali_pmm_internal_state_t *) _mali_osk_malloc(sizeof(*pmm_state)); MALI_CHECK_NON_NULL( pmm_state, _MALI_OSK_ERR_NOMEM ); /* All values get 0 as default */ _mali_osk_memset(pmm_state, 0, sizeof(*pmm_state)); /* Set up the initial PMM state */ pmm_state->waiting = 0; pmm_state->status = MALI_PMM_STATUS_IDLE; pmm_state->state = MALI_PMM_STATE_UNAVAILABLE; /* Until a core registers */ /* Set up policy via compile time option for the moment */ #if MALI_PMM_ALWAYS_ON pmm_state->policy = MALI_PMM_POLICY_ALWAYS_ON; #else pmm_state->policy = MALI_PMM_POLICY_JOB_CONTROL; #endif #if MALI_PMM_TRACE _mali_pmm_trace_policy_change( MALI_PMM_POLICY_NONE, pmm_state->policy ); #endif /* Set up assumes all values are initialized to NULL or MALI_FALSE, so * we can exit halfway through set up and perform clean up */ #if !MALI_PMM_NO_PMU if( mali_platform_init(resource) != _MALI_OSK_ERR_OK ) goto pmm_fail_cleanup; pmm_state->pmu_initialized = MALI_TRUE; #endif pmm_state->queue = _mali_osk_notification_queue_init(); if( !pmm_state->queue ) goto pmm_fail_cleanup; pmm_state->iqueue = _mali_osk_notification_queue_init(); if( !pmm_state->iqueue ) goto pmm_fail_cleanup; /* We are creating an IRQ handler just for the worker thread it gives us */ pmm_state->irq = _mali_osk_irq_init( _MALI_OSK_IRQ_NUMBER_PMM, malipmm_irq_uhandler, malipmm_irq_bhandler, NULL, NULL, (void *)pmm_state, /* PMM state is passed to IRQ */ "PMM handler" ); if( !pmm_state->irq ) goto pmm_fail_cleanup; #ifdef CONFIG_SMP mali_pmm_lock = _mali_osk_lock_init((_mali_osk_lock_flags_t)( _MALI_OSK_LOCKFLAG_READERWRITER | _MALI_OSK_LOCKFLAG_ORDERED), 0, 0); if( !mali_pmm_lock ) goto pmm_fail_cleanup; #endif /* CONFIG_SMP */ pmm_state->lock = _mali_osk_lock_init((_mali_osk_lock_flags_t)(_MALI_OSK_LOCKFLAG_READERWRITER | _MALI_OSK_LOCKFLAG_ORDERED), 0, 75); if( !pmm_state->lock ) goto pmm_fail_cleanup; if( _mali_osk_atomic_init( &(pmm_state->messages_queued), 0 ) != _MALI_OSK_ERR_OK ) { goto pmm_fail_cleanup; } MALIPMM_DEBUG_PRINT( ("PMM: subsystem created, policy=%d\n", pmm_state->policy) ); MALI_SUCCESS; pmm_fail_cleanup: MALI_PRINT_ERROR( ("PMM: subsystem failed to be created\n") ); if( pmm_state ) { _mali_osk_resource_type_t t = PMU; if( pmm_state->lock ) _mali_osk_lock_term( pmm_state->lock ); if( pmm_state->irq ) _mali_osk_irq_term( pmm_state->irq ); if( pmm_state->queue ) _mali_osk_notification_queue_term( pmm_state->queue ); if( pmm_state->iqueue ) _mali_osk_notification_queue_term( pmm_state->iqueue ); if( pmm_state->pmu_initialized ) ( mali_platform_deinit(&t) ); _mali_osk_free(pmm_state); pmm_state = NULL; } MALI_ERROR( _MALI_OSK_ERR_FAULT ); }
struct mali_pp_core *mali_pp_create(const _mali_osk_resource_t *resource, struct mali_group *group) { struct mali_pp_core* core = NULL; MALI_DEBUG_PRINT(2, ("Mali PP: Creating Mali PP core: %s\n", resource->description)); MALI_DEBUG_PRINT(2, ("Mali PP: Base address of PP core: 0x%x\n", resource->base)); if (mali_global_num_pp_cores >= MALI_MAX_NUMBER_OF_PP_CORES) { MALI_PRINT_ERROR(("Mali PP: Too many PP core objects created\n")); return NULL; } core = _mali_osk_malloc(sizeof(struct mali_pp_core)); if (NULL != core) { core->group = group; core->core_id = mali_global_num_pp_cores; core->running_job = NULL; core->counter_src0 = MALI_HW_CORE_NO_COUNTER; core->counter_src1 = MALI_HW_CORE_NO_COUNTER; core->counter_src0_used = MALI_HW_CORE_NO_COUNTER; core->counter_src1_used = MALI_HW_CORE_NO_COUNTER; if (_MALI_OSK_ERR_OK == mali_hw_core_create(&core->hw_core, resource, MALI200_REG_SIZEOF_REGISTER_BANK)) { _mali_osk_errcode_t ret; mali_group_lock(group); ret = mali_pp_reset(core); mali_group_unlock(group); if (_MALI_OSK_ERR_OK == ret) { /* Setup IRQ handlers (which will do IRQ probing if needed) */ core->irq = _mali_osk_irq_init(resource->irq, mali_pp_upper_half, mali_pp_bottom_half, mali_pp_irq_probe_trigger, mali_pp_irq_probe_ack, core, "mali_pp_irq_handlers"); if (NULL != core->irq) { /* Initialise the timeout timer */ core->timeout_timer = _mali_osk_timer_init(); if(NULL != core->timeout_timer) { _mali_osk_timer_setcallback(core->timeout_timer, mali_pp_timeout, (void *)core); mali_global_pp_cores[mali_global_num_pp_cores] = core; mali_global_num_pp_cores++; return core; } else { MALI_PRINT_ERROR(("Failed to setup timeout timer for PP core %s\n", core->hw_core.description)); /* Release IRQ handlers */ _mali_osk_irq_term(core->irq); } } else { MALI_PRINT_ERROR(("Mali PP: Failed to setup interrupt handlers for PP core %s\n", core->hw_core.description)); } } mali_hw_core_delete(&core->hw_core); } _mali_osk_free(core); } else { MALI_PRINT_ERROR(("Mali PP: Failed to allocate memory for PP core\n")); } return NULL; }
struct mali_gp_core *mali_gp_create(const _mali_osk_resource_t * resource, struct mali_group *group) { struct mali_gp_core* core = NULL; MALI_DEBUG_ASSERT(NULL == mali_global_gp_core); MALI_DEBUG_PRINT(2, ("Mali GP: Creating Mali GP core: %s\n", resource->description)); core = _mali_osk_malloc(sizeof(struct mali_gp_core)); if (NULL != core) { core->group = group; core->running_job = NULL; core->counter_src0 = MALI_HW_CORE_NO_COUNTER; core->counter_src1 = MALI_HW_CORE_NO_COUNTER; core->counter_src0_used = MALI_HW_CORE_NO_COUNTER; core->counter_src1_used = MALI_HW_CORE_NO_COUNTER; if (_MALI_OSK_ERR_OK == mali_hw_core_create(&core->hw_core, resource, MALIGP2_REGISTER_ADDRESS_SPACE_SIZE)) { _mali_osk_errcode_t ret; mali_group_lock(group); ret = mali_gp_reset(core); mali_group_unlock(group); if (_MALI_OSK_ERR_OK == ret) { core->irq = _mali_osk_irq_init(resource->irq, mali_gp_upper_half, mali_gp_bottom_half, mali_gp_irq_probe_trigger, mali_gp_irq_probe_ack, core, "mali_gp_irq_handlers"); if (NULL != core->irq) { core->timeout_timer = _mali_osk_timer_init(); if(NULL != core->timeout_timer) { _mali_osk_timer_setcallback(core->timeout_timer, mali_gp_timeout, (void *)core); MALI_DEBUG_PRINT(4, ("Mali GP: set global gp core from 0x%08X to 0x%08X\n", mali_global_gp_core, core)); mali_global_gp_core = core; return core; } else { MALI_PRINT_ERROR(("Failed to setup timeout timer for GP core %s\n", core->hw_core.description)); _mali_osk_irq_term(core->irq); } } else { MALI_PRINT_ERROR(("Failed to setup interrupt handlers for GP core %s\n", core->hw_core.description)); } } mali_hw_core_delete(&core->hw_core); } _mali_osk_free(core); } else { MALI_PRINT_ERROR(("Failed to allocate memory for GP core\n")); } return NULL; }