hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/mips/kernel/csrc-r4k.c
....@@ -6,6 +6,7 @@
66 * Copyright (C) 2007 by Ralf Baechle
77 */
88 #include <linux/clocksource.h>
9
+#include <linux/cpufreq.h>
910 #include <linux/init.h>
1011 #include <linux/sched_clock.h>
1112
....@@ -65,6 +66,45 @@
6566 return false;
6667 }
6768
69
+#ifdef CONFIG_CPU_FREQ
70
+
71
+static bool __read_mostly r4k_clock_unstable;
72
+
73
+static void r4k_clocksource_unstable(char *reason)
74
+{
75
+ if (r4k_clock_unstable)
76
+ return;
77
+
78
+ r4k_clock_unstable = true;
79
+
80
+ pr_info("R4K timer is unstable due to %s\n", reason);
81
+
82
+ clocksource_mark_unstable(&clocksource_mips);
83
+}
84
+
85
+static int r4k_cpufreq_callback(struct notifier_block *nb,
86
+ unsigned long val, void *data)
87
+{
88
+ if (val == CPUFREQ_POSTCHANGE)
89
+ r4k_clocksource_unstable("CPU frequency change");
90
+
91
+ return 0;
92
+}
93
+
94
+static struct notifier_block r4k_cpufreq_notifier = {
95
+ .notifier_call = r4k_cpufreq_callback,
96
+};
97
+
98
+static int __init r4k_register_cpufreq_notifier(void)
99
+{
100
+ return cpufreq_register_notifier(&r4k_cpufreq_notifier,
101
+ CPUFREQ_TRANSITION_NOTIFIER);
102
+
103
+}
104
+core_initcall(r4k_register_cpufreq_notifier);
105
+
106
+#endif /* !CONFIG_CPU_FREQ */
107
+
68108 int __init init_r4k_clocksource(void)
69109 {
70110 if (!cpu_has_counter || !mips_hpt_frequency)
....@@ -78,7 +118,7 @@
78118 * by the VDSO (HWREna is configured by configure_hwrena()).
79119 */
80120 if (cpu_has_mips_r2_r6 && rdhwr_count_usable())
81
- clocksource_mips.archdata.vdso_clock_mode = VDSO_CLOCK_R4K;
121
+ clocksource_mips.vdso_clock_mode = VDSO_CLOCKMODE_R4K;
82122
83123 clocksource_register_hz(&clocksource_mips, mips_hpt_frequency);
84124