/** Function to handle a GPU state change for the demand power policy * * This function is called whenever the GPU has transitioned to another state. It first checks that the transition is * complete and then moves the state machine to the next state. */ static void demand_state_changed(kbase_device *kbdev) { kbasep_pm_policy_demand *data = &kbdev->pm.policy_data.demand; switch(data->state) { case KBASEP_PM_DEMAND_STATE_CHANGING_POLICY: case KBASEP_PM_DEMAND_STATE_POWERING_UP: case KBASEP_PM_DEMAND_STATE_POWERING_DOWN: if (kbase_pm_get_pwr_active(kbdev)) { /* Cores are still transitioning - ignore the event */ return; } break; default: /* Must not call kbase_pm_get_pwr_active here as the clock may be turned off */ break; } switch(data->state) { case KBASEP_PM_DEMAND_STATE_CHANGING_POLICY: /* Signal power events before switching the policy */ kbase_pm_power_up_done(kbdev); kbase_pm_power_down_done(kbdev); kbase_pm_change_policy(kbdev); break; case KBASEP_PM_DEMAND_STATE_POWERING_UP: data->state = KBASEP_PM_DEMAND_STATE_POWERED_UP; kbase_pm_power_up_done(kbdev); /* State changed, try to run jobs */ kbase_js_try_run_jobs(kbdev); break; case KBASEP_PM_DEMAND_STATE_POWERING_DOWN: data->state = KBASEP_PM_DEMAND_STATE_POWERED_DOWN; /* Disable interrupts and turn the clock off */ kbase_pm_disable_interrupts(kbdev); kbase_pm_clock_off(kbdev); kbase_pm_power_down_done(kbdev); break; case KBASEP_PM_DEMAND_STATE_POWERED_UP: /* Core states may have been changed, try to run jobs */ kbase_js_try_run_jobs(kbdev); break; default: break; } }
/** Function to handle a GPU state change for the always_on power policy. * * This function is called whenever the GPU has transitioned to another state. It first checks that the transition is * complete and then moves the state machine to the next state. * * @param kbdev The kbase device structure for the device */ static void always_on_state_changed(kbase_device *kbdev) { kbasep_pm_policy_always_on *data = &kbdev->pm.policy_data.always_on; switch(data->state) { case KBASEP_PM_ALWAYS_ON_STATE_POWERING_UP: if (kbase_pm_get_pwr_active(kbdev)) { /* Cores still transitioning */ return; } /* All cores have transitioned, inform the OS */ kbase_pm_power_up_done(kbdev); data->state = KBASEP_PM_ALWAYS_ON_STATE_POWERED_UP; break; case KBASEP_PM_ALWAYS_ON_STATE_POWERING_DOWN: if (kbase_pm_get_pwr_active(kbdev)) { /* Cores still transitioning */ return; } /* All cores have transitioned, turn the clock and interrupts off */ kbase_pm_disable_interrupts(kbdev); kbase_pm_clock_off(kbdev); /* Inform the OS */ kbase_pm_power_down_done(kbdev); data->state = KBASEP_PM_ALWAYS_ON_STATE_POWERED_DOWN; break; case KBASEP_PM_ALWAYS_ON_STATE_CHANGING_POLICY: if (kbase_pm_get_pwr_active(kbdev)) { /* Cores still transitioning */ return; } /* All cores have transitioned, inform the system we can change policy*/ kbase_pm_change_policy(kbdev); break; default: break; } }