Skip to content

Commit 6242258

Browse files
committed
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fixes from Thomas Gleixner: "A small set of fixes for time(r) related issues: - Fix a long standing conversion issue in jiffies_to_msecs() for odd HZ values like 1024 or 1200 which resulted in returning 0 for small jiffies values due to rounding down. - Use the proper CONFIG symbol in the new Y2038 safe compat code for posix-timers. Not yet a visible breakage, but this will immediately trigger when the architecture support for the new interfaces is merged. - Return an error code in the STM32 clocksource driver on failure instead of success. - Remove the redundant and stale irq disabled check in the posix cpu timer code. The check is at the wrong place anyway and lockdep already covers it via the sighand lock locking coverage" * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: time: Make sure jiffies_to_msecs() preserves non-zero time periods posix-timers: Fix nanosleep_copyout() for CONFIG_COMPAT_32BIT_TIME clocksource/drivers/stm32: Fix error return code posix-cpu-timers: Remove lockdep_assert_irqs_disabled()
2 parents 78fea63 + abcbcb8 commit 6242258

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

drivers/clocksource/timer-stm32.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,10 @@ static int __init stm32_timer_init(struct device_node *node)
304304

305305
to->private_data = kzalloc(sizeof(struct stm32_timer_private),
306306
GFP_KERNEL);
307-
if (!to->private_data)
307+
if (!to->private_data) {
308+
ret = -ENOMEM;
308309
goto deinit;
310+
}
309311

310312
rstc = of_reset_control_get(node, NULL);
311313
if (!IS_ERR(rstc)) {

kernel/time/hrtimer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ EXPORT_SYMBOL_GPL(hrtimer_init_sleeper);
16591659
int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts)
16601660
{
16611661
switch(restart->nanosleep.type) {
1662-
#ifdef CONFIG_COMPAT
1662+
#ifdef CONFIG_COMPAT_32BIT_TIME
16631663
case TT_COMPAT:
16641664
if (compat_put_timespec64(ts, restart->nanosleep.compat_rmtp))
16651665
return -EFAULT;

kernel/time/posix-cpu-timers.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,6 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
604604
/*
605605
* Disarm any old timer after extracting its expiry time.
606606
*/
607-
lockdep_assert_irqs_disabled();
608607

609608
ret = 0;
610609
old_incr = timer->it.cpu.incr;
@@ -1049,7 +1048,6 @@ static void posix_cpu_timer_rearm(struct k_itimer *timer)
10491048
/*
10501049
* Now re-arm for the new expiry time.
10511050
*/
1052-
lockdep_assert_irqs_disabled();
10531051
arm_timer(timer);
10541052
unlock:
10551053
unlock_task_sighand(p, &flags);

kernel/time/time.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*/
2929

3030
#include <linux/export.h>
31+
#include <linux/kernel.h>
3132
#include <linux/timex.h>
3233
#include <linux/capability.h>
3334
#include <linux/timekeeper_internal.h>
@@ -314,9 +315,10 @@ unsigned int jiffies_to_msecs(const unsigned long j)
314315
return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC);
315316
#else
316317
# if BITS_PER_LONG == 32
317-
return (HZ_TO_MSEC_MUL32 * j) >> HZ_TO_MSEC_SHR32;
318+
return (HZ_TO_MSEC_MUL32 * j + (1ULL << HZ_TO_MSEC_SHR32) - 1) >>
319+
HZ_TO_MSEC_SHR32;
318320
# else
319-
return (j * HZ_TO_MSEC_NUM) / HZ_TO_MSEC_DEN;
321+
return DIV_ROUND_UP(j * HZ_TO_MSEC_NUM, HZ_TO_MSEC_DEN);
320322
# endif
321323
#endif
322324
}

0 commit comments

Comments
 (0)