Skip to content

Commit 4f37a68

Browse files
Martin SchwidefskyKAGA-KOKO
authored andcommitted
s390: Use direct ktime path for s390 clockevent device
The clock comparator on s390 uses the same format as the TOD clock. If the value in the clock comparator is smaller than the current TOD value an interrupt is pending. Use the CLOCK_EVT_FEAT_KTIME feature to get the unmodified ktime of the next clockevent expiration and use it to program the clock comparator without querying the TOD clock. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: john stultz <johnstul@us.ibm.com> Link: http://lkml.kernel.org/r/20110823133143.153017933@de.ibm.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 65516f8 commit 4f37a68

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

arch/s390/kernel/time.c

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

112-
static int s390_next_event(unsigned long delta,
112+
static int s390_next_ktime(ktime_t expires,
113113
struct clock_event_device *evt)
114114
{
115-
S390_lowcore.clock_comparator = get_clock() + delta;
115+
s64 nsecs;
116+
117+
nsecs = ktime_to_ns(ktime_sub(expires, ktime_get_monotonic_offset()));
118+
do_div(nsecs, 125);
119+
S390_lowcore.clock_comparator = TOD_UNIX_EPOCH + (nsecs << 9);
116120
set_clock_comparator(S390_lowcore.clock_comparator);
117121
return 0;
118122
}
@@ -137,14 +141,15 @@ void init_cpu_timer(void)
137141
cpu = smp_processor_id();
138142
cd = &per_cpu(comparators, cpu);
139143
cd->name = "comparator";
140-
cd->features = CLOCK_EVT_FEAT_ONESHOT;
144+
cd->features = CLOCK_EVT_FEAT_ONESHOT |
145+
CLOCK_EVT_FEAT_KTIME;
141146
cd->mult = 16777;
142147
cd->shift = 12;
143148
cd->min_delta_ns = 1;
144149
cd->max_delta_ns = LONG_MAX;
145150
cd->rating = 400;
146151
cd->cpumask = cpumask_of(cpu);
147-
cd->set_next_event = s390_next_event;
152+
cd->set_next_ktime = s390_next_ktime;
148153
cd->set_mode = s390_set_mode;
149154

150155
clockevents_register_device(cd);

0 commit comments

Comments
 (0)