Skip to content

Commit 8adbf78

Browse files
author
Martin Schwidefsky
committed
s390,time: revert direct ktime path for s390 clockevent device
Git commit 4f37a68 "s390: Use direct ktime path for s390 clockevent device" makes use of the CLOCK_EVT_FEAT_KTIME clockevent option to avoid the delta calculation with ktime_get() in clockevents_program_event and the get_tod_clock() in s390_next_event. This is based on the assumption that the difference between the internal ktime and the hardware clock is reflected in the wall_to_monotonic delta. But this is not true, the ntp corrections are applied via changes to the tk->mult multiplier and this is not reflected in wall_to_monotonic. In theory this could be solved by using the raw monotonic clock but it is simpler to switch back to the standard clock delta calculation. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 79c74ec commit 8adbf78

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

arch/s390/kernel/time.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,10 @@ static void fixup_clock_comparator(unsigned long long delta)
108108
set_clock_comparator(S390_lowcore.clock_comparator);
109109
}
110110

111-
static int s390_next_ktime(ktime_t expires,
111+
static int s390_next_event(unsigned long delta,
112112
struct clock_event_device *evt)
113113
{
114-
struct timespec ts;
115-
u64 nsecs;
116-
117-
ts.tv_sec = ts.tv_nsec = 0;
118-
monotonic_to_bootbased(&ts);
119-
nsecs = ktime_to_ns(ktime_add(timespec_to_ktime(ts), expires));
120-
do_div(nsecs, 125);
121-
S390_lowcore.clock_comparator = sched_clock_base_cc + (nsecs << 9);
122-
/* Program the maximum value if we have an overflow (== year 2042) */
123-
if (unlikely(S390_lowcore.clock_comparator < sched_clock_base_cc))
124-
S390_lowcore.clock_comparator = -1ULL;
114+
S390_lowcore.clock_comparator = get_tod_clock() + delta;
125115
set_clock_comparator(S390_lowcore.clock_comparator);
126116
return 0;
127117
}
@@ -146,15 +136,14 @@ void init_cpu_timer(void)
146136
cpu = smp_processor_id();
147137
cd = &per_cpu(comparators, cpu);
148138
cd->name = "comparator";
149-
cd->features = CLOCK_EVT_FEAT_ONESHOT |
150-
CLOCK_EVT_FEAT_KTIME;
139+
cd->features = CLOCK_EVT_FEAT_ONESHOT;
151140
cd->mult = 16777;
152141
cd->shift = 12;
153142
cd->min_delta_ns = 1;
154143
cd->max_delta_ns = LONG_MAX;
155144
cd->rating = 400;
156145
cd->cpumask = cpumask_of(cpu);
157-
cd->set_next_ktime = s390_next_ktime;
146+
cd->set_next_event = s390_next_event;
158147
cd->set_mode = s390_set_mode;
159148

160149
clockevents_register_device(cd);

0 commit comments

Comments
 (0)