mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-14 08:36:12 -04:00
msm: kgsl: Correct behavior of gpu_max_clock sysfs node
The legacy behavior of gpu_max_clock sysfs node is to update thermal_pwrlevel instead of max_pwrlevel. Restore the legacy behavior to avoid breaking entities using this sysfs node. Also, ensure thermal limit set by devfreq cooling framework and sysfs nodes like gpu_max_clock doesn't overwrite each other and instead a consolidated limit based on limit set by both entities is used as a final thermal limit. Change-Id: I006786723d3e9c0deb29aec90b57eba8df1ec1d0 Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
This commit is contained in:
parent
e4d3a647b0
commit
c0ca3ea31c
3 changed files with 21 additions and 13 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2010-2020, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2010-2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/interconnect.h>
|
||||
|
|
@ -297,7 +297,8 @@ static void kgsl_pwrctrl_set_thermal_pwrlevel(struct kgsl_device *device,
|
|||
if (level >= pwr->num_pwrlevels)
|
||||
level = pwr->num_pwrlevels - 1;
|
||||
|
||||
pwr->thermal_pwrlevel = level;
|
||||
pwr->sysfs_thermal_pwrlevel = level;
|
||||
pwr->thermal_pwrlevel = max(pwr->cooling_thermal_pwrlevel, pwr->sysfs_thermal_pwrlevel);
|
||||
|
||||
/* Update the current level using the new limit */
|
||||
kgsl_pwrctrl_pwrlevel_change(device, pwr->active_pwrlevel);
|
||||
|
|
@ -921,7 +922,7 @@ static ssize_t _max_clock_mhz_show(struct kgsl_device *device, char *buf)
|
|||
struct kgsl_pwrctrl *pwr = &device->pwrctrl;
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%d\n",
|
||||
pwr->pwrlevels[pwr->max_pwrlevel].gpu_freq / 1000000);
|
||||
pwr->pwrlevels[pwr->thermal_pwrlevel].gpu_freq / 1000000);
|
||||
}
|
||||
|
||||
static ssize_t max_clock_mhz_show(struct device *dev,
|
||||
|
|
@ -937,7 +938,6 @@ static ssize_t _max_clock_mhz_store(struct kgsl_device *device,
|
|||
{
|
||||
u32 freq;
|
||||
int ret, level;
|
||||
struct kgsl_pwrctrl *pwr = &device->pwrctrl;
|
||||
|
||||
ret = kstrtou32(buf, 0, &freq);
|
||||
if (ret)
|
||||
|
|
@ -947,11 +947,12 @@ static ssize_t _max_clock_mhz_store(struct kgsl_device *device,
|
|||
if (level < 0)
|
||||
return level;
|
||||
|
||||
mutex_lock(&device->mutex);
|
||||
pwr->max_pwrlevel = min_t(unsigned int, level, pwr->min_pwrlevel);
|
||||
kgsl_pwrctrl_pwrlevel_change(device, pwr->active_pwrlevel);
|
||||
mutex_unlock(&device->mutex);
|
||||
|
||||
/*
|
||||
* You would think this would set max_pwrlevel but the legacy behavior
|
||||
* is that it set thermal_pwrlevel instead so we don't want to mess with
|
||||
* that.
|
||||
*/
|
||||
kgsl_pwrctrl_set_thermal_pwrlevel(device, level);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
@ -1552,6 +1553,8 @@ int kgsl_pwrctrl_init(struct kgsl_device *device)
|
|||
pwr->max_pwrlevel = 0;
|
||||
pwr->min_pwrlevel = pwr->num_pwrlevels - 1;
|
||||
pwr->thermal_pwrlevel = 0;
|
||||
pwr->sysfs_thermal_pwrlevel = 0;
|
||||
pwr->cooling_thermal_pwrlevel = 0;
|
||||
pwr->thermal_pwrlevel_floor = pwr->min_pwrlevel;
|
||||
|
||||
pwr->wakeup_maxpwrlevel = 0;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2010-2020, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2010-2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
#ifndef __KGSL_PWRCTRL_H
|
||||
#define __KGSL_PWRCTRL_H
|
||||
|
|
@ -89,7 +89,9 @@ struct kgsl_pwrlevel {
|
|||
* @nb - Notifier block to receive GPU OPP change event
|
||||
* @active_pwrlevel - The currently active power level
|
||||
* @previous_pwrlevel - The power level before transition
|
||||
* @thermal_pwrlevel - maximum powerlevel constraint from thermal
|
||||
* @thermal_pwrlevel - consolidated maximum thermal powerlevel constraint
|
||||
* @sysfs_thermal_pwrlevel - maximum powerlevel constraint from sysfs
|
||||
* @cooling_thermal_pwrlevel - maximum pwrlevel constraint from devfreq cooling fw
|
||||
* @thermal_pwrlevel_floor - minimum powerlevel constraint from thermal
|
||||
* @default_pwrlevel - device wake up power level
|
||||
* @max_pwrlevel - maximum allowable powerlevel per the user
|
||||
|
|
@ -133,6 +135,8 @@ struct kgsl_pwrctrl {
|
|||
unsigned int active_pwrlevel;
|
||||
unsigned int previous_pwrlevel;
|
||||
unsigned int thermal_pwrlevel;
|
||||
unsigned int sysfs_thermal_pwrlevel;
|
||||
unsigned int cooling_thermal_pwrlevel;
|
||||
unsigned int thermal_pwrlevel_floor;
|
||||
unsigned int default_pwrlevel;
|
||||
unsigned int wakeup_maxpwrlevel;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2010-2020, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2010-2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/devfreq_cooling.h>
|
||||
|
|
@ -654,7 +654,8 @@ static int opp_notify(struct notifier_block *nb,
|
|||
min_level = level;
|
||||
}
|
||||
|
||||
pwr->thermal_pwrlevel = max_level;
|
||||
pwr->cooling_thermal_pwrlevel = max_level;
|
||||
pwr->thermal_pwrlevel = max(pwr->cooling_thermal_pwrlevel, pwr->sysfs_thermal_pwrlevel);
|
||||
pwr->thermal_pwrlevel_floor = min_level;
|
||||
|
||||
/* Update the current level using the new limit */
|
||||
|
|
|
|||
Loading…
Reference in a new issue