[RAMEN9610-10216][COMMON] thermal: gpu_cooling: Modify GPU Frequency unit to KHz
authorHyeonseong Gil <hs.gil@samsung.com>
Mon, 13 Aug 2018 05:16:30 +0000 (14:16 +0900)
committerhskang <hs1218.kang@samsung.com>
Thu, 3 Jan 2019 11:00:28 +0000 (20:00 +0900)
GPU API was modified to use KHz frequency.

Change-Id: I0870cccf51cffd3f7b3b42f94ce7a245e2f6cffe
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/thermal/gpu_cooling.c

index a795d8f5a65fb33de728e6e43114733848e22053..fef41031919aeb7d87d25d20267d4c9dd3e9ec48 100644 (file)
@@ -297,7 +297,7 @@ static int build_dyn_power_table(struct gpufreq_cooling_device *gpufreq_cdev,
 
                freq = gpu_dvfs_get_clock(num_opps - i - 1);
 
-               if (freq > gpu_dvfs_get_max_freq())
+               if (freq > gpu_dvfs_get_max_freq() || freq == 0)
                        continue;
 
                voltage_mv = gpu_dvfs_get_voltage(freq) / 1000;
@@ -306,7 +306,7 @@ static int build_dyn_power_table(struct gpufreq_cooling_device *gpufreq_cdev,
                 * Do the multiplication with MHz and millivolt so as
                 * to not overflow.
                 */
-               power = (u64)capacitance * freq * voltage_mv * voltage_mv;
+               power = (u64)capacitance * (freq / 1000) * voltage_mv * voltage_mv;
                do_div(power, 1000000000);
 
                power_table[i].frequency = (unsigned int)freq;
@@ -564,7 +564,6 @@ static int gpufreq_apply_cooling(struct gpufreq_cooling_device *gpufreq_cdev,
                return -EINVAL;
        }
 
-       gpu_cooling_freq = gpu_cooling_freq / 1000;
        blocking_notifier_call_chain(&gpu_notifier, GPU_THROTTLING, &gpu_cooling_freq);
 
        return 0;
@@ -742,7 +741,7 @@ static int gpufreq_state2power(struct thermal_cooling_device *cdev,
        int ret;
        struct gpufreq_cooling_device *gpufreq_cdev = cdev->devdata;
 
-       freq = gpu_freq_table[state].frequency / 1000;
+       freq = gpu_freq_table[state].frequency;
        if (!freq)
                return -EINVAL;
 
@@ -794,7 +793,7 @@ static int gpufreq_power2state(struct thermal_cooling_device *cdev,
        dyn_power = dyn_power > 0 ? dyn_power : 0;
        target_freq = gpu_power_to_freq(gpufreq_cdev, dyn_power);
 
-       *state = gpufreq_cooling_get_level(0, target_freq * 1000);
+       *state = gpufreq_cooling_get_level(0, target_freq);
        if (*state == THERMAL_CSTATE_INVALID) {
                pr_warn("Failed to convert %dKHz for gpu into a cdev state\n",
                                     target_freq);
@@ -1041,7 +1040,7 @@ static int gpu_cooling_table_init(void)
 
                gpu_freq_table[count].flags = 0;
                gpu_freq_table[count].driver_data = count;
-               gpu_freq_table[count].frequency = (unsigned int)freq * 1000;
+               gpu_freq_table[count].frequency = (unsigned int)freq;
 
                pr_info("[GPU cooling] index : %d, frequency : %d\n",
                        gpu_freq_table[count].driver_data, gpu_freq_table[count].frequency);