From 4ee25aa27ff123aa723751ba22c437fe039dae82 Mon Sep 17 00:00:00 2001 From: Young Hwan Kwak Date: Sat, 29 Aug 2020 17:13:48 +0900 Subject: [PATCH] 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 --- drivers/gpu/msm/kgsl_pwrctrl.c | 30 +++++++++++++++--------------- drivers/gpu/msm/kgsl_pwrctrl.h | 2 -- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/msm/kgsl_pwrctrl.c b/drivers/gpu/msm/kgsl_pwrctrl.c index 0988aea6132a..801c6205478c 100644 --- a/drivers/gpu/msm/kgsl_pwrctrl.c +++ b/drivers/gpu/msm/kgsl_pwrctrl.c @@ -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; } diff --git a/drivers/gpu/msm/kgsl_pwrctrl.h b/drivers/gpu/msm/kgsl_pwrctrl.h index eb2ce504455b..3489d79eeca6 100644 --- a/drivers/gpu/msm/kgsl_pwrctrl.h +++ b/drivers/gpu/msm/kgsl_pwrctrl.h @@ -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 */