Commit d4496b39559c6d43f83e4c08b899984f8b8089b5
1 parent
7c1e768974
Exists in
master
and in
20 other branches
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 <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Showing 1 changed file with 8 additions and 3 deletions Side-by-side Diff
kernel/time/tick-broadcast.c
... | ... | @@ -175,6 +175,8 @@ |
175 | 175 | */ |
176 | 176 | static void tick_handle_periodic_broadcast(struct clock_event_device *dev) |
177 | 177 | { |
178 | + ktime_t next; | |
179 | + | |
178 | 180 | tick_do_periodic_broadcast(); |
179 | 181 | |
180 | 182 | /* |
181 | 183 | |
... | ... | @@ -185,10 +187,13 @@ |
185 | 187 | |
186 | 188 | /* |
187 | 189 | * 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. | |
189 | 194 | */ |
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); | |
192 | 197 | |
193 | 198 | if (!clockevents_program_event(dev, next, ktime_get())) |
194 | 199 | return; |