struct gpufreq_cooling_device {
int id;
struct thermal_cooling_device *cool_dev;
- unsigned int gpufreq_state;
+ unsigned long gpufreq_state;
unsigned int gpufreq_val;
u32 last_load;
struct power_table *dyn_power_table;
}
EXPORT_SYMBOL_GPL(gpufreq_cooling_get_level);
+/**
+ * gpufreq_cooling_get_freq - for a give gpu, return the cooling frequency.
+ * @gpu: gpu for which the level is required
+ * @level: the level of interest
+ *
+ * This function will match the cooling level corresponding to the
+ * requested @freq and return it.
+ *
+ * Return: The matched cooling level on success or THERMAL_CFREQ_INVALID
+ * otherwise.
+ */
+static u32 gpufreq_cooling_get_freq(unsigned int gpu, unsigned long level)
+{
+ unsigned int val = 0;
+
+ if (get_property(gpu, level, &val, GET_FREQ))
+ return THERMAL_CFREQ_INVALID;
+
+ return val;
+}
+EXPORT_SYMBOL_GPL(gpufreq_cooling_get_level);
+
/**
* build_dyn_power_table() - create a dynamic power to frequency table
* @gpufreq_cdev: the gpufreq cooling device in which to store the table
static int gpufreq_apply_cooling(struct gpufreq_cooling_device *gpufreq_cdev,
unsigned long cooling_state)
{
+ unsigned int gpu_cooling_freq = 0;
+
/* Check if the old cooling action is same as new cooling action */
if (gpufreq_cdev->gpufreq_state == cooling_state)
return 0;
gpufreq_cdev->gpufreq_state = cooling_state;
- blocking_notifier_call_chain(&gpu_notifier, GPU_THROTTLING, &cooling_state);
+ gpu_cooling_freq = gpufreq_cooling_get_freq(0, gpufreq_cdev->gpufreq_state);
+ if (gpu_cooling_freq == THERMAL_CFREQ_INVALID) {
+ pr_warn("Failed to convert %lu gpu_level\n",
+ gpufreq_cdev->gpufreq_state);
+ return -EINVAL;
+ }
+
+ gpu_cooling_freq = gpu_cooling_freq / 1000;
+ blocking_notifier_call_chain(&gpu_notifier, GPU_THROTTLING, &gpu_cooling_freq);
return 0;
}
struct ect_ap_thermal_function *function;
int last_level = -1, count = 0;
#else
- struct cpufreq_frequency_table *table_ptr;
unsigned int table_size;
u32 gpu_idx_num = 0;
#endif