Commit 28615e37 authored by Dmitry Osipenko's avatar Dmitry Osipenko Committed by Chanwoo Choi

PM / devfreq: tegra30: Use kHz units for dependency threshold

The dependency threshold designates a memory activity level below which
CPU's frequency isn't accounted. Currently the threshold is given in
"memory cycle" units and that value depends on the polling interval which
is fixed to 12ms in the driver. Later on we'd want to add support for a
variable polling interval and thus the threshold value either needs to be
scaled in accordance to the polling interval or it needs to be represented
in a units that do not depend on the polling interval.

It is nicer to have threshold value being defined independently of the
polling interval, thus this patch converts the dependency threshold units
from "cycle" to "kHz". Having this change as a separate-preparatory patch
will make easier to follow further patches.
Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
Reviewed-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
parent 88ec8164
...@@ -96,9 +96,10 @@ struct tegra_devfreq_device_config { ...@@ -96,9 +96,10 @@ struct tegra_devfreq_device_config {
unsigned int boost_down_threshold; unsigned int boost_down_threshold;
/* /*
* Threshold of activity (cycles) below which the CPU frequency isn't * Threshold of activity (cycles translated to kHz) below which the
* to be taken into account. This is to avoid increasing the EMC * CPU frequency isn't to be taken into account. This is to avoid
* frequency when the CPU is very busy but not accessing the bus often. * increasing the EMC frequency when the CPU is very busy but not
* accessing the bus often.
*/ */
u32 avg_dependency_threshold; u32 avg_dependency_threshold;
}; };
...@@ -126,7 +127,7 @@ static const struct tegra_devfreq_device_config actmon_device_configs[] = { ...@@ -126,7 +127,7 @@ static const struct tegra_devfreq_device_config actmon_device_configs[] = {
.boost_down_coeff = 90, .boost_down_coeff = 90,
.boost_up_threshold = 27, .boost_up_threshold = 27,
.boost_down_threshold = 10, .boost_down_threshold = 10,
.avg_dependency_threshold = 50000, .avg_dependency_threshold = 16000, /* 16MHz in kHz units */
}, },
}; };
...@@ -311,7 +312,6 @@ static unsigned long actmon_device_target_freq(struct tegra_devfreq *tegra, ...@@ -311,7 +312,6 @@ static unsigned long actmon_device_target_freq(struct tegra_devfreq *tegra,
target_freq = dev->avg_count / ACTMON_SAMPLING_PERIOD; target_freq = dev->avg_count / ACTMON_SAMPLING_PERIOD;
avg_sustain_coef = 100 * 100 / dev->config->boost_up_threshold; avg_sustain_coef = 100 * 100 / dev->config->boost_up_threshold;
target_freq = do_percent(target_freq, avg_sustain_coef); target_freq = do_percent(target_freq, avg_sustain_coef);
target_freq += dev->boost_freq;
return target_freq; return target_freq;
} }
...@@ -322,15 +322,18 @@ static void actmon_update_target(struct tegra_devfreq *tegra, ...@@ -322,15 +322,18 @@ static void actmon_update_target(struct tegra_devfreq *tegra,
unsigned long cpu_freq = 0; unsigned long cpu_freq = 0;
unsigned long static_cpu_emc_freq = 0; unsigned long static_cpu_emc_freq = 0;
if (dev->config->avg_dependency_threshold) { dev->target_freq = actmon_device_target_freq(tegra, dev);
if (dev->config->avg_dependency_threshold &&
dev->config->avg_dependency_threshold <= dev->target_freq) {
cpu_freq = cpufreq_quick_get(0); cpu_freq = cpufreq_quick_get(0);
static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq); static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq);
}
dev->target_freq = actmon_device_target_freq(tegra, dev); dev->target_freq += dev->boost_freq;
if (dev->avg_count >= dev->config->avg_dependency_threshold)
dev->target_freq = max(dev->target_freq, static_cpu_emc_freq); dev->target_freq = max(dev->target_freq, static_cpu_emc_freq);
} else {
dev->target_freq += dev->boost_freq;
}
} }
static irqreturn_t actmon_thread_isr(int irq, void *data) static irqreturn_t actmon_thread_isr(int irq, void *data)
...@@ -396,15 +399,16 @@ static unsigned long ...@@ -396,15 +399,16 @@ static unsigned long
tegra_actmon_cpufreq_contribution(struct tegra_devfreq *tegra, tegra_actmon_cpufreq_contribution(struct tegra_devfreq *tegra,
unsigned int cpu_freq) unsigned int cpu_freq)
{ {
struct tegra_devfreq_device *actmon_dev = &tegra->devices[MCCPU];
unsigned long static_cpu_emc_freq, dev_freq; unsigned long static_cpu_emc_freq, dev_freq;
dev_freq = actmon_device_target_freq(tegra, actmon_dev);
/* check whether CPU's freq is taken into account at all */ /* check whether CPU's freq is taken into account at all */
if (tegra->devices[MCCPU].avg_count < if (dev_freq < actmon_dev->config->avg_dependency_threshold)
tegra->devices[MCCPU].config->avg_dependency_threshold)
return 0; return 0;
static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq); static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq);
dev_freq = actmon_device_target_freq(tegra, &tegra->devices[MCCPU]);
if (dev_freq >= static_cpu_emc_freq) if (dev_freq >= static_cpu_emc_freq)
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment