timer updates for 4.14
Subsystems (10)
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 small update for the time(r) subsystem:
- A new clocksource driver IMX-TPM
- Minor fixes to the alarmtimer facility
- Device tree cleanups for Renesas drivers
- A new kselftest and fixes for the timer related tests
- Conversion of the clocksource drivers to use %pOF
- Use the proper helpers to access rlimits in the posix-cpu-timer code.
Thanks,
tglx
------------------>
Alexandre Belloni (1):
alarmtimer: Ensure RTC module is not unloaded
Dong Aisheng (2):
dt-bindings: timer: Add nxp tpm timer binding doc clocksource/drivers/imx-tpm: Add imx tpm timer support
Geert Uytterhoeven (1):
alarmtimer: Fix unavailable wake-up source in sysfs
Greg Hackmann (2):
kselftests: timers: set-timer-lat: Tweak reporting when timer fires early
kselftests: timers: set-timer-lat: Add one-shot timer test cases
John Stultz (2):
kselftests: timers: freq-step: Define ADJ_SETOFFSET if device has older kernel headers
kselftests: timers: freq-step: Fix build warning
Krzysztof Opasiak (1):
posix-cpu-timers: Use dedicated helper to access rlimit values
Magnus Damm (6):
devicetree: bindings: Remove sh7372 CMT binding
devicetree: bindings: R-Car Gen2 CMT0 and CMT1 bindings
devicetree: bindings: r8a73a4 and R-Car Gen2 CMT bindings
devicetree: bindings: Deprecate property, update example
devicetree: bindings: Remove unused 32-bit CMT bindings
devicetree: bindings: Remove deprecated properties
Markus Elfring (1):
clocksource/drivers/bcm2835: Remove message for a memory allocation failure
Rob Herring (1):
clocksource: Convert to using %pOF instead of full_name
Stafford Horne (1):
timekeeping: Use proper timekeeper for debug code
.../devicetree/bindings/timer/nxp,tpm-timer.txt | 28 +++ .../devicetree/bindings/timer/renesas,cmt.txt | 73 +++---- drivers/clocksource/Kconfig | 8 + drivers/clocksource/Makefile | 1 + drivers/clocksource/bcm2835_timer.c | 1 - drivers/clocksource/tango_xtal.c | 6 +- drivers/clocksource/timer-imx-tpm.c | 239 +++++++++++++++++++++ drivers/clocksource/timer-of.c | 11 +- drivers/clocksource/timer-probe.c | 3 +- drivers/clocksource/timer-stm32.c | 8 +- kernel/time/alarmtimer.c | 17 +- kernel/time/posix-cpu-timers.c | 14 +- kernel/time/timekeeping.c | 2 +- tools/testing/selftests/timers/freq-step.c | 8 +- tools/testing/selftests/timers/set-timer-lat.c | 103 +++++++-- 15 files changed, 439 insertions(+), 83 deletions(-) create mode 100644 Documentation/devicetree/bindings/timer/nxp,tpm-timer.txt create mode 100644 drivers/clocksource/timer-imx-tpm.c
Documentation/devicetree/bindings/timer/nxp,tpm-timer.txt new file +28 -0
@@ -0,0 +1,28 @@ +NXP Low Power Timer/Pulse Width Modulation Module (TPM) + +The Timer/PWM Module (TPM) supports input capture, output compare, +and the generation of PWM signals to control electric motor and power +management applications. The counter, compare and capture registers +are clocked by an asynchronous clock that can remain enabled in low +power modes. TPM can support global counter bus where one TPM drives +the counter bus for the others, provided bit width is the same. + +Required properties: + +- compatible : should be "fsl,imx7ulp-tpm" +- reg : Specifies base physical address and size of the register sets + for the clock event device and clock source device. +- 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". + +Example: +tpm5: tpm@40260000 { + compatible = "fsl,imx7ulp-tpm"; + reg = <0x40260000 0x1000>; + interrupts = <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clks IMX7ULP_CLK_NIC1_BUS_DIV>, + <&clks IMX7ULP_CLK_LPTPM5>; + clock-names = "ipg", "per"; +};
Documentation/devicetree/bindings/timer/renesas,cmt.txt +32 -41
99 lines not on this page · raw message
drivers/clocksource/Kconfig +8 -0
@@ -598,6 +598,14 @@ config CLKSRC_IMX_GPT depends on ARM && CLKDEV_LOOKUP select CLKSRC_MMIO +config CLKSRC_IMX_TPM + bool "Clocksource using i.MX TPM" if COMPILE_TEST + depends on ARM && CLKDEV_LOOKUP && GENERIC_CLOCKEVENTS + select CLKSRC_MMIO + help + Enable this option to use IMX Timer/PWM Module (TPM) timer as + clocksource. + config CLKSRC_ST_LPC bool "Low power clocksource found in the LPC" if COMPILE_TEST select TIMER_OF if OF
drivers/clocksource/Makefile +1 -0
@@ -67,6 +67,7 @@ obj-$(CONFIG_CLKSRC_VERSATILE) += versatile.o obj-$(CONFIG_CLKSRC_MIPS_GIC) += mips-gic-timer.o obj-$(CONFIG_CLKSRC_TANGO_XTAL) += tango_xtal.o obj-$(CONFIG_CLKSRC_IMX_GPT) += timer-imx-gpt.o +obj-$(CONFIG_CLKSRC_IMX_TPM) += timer-imx-tpm.o obj-$(CONFIG_ASM9260_TIMER) += asm9260_timer.o obj-$(CONFIG_H8300_TMR8) += h8300_timer8.o obj-$(CONFIG_H8300_TMR16) += h8300_timer16.o
drivers/clocksource/bcm2835_timer.c +0 -1
@@ -114,7 +114,6 @@ static int __init bcm2835_timer_init(struct device_node *node) timer =kzalloc (sizeof (*timer),GFP_KERNEL );if (!timer) { -pr_err ("Can't allocate timer struct\n" ); ret = -ENOMEM ; goto err_iounmap; }
drivers/clocksource/tango_xtal.c +3 -3
@@ -26,13 +26,13 @@ static int __init tango_clocksource_init(struct device_node *np) xtal_in_cnt =of_iomap (np,0 );if (xtal_in_cnt ==NULL ) { -pr_err ("%s: invalid address\n" , np->full_name); +pr_err ("%pOF: invalid address\n" , np);return -ENXIO ; } clk =of_clk_get (np,0 );if (IS_ERR (clk)) { -pr_err ("%s: invalid clock\n" , np->full_name); +pr_err ("%pOF: invalid clock\n" , np);return PTR_ERR (clk); }
@@ -43,7 +43,7 @@ static int __init tango_clocksource_init(struct device_node *np) ret =clocksource_mmio_init (xtal_in_cnt,"tango-xtal" , xtal_freq,350 ,32 , clocksource_mmio_readl_up);if (ret) { -pr_err ("%s: registration failed\n" , np->full_name); +pr_err ("%pOF: registration failed\n" , np);return ret; }
drivers/clocksource/timer-imx-tpm.c new file +239 -0
239 lines not on this page · raw message
drivers/clocksource/timer-of.c +5 -6
@@ -52,7 +52,7 @@ static __init int timer_irq_init(struct device_node *np, of_irq->irq =irq_of_parse_and_map (np, of_irq->index); }if (!of_irq->irq) { -pr_err ("Failed to map interrupt for %s\n" , np->full_name); +pr_err ("Failed to map interrupt for %pOF\n" , np);return -EINVAL ; }
@@ -63,8 +63,7 @@ static __init int timer_irq_init(struct device_node *np, of_irq->flags ? of_irq->flags :IRQF_TIMER , np->full_name, clkevt);if (ret) { -pr_err ("Failed to request irq %d for %s\n" , of_irq->irq, - np->full_name); +pr_err ("Failed to request irq %d for %pOF\n" , of_irq->irq, np);return ret; }
@@ -88,20 +87,20 @@ static __init int timer_clk_init(struct device_node *np, of_clk->clk = of_clk->name ?of_clk_get_by_name (np, of_clk->name) :of_clk_get (np, of_clk->index);if (IS_ERR (of_clk->clk)) { -pr_err ("Failed to get clock for %s\n" , np->full_name); +pr_err ("Failed to get clock for %pOF\n" , np);return PTR_ERR (of_clk->clk); } ret =clk_prepare_enable (of_clk->clk);if (ret) { -pr_err ("Failed for enable clock for %s\n" , np->full_name); +pr_err ("Failed for enable clock for %pOF\n" , np); goto out_clk_put; } of_clk->rate =clk_get_rate (of_clk->clk);if (!of_clk->rate) { ret = -EINVAL ; -pr_err ("Failed to get clock rate for %s\n" , np->full_name); +pr_err ("Failed to get clock rate for %pOF\n" , np); goto out_clk_disable; }
drivers/clocksource/timer-probe.c +1 -2
@@ -40,8 +40,7 @@ void __init timer_probe(void) ret =init_func_ret (np);if (ret) { -pr_err ("Failed to initialize '%s': %d\n" , -of_node_full_name (np), ret); +pr_err ("Failed to initialize '%pOF': %d\n" , np, ret);continue ; }
drivers/clocksource/timer-stm32.c +4 -4
@@ -138,7 +138,7 @@ static int __init stm32_clockevent_init(struct device_node *np) irq =irq_of_parse_and_map (np,0 );if (!irq) { ret = -EINVAL ; -pr_err ("%s: failed to get irq.\n" , np->full_name); +pr_err ("%pOF: failed to get irq.\n" , np); goto err_get_irq; }
@@ -168,12 +168,12 @@ static int __init stm32_clockevent_init(struct device_node *np) ret =request_irq (irq, stm32_clock_event_handler,IRQF_TIMER ,"stm32 clockevent" , data);if (ret) { -pr_err ("%s: failed to request irq.\n" , np->full_name); +pr_err ("%pOF: failed to request irq.\n" , np); goto err_get_irq; } -pr_info ("%s: STM32 clockevent driver initialized (%d bits)\n" , - np->full_name, bits); +pr_info ("%pOF: STM32 clockevent driver initialized (%d bits)\n" , + np, bits);return ret;
kernel/time/alarmtimer.c +15 -2
@@ -28,6 +28,7 @@#include <linux/workqueue.h> #include <linux/freezer.h> #include <linux/compat.h> +#include <linux/module.h> #include "posix-timers.h"
@@ -56,9 +57,9 @@ static ktime_t freezer_delta;static DEFINE_SPINLOCK (freezer_delta_lock);#endif +#ifdef CONFIG_RTC_CLASS static struct wakeup_source *ws; -#ifdef CONFIG_RTC_CLASS /* rtc timer and device for setting alarm wakeups at suspend */ static struct rtc_timer rtctimer;static struct rtc_device *rtcdev;
@@ -89,6 +90,7 @@ static int alarmtimer_rtc_add_device(struct device *dev, {unsigned long flags;struct rtc_device *rtc =to_rtc_device (dev); +struct wakeup_source *__ws;if (rtcdev)return -EBUSY ;
@@ -98,13 +100,25 @@ static int alarmtimer_rtc_add_device(struct device *dev,if (!device_may_wakeup (rtc->dev.parent))return -1 ; + __ws =wakeup_source_register ("alarmtimer" ); +spin_lock_irqsave (&rtcdev_lock, flags);if (!rtcdev) { +if (!try_module_get (rtc->owner)) { +spin_unlock_irqrestore (&rtcdev_lock, flags); +return -1 ; + } + rtcdev = rtc;/* hold a reference so it doesn't go away */ get_device (dev); + ws = __ws; + __ws =NULL ; }spin_unlock_irqrestore (&rtcdev_lock, flags); + +wakeup_source_unregister (__ws); +return 0 ; }
@@ -860,7 +874,6 @@ static int __init alarmtimer_init(void) error =PTR_ERR (pdev); goto out_drv; } - ws =wakeup_source_register ("alarmtimer" );return 0 ; out_drv:
kernel/time/posix-cpu-timers.c +6 -8
@@ -799,7 +799,6 @@ static void check_thread_timers(struct task_struct *tsk, struct list_head *firing) {struct list_head *timers = tsk->cpu_timers; -struct signal_struct *const sig = tsk->signal;struct task_cputime *tsk_expires = &tsk->cputime_expires;u64 expires;unsigned long soft;
@@ -823,10 +822,9 @@ static void check_thread_timers(struct task_struct *tsk,/* * Check for the special case thread timers. */ - soft =READ_ONCE (sig->rlim[RLIMIT_RTTIME ].rlim_cur); + soft =task_rlimit (tsk,RLIMIT_RTTIME );if (soft !=RLIM_INFINITY ) { -unsigned long hard = -READ_ONCE (sig->rlim[RLIMIT_RTTIME ].rlim_max); +unsigned long hard =task_rlimit_max (tsk,RLIMIT_RTTIME );if (hard !=RLIM_INFINITY && tsk->rt.timeout >DIV_ROUND_UP (hard,USEC_PER_SEC /HZ )) {
@@ -847,7 +845,8 @@ static void check_thread_timers(struct task_struct *tsk,*/ if (soft < hard) { soft +=USEC_PER_SEC ; - sig->rlim[RLIMIT_RTTIME ].rlim_cur = soft; + tsk->signal->rlim[RLIMIT_RTTIME ].rlim_cur = + soft; }if (print_fatal_signals) { pr_info("RT Watchdog Timeout (soft): %s[%d]\n",
@@ -938,11 +937,10 @@ static void check_process_timers(struct task_struct *tsk, SIGPROF);check_cpu_itimer (tsk, &sig->it[CPUCLOCK_VIRT ], &virt_expires, utime,SIGVTALRM ); - soft =READ_ONCE (sig->rlim[RLIMIT_CPU ].rlim_cur); + soft =task_rlimit (tsk,RLIMIT_CPU );if (soft !=RLIM_INFINITY ) {unsigned long psecs =div_u64 (ptime,NSEC_PER_SEC ); -unsigned long hard = -READ_ONCE (sig->rlim[RLIMIT_CPU ].rlim_max); +unsigned long hard =task_rlimit_max (tsk,RLIMIT_CPU );u64 x;if (psecs >= hard) {/*
kernel/time/timekeeping.c +1 -1
@@ -2066,7 +2066,7 @@ void update_wall_time(void) goto out;/* Do some additional sanity checking */ -timekeeping_check_update (real_tk, offset); +timekeeping_check_update (tk, offset);/* * With NO_HZ we may have to accumulate many cycle_intervals
tools/testing/selftests/timers/freq-step.c +6 -2
@@ -33,6 +33,10 @@#define MAX_FREQ_ERROR 10e-6#define MAX_STDDEV 1000e-9 +#ifndef ADJ_SETOFFSET +#define ADJ_SETOFFSET 0x0100 +#endif +struct sample {double offset;double time;
@@ -262,7 +266,7 @@ int main(int argc, char **argv)set_frequency (0.0 );if (fails) -ksft_exit_fail (); +return ksft_exit_fail (); -ksft_exit_pass (); +return ksft_exit_pass (); }
tools/testing/selftests/timers/set-timer-lat.c +90 -13
164 lines not on this page · raw message