msm: kgsl: Show max gpu temperature

Parse the thermal zone names from gpu DT to get each zone's temperature
and print the maximum temperature among them in sysfs.

CRs-Fixed: 2765368
Change-Id: I37767d1bf9a8d4887dfcbad56ebdf17d27e4e465
Signed-off-by: Young Hwan Kwak <ykwak@codeaurora.org>
This commit is contained in:
Young Hwan Kwak 2020-08-29 17:13:48 +09:00
commit 4ee25aa27f
2 changed files with 15 additions and 17 deletions

View file

@ -1007,23 +1007,27 @@ static ssize_t freq_table_mhz_show(struct device *dev,
static ssize_t _gpu_tmu_show(struct kgsl_device *device,
char *buf)
{
struct kgsl_pwrctrl *pwr = &device->pwrctrl;
struct device *dev;
struct thermal_zone_device *thermal_dev;
int ret, temperature = 0;
int temperature = 0, max_temp = 0;
const char *name;
struct property *prop;
if (!pwr->tzone_name)
return 0;
dev = &device->pdev->dev;
thermal_dev = thermal_zone_get_zone_by_name((char *)pwr->tzone_name);
if (thermal_dev == NULL)
return 0;
of_property_for_each_string(dev->of_node, "qcom,tzone-names", prop, name) {
thermal_dev = thermal_zone_get_zone_by_name(name);
if (IS_ERR(thermal_dev))
continue;
ret = thermal_zone_get_temp(thermal_dev, &temperature);
if (ret)
return 0;
if (thermal_zone_get_temp(thermal_dev, &temperature))
continue;
max_temp = max(temperature, max_temp);
}
return scnprintf(buf, PAGE_SIZE, "%d\n",
temperature);
max_temp);
}
static ssize_t temp_show(struct device *dev,
@ -1574,10 +1578,6 @@ int kgsl_pwrctrl_init(struct kgsl_device *device)
timer_setup(&pwr->minbw_timer, kgsl_minbw_timer, 0);
/* temperature sensor name */
of_property_read_string(pdev->dev.of_node, "qcom,tzone-name",
&pwr->tzone_name);
return 0;
}

View file

@ -110,7 +110,6 @@ struct kgsl_pwrlevel {
* higher priority thread
* 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
*/
struct kgsl_pwrctrl {
@ -158,7 +157,6 @@ struct kgsl_pwrctrl {
bool superfast;
unsigned int gpu_bimc_int_clk_freq;
bool gpu_bimc_interface_enabled;
const char *tzone_name;
/** @icc_path: Interconnect path for the GPU (if applicable) */
struct icc_path *icc_path;
/** cur_ab: The last ab voted by the driver */