[GIT pull] timer updates for 4.17

2018-04-29 Thread Thomas Gleixner
Linus,

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

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

Two fixes from the timer departement:

 - Fix a long standing issue in the NOHZ tick code which causes RB tree
   corruption, delayed timers and other malfunctions. The cause for this is
   code which modifies the expiry time of an enqueued hrtimer.

 - Revert the CLOCK_MONOTONIC/CLOCK_BOOTTIME unification due to regression
   reports. Seems userspace _is_ relying on the documented behaviour
   despite our hope that it wont.

Thanks,

tglx

-->
Thomas Gleixner (2):
  tick/sched: Do not mess with an enqueued hrtimer
  Revert: Unify CLOCK_MONOTONIC and CLOCK_BOOTTIME


 Documentation/trace/ftrace.rst  | 14 +--
 drivers/input/evdev.c   |  7 +++-
 include/linux/hrtimer.h |  2 +
 include/linux/timekeeper_internal.h |  2 -
 include/linux/timekeeping.h | 37 --
 include/uapi/linux/time.h   |  1 -
 kernel/time/hrtimer.c   | 16 +++-
 kernel/time/posix-stubs.c   |  2 -
 kernel/time/posix-timers.c  | 26 -
 kernel/time/tick-common.c   | 15 ---
 kernel/time/tick-internal.h |  6 ---
 kernel/time/tick-sched.c| 19 +++--
 kernel/time/timekeeping.c   | 78 ++---
 kernel/time/timekeeping.h   |  1 +
 kernel/trace/trace.c|  2 +-
 15 files changed, 119 insertions(+), 109 deletions(-)

diff --git a/Documentation/trace/ftrace.rst b/Documentation/trace/ftrace.rst
index e45f0786f3f9..67d9c38e95eb 100644
--- a/Documentation/trace/ftrace.rst
+++ b/Documentation/trace/ftrace.rst
@@ -461,9 +461,17 @@ of ftrace. Here is a list of some of the key files:
and ticks at the same rate as the hardware clocksource.
 
boot:
-   Same as mono. Used to be a separate clock which accounted
-   for the time spent in suspend while CLOCK_MONOTONIC did
-   not.
+   This is the boot clock (CLOCK_BOOTTIME) and is based on the
+   fast monotonic clock, but also accounts for time spent in
+   suspend. Since the clock access is designed for use in
+   tracing in the suspend path, some side effects are possible
+   if clock is accessed after the suspend time is accounted before
+   the fast mono clock is updated. In this case, the clock update
+   appears to happen slightly sooner than it normally would have.
+   Also on 32-bit systems, it's possible that the 64-bit boot 
offset
+   sees a partial update. These effects are rare and post
+   processing should be able to handle them. See comments in the
+   ktime_get_boot_fast_ns() function for more information.
 
To set a clock, simply echo the clock name into this file::
 
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 46115a392098..c81c79d01d93 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -31,6 +31,7 @@
 enum evdev_clock_type {
EV_CLK_REAL = 0,
EV_CLK_MONO,
+   EV_CLK_BOOT,
EV_CLK_MAX
 };
 
@@ -197,10 +198,12 @@ static int evdev_set_clk_type(struct evdev_client 
*client, unsigned int clkid)
case CLOCK_REALTIME:
clk_type = EV_CLK_REAL;
break;
-   case CLOCK_BOOTTIME:
case CLOCK_MONOTONIC:
clk_type = EV_CLK_MONO;
break;
+   case CLOCK_BOOTTIME:
+   clk_type = EV_CLK_BOOT;
+   break;
default:
return -EINVAL;
}
@@ -311,6 +314,8 @@ static void evdev_events(struct input_handle *handle,
 
ev_time[EV_CLK_MONO] = ktime_get();
ev_time[EV_CLK_REAL] = ktime_mono_to_real(ev_time[EV_CLK_MONO]);
+   ev_time[EV_CLK_BOOT] = ktime_mono_to_any(ev_time[EV_CLK_MONO],
+TK_OFFS_BOOT);
 
rcu_read_lock();
 
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index a2656c3ebe81..3892e9c8b2de 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -161,9 +161,11 @@ struct hrtimer_clock_base {
 enum  hrtimer_base_type {
HRTIMER_BASE_MONOTONIC,
HRTIMER_BASE_REALTIME,
+   HRTIMER_BASE_BOOTTIME,
HRTIMER_BASE_TAI,
HRTIMER_BASE_MONOTONIC_SOFT,
HRTIMER_BASE_REALTIME_SOFT,
+   HRTIMER_BASE_BOOTTIME_SOFT,
HRTIMER_BASE_TAI_SOFT,
HRTIMER_MAX_CLOCK_BASES,
 };
diff --git a/include/linux/timekeeper_internal.h 
b/include/linux/timekeeper_internal.h
index 4b3dca173e89..7acb953298a7 100644
--- a/include/linux/timekeeper_internal.h
+++ b/include/linux/timekeeper_internal.h
@@ -52,7 +52,6 @@ struct tk_read_base {
  * @offs_real: Offset clock monotonic -> clock realtime
  * @offs_boot: 

[GIT pull] timer updates for 4.17

2018-04-16 Thread Thomas Gleixner
Linus,

please consider to 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

That's a branch which got forgotten during the merge window, but it
contains only fixes and hardware enablement. No fundamental changes.

 - Various fixes for the imx-tpm clocksource driver

 - A new timer driver for the NCPM7xx SoC family

Thanks,

tglx

-->
Anson Huang (4):
  dt-bindings: timer: tpm: fix typo of clock name
  clocksource/drivers/imx-tpm: Fix typo of clock name
  clocksource/drivers/imx-tpm: Correct some registers operation flow
  clocksource/drivers/imx-tpm: Add different counter width support

Tomer Maimon (2):
  dt-binding: timer: document NPCM7xx timer DT bindings
  clocksource/drivers/npcm: Add NPCM7xx timer driver


 .../bindings/timer/nuvoton,npcm7xx-timer.txt   |  21 ++
 .../devicetree/bindings/timer/nxp,tpm-timer.txt|   2 +-
 drivers/clocksource/Kconfig|   8 +
 drivers/clocksource/Makefile   |   1 +
 drivers/clocksource/timer-imx-tpm.c|  43 -
 drivers/clocksource/timer-npcm7xx.c| 215 +
 6 files changed, 279 insertions(+), 11 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/timer/nuvoton,npcm7xx-timer.txt
 create mode 100644 drivers/clocksource/timer-npcm7xx.c

diff --git a/Documentation/devicetree/bindings/timer/nuvoton,npcm7xx-timer.txt 
b/Documentation/devicetree/bindings/timer/nuvoton,npcm7xx-timer.txt
new file mode 100644
index ..ea22dfe485be
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/nuvoton,npcm7xx-timer.txt
@@ -0,0 +1,21 @@
+Nuvoton NPCM7xx timer
+
+Nuvoton NPCM7xx have three timer modules, each timer module provides five 
24-bit
+timer counters.
+
+Required properties:
+- compatible  : "nuvoton,npcm750-timer" for Poleg NPCM750.
+- reg : Offset and length of the register set for the device.
+- interrupts  : Contain the timer interrupt with flags for
+falling edge.
+- clocks  : phandle of timer reference clock (usually a 25 MHz clock).
+
+Example:
+
+timer@f0008000 {
+compatible = "nuvoton,npcm750-timer";
+interrupts = ;
+reg = <0xf0008000 0x50>;
+clocks = <&clk NPCM7XX_CLK_TIMER>;
+};
+
diff --git a/Documentation/devicetree/bindings/timer/nxp,tpm-timer.txt 
b/Documentation/devicetree/bindings/timer/nxp,tpm-timer.txt
index b4aa7ddb5b13..f82087b220f4 100644
--- a/Documentation/devicetree/bindings/timer/nxp,tpm-timer.txt
+++ b/Documentation/devicetree/bindings/timer/nxp,tpm-timer.txt
@@ -15,7 +15,7 @@ Required properties:
 - interrupts : Should be the clock event device interrupt.
 - clocks : The clocks provided by the SoC to drive the timer, must contain
an entry for each entry in clock-names.
-- clock-names : Must include the following entries: "igp" and "per".
+- clock-names : Must include the following entries: "ipg" and "per".
 
 Example:
 tpm5: tpm@4026 {
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index b3b4ed9b6874..76194bc20bdf 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -130,6 +130,14 @@ config VT8500_TIMER
help
  Enables support for the VT8500 driver.
 
+config NPCM7XX_TIMER
+   bool "NPCM7xx timer driver" if COMPILE_TEST
+   depends on HAS_IOMEM
+   select CLKSRC_MMIO
+   help
+ Enable 24-bit TIMER0 and TIMER1 counters in the NPCM7xx architecture,
+ While TIMER0 serves as clockevent and TIMER1 serves as clocksource.
+
 config CADENCE_TTC_TIMER
bool "Cadence TTC timer driver" if COMPILE_TEST
depends on COMMON_CLK
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index d6dec4489d66..74387877f7cf 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_CLKSRC_NPS)  += timer-nps.o
 obj-$(CONFIG_OXNAS_RPS_TIMER)  += timer-oxnas-rps.o
 obj-$(CONFIG_OWL_TIMER)+= owl-timer.o
 obj-$(CONFIG_SPRD_TIMER)   += timer-sprd.o
+obj-$(CONFIG_NPCM7XX_TIMER)+= timer-npcm7xx.o
 
 obj-$(CONFIG_ARC_TIMERS)   += arc_timer.o
 obj-$(CONFIG_ARM_ARCH_TIMER)   += arm_arch_timer.o
diff --git a/drivers/clocksource/timer-imx-tpm.c 
b/drivers/clocksource/timer-imx-tpm.c
index 21bffdcb2f20..05d97a6871d8 100644
--- a/drivers/clocksource/timer-imx-tpm.c
+++ b/drivers/clocksource/timer-imx-tpm.c
@@ -17,9 +17,14 @@
 #include 
 #include 
 
+#define TPM_PARAM  0x4
+#define TPM_PARAM_WIDTH_SHIFT  16
+#define TPM_PARAM_WIDTH_MASK   (0xff << 16)
 #define TPM_SC 0x10
 #define TPM_SC_CMOD_INC_PER_CNT(0x1 << 3)
 #define TPM_SC_CMOD_DIV_DEFAULT0x3
+#define TPM_SC_CMOD_DIV_MAX0x7
+#define TPM_SC_TOF_MASK