msm: kgsl: add api to limit gpu fmax

Existing api returns failure when requested frequency
is larger than fmax supported. This creates problem to
clients as they consider this as error case. This
can be improved if api returns success when requested
frequency is larger than fmax supported because requested
limit frequency is larger than fmax device will never
go beyond that at all and clients can execute normally.

Change-Id: Id1077ca03019a61d7fd6fef8eccd605131b9c150
Signed-off-by: Pranav Patel <pranavp@codeaurora.org>
This commit is contained in:
Pranav Patel 2020-05-06 15:51:57 +05:30
parent 123887723b
commit 07e044960d
2 changed files with 37 additions and 1 deletions

View file

@ -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

View file

@ -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);