hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/include/linux/clocksource.h
....@@ -23,7 +23,8 @@
2323 struct clocksource;
2424 struct module;
2525
26
-#ifdef CONFIG_ARCH_CLOCKSOURCE_DATA
26
+#if defined(CONFIG_ARCH_CLOCKSOURCE_DATA) || \
27
+ defined(CONFIG_GENERIC_GETTIMEOFDAY)
2728 #include <asm/clocksource.h>
2829 #endif
2930
....@@ -34,9 +35,19 @@
3435 * Provides mostly state-free accessors to the underlying hardware.
3536 * This is the structure used for system time.
3637 *
37
- * @name: ptr to clocksource name
38
- * @list: list head for registration
39
- * @rating: rating value for selection (higher is better)
38
+ * @read: Returns a cycle value, passes clocksource as argument
39
+ * @mask: Bitmask for two's complement
40
+ * subtraction of non 64 bit counters
41
+ * @mult: Cycle to nanosecond multiplier
42
+ * @shift: Cycle to nanosecond divisor (power of two)
43
+ * @max_idle_ns: Maximum idle time permitted by the clocksource (nsecs)
44
+ * @maxadj: Maximum adjustment value to mult (~11%)
45
+ * @archdata: Optional arch-specific data
46
+ * @max_cycles: Maximum safe cycle value which won't overflow on
47
+ * multiplication
48
+ * @name: Pointer to clocksource name
49
+ * @list: List head for registration (internal)
50
+ * @rating: Rating value for selection (higher is better)
4051 * To avoid rating inflation the following
4152 * list should give you a guide as to how
4253 * to assign your clocksource a rating
....@@ -51,27 +62,23 @@
5162 * 400-499: Perfect
5263 * The ideal clocksource. A must-use where
5364 * available.
54
- * @read: returns a cycle value, passes clocksource as argument
55
- * @enable: optional function to enable the clocksource
56
- * @disable: optional function to disable the clocksource
57
- * @mask: bitmask for two's complement
58
- * subtraction of non 64 bit counters
59
- * @mult: cycle to nanosecond multiplier
60
- * @shift: cycle to nanosecond divisor (power of two)
61
- * @max_idle_ns: max idle time permitted by the clocksource (nsecs)
62
- * @maxadj: maximum adjustment value to mult (~11%)
63
- * @max_cycles: maximum safe cycle value which won't overflow on multiplication
64
- * @flags: flags describing special properties
65
- * @archdata: arch-specific data
66
- * @suspend: suspend function for the clocksource, if necessary
67
- * @resume: resume function for the clocksource, if necessary
65
+ * @flags: Flags describing special properties
66
+ * @enable: Optional function to enable the clocksource
67
+ * @disable: Optional function to disable the clocksource
68
+ * @suspend: Optional suspend function for the clocksource
69
+ * @resume: Optional resume function for the clocksource
6870 * @mark_unstable: Optional function to inform the clocksource driver that
6971 * the watchdog marked the clocksource unstable
70
- * @owner: module reference, must be set by clocksource in modules
72
+ * @tick_stable: Optional function called periodically from the watchdog
73
+ * code to provide stable syncrhonization points
74
+ * @wd_list: List head to enqueue into the watchdog list (internal)
75
+ * @cs_last: Last clocksource value for clocksource watchdog
76
+ * @wd_last: Last watchdog value corresponding to @cs_last
77
+ * @owner: Module reference, must be set by clocksource in modules
7178 *
7279 * Note: This struct is not used in hotpathes of the timekeeping code
7380 * because the timekeeper caches the hot path fields in its own data
74
- * structure, so no line cache alignment is required,
81
+ * structure, so no cache line alignment is required,
7582 *
7683 * The pointer to the clocksource itself is handed to the read
7784 * callback. If you need extra information there you can wrap struct
....@@ -80,35 +87,37 @@
8087 * structure.
8188 */
8289 struct clocksource {
83
- u64 (*read)(struct clocksource *cs);
84
- u64 mask;
85
- u32 mult;
86
- u32 shift;
87
- u64 max_idle_ns;
88
- u32 maxadj;
90
+ u64 (*read)(struct clocksource *cs);
91
+ u64 mask;
92
+ u32 mult;
93
+ u32 shift;
94
+ u64 max_idle_ns;
95
+ u32 maxadj;
8996 #ifdef CONFIG_ARCH_CLOCKSOURCE_DATA
9097 struct arch_clocksource_data archdata;
9198 #endif
92
- u64 max_cycles;
93
- const char *name;
94
- struct list_head list;
95
- int rating;
96
- int (*enable)(struct clocksource *cs);
97
- void (*disable)(struct clocksource *cs);
98
- unsigned long flags;
99
- void (*suspend)(struct clocksource *cs);
100
- void (*resume)(struct clocksource *cs);
101
- void (*mark_unstable)(struct clocksource *cs);
102
- void (*tick_stable)(struct clocksource *cs);
99
+ u64 max_cycles;
100
+ const char *name;
101
+ struct list_head list;
102
+ int rating;
103
+ enum vdso_clock_mode vdso_clock_mode;
104
+ unsigned long flags;
105
+
106
+ int (*enable)(struct clocksource *cs);
107
+ void (*disable)(struct clocksource *cs);
108
+ void (*suspend)(struct clocksource *cs);
109
+ void (*resume)(struct clocksource *cs);
110
+ void (*mark_unstable)(struct clocksource *cs);
111
+ void (*tick_stable)(struct clocksource *cs);
103112
104113 /* private: */
105114 #ifdef CONFIG_CLOCKSOURCE_WATCHDOG
106115 /* Watchdog related data, used by the framework */
107
- struct list_head wd_list;
108
- u64 cs_last;
109
- u64 wd_last;
116
+ struct list_head wd_list;
117
+ u64 cs_last;
118
+ u64 wd_last;
110119 #endif
111
- struct module *owner;
120
+ struct module *owner;
112121 };
113122
114123 /*
....@@ -122,7 +131,7 @@
122131 #define CLOCK_SOURCE_UNSTABLE 0x40
123132 #define CLOCK_SOURCE_SUSPEND_NONSTOP 0x80
124133 #define CLOCK_SOURCE_RESELECT 0x100
125
-
134
+#define CLOCK_SOURCE_VERIFY_PERCPU 0x200
126135 /* simplify initialization of mask field */
127136 #define CLOCKSOURCE_MASK(bits) GENMASK_ULL((bits) - 1, 0)
128137
....@@ -243,6 +252,11 @@
243252 __clocksource_update_freq_scale(cs, 1000, khz);
244253 }
245254
255
+#ifdef CONFIG_ARCH_CLOCKSOURCE_INIT
256
+extern void clocksource_arch_init(struct clocksource *cs);
257
+#else
258
+static inline void clocksource_arch_init(struct clocksource *cs) { }
259
+#endif
246260
247261 extern int timekeeping_notify(struct clocksource *clock);
248262
....@@ -258,9 +272,6 @@
258272
259273 #define TIMER_OF_DECLARE(name, compat, fn) \
260274 OF_DECLARE_1_RET(timer, name, compat, fn)
261
-
262
-#define CLOCKSOURCE_OF_DECLARE(name, compat, fn) \
263
- TIMER_OF_DECLARE(name, compat, fn)
264275
265276 #ifdef CONFIG_TIMER_PROBE
266277 extern void timer_probe(void);