summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_cpu.c
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2005-02-26 22:37:49 +0000
committernjl <njl@FreeBSD.org>2005-02-26 22:37:49 +0000
commitd63a2d86cd8c93bba7b23995ae917f899949a292 (patch)
tree294f5987bf496bd81975e1e1e4c34dd45140bcf5 /sys/kern/kern_cpu.c
parentd8a075eadaeb1dc67c925227052129147c249810 (diff)
downloadFreeBSD-src-d63a2d86cd8c93bba7b23995ae917f899949a292.zip
FreeBSD-src-d63a2d86cd8c93bba7b23995ae917f899949a292.tar.gz
Allow users to reject levels below a given frequency (in MHz) via the
debug.cpufreq.lowest tunable and sysctl. Some systems seem to have problems with the lowest frequencies so setting this prevents them from being available or used.
Diffstat (limited to 'sys/kern/kern_cpu.c')
-rw-r--r--sys/kern/kern_cpu.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/kern/kern_cpu.c b/sys/kern/kern_cpu.c
index 355b258..4bf9d36 100644
--- a/sys/kern/kern_cpu.c
+++ b/sys/kern/kern_cpu.c
@@ -109,7 +109,13 @@ static driver_t cpufreq_driver = {
static devclass_t cpufreq_dc;
DRIVER_MODULE(cpufreq, cpu, cpufreq_driver, cpufreq_dc, 0, 0);
-static eventhandler_tag cf_ev_tag;
+static eventhandler_tag cf_ev_tag;
+
+static int cf_lowest_freq;
+TUNABLE_INT("debug.cpufreq.lowest", &cf_lowest_freq);
+SYSCTL_NODE(_debug, OID_AUTO, cpufreq, CTLFLAG_RD, NULL, "cpufreq debugging");
+SYSCTL_INT(_debug_cpufreq, OID_AUTO, lowest, CTLFLAG_RW, &cf_lowest_freq, 1,
+ "Don't provide levels below this frequency.");
static int
cpufreq_attach(device_t dev)
@@ -206,6 +212,10 @@ cf_set_method(device_t dev, const struct cf_level *level, int priority)
} else if (priority < sc->curr_priority)
return (EPERM);
+ /* Reject levels that are below our specified threshold. */
+ if (level->total_set.freq <= cf_lowest_freq)
+ return (EINVAL);
+
/* If already at this level, just return. */
if (CPUFREQ_CMP(sc->curr_level.total_set.freq, level->total_set.freq))
return (0);
@@ -474,6 +484,12 @@ cf_levels_method(device_t dev, struct cf_level *levels, int *count)
/* Finally, output the list of levels. */
i = 0;
TAILQ_FOREACH(lev, &sc->all_levels, link) {
+ /* Skip levels that have a frequency that is too low. */
+ if (lev->total_set.freq <= cf_lowest_freq) {
+ sc->all_count--;
+ continue;
+ }
+
levels[i] = *lev;
i++;
}
OpenPOWER on IntegriCloud