[RAMEN9610-8149] [COMMON] samsung: exynos-dm: Re-organize the mutex_lock with wrapper
authorHyeonseong Gil <hs.gil@samsung.com>
Fri, 18 May 2018 06:52:49 +0000 (15:52 +0900)
committerhskang <hs1218.kang@samsung.com>
Thu, 15 Nov 2018 04:58:19 +0000 (13:58 +0900)
Change-Id: I8a078e58f623b2754c12867dc910fd026d87c0a0
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/devfreq/devfreq.c
drivers/soc/samsung/exynos-dm.c
include/soc/samsung/exynos-dm.h

index b5f06fde0e9cecedabd7f1b0e9b6e3be5dd00110..b3e7febc028cc29e6af9006e0898e622754b7cba 100644 (file)
@@ -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.
index d74026c0670cc9435059c832003753cef4f8e4db..779d4926228863e6368859d8d2278a68f8bd628e 100644 (file)
@@ -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;
index f4f87c0351e5ccb31f789475d490d4f44fa714d6..8858e6e103981e5386d65d5565c3ebabd02fcc94 100644 (file)
@@ -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 */