From 72fc78c2f8f9f1e551d0c59711fb9ca34dec9d33 Mon Sep 17 00:00:00 2001 From: Hareesh Gundu Date: Fri, 10 Jul 2020 20:44:33 +0530 Subject: [PATCH] msm: kgsl: 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 --- drivers/gpu/msm/governor_gpubw_mon.c | 66 +++++++++++++++++++++++++++- drivers/gpu/msm/msm_adreno_devfreq.h | 1 + 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/msm/governor_gpubw_mon.c b/drivers/gpu/msm/governor_gpubw_mon.c index cb120cef6023..f6e41577ca95 100644 --- a/drivers/gpu/msm/governor_gpubw_mon.c +++ b/drivers/gpu/msm/governor_gpubw_mon.c @@ -31,6 +31,61 @@ static void _update_cutoff(struct devfreq_msm_adreno_tz_data *priv, } } +static ssize_t cur_ab_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, "%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) { @@ -70,7 +125,7 @@ static int devfreq_gpubw_get_target(struct devfreq *df, priv->bus.ram_time += b.ram_time; priv->bus.ram_wait += b.ram_wait; - 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) / @@ -174,12 +229,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); diff --git a/drivers/gpu/msm/msm_adreno_devfreq.h b/drivers/gpu/msm/msm_adreno_devfreq.h index 465a960e16fd..58789dcea43b 100644 --- a/drivers/gpu/msm/msm_adreno_devfreq.h +++ b/drivers/gpu/msm/msm_adreno_devfreq.h @@ -78,6 +78,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;