Skip to contentSkip to conversation

timer updates for 4,9

GIT PULL Thomas Gleixner 1 participant 1 message Oct 3, 2016

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

Linus,

please pull the latest timers-core-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers-core-for-linus

A rather smalish set of updates for timers and timekeeping:

- Two core fixes to prevent potential undefinded behaviour about which gcc is complaining rightfully.

- A fix to prevent stopping the tick on an (soon) offline CPU so it can complete the shutdown procedure.

- Wait for clocks to stabilize before making decisions, so a not yet validated clock is not rejected.

- The usual pile of fixes to the various clocksource drivers.

- Core code typo and include fixlets.

Thanks,

tglx

------------------>
Alexandre Belloni (3):
clocksource/drivers/timer-atmel-pit: Drop at91sam926x_pit_common_init clocksource/drivers/timer-atmel-pit: Remove uselesss WARN_ON_ONCE clocksource/drivers/timer-atmel-pit: Simplify IRQ handler

Christoph Hellwig (1):
timekeeping: Include the correct header for errno definitions

Daniel Lezcano (2):
clocksource/drivers/moxart: Replace setup_irq by request_irq clocksource/drivers/moxart: Replace panic by pr_err

Jisheng Zhang (1):
clocksource/drivers/ti-32k: Prevent ftrace recursion

Joel Stanley (3):
clocksource/drivers/moxart: Refactor enable/disable clocksource/drivers/moxart: Use struct to hold state clocksource/drivers/moxart: Add Aspeed support

Kyle Walker (1):
clocksource: Defer override invalidation unless clock is unstable

Neil Armstrong (1):
clocksource/drivers/oxnas: Add OX820 compatible

Paul Burton (2):
clocksource/mips-gic-timer: Print an error if IRQ setup fails clocksource/mips-gic-timer: Stop checking cpu_has_counter

Pratyush Patel (1):
hrtimer: Spelling fixes

Ruchi Kandoi (1):
timekeeping: Prints the amounts of time spent during suspend

Vegard Nossum (2):
time: Avoid undefined behaviour in timespec64_add_safe()
time: Avoid undefined behaviour in ktime_add_safe()

Wanpeng Li (1):
tick/nohz: Prevent stopping the tick on an offline CPU

 .../bindings/timer/moxa,moxart-timer.txt           |   4 +-
 .../devicetree/bindings/timer/oxsemi,rps-timer.txt |   2 +-
 drivers/clocksource/mips-gic-timer.c               |   7 +-
 drivers/clocksource/moxart_timer.c                 | 193 ++++++++++++++-------
 drivers/clocksource/timer-atmel-pit.c              |  96 ++++------
 drivers/clocksource/timer-oxnas-rps.c              |   2 +
 drivers/clocksource/timer-ti-32k.c                 |   2 +-
 include/linux/ktime.h                              |   7 +
 include/linux/time64.h                             |   1 +
 include/linux/timekeeping.h                        |   2 +-
 kernel/time/clocksource.c                          |  15 +-
 kernel/time/hrtimer.c                              |   6 +-
 kernel/time/tick-sched.c                           |   7 +-
 kernel/time/time.c                                 |   2 +-
 kernel/time/timekeeping_debug.c                    |   2 +
 15 files changed, 210 insertions(+), 138 deletions(-)
Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt +3 -1
index da2d510cae47..e207c11630af 100644
@@ -2,7 +2,9 @@ MOXA ART timer
 
 Required properties:
 
-- compatible : Must be "moxa,moxart-timer"
+- compatible : Must be one of:
+ 	- "moxa,moxart-timer"
+ 	- "aspeed,ast2400-timer"
 - reg : Should contain registers location and length
 - interrupts : Should contain the timer interrupt number
 - clocks : Should contain phandle for the clock that drives the counter
Documentation/devicetree/bindings/timer/oxsemi,rps-timer.txt +1 -1
index 3ca89cd1caef..d191612539e8 100644
@@ -2,7 +2,7 @@ Oxford Semiconductor OXNAS SoCs Family RPS Timer
 ================================================
 
 Required properties:
-- compatible: Should be "oxsemi,ox810se-rps-timer"
+- compatible: Should be "oxsemi,ox810se-rps-timer" or "oxsemi,ox820-rps-timer"
 - reg : Specifies base physical address and size of the registers.
 - interrupts : The interrupts of the two timers
 - clocks : The phandle of the timer clock source
drivers/clocksource/mips-gic-timer.c +5 -2
index b4b3ab5a11ad..7a960cd01104 100644
@@ -109,12 +109,15 @@ static int gic_clockevent_init(void)
 {
 	int ret;
 
-	if (!cpu_has_counter || !gic_frequency)
+	if (!gic_frequency)
 		return -ENXIO;
 
 	ret = setup_percpu_irq(gic_timer_irq, &gic_compare_irqaction);
-	if (ret < 0)
+	if (ret < 0) {
+		pr_err("GIC timer IRQ %d setup failed: %d\n",
+		       gic_timer_irq, ret);
 		return ret;
+	}
 
 	cpuhp_setup_state(CPUHP_AP_MIPS_GIC_TIMER_STARTING,
 			  "AP_MIPS_GIC_TIMER_STARTING", gic_starting_cpu,
drivers/clocksource/moxart_timer.c +129 -64

272 lines not on this page · raw message

drivers/clocksource/timer-atmel-pit.c +37 -59

118 lines not on this page · raw message

drivers/clocksource/timer-oxnas-rps.c +2 -0
index bd887e2a8cf8..d630bf417773 100644
@@ -295,3 +295,5 @@ err_alloc:
 
 CLOCKSOURCE_OF_DECLARE(ox810se_rps,
 		       "oxsemi,ox810se-rps-timer", oxnas_rps_timer_init);
+CLOCKSOURCE_OF_DECLARE(ox820_rps,
+		       "oxsemi,ox820se-rps-timer", oxnas_rps_timer_init);
drivers/clocksource/timer-ti-32k.c +1 -1
index 92b7e390f6c8..cf5b14e442e4 100644
@@ -65,7 +65,7 @@ static inline struct ti_32k *to_ti_32k(struct clocksource *cs)
 	return container_of(cs, struct ti_32k, cs);
 }
 
-static cycle_t ti_32k_read_cycles(struct clocksource *cs)
+static cycle_t notrace ti_32k_read_cycles(struct clocksource *cs)
 {
 	struct ti_32k *ti = to_ti_32k(cs);
 
include/linux/ktime.h +7 -0
index 2b6a204bd8d4..3ffc69ebe967 100644
@@ -64,6 +64,13 @@ static inline ktime_t ktime_set(const s64 secs, const unsigned long nsecs)
 		({ (ktime_t){ .tv64 = (lhs).tv64 + (rhs).tv64 }; })
 
 /*
+ * Same as ktime_add(), but avoids undefined behaviour on overflow; however,
+ * this means that you must check the result for overflow yourself.
+ */
+#define ktime_add_unsafe(lhs, rhs) \
+		({ (ktime_t){ .tv64 = (u64) (lhs).tv64 + (rhs).tv64 }; })
+
+/*
  * Add a ktime_t variable and a scalar nanosecond value.
  * res = kt + nsval:
  */
include/linux/time64.h +1 -0
index 7e5d2fa9ac46..980c71b3001a 100644
@@ -5,6 +5,7 @@
 #include <linux/math64.h>
 
 typedef __s64 time64_t;
+typedef __u64 timeu64_t;
 
 /*
  * This wants to go into uapi/linux/time.h once we agreed about the
include/linux/timekeeping.h +1 -1
index 816b7543f81b..09168c52ab64 100644
@@ -1,7 +1,7 @@
 #ifndef _LINUX_TIMEKEEPING_H
 #define _LINUX_TIMEKEEPING_H
 
-#include <asm-generic/errno-base.h>
+#include <linux/errno.h>
 
 /* Included from linux/ktime.h */
 
kernel/time/clocksource.c +12 -3
index 6a5a310a1a53..7e4fad75acaa 100644
@@ -600,9 +600,18 @@ static void __clocksource_select(bool skipcur)
 		 */
 		if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && oneshot) {
 			/* Override clocksource cannot be used. */
-			pr_warn("Override clocksource %s is not HRT compatible - cannot switch while in HRT/NOHZ mode\n",
-				cs->name);
-			override_name[0] = 0;
+			if (cs->flags & CLOCK_SOURCE_UNSTABLE) {
+				pr_warn("Override clocksource %s is unstable and not HRT compatible - cannot switch while in HRT/NOHZ mode\n",
+					cs->name);
+				override_name[0] = 0;
+			} else {
+				/*
+				 * The override cannot be currently verified.
+				 * Deferring to let the watchdog check.
+				 */
+				pr_info("Override clocksource %s is not currently HRT compatible - deferring\n",
+					cs->name);
+			}
 		} else
 			/* Override clocksource can be used. */
 			best = cs;
kernel/time/hrtimer.c +3 -3
index 9ba7c820fc23..bb5ec425dfe0 100644
@@ -307,7 +307,7 @@ EXPORT_SYMBOL_GPL(__ktime_divns);
  */
 ktime_t ktime_add_safe(const ktime_t lhs, const ktime_t rhs)
 {
-	ktime_t res = ktime_add(lhs, rhs);
+	ktime_t res = ktime_add_unsafe(lhs, rhs);
 
 	/*
 	 * We use KTIME_SEC_MAX here, the maximum timeout which we can
@@ -703,7 +703,7 @@ static void clock_was_set_work(struct work_struct *work)
 static DECLARE_WORK(hrtimer_work, clock_was_set_work);
 
 /*
- * Called from timekeeping and resume code to reprogramm the hrtimer
+ * Called from timekeeping and resume code to reprogram the hrtimer
  * interrupt device on all cpus.
  */
 void clock_was_set_delayed(void)
@@ -1241,7 +1241,7 @@ static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base,
 
 	/*
 	 * Note: We clear the running state after enqueue_hrtimer and
-	 * we do not reprogramm the event hardware. Happens either in
+	 * we do not reprogram the event hardware. Happens either in
 	 * hrtimer_start_range_ns() or in hrtimer_interrupt()
 	 *
 	 * Note: Because we dropped the cpu_base->lock above,
kernel/time/tick-sched.c +5 -2
index 2ec7c00228f3..3bcb61b52f6c 100644
@@ -186,10 +186,13 @@ static bool check_tick_dependency(atomic_t *dep)
 	return false;
 }
 
-static bool can_stop_full_tick(struct tick_sched *ts)
+static bool can_stop_full_tick(int cpu, struct tick_sched *ts)
 {
 	WARN_ON_ONCE(!irqs_disabled());
 
+	if (unlikely(!cpu_online(cpu)))
+		return false;
+
 	if (check_tick_dependency(&tick_dep_mask))
 		return false;
 
@@ -843,7 +846,7 @@ static void tick_nohz_full_update_tick(struct tick_sched *ts)
 	if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
 		return;
 
-	if (can_stop_full_tick(ts))
+	if (can_stop_full_tick(cpu, ts))
 		tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
 	else if (ts->tick_stopped)
 		tick_nohz_restart_sched_tick(ts, ktime_get());
kernel/time/time.c +1 -1
index 667b9335f5d6..bd62fb8e8e77 100644
@@ -780,7 +780,7 @@ struct timespec64 timespec64_add_safe(const struct timespec64 lhs,
 {
 	struct timespec64 res;
 
-	set_normalized_timespec64(&res, lhs.tv_sec + rhs.tv_sec,
+	set_normalized_timespec64(&res, (timeu64_t) lhs.tv_sec + rhs.tv_sec,
 			lhs.tv_nsec + rhs.tv_nsec);
 
 	if (unlikely(res.tv_sec < lhs.tv_sec || res.tv_sec < rhs.tv_sec)) {
kernel/time/timekeeping_debug.c +2 -0
index 107310a6f36f..ca9fb800336b 100644
@@ -75,5 +75,7 @@ void tk_debug_account_sleep_time(struct timespec64 *t)
 	int bin = min(fls(t->tv_sec), NUM_BINS-1);
 
 	sleep_time_bin[bin]++;
+	pr_info("Suspended for %lld.%03lu seconds\n", (s64)t->tv_sec,
+			t->tv_nsec / NSEC_PER_MSEC);
 }