devfreq: Add support to configure bus dcvs sampling interval

Add support to configure bus dcvs sampling interval through the
sysfs entry. Also expose cur_ab vote value to sysfs.

$ echo 25000 > /sys/class/devfreq/soc:qcom,kgsl-busmon/sampling_interval
$ cat /sys/class/devfreq/soc:qcom,kgsl-busmon/cur_ab .

Change-Id: I77df55de2766d3fd818c27f717cfc4ae598bb0bd
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
This commit is contained in:
Hareesh Gundu 2020-07-01 23:01:18 +05:30
parent c77acc02d4
commit af88f06094
2 changed files with 72 additions and 7 deletions

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
*/
#include <linux/devfreq.h>
@ -45,15 +45,70 @@ static inline int devfreq_get_freq_level(struct devfreq *devfreq,
return -EINVAL;
}
static int devfreq_gpubw_get_target(struct devfreq *df,
unsigned long *freq)
static ssize_t cur_ab_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct devfreq_msm_adreno_tz_data *priv = df->data;
struct devfreq *df = to_devfreq(dev);
struct msm_busmon_extended_profile *bus_profile = container_of(
(df->profile),
struct msm_busmon_extended_profile,
profile);
return scnprintf(buf, PAGE_SIZE, "%llu\n", bus_profile->ab_mbytes);
}
static ssize_t sampling_interval_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct devfreq *df = to_devfreq(dev);
struct msm_busmon_extended_profile *bus_profile = container_of(
(df->profile),
struct msm_busmon_extended_profile,
profile);
return scnprintf(buf, PAGE_SIZE, "%d\n", bus_profile->sampling_ms);
}
static ssize_t sampling_interval_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct devfreq *df = to_devfreq(dev);
struct msm_busmon_extended_profile *bus_profile = container_of(
(df->profile),
struct msm_busmon_extended_profile,
profile);
u32 value;
int ret;
ret = kstrtou32(buf, 0, &value);
if (ret)
return ret;
bus_profile->sampling_ms = value;
return count;
}
static DEVICE_ATTR_RW(sampling_interval);
static DEVICE_ATTR_RO(cur_ab);
static const struct device_attribute *gpubw_attr_list[] = {
&dev_attr_sampling_interval,
&dev_attr_cur_ab,
NULL
};
static int devfreq_gpubw_get_target(struct devfreq *df,
unsigned long *freq)
{
struct devfreq_msm_adreno_tz_data *priv = df->data;
struct msm_busmon_extended_profile *bus_profile = container_of(
(df->profile),
struct msm_busmon_extended_profile,
profile);
struct devfreq_dev_status *stats = &df->last_status;
struct xstats b;
int result;
@ -87,7 +142,7 @@ static int devfreq_gpubw_get_target(struct devfreq *df,
level = devfreq_get_freq_level(df, stats->current_frequency);
if (priv->bus.total_time < LONG_FLOOR)
if (priv->bus.total_time < bus_profile->sampling_ms)
return result;
norm_max_cycles = (unsigned int)(priv->bus.ram_time) /
@ -187,12 +242,21 @@ static int gpubw_start(struct devfreq *devfreq)
priv->bus.p_up[priv->bus.num - 1] = 100;
_update_cutoff(priv, priv->bus.max);
bus_profile->sampling_ms = LONG_FLOOR;
for (i = 0; gpubw_attr_list[i] != NULL; i++)
device_create_file(&devfreq->dev, gpubw_attr_list[i]);
return 0;
}
static int gpubw_stop(struct devfreq *devfreq)
{
struct devfreq_msm_adreno_tz_data *priv = devfreq->data;
int i;
for (i = 0; gpubw_attr_list[i] != NULL; i++)
device_remove_file(&devfreq->dev, gpubw_attr_list[i]);
if (priv) {
kfree(priv->bus.up);

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
*/
#ifndef MSM_ADRENO_DEVFREQ_H
@ -77,6 +77,7 @@ struct msm_adreno_extended_profile {
struct msm_busmon_extended_profile {
u32 flag;
u32 sampling_ms;
unsigned long percent_ab;
unsigned long ab_mbytes;
struct devfreq_msm_adreno_tz_data *private_data;