diff --git a/drivers/gpu/msm/kgsl_pwrctrl.c b/drivers/gpu/msm/kgsl_pwrctrl.c index 606df36eca7d..ca22326773bc 100644 --- a/drivers/gpu/msm/kgsl_pwrctrl.c +++ b/drivers/gpu/msm/kgsl_pwrctrl.c @@ -3283,6 +3283,41 @@ int kgsl_pwr_limits_set_freq(void *limit_ptr, unsigned int freq) } EXPORT_SYMBOL(kgsl_pwr_limits_set_freq); +/** + * kgsl_pwr_limits_set_gpu_fmax() - Set the requested limit for the + * client, if requested freq value is larger than fmax supported + * function returns with success. + * @limit_ptr: Client handle + * @freq: Client requested frequency + * + * Set the new limit for the client and adjust the clocks + */ +int kgsl_pwr_limits_set_gpu_fmax(void *limit_ptr, unsigned int freq) +{ + struct kgsl_pwrctrl *pwr; + struct kgsl_pwr_limit *limit = limit_ptr; + int level; + + if (IS_ERR_OR_NULL(limit)) + return -EINVAL; + + pwr = &limit->device->pwrctrl; + + /* + * When requested frequency is greater than fmax, + * requested limit is implicit, return success here. + */ + if (freq >= pwr->pwrlevels[0].gpu_freq) + return 0; + + level = _get_nearest_pwrlevel(pwr, freq); + if (level < 0) + return -EINVAL; + _update_limits(limit, KGSL_PWR_SET_LIMIT, level); + return 0; +} +EXPORT_SYMBOL(kgsl_pwr_limits_set_gpu_fmax); + /** * kgsl_pwr_limits_set_default() - Set the default thermal limit for the client * @limit_ptr: Client handle diff --git a/include/linux/msm_kgsl.h b/include/linux/msm_kgsl.h index a527a0a3bf62..c84db40e015e 100644 --- a/include/linux/msm_kgsl.h +++ b/include/linux/msm_kgsl.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (c) 2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2018, 2020 The Linux Foundation. All rights reserved. */ #ifndef _MSM_KGSL_H #define _MSM_KGSL_H @@ -11,6 +11,7 @@ void *kgsl_pwr_limits_add(u32 id); void kgsl_pwr_limits_del(void *limit); int kgsl_pwr_limits_set_freq(void *limit, unsigned int freq); +int kgsl_pwr_limits_set_gpu_fmax(void *limit, unsigned int freq); void kgsl_pwr_limits_set_default(void *limit); unsigned int kgsl_pwr_limits_get_freq(u32 id);