--- kern_cpu.c.orig 2008-11-08 13:12:24.000000000 -0500 +++ kern_cpu.c 2008-11-08 10:33:18.000000000 -0500 @@ -131,12 +131,16 @@ DRIVER_MODULE(cpufreq, cpu, cpufreq_driver, cpufreq_dc, 0, 0); static int cf_lowest_freq; +static int cf_highest_freq; static int cf_verbose; TUNABLE_INT("debug.cpufreq.lowest", &cf_lowest_freq); +TUNABLE_INT("debug.cpufreq.highest", &cf_highest_freq); TUNABLE_INT("debug.cpufreq.verbose", &cf_verbose); 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."); +SYSCTL_INT(_debug_cpufreq, OID_AUTO, highest, CTLFLAG_RW, &cf_highest_freq, 1, + "Don't provide levels above this frequency."); SYSCTL_INT(_debug_cpufreq, OID_AUTO, verbose, CTLFLAG_RW, &cf_verbose, 1, "Print verbose debugging messages"); @@ -295,6 +299,14 @@ goto out; } + /* Reject levels that are above our specified threshold. */ + if (cf_highest_freq > 0 && level->total_set.freq > cf_highest_freq) { + CF_DEBUG("rejecting freq %d, greater than %d limit\n", + level->total_set.freq, cf_highest_freq); + error = EINVAL; + goto out; + } + /* If already at this level, just return. */ if (CPUFREQ_CMP(sc->curr_level.total_set.freq, level->total_set.freq)) { CF_DEBUG("skipping freq %d, same as current level %d\n", @@ -617,8 +629,13 @@ continue; } - /* Skip levels that have a frequency that is too low. */ - if (lev->total_set.freq < cf_lowest_freq) { + /* + * Skip levels that have a frequency that is too low or too + * high. + */ + if (lev->total_set.freq < cf_lowest_freq || + (cf_highest_freq > 0 && + lev->total_set.freq > cf_highest_freq)) { sc->all_count--; continue; }