Skip to content

Commit 9465d9c

Browse files
committed
Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer updates from Thomas Gleixner: "The time/timekeeping/timer folks deliver with this update: - Fix a reintroduced signed/unsigned issue and cleanup the whole signed/unsigned mess in the timekeeping core so this wont happen accidentaly again. - Add a new trace clock based on boot time - Prevent injection of random sleep times when PM tracing abuses the RTC for storage - Make posix timers configurable for real tiny systems - Add tracepoints for the alarm timer subsystem so timer based suspend wakeups can be instrumented - The usual pile of fixes and updates to core and drivers" * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (23 commits) timekeeping: Use mul_u64_u32_shr() instead of open coding it timekeeping: Get rid of pointless typecasts timekeeping: Make the conversion call chain consistently unsigned timekeeping_Force_unsigned_clocksource_to_nanoseconds_conversion alarmtimer: Add tracepoints for alarm timers trace: Update documentation for mono, mono_raw and boot clock trace: Add an option for boot clock as trace clock timekeeping: Add a fast and NMI safe boot clock timekeeping/clocksource_cyc2ns: Document intended range limitation timekeeping: Ignore the bogus sleep time if pm_trace is enabled selftests/timers: Fix spelling mistake "Asyncrhonous" -> "Asynchronous" clocksource/drivers/bcm2835_timer: Unmap region obtained by of_iomap clocksource/drivers/arm_arch_timer: Map frame with of_io_request_and_map() arm64: dts: rockchip: Arch counter doesn't tick in system suspend clocksource/drivers/arm_arch_timer: Don't assume clock runs in suspend posix-timers: Make them configurable posix_cpu_timers: Move the add_device_randomness() call to a proper place timer: Move sys_alarm from timer.c to itimer.c ptp_clock: Allow for it to be optional Kconfig: Regenerate *.c_shipped files after previous changes ...
2 parents e71c397 + c029a2b commit 9465d9c

61 files changed

Lines changed: 1479 additions & 1041 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/devicetree/bindings/arm/arch_timer.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ to deliver its interrupts via SPIs.
3838
architecturally-defined reset values. Only supported for 32-bit
3939
systems which follow the ARMv7 architected reset values.
4040

41+
- arm,no-tick-in-suspend : The main counter does not tick when the system is in
42+
low-power system suspend on some SoCs. This behavior does not match the
43+
Architecture Reference Manual's specification that the system counter "must
44+
be implemented in an always-on power domain."
45+
4146

4247
Example:
4348

‎Documentation/kbuild/kconfig-language.txt‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,34 @@ applicable everywhere (see syntax).
113113
That will limit the usefulness but on the other hand avoid
114114
the illegal configurations all over.
115115

116+
- weak reverse dependencies: "imply" <symbol> ["if" <expr>]
117+
This is similar to "select" as it enforces a lower limit on another
118+
symbol except that the "implied" symbol's value may still be set to n
119+
from a direct dependency or with a visible prompt.
120+
121+
Given the following example:
122+
123+
config FOO
124+
tristate
125+
imply BAZ
126+
127+
config BAZ
128+
tristate
129+
depends on BAR
130+
131+
The following values are possible:
132+
133+
FOO BAR BAZ's default choice for BAZ
134+
--- --- ------------- --------------
135+
n y n N/m/y
136+
m y m M/y/n
137+
y y y Y/n
138+
y n * N
139+
140+
This is useful e.g. with multiple drivers that want to indicate their
141+
ability to hook into a secondary subsystem while allowing the user to
142+
configure that subsystem out without also having to unset these drivers.
143+
116144
- limiting menu display: "visible if" <expr>
117145
This attribute is only applicable to menu blocks, if the condition is
118146
false, the menu block is not displayed to the user (the symbols
@@ -481,6 +509,7 @@ historical issues resolved through these different solutions.
481509
b) Match dependency semantics:
482510
b1) Swap all "select FOO" to "depends on FOO" or,
483511
b2) Swap all "depends on FOO" to "select FOO"
512+
c) Consider the use of "imply" instead of "select"
484513

485514
The resolution to a) can be tested with the sample Kconfig file
486515
Documentation/kbuild/Kconfig.recursion-issue-01 through the removal

‎Documentation/trace/ftrace.txt‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,26 @@ of ftrace. Here is a list of some of the key files:
362362
to correlate events across hypervisor/guest if
363363
tb_offset is known.
364364

365+
mono: This uses the fast monotonic clock (CLOCK_MONOTONIC)
366+
which is monotonic and is subject to NTP rate adjustments.
367+
368+
mono_raw:
369+
This is the raw monotonic clock (CLOCK_MONOTONIC_RAW)
370+
which is montonic but is not subject to any rate adjustments
371+
and ticks at the same rate as the hardware clocksource.
372+
373+
boot: This is the boot clock (CLOCK_BOOTTIME) and is based on the
374+
fast monotonic clock, but also accounts for time spent in
375+
suspend. Since the clock access is designed for use in
376+
tracing in the suspend path, some side effects are possible
377+
if clock is accessed after the suspend time is accounted before
378+
the fast mono clock is updated. In this case, the clock update
379+
appears to happen slightly sooner than it normally would have.
380+
Also on 32-bit systems, it's possible that the 64-bit boot offset
381+
sees a partial update. These effects are rare and post
382+
processing should be able to handle them. See comments in the
383+
ktime_get_boot_fast_ns() function for more information.
384+
365385
To set a clock, simply echo the clock name into this file.
366386

367387
echo global > trace_clock

‎arch/alpha/kernel/osf_sys.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,11 +1029,16 @@ SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv,
10291029
return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
10301030
}
10311031

1032+
asmlinkage long sys_ni_posix_timers(void);
1033+
10321034
SYSCALL_DEFINE2(osf_getitimer, int, which, struct itimerval32 __user *, it)
10331035
{
10341036
struct itimerval kit;
10351037
int error;
10361038

1039+
if (!IS_ENABLED(CONFIG_POSIX_TIMERS))
1040+
return sys_ni_posix_timers();
1041+
10371042
error = do_getitimer(which, &kit);
10381043
if (!error && put_it32(it, &kit))
10391044
error = -EFAULT;
@@ -1047,6 +1052,9 @@ SYSCALL_DEFINE3(osf_setitimer, int, which, struct itimerval32 __user *, in,
10471052
struct itimerval kin, kout;
10481053
int error;
10491054

1055+
if (!IS_ENABLED(CONFIG_POSIX_TIMERS))
1056+
return sys_ni_posix_timers();
1057+
10501058
if (in) {
10511059
if (get_it32(&kin, in))
10521060
return -EFAULT;

‎arch/arm64/boot/dts/rockchip/rk3399.dtsi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
<GIC_PPI 14 IRQ_TYPE_LEVEL_LOW 0>,
175175
<GIC_PPI 11 IRQ_TYPE_LEVEL_LOW 0>,
176176
<GIC_PPI 10 IRQ_TYPE_LEVEL_LOW 0>;
177+
arm,no-tick-in-suspend;
177178
};
178179

179180
xin24m: xin24m {

‎arch/x86/kernel/rtc.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ void mach_get_cmos_time(struct timespec *now)
6464
unsigned int status, year, mon, day, hour, min, sec, century = 0;
6565
unsigned long flags;
6666

67+
/*
68+
* If pm_trace abused the RTC as storage, set the timespec to 0,
69+
* which tells the caller that this RTC value is unusable.
70+
*/
71+
if (!pm_trace_rtc_valid()) {
72+
now->tv_sec = now->tv_nsec = 0;
73+
return;
74+
}
75+
6776
spin_lock_irqsave(&rtc_lock, flags);
6877

6978
/*

‎drivers/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ obj-$(CONFIG_INPUT) += input/
107107
obj-$(CONFIG_RTC_LIB) += rtc/
108108
obj-y += i2c/ media/
109109
obj-$(CONFIG_PPS) += pps/
110-
obj-$(CONFIG_PTP_1588_CLOCK) += ptp/
110+
obj-y += ptp/
111111
obj-$(CONFIG_W1) += w1/
112112
obj-y += power/
113113
obj-$(CONFIG_HWMON) += hwmon/

‎drivers/base/power/trace.c‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/pm-trace.h>
1111
#include <linux/export.h>
1212
#include <linux/rtc.h>
13+
#include <linux/suspend.h>
1314

1415
#include <linux/mc146818rtc.h>
1516

@@ -74,6 +75,9 @@
7475

7576
#define DEVSEED (7919)
7677

78+
bool pm_trace_rtc_abused __read_mostly;
79+
EXPORT_SYMBOL_GPL(pm_trace_rtc_abused);
80+
7781
static unsigned int dev_hash_value;
7882

7983
static int set_magic_time(unsigned int user, unsigned int file, unsigned int device)
@@ -104,6 +108,7 @@ static int set_magic_time(unsigned int user, unsigned int file, unsigned int dev
104108
time.tm_min = (n % 20) * 3;
105109
n /= 20;
106110
mc146818_set_time(&time);
111+
pm_trace_rtc_abused = true;
107112
return n ? -1 : 0;
108113
}
109114

@@ -239,9 +244,31 @@ int show_trace_dev_match(char *buf, size_t size)
239244
return ret;
240245
}
241246

247+
static int
248+
pm_trace_notify(struct notifier_block *nb, unsigned long mode, void *_unused)
249+
{
250+
switch (mode) {
251+
case PM_POST_HIBERNATION:
252+
case PM_POST_SUSPEND:
253+
if (pm_trace_rtc_abused) {
254+
pm_trace_rtc_abused = false;
255+
pr_warn("Possible incorrect RTC due to pm_trace, please use 'ntpdate' or 'rdate' to reset it.\n");
256+
}
257+
break;
258+
default:
259+
break;
260+
}
261+
return 0;
262+
}
263+
264+
static struct notifier_block pm_trace_nb = {
265+
.notifier_call = pm_trace_notify,
266+
};
267+
242268
static int early_resume_init(void)
243269
{
244270
hash_value_early_read = read_magic_time();
271+
register_pm_notifier(&pm_trace_nb);
245272
return 0;
246273
}
247274

‎drivers/char/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ config HANGCHECK_TIMER
542542
config MMTIMER
543543
tristate "MMTIMER Memory mapped RTC for SGI Altix"
544544
depends on IA64_GENERIC || IA64_SGI_SN2
545+
depends on POSIX_TIMERS
545546
default y
546547
help
547548
The mmtimer device allows direct userspace access to the

‎drivers/clocksource/arm_arch_timer.c‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ static struct clock_event_device __percpu *arch_timer_evt;
8181
static enum ppi_nr arch_timer_uses_ppi = VIRT_PPI;
8282
static bool arch_timer_c3stop;
8383
static bool arch_timer_mem_use_virtual;
84+
static bool arch_counter_suspend_stop;
8485

8586
static bool evtstrm_enable = IS_ENABLED(CONFIG_ARM_ARCH_TIMER_EVTSTREAM);
8687

@@ -576,7 +577,7 @@ static struct clocksource clocksource_counter = {
576577
.rating = 400,
577578
.read = arch_counter_read,
578579
.mask = CLOCKSOURCE_MASK(56),
579-
.flags = CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SUSPEND_NONSTOP,
580+
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
580581
};
581582

582583
static struct cyclecounter cyclecounter = {
@@ -616,6 +617,8 @@ static void __init arch_counter_register(unsigned type)
616617
arch_timer_read_counter = arch_counter_get_cntvct_mem;
617618
}
618619

620+
if (!arch_counter_suspend_stop)
621+
clocksource_counter.flags |= CLOCK_SOURCE_SUSPEND_NONSTOP;
619622
start_count = arch_timer_read_counter();
620623
clocksource_register_hz(&clocksource_counter, arch_timer_rate);
621624
cyclecounter.mult = clocksource_counter.mult;
@@ -907,6 +910,10 @@ static int __init arch_timer_of_init(struct device_node *np)
907910
of_property_read_bool(np, "arm,cpu-registers-not-fw-configured"))
908911
arch_timer_uses_ppi = PHYS_SECURE_PPI;
909912

913+
/* On some systems, the counter stops ticking when in suspend. */
914+
arch_counter_suspend_stop = of_property_read_bool(np,
915+
"arm,no-tick-in-suspend");
916+
910917
return arch_timer_init();
911918
}
912919
CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init);
@@ -964,8 +971,9 @@ static int __init arch_timer_mem_init(struct device_node *np)
964971
}
965972

966973
ret= -ENXIO;
967-
base = arch_counter_base = of_iomap(best_frame, 0);
968-
if (!base) {
974+
base = arch_counter_base = of_io_request_and_map(best_frame, 0,
975+
"arch_mem_timer");
976+
if (IS_ERR(base)) {
969977
pr_err("arch_timer: Can't map frame's registers\n");
970978
goto out;
971979
}

0 commit comments

Comments
 (0)