s390/timer: avoid overflow when programming clock comparator
[~shefty/rdma-dev.git] / arch / s390 / kernel / time.c
index a5f4f5a1d24b951ac8e7e10cc9af81e153208c63..0aa98db8a80dff08f4ba392139e80eec173bfd62 100644 (file)
@@ -120,6 +120,9 @@ static int s390_next_ktime(ktime_t expires,
        nsecs = ktime_to_ns(ktime_add(timespec_to_ktime(ts), expires));
        do_div(nsecs, 125);
        S390_lowcore.clock_comparator = sched_clock_base_cc + (nsecs << 9);
+       /* Program the maximum value if we have an overflow (== year 2042) */
+       if (unlikely(S390_lowcore.clock_comparator < sched_clock_base_cc))
+               S390_lowcore.clock_comparator = -1ULL;
        set_clock_comparator(S390_lowcore.clock_comparator);
        return 0;
 }