From 3724682760ddddbb11453a79e5e9646198a1d98c Mon Sep 17 00:00:00 2001 From: Hyeonseong Gil Date: Fri, 18 May 2018 15:52:49 +0900 Subject: [PATCH] [RAMEN9610-8149] [COMMON] samsung: exynos-dm: Re-organize the mutex_lock with wrapper Change-Id: I8a078e58f623b2754c12867dc910fd026d87c0a0 Signed-off-by: Hyeonseong Gil --- drivers/devfreq/devfreq.c | 7 +++--- drivers/soc/samsung/exynos-dm.c | 44 +++++++++++++++++++++++++++------ include/soc/samsung/exynos-dm.h | 6 +++++ 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index b5f06fde0e9c..b3e7febc028c 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -332,11 +332,10 @@ int update_devfreq(struct devfreq *devfreq) pm_qos_max = (unsigned long)pm_qos_request(gov_data->pm_qos_class_max); #endif if (devfreq->str_freq) - policy_update_call_to_DM(dm_type, devfreq->str_freq, - devfreq->str_freq); + policy_update_with_DM_CALL(dm_type, devfreq->str_freq, + devfreq->str_freq, &freq); else - policy_update_call_to_DM(dm_type, freq, pm_qos_max); - DM_CALL(dm_type, &freq); + policy_update_with_DM_CALL(dm_type, freq, pm_qos_max, &freq); #else /* * Adjust the frequency with user freq and QoS. diff --git a/drivers/soc/samsung/exynos-dm.c b/drivers/soc/samsung/exynos-dm.c index d74026c0670c..779d49262288 100644 --- a/drivers/soc/samsung/exynos-dm.c +++ b/drivers/soc/samsung/exynos-dm.c @@ -661,7 +661,7 @@ static bool max_flag = false; #define POLICY_REQ 4 -int policy_update_call_to_DM(int dm_type, u32 min_freq, u32 max_freq) +static int __policy_update_call_to_DM(int dm_type, u32 min_freq, u32 max_freq) { struct exynos_dm_data *dm; struct timeval pre, before, after; @@ -676,7 +676,6 @@ int policy_update_call_to_DM(int dm_type, u32 min_freq, u32 max_freq) dbg_snapshot_dm((int)dm_type, min_freq, max_freq, pre_time, time); #endif do_gettimeofday(&pre); - mutex_lock(&exynos_dm->lock); do_gettimeofday(&before); min_freq = min(min_freq, max_freq); @@ -715,7 +714,6 @@ int policy_update_call_to_DM(int dm_type, u32 min_freq, u32 max_freq) out: do_gettimeofday(&after); - mutex_unlock(&exynos_dm->lock); pre_time = (before.tv_sec - pre.tv_sec) * USEC_PER_SEC + (before.tv_usec - pre.tv_usec); @@ -779,7 +777,7 @@ static int constraint_checker_max(struct list_head *head, u32 freq) /* * DM CALL */ -int DM_CALL(int dm_type, unsigned long *target_freq) +static int __DM_CALL(int dm_type, unsigned long *target_freq) { struct exynos_dm_data *dm; int i; @@ -793,7 +791,6 @@ int DM_CALL(int dm_type, unsigned long *target_freq) dbg_snapshot_dm((int)dm_type, *target_freq, 1, pre_time, time); #endif do_gettimeofday(&pre); - mutex_lock(&exynos_dm->lock); do_gettimeofday(&before); dm = &exynos_dm->dm_data[dm_type]; @@ -811,7 +808,6 @@ int DM_CALL(int dm_type, unsigned long *target_freq) ret = dm_data_updater(dm_type); if (ret) { pr_err("Failed to update DM DATA!\n"); - mutex_unlock(&exynos_dm->lock); return -EAGAIN; } @@ -846,7 +842,6 @@ int DM_CALL(int dm_type, unsigned long *target_freq) } do_gettimeofday(&after); - mutex_unlock(&exynos_dm->lock); pre_time = (before.tv_sec - pre.tv_sec) * USEC_PER_SEC + (before.tv_usec - pre.tv_usec); @@ -906,6 +901,41 @@ static int dm_data_updater(int dm_type) return 0; } + +int policy_update_call_to_DM(int dm_type, u32 min_freq, u32 max_freq) +{ + int ret = 0; + + mutex_lock(&exynos_dm->lock); + ret = __policy_update_call_to_DM(dm_type, min_freq, max_freq); + mutex_unlock(&exynos_dm->lock); + + return ret; +} + +int DM_CALL(int dm_type, unsigned long *target_freq) +{ + int ret = 0; + + mutex_lock(&exynos_dm->lock); + ret = __DM_CALL(dm_type, target_freq); + mutex_unlock(&exynos_dm->lock); + + return ret; +} + +int policy_update_with_DM_CALL(int dm_type, u32 min_freq, u32 max_freq, unsigned long *target_freq) +{ + int ret = 0; + + mutex_lock(&exynos_dm->lock); + __policy_update_call_to_DM(dm_type, min_freq, max_freq); + ret = __DM_CALL(dm_type, target_freq); + mutex_unlock(&exynos_dm->lock); + + return ret; +} + static int constraint_data_updater(int dm_type, int cnt) { struct exynos_dm_data *dm; diff --git a/include/soc/samsung/exynos-dm.h b/include/soc/samsung/exynos-dm.h index f4f87c0351e5..8858e6e10398 100644 --- a/include/soc/samsung/exynos-dm.h +++ b/include/soc/samsung/exynos-dm.h @@ -112,6 +112,7 @@ int register_exynos_dm_freq_scaler(int dm_type, int unregister_exynos_dm_freq_scaler(int dm_type); int policy_update_call_to_DM(int dm_type, u32 min_freq, u32 max_freq); int DM_CALL(int dm_type, unsigned long *target_freq); +int policy_update_with_DM_CALL(int dm_type, u32 min_freq, u32 max_freq, unsigned long *target_freq); #else static inline int exynos_dm_data_init(int dm_type, void *data, @@ -152,6 +153,11 @@ int DM_CALL(int dm_type, unsigned long *target_freq) { return 0; } +static inline +int policy_update_with_DM_CALL(int dm_type, u32 min_freq, u32 max_freq, unsigned long *target_freq) +{ + return 0; +} #endif #endif /* __EXYNOS_DM_H */ -- 2.20.1