summaryrefslogtreecommitdiffstats
path: root/sys/contrib
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2007-03-26 18:03:29 +0000
committernjl <njl@FreeBSD.org>2007-03-26 18:03:29 +0000
commit4933ca0aa02fff68e3e30186b454ed25d7d926fb (patch)
tree38a5baa5f3b7261150b7178ed80307e7f2bd65c9 /sys/contrib
parent3cb53690e0c2c81ed3b336133bf003c7b3173abf (diff)
downloadFreeBSD-src-4933ca0aa02fff68e3e30186b454ed25d7d926fb.zip
FreeBSD-src-4933ca0aa02fff68e3e30186b454ed25d7d926fb.tar.gz
Add an interface for drivers to be notified of changes to CPU frequency.
cpufreq_pre_change is called before the change, giving each driver a chance to revoke the change. cpufreq_post_change provides the results of the change (success or failure). cpufreq_levels_changed gives the unit number of the cpufreq device whose number of available levels has changed. Hook in all the drivers I could find that needed it. * TSC: update TSC frequency value. When the available levels change, take the highest possible level and notify the timecounter set_cputicker() of that freq. This gets rid of the "calcru: runtime went backwards" messages. * identcpu: updates the sysctl hw.clockrate value * Profiling: if profiling is active when the clock changes, let the user know the results may be inaccurate. Reviewed by: bde, phk MFC after: 1 month
Diffstat (limited to 'sys/contrib')
-rw-r--r--sys/contrib/altq/altq/altq_subr.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/contrib/altq/altq/altq_subr.c b/sys/contrib/altq/altq/altq_subr.c
index 0b4d22d..fb6b91c 100644
--- a/sys/contrib/altq/altq/altq_subr.c
+++ b/sys/contrib/altq/altq/altq_subr.c
@@ -74,6 +74,9 @@
#if __FreeBSD__ < 3
#include "opt_cpu.h" /* for FreeBSD-2.2.8 to get i586_ctr_freq */
#endif
+#include <sys/bus.h>
+#include <sys/cpu.h>
+#include <sys/eventhandler.h>
#include <machine/clock.h>
#endif
#if defined(__i386__)
@@ -898,6 +901,22 @@ extern u_int64_t cycles_per_usec; /* alpha cpu clock frequency */
extern u_int64_t cpu_tsc_freq;
#endif /* __alpha__ */
+#if (__FreeBSD_version >= 700035)
+/* Update TSC freq with the value indicated by the caller. */
+static void
+tsc_freq_changed(void *arg, const struct cf_level *level, int status)
+{
+ /* If there was an error during the transition, don't do anything. */
+ if (status != 0)
+ return;
+
+ /* Total setting for this level gives the new frequency in MHz. */
+ machclk_freq = level->total_set.freq * 1000000;
+}
+EVENTHANDLER_DEFINE(cpufreq_post_change, tsc_freq_changed, NULL,
+ EVENTHANDLER_PRI_ANY);
+#endif /* __FreeBSD_version >= 700035 */
+
void
init_machclk(void)
{
OpenPOWER on IntegriCloud