diff options
Diffstat (limited to 'drivers/media/video/samsung/mali/linux/mali_osk_pm.c')
-rw-r--r-- | drivers/media/video/samsung/mali/linux/mali_osk_pm.c | 204 |
1 files changed, 39 insertions, 165 deletions
diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_pm.c b/drivers/media/video/samsung/mali/linux/mali_osk_pm.c index 2438cbc..20fb7b4 100644 --- a/drivers/media/video/samsung/mali/linux/mali_osk_pm.c +++ b/drivers/media/video/samsung/mali/linux/mali_osk_pm.c @@ -1,5 +1,5 @@ -/* - * Copyright (C) 2010 ARM Limited. All rights reserved. +/** + * Copyright (C) 2010-2012 ARM Limited. All rights reserved. * * This program is free software and is provided to you under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence. @@ -18,193 +18,67 @@ #ifdef CONFIG_PM_RUNTIME #include <linux/pm_runtime.h> #endif /* CONFIG_PM_RUNTIME */ - #include <linux/platform_device.h> - #include "mali_platform.h" #include "mali_osk.h" #include "mali_uk_types.h" -#include "mali_pmm.h" #include "mali_kernel_common.h" #include "mali_kernel_license.h" #include "mali_linux_pm.h" -#include "mali_linux_pm_testsuite.h" - -#if MALI_LICENSE_IS_GPL -#if MALI_PMM_RUNTIME_JOB_CONTROL_ON -#ifdef CONFIG_PM_RUNTIME -static int is_runtime =0; -#endif /* CONFIG_PM_RUNTIME */ -#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */ -#endif /* MALI_LICENSE_IS_GPL */ - -#if MALI_POWER_MGMT_TEST_SUITE - -#ifdef CONFIG_PM -unsigned int mali_pmm_events_triggered_mask = 0; -#endif /* CONFIG_PM */ - -void _mali_osk_pmm_policy_events_notifications(mali_pmm_event_id mali_pmm_event) -{ -#if MALI_LICENSE_IS_GPL -#ifdef CONFIG_PM - - switch (mali_pmm_event) - { - case MALI_PMM_EVENT_JOB_QUEUED: - if (mali_job_scheduling_events_recording_on == 1) - { - mali_pmm_events_triggered_mask |= (1<<0); - } - break; - - case MALI_PMM_EVENT_JOB_SCHEDULED: - if (mali_job_scheduling_events_recording_on == 1) - { - mali_pmm_events_triggered_mask |= (1<<1); - } - break; - - case MALI_PMM_EVENT_JOB_FINISHED: - if (mali_job_scheduling_events_recording_on == 1) - { - mali_pmm_events_triggered_mask |= (1<<2); - mali_job_scheduling_events_recording_on = 0; - pwr_mgmt_status_reg = mali_pmm_events_triggered_mask; - } - break; - - case MALI_PMM_EVENT_TIMEOUT: - if (mali_timeout_event_recording_on == 1) - { - pwr_mgmt_status_reg = (1<<3); - mali_timeout_event_recording_on = 0; - } - break; - - default: +#include "mali_kernel_license.h" - break; +#if ! MALI_LICENSE_IS_GPL +#undef CONFIG_PM_RUNTIME +#endif - } -#endif /* CONFIG_PM */ +extern struct platform_device mali_gpu_device; -#endif /* MALI_LICENSE_IS_GPL */ -} -#endif /* MALI_POWER_MGMT_TEST_SUITE */ - -/** This function is called when the Mali device has completed power up - * operation. - */ -void _mali_osk_pmm_power_up_done(mali_pmm_message_data data) -{ -#if MALI_LICENSE_IS_GPL -#ifdef CONFIG_PM - is_wake_up_needed = 1; - wake_up_process(pm_thread); - MALI_DEBUG_PRINT(4, ("OSPMM: MALI OSK Power up Done\n" )); - return; -#endif /* CONFIG_PM */ -#endif /* MALI_LICENSE_IS_GPL */ -} +#ifdef CONFIG_PM_RUNTIME +static mali_bool have_runtime_reference = MALI_FALSE; +#endif -/** This function is called when the Mali device has completed power down - * operation. - */ -void _mali_osk_pmm_power_down_done(mali_pmm_message_data data) +void _mali_osk_pm_dev_enable(void) { -#if MALI_LICENSE_IS_GPL -#ifdef CONFIG_PM - is_wake_up_needed = 1; -#if MALI_POWER_MGMT_TEST_SUITE - if (is_mali_pmu_present == 0) - { - pwr_mgmt_status_reg = _mali_pmm_cores_list(); - } -#endif /* MALI_POWER_MGMT_TEST_SUITE */ - wake_up_process(pm_thread); - MALI_DEBUG_PRINT(4, ("OSPMM: MALI Power down Done\n" )); - return; - -#endif /* CONFIG_PM */ -#endif /* MALI_LICENSE_IS_GPL */ +#ifdef CONFIG_PM_RUNTIME + pm_runtime_enable(&(mali_gpu_device.dev)); +#endif } -/** This function is invoked when mali device is idle. -*/ -_mali_osk_errcode_t _mali_osk_pmm_dev_idle(void) +/* NB: Function is not thread safe */ +_mali_osk_errcode_t _mali_osk_pm_dev_idle(void) { - _mali_osk_errcode_t err = 0; -#if MALI_LICENSE_IS_GPL #ifdef CONFIG_PM_RUNTIME -#if MALI_PMM_RUNTIME_JOB_CONTROL_ON - err = pm_runtime_put_sync(&(mali_gpu_device.dev)); - if(err) + if (MALI_TRUE == have_runtime_reference) { - MALI_DEBUG_PRINT(4, ("OSPMM: Error in _mali_osk_pmm_dev_idle\n" )); + int err; + err = pm_runtime_put_sync(&(mali_gpu_device.dev)); + if (0 > err) + { + MALI_PRINT_ERROR(("OSK PM: pm_runtime_put_sync() returned error code %d\n", err)); + return _MALI_OSK_ERR_FAULT; + } + have_runtime_reference = MALI_FALSE; } -#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */ -#endif /* CONFIG_PM_RUNTIME */ -#endif /* MALI_LICENSE_IS_GPL */ - return err; +#endif + return _MALI_OSK_ERR_OK; } -/** This funtion is invoked when mali device needs to be activated. -*/ -int _mali_osk_pmm_dev_activate(void) +/* NB: Function is not thread safe */ +_mali_osk_errcode_t _mali_osk_pm_dev_activate(void) { - -#if MALI_LICENSE_IS_GPL #ifdef CONFIG_PM_RUNTIME -#if MALI_PMM_RUNTIME_JOB_CONTROL_ON - int err = 0; - if(is_runtime == 0) + if (MALI_TRUE != have_runtime_reference) { - pm_suspend_ignore_children(&(mali_gpu_device.dev), true); - pm_runtime_enable(&(mali_gpu_device.dev)); + int err; err = pm_runtime_get_sync(&(mali_gpu_device.dev)); - is_runtime = 1; - } - else - { - err = pm_runtime_get_sync(&(mali_gpu_device.dev)); - } - if(err < 0) - { - MALI_PRINT(("OSPMM: Error in _mali_osk_pmm_dev_activate, err : %d\n",err )); - } -#endif /* MALI_PMM_RUNTIME_JOB_CONTROL_ON */ -#endif /* CONFIG_PM_RUNTIME */ -#endif /* MALI_LICENSE_IS_GPL */ - - return err; -} - -void _mali_osk_pmm_ospmm_cleanup( void ) -{ -#if MALI_LICENSE_IS_GPL -#ifdef CONFIG_PM - int thread_state; - thread_state = mali_get_ospmm_thread_state(); - if (thread_state) - { - _mali_osk_pmm_dvfs_operation_done(0); + if (0 > err) + { + MALI_PRINT_ERROR(("OSK PM: pm_runtime_get_sync() returned error code %d\n", err)); + return _MALI_OSK_ERR_FAULT; + } + have_runtime_reference = MALI_TRUE; } -#endif /* CONFIG_PM */ -#endif /* MALI_LICENSE_IS_GPL */ +#endif + return _MALI_OSK_ERR_OK; } - -void _mali_osk_pmm_dvfs_operation_done(mali_pmm_message_data data) -{ -#if MALI_LICENSE_IS_GPL -#ifdef CONFIG_PM - is_wake_up_needed = 1; - wake_up_process(dvfs_pm_thread); - MALI_DEBUG_PRINT(4, ("OSPMM: MALI OSK DVFS Operation done\n" )); - return; -#endif /* CONFIG_PM */ -#endif /* MALI_LICENSE_IS_GPL */ -} - - |