Skip to content

Commit 28615e3

Browse files
digetxchanwoochoi
authored andcommitted
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: Dmitry Osipenko <[email protected]> Reviewed-by: Chanwoo Choi <[email protected]> Signed-off-by: Chanwoo Choi <[email protected]>
1 parent 88ec816 commit 28615e3

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

drivers/devfreq/tegra30-devfreq.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ struct tegra_devfreq_device_config {
9696
unsigned int boost_down_threshold;
9797

9898
/*
99-
* Threshold of activity (cycles) below which the CPU frequency isn't
100-
* to be taken into account. This is to avoid increasing the EMC
101-
* frequency when the CPU is very busy but not accessing the bus often.
99+
* Threshold of activity (cycles translated to kHz) below which the
100+
* CPU frequency isn't to be taken into account. This is to avoid
101+
* increasing the EMC frequency when the CPU is very busy but not
102+
* accessing the bus often.
102103
*/
103104
u32 avg_dependency_threshold;
104105
};
@@ -126,7 +127,7 @@ static const struct tegra_devfreq_device_config actmon_device_configs[] = {
126127
.boost_down_coeff = 90,
127128
.boost_up_threshold = 27,
128129
.boost_down_threshold = 10,
129-
.avg_dependency_threshold = 50000,
130+
.avg_dependency_threshold = 16000, /* 16MHz in kHz units */
130131
},
131132
};
132133

@@ -311,7 +312,6 @@ static unsigned long actmon_device_target_freq(struct tegra_devfreq *tegra,
311312
target_freq = dev->avg_count / ACTMON_SAMPLING_PERIOD;
312313
avg_sustain_coef = 100 * 100 / dev->config->boost_up_threshold;
313314
target_freq = do_percent(target_freq, avg_sustain_coef);
314-
target_freq += dev->boost_freq;
315315

316316
return target_freq;
317317
}
@@ -322,15 +322,18 @@ static void actmon_update_target(struct tegra_devfreq *tegra,
322322
unsigned long cpu_freq = 0;
323323
unsigned long static_cpu_emc_freq = 0;
324324

325-
if (dev->config->avg_dependency_threshold) {
325+
dev->target_freq = actmon_device_target_freq(tegra, dev);
326+
327+
if (dev->config->avg_dependency_threshold &&
328+
dev->config->avg_dependency_threshold <= dev->target_freq) {
326329
cpu_freq = cpufreq_quick_get(0);
327330
static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq);
328-
}
329331

330-
dev->target_freq = actmon_device_target_freq(tegra, dev);
331-
332-
if (dev->avg_count >= dev->config->avg_dependency_threshold)
332+
dev->target_freq += dev->boost_freq;
333333
dev->target_freq = max(dev->target_freq, static_cpu_emc_freq);
334+
} else {
335+
dev->target_freq += dev->boost_freq;
336+
}
334337
}
335338

336339
static irqreturn_t actmon_thread_isr(int irq, void *data)
@@ -396,15 +399,16 @@ static unsigned long
396399
tegra_actmon_cpufreq_contribution(struct tegra_devfreq *tegra,
397400
unsigned int cpu_freq)
398401
{
402+
struct tegra_devfreq_device *actmon_dev = &tegra->devices[MCCPU];
399403
unsigned long static_cpu_emc_freq, dev_freq;
400404

405+
dev_freq = actmon_device_target_freq(tegra, actmon_dev);
406+
401407
/* check whether CPU's freq is taken into account at all */
402-
if (tegra->devices[MCCPU].avg_count <
403-
tegra->devices[MCCPU].config->avg_dependency_threshold)
408+
if (dev_freq < actmon_dev->config->avg_dependency_threshold)
404409
return 0;
405410

406411
static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq);
407-
dev_freq = actmon_device_target_freq(tegra, &tegra->devices[MCCPU]);
408412

409413
if (dev_freq >= static_cpu_emc_freq)
410414
return 0;

0 commit comments

Comments
 (0)