msm: kgsl: show max gpu temperature
Parse the thermal zone names from gpu dtsi to get
each zone's temperature. Print the maximum temperature
in sysfs.
Change-Id: Ibeaf72e818f6c068b232229ffa27513fe4b03af4
Signed-off-by: Puranam V G Tejaswi <pvgtejas@codeaurora.org>
diff --git a/Documentation/devicetree/bindings/gpu/adreno.txt b/Documentation/devicetree/bindings/gpu/adreno.txt
index a59a322..dfde793 100644
--- a/Documentation/devicetree/bindings/gpu/adreno.txt
+++ b/Documentation/devicetree/bindings/gpu/adreno.txt
@@ -208,6 +208,10 @@
Specify the name of GPU temperature sensor. This name will be used
to get the temperature from the thermal driver API.
+- tzone-names:
+ Specify the names of GPU thermal zones. These will be used
+ to get the temperature from the thermal driver API.
+
- qcom,enable-midframe-timer:
Boolean. Enables the use of midframe sampling timer. This timer
samples the GPU powerstats if the cmdbatch expiry takes longer than
diff --git a/drivers/gpu/msm/kgsl_pwrctrl.c b/drivers/gpu/msm/kgsl_pwrctrl.c
index b2679b3..d6fc98b 100644
--- a/drivers/gpu/msm/kgsl_pwrctrl.c
+++ b/drivers/gpu/msm/kgsl_pwrctrl.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2010-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -1462,28 +1462,23 @@
struct kgsl_device *device = kgsl_device_from_dev(dev);
struct kgsl_pwrctrl *pwr;
struct thermal_zone_device *thermal_dev;
- int ret, temperature = 0;
+ int i, max_temp = 0;
if (device == NULL)
- goto done;
+ return 0;
pwr = &device->pwrctrl;
- if (!pwr->tzone_name)
- goto done;
+ for (i = 0; i < KGSL_MAX_TZONE_NAMES; i++) {
+ int temp = 0;
- thermal_dev = thermal_zone_get_zone_by_name((char *)pwr->tzone_name);
- if (thermal_dev == NULL)
- goto done;
+ thermal_dev = thermal_zone_get_zone_by_name(
+ pwr->tzone_names[i]);
+ if (!(thermal_zone_get_temp(thermal_dev, &temp)))
+ max_temp = max_t(int, temp, max_temp);
+ }
- ret = thermal_zone_get_temp(thermal_dev, &temperature);
- if (ret)
- goto done;
-
- return snprintf(buf, PAGE_SIZE, "%d\n",
- temperature);
-done:
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%d\n", max_temp);
}
static ssize_t kgsl_pwrctrl_pwrscale_store(struct device *dev,
@@ -2414,8 +2409,9 @@
kgsl_pwrctrl_vbif_init();
/* temperature sensor name */
- of_property_read_string(pdev->dev.of_node, "qcom,tzone-name",
- &pwr->tzone_name);
+
+ of_property_read_string_array(pdev->dev.of_node, "tzone-names",
+ pwr->tzone_names, KGSL_MAX_TZONE_NAMES);
return result;
diff --git a/drivers/gpu/msm/kgsl_pwrctrl.h b/drivers/gpu/msm/kgsl_pwrctrl.h
index 0780737..23fbc2e 100644
--- a/drivers/gpu/msm/kgsl_pwrctrl.h
+++ b/drivers/gpu/msm/kgsl_pwrctrl.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2010-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -30,6 +30,8 @@
#define KGSL_MAX_PWRLEVELS 10
+#define KGSL_MAX_TZONE_NAMES 2
+
/* Only two supported levels, min & max */
#define KGSL_CONSTRAINT_PWR_MAXLEVELS 2
@@ -169,7 +171,7 @@
* @sysfs_pwr_limit - pointer to the sysfs limits node
* isense_clk_indx - index of isense clock, 0 if no isense
* isense_clk_on_level - isense clock rate is XO rate below this level.
- * tzone_name - pointer to thermal zone name of GPU temperature sensor
+ * tzone_names - array of thermal zone names of GPU temperature sensors
*/
struct kgsl_pwrctrl {
@@ -226,7 +228,7 @@
struct kgsl_pwr_limit *sysfs_pwr_limit;
unsigned int gpu_bimc_int_clk_freq;
bool gpu_bimc_interface_enabled;
- const char *tzone_name;
+ const char *tzone_names[KGSL_MAX_TZONE_NAMES];
};
int kgsl_pwrctrl_init(struct kgsl_device *device);