Skip to content

Commit d4496b3

Browse files
committed
clockevents: prevent endless loop in periodic broadcast handler
The reprogramming of the periodic broadcast handler was broken, when the first programming returned -ETIME. The clockevents code stores the new expiry value in the clock events device next_event field only when the programming time has not been elapsed yet. The loop in question calculates the new expiry value from the next_event value and therefor never increases. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 7c1e768 commit d4496b3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

kernel/time/tick-broadcast.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ static void tick_do_periodic_broadcast(void)
175175
*/
176176
static void tick_handle_periodic_broadcast(struct clock_event_device *dev)
177177
{
178+
ktime_t next;
179+
178180
tick_do_periodic_broadcast();
179181

180182
/*
@@ -185,10 +187,13 @@ static void tick_handle_periodic_broadcast(struct clock_event_device *dev)
185187

186188
/*
187189
* Setup the next period for devices, which do not have
188-
* periodic mode:
190+
* periodic mode. We read dev->next_event first and add to it
191+
* when the event alrady expired. clockevents_program_event()
192+
* sets dev->next_event only when the event is really
193+
* programmed to the device.
189194
*/
190-
for (;;) {
191-
ktime_t next = ktime_add(dev->next_event, tick_period);
195+
for (next = dev->next_event; ;) {
196+
next = ktime_add(next, tick_period);
192197

193198
if (!clockevents_program_event(dev, next, ktime_get()))
194199
return;

0 commit comments

Comments
 (0)