Commit bf33772f authored by Anand Moon's avatar Anand Moon

exynos: thermal: show throttle counters.

Changes updates the counters in changes of state of TMU.
Created sysfs throttle file to show the counters.

$ /sys/devices/10060000.tmu/throttle

Change-Id: I233b640b229e95ee38bdc1dbb3ca59330cc3fdbc
parent 52b56846
...@@ -226,6 +226,8 @@ static enum mif_noti_state_t mif_old_state = MIF_TH_LV1; ...@@ -226,6 +226,8 @@ static enum mif_noti_state_t mif_old_state = MIF_TH_LV1;
static bool is_suspending; static bool is_suspending;
static bool is_cpu_hotplugged_out; static bool is_cpu_hotplugged_out;
static unsigned long ctmu_normal, ctmu_cold, ctmu_hot, ctmu_critical, throttle_cpu;
static BLOCKING_NOTIFIER_HEAD(exynos_tmu_notifier); static BLOCKING_NOTIFIER_HEAD(exynos_tmu_notifier);
static BLOCKING_NOTIFIER_HEAD(exynos_gpu_notifier); static BLOCKING_NOTIFIER_HEAD(exynos_gpu_notifier);
...@@ -540,18 +542,35 @@ static void exynos_check_tmu_noti_state(int min_temp, int max_temp) ...@@ -540,18 +542,35 @@ static void exynos_check_tmu_noti_state(int min_temp, int max_temp)
enum tmu_noti_state_t cur_state; enum tmu_noti_state_t cur_state;
/* check current temperature state */ /* check current temperature state */
if (max_temp > HOT_CRITICAL_TEMP) if (max_temp > HOT_CRITICAL_TEMP) {
cur_state = TMU_CRITICAL; cur_state = TMU_CRITICAL;
else if (max_temp > HOT_NORMAL_TEMP && max_temp <= HOT_CRITICAL_TEMP) ctmu_critical++;
} else if (max_temp > HOT_NORMAL_TEMP && max_temp <= HOT_CRITICAL_TEMP) {
cur_state = TMU_HOT; cur_state = TMU_HOT;
else if (max_temp > COLD_TEMP && max_temp <= HOT_NORMAL_TEMP) ctmu_hot++;
} else if (max_temp > COLD_TEMP && max_temp <= HOT_NORMAL_TEMP) {
cur_state = TMU_NORMAL; cur_state = TMU_NORMAL;
else ctmu_normal++;
} else {
cur_state = TMU_COLD; cur_state = TMU_COLD;
ctmu_cold++;
}
if (min_temp <= COLD_TEMP) if (min_temp <= COLD_TEMP)
cur_state = TMU_COLD; cur_state = TMU_COLD;
/* Just to check for overflow */
if (ctmu_critical >= ULONG_MAX)
ctmu_critical = 0;
if (ctmu_hot >= ULONG_MAX)
ctmu_hot = 0;
if (ctmu_normal >= ULONG_MAX)
ctmu_normal = 0;
if (ctmu_cold > ULONG_MAX)
ctmu_cold = 0;
if (throttle_cpu > ULONG_MAX)
throttle_cpu = 0;
exynos_tmu_call_notifier(cur_state, max_temp); exynos_tmu_call_notifier(cur_state, max_temp);
} }
...@@ -666,6 +685,7 @@ static int __ref exynos_throttle_cpu_hotplug(struct thermal_zone_device *thermal ...@@ -666,6 +685,7 @@ static int __ref exynos_throttle_cpu_hotplug(struct thermal_zone_device *thermal
* If current temperature is lower than low threshold, * If current temperature is lower than low threshold,
* call big_cores_hotplug(false) for hotplugged out cpus. * call big_cores_hotplug(false) for hotplugged out cpus.
*/ */
throttle_cpu++;
ret = big_cores_hotplug(false); ret = big_cores_hotplug(false);
if (ret) if (ret)
pr_err("%s: failed big cores hotplug in\n", pr_err("%s: failed big cores hotplug in\n",
...@@ -679,6 +699,7 @@ static int __ref exynos_throttle_cpu_hotplug(struct thermal_zone_device *thermal ...@@ -679,6 +699,7 @@ static int __ref exynos_throttle_cpu_hotplug(struct thermal_zone_device *thermal
* If current temperature is higher than high threshold, * If current temperature is higher than high threshold,
* call big_cores_hotplug(true) to hold temperature down. * call big_cores_hotplug(true) to hold temperature down.
*/ */
throttle_cpu++;
ret = big_cores_hotplug(true); ret = big_cores_hotplug(true);
if (ret) if (ret)
pr_err("%s: failed big cores hotplug out\n", pr_err("%s: failed big cores hotplug out\n",
...@@ -1778,8 +1799,25 @@ exynos_thermal_sensor_temp(struct device *dev, ...@@ -1778,8 +1799,25 @@ exynos_thermal_sensor_temp(struct device *dev,
static DEVICE_ATTR(temp, S_IRUSR | S_IRGRP, exynos_thermal_sensor_temp, NULL); static DEVICE_ATTR(temp, S_IRUSR | S_IRGRP, exynos_thermal_sensor_temp, NULL);
static ssize_t exynos_throttle_counter(struct device *dev,
struct device_attribute *attr, char *buf)
{
int len = 0;
len += snprintf(&buf[len], PAGE_SIZE, "TMU_NORMAL :%ld\n", ctmu_normal);
len += snprintf(&buf[len], PAGE_SIZE, "TMU_COLD :%ld\n", ctmu_cold);
len += snprintf(&buf[len], PAGE_SIZE, "TMU_HOT :%ld\n", ctmu_hot);
len += snprintf(&buf[len], PAGE_SIZE, "TMU_CRITICAL :%ld\n", ctmu_critical);
len += snprintf(&buf[len], PAGE_SIZE, "THROTTLE_CPU :%ld\n", throttle_cpu);
return len;
}
static DEVICE_ATTR(throttle, S_IRUGO, exynos_throttle_counter, NULL);
static struct attribute *exynos_thermal_sensor_attributes[] = { static struct attribute *exynos_thermal_sensor_attributes[] = {
&dev_attr_temp.attr, &dev_attr_temp.attr,
&dev_attr_throttle.attr,
NULL NULL
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment