.. | .. |
---|
23 | 23 | struct clocksource; |
---|
24 | 24 | struct module; |
---|
25 | 25 | |
---|
26 | | -#ifdef CONFIG_ARCH_CLOCKSOURCE_DATA |
---|
| 26 | +#if defined(CONFIG_ARCH_CLOCKSOURCE_DATA) || \ |
---|
| 27 | + defined(CONFIG_GENERIC_GETTIMEOFDAY) |
---|
27 | 28 | #include <asm/clocksource.h> |
---|
28 | 29 | #endif |
---|
29 | 30 | |
---|
.. | .. |
---|
34 | 35 | * Provides mostly state-free accessors to the underlying hardware. |
---|
35 | 36 | * This is the structure used for system time. |
---|
36 | 37 | * |
---|
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) |
---|
40 | 51 | * To avoid rating inflation the following |
---|
41 | 52 | * list should give you a guide as to how |
---|
42 | 53 | * to assign your clocksource a rating |
---|
.. | .. |
---|
51 | 62 | * 400-499: Perfect |
---|
52 | 63 | * The ideal clocksource. A must-use where |
---|
53 | 64 | * 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 |
---|
68 | 70 | * @mark_unstable: Optional function to inform the clocksource driver that |
---|
69 | 71 | * 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 |
---|
71 | 78 | * |
---|
72 | 79 | * Note: This struct is not used in hotpathes of the timekeeping code |
---|
73 | 80 | * 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, |
---|
75 | 82 | * |
---|
76 | 83 | * The pointer to the clocksource itself is handed to the read |
---|
77 | 84 | * callback. If you need extra information there you can wrap struct |
---|
.. | .. |
---|
80 | 87 | * structure. |
---|
81 | 88 | */ |
---|
82 | 89 | 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; |
---|
89 | 96 | #ifdef CONFIG_ARCH_CLOCKSOURCE_DATA |
---|
90 | 97 | struct arch_clocksource_data archdata; |
---|
91 | 98 | #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); |
---|
103 | 112 | |
---|
104 | 113 | /* private: */ |
---|
105 | 114 | #ifdef CONFIG_CLOCKSOURCE_WATCHDOG |
---|
106 | 115 | /* 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; |
---|
110 | 119 | #endif |
---|
111 | | - struct module *owner; |
---|
| 120 | + struct module *owner; |
---|
112 | 121 | }; |
---|
113 | 122 | |
---|
114 | 123 | /* |
---|
.. | .. |
---|
122 | 131 | #define CLOCK_SOURCE_UNSTABLE 0x40 |
---|
123 | 132 | #define CLOCK_SOURCE_SUSPEND_NONSTOP 0x80 |
---|
124 | 133 | #define CLOCK_SOURCE_RESELECT 0x100 |
---|
125 | | - |
---|
| 134 | +#define CLOCK_SOURCE_VERIFY_PERCPU 0x200 |
---|
126 | 135 | /* simplify initialization of mask field */ |
---|
127 | 136 | #define CLOCKSOURCE_MASK(bits) GENMASK_ULL((bits) - 1, 0) |
---|
128 | 137 | |
---|
.. | .. |
---|
243 | 252 | __clocksource_update_freq_scale(cs, 1000, khz); |
---|
244 | 253 | } |
---|
245 | 254 | |
---|
| 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 |
---|
246 | 260 | |
---|
247 | 261 | extern int timekeeping_notify(struct clocksource *clock); |
---|
248 | 262 | |
---|
.. | .. |
---|
258 | 272 | |
---|
259 | 273 | #define TIMER_OF_DECLARE(name, compat, fn) \ |
---|
260 | 274 | OF_DECLARE_1_RET(timer, name, compat, fn) |
---|
261 | | - |
---|
262 | | -#define CLOCKSOURCE_OF_DECLARE(name, compat, fn) \ |
---|
263 | | - TIMER_OF_DECLARE(name, compat, fn) |
---|
264 | 275 | |
---|
265 | 276 | #ifdef CONFIG_TIMER_PROBE |
---|
266 | 277 | extern void timer_probe(void); |
---|