/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 2007 by Ralf Baechle
*/ #include <linux/clocksource.h> #include <linux/cpufreq.h> #include <linux/init.h> #include <linux/sched_clock.h>
/* * Older QEMUs have a broken implementation of RDHWR for the CP0 count * which always returns a constant value. Try to identify this and don't * use it in the VDSO if it is broken. This workaround can be removed * once the fix has been in QEMU stable for a reasonable amount of time.
*/ for (i = 0, prev = rdhwr_count(); i < 100; i++) {
curr = rdhwr_count();
if (curr != prev) returntrue;
prev = curr;
}
pr_warn("Not using R4K clocksource in VDSO due to broken RDHWR\n"); returnfalse;
}
staticinline __init bool count_can_be_sched_clock(void)
{ if (IS_ENABLED(CONFIG_CPU_FREQ)) returnfalse;
if (num_possible_cpus() > 1 &&
!IS_ENABLED(CONFIG_HAVE_UNSTABLE_SCHED_CLOCK)) returnfalse;
returntrue;
}
#ifdef CONFIG_CPU_FREQ
staticbool __read_mostly r4k_clock_unstable;
staticvoid r4k_clocksource_unstable(char *reason)
{ if (r4k_clock_unstable) return;
r4k_clock_unstable = true;
pr_info("R4K timer is unstable due to %s\n", reason);
clocksource_mark_unstable(&clocksource_mips);
}
staticint r4k_cpufreq_callback(struct notifier_block *nb, unsignedlong val, void *data)
{ if (val == CPUFREQ_POSTCHANGE)
r4k_clocksource_unstable("CPU frequency change");
int __init init_r4k_clocksource(void)
{ if (!cpu_has_counter || !mips_hpt_frequency) return -ENXIO;
/* Calculate a somewhat reasonable rating value */
clocksource_mips.rating = 200;
clocksource_mips.rating += clamp(mips_hpt_frequency / 10000000, 0, 99);
/* * R2 onwards makes the count accessible to user mode so it can be used * by the VDSO (HWREna is configured by configure_hwrena()).
*/ if (cpu_has_mips_r2_r6 && rdhwr_count_usable())
clocksource_mips.vdso_clock_mode = VDSO_CLOCKMODE_R4K;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.