diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2011-05-20 14:06:24 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2011-05-20 14:08:05 -0400 |
commit | 250f972d85effad5b6e10da4bbd877e6a4b503b6 (patch) | |
tree | 007393a6fc6439af7e0121dd99a6f9f9fb8405bc /kernel/time | |
parent | 7372b0b122af0f6675f3ab65bfd91c8a438e0480 (diff) | |
parent | bbe7b8bef48c567f5ff3f6041c1fb011292e8f12 (diff) |
Merge branch 'timers/urgent' into timers/core
Reason: Get upstream fixes and kfree_rcu which is necessary for a
follow up patch.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/time')
-rw-r--r-- | kernel/time/clockevents.c | 64 | ||||
-rw-r--r-- | kernel/time/clocksource.c | 42 | ||||
-rw-r--r-- | kernel/time/tick-broadcast.c | 12 |
3 files changed, 96 insertions, 22 deletions
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index 0d74b9ba90c8..c027d4f602f1 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c | |||
@@ -194,6 +194,70 @@ void clockevents_register_device(struct clock_event_device *dev) | |||
194 | } | 194 | } |
195 | EXPORT_SYMBOL_GPL(clockevents_register_device); | 195 | EXPORT_SYMBOL_GPL(clockevents_register_device); |
196 | 196 | ||
197 | static void clockevents_config(struct clock_event_device *dev, | ||
198 | u32 freq) | ||
199 | { | ||
200 | u64 sec; | ||
201 | |||
202 | if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT)) | ||
203 | return; | ||
204 | |||
205 | /* | ||
206 | * Calculate the maximum number of seconds we can sleep. Limit | ||
207 | * to 10 minutes for hardware which can program more than | ||
208 | * 32bit ticks so we still get reasonable conversion values. | ||
209 | */ | ||
210 | sec = dev->max_delta_ticks; | ||
211 | do_div(sec, freq); | ||
212 | if (!sec) | ||
213 | sec = 1; | ||
214 | else if (sec > 600 && dev->max_delta_ticks > UINT_MAX) | ||
215 | sec = 600; | ||
216 | |||
217 | clockevents_calc_mult_shift(dev, freq, sec); | ||
218 | dev->min_delta_ns = clockevent_delta2ns(dev->min_delta_ticks, dev); | ||
219 | dev->max_delta_ns = clockevent_delta2ns(dev->max_delta_ticks, dev); | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * clockevents_config_and_register - Configure and register a clock event device | ||
224 | * @dev: device to register | ||
225 | * @freq: The clock frequency | ||
226 | * @min_delta: The minimum clock ticks to program in oneshot mode | ||
227 | * @max_delta: The maximum clock ticks to program in oneshot mode | ||
228 | * | ||
229 | * min/max_delta can be 0 for devices which do not support oneshot mode. | ||
230 | */ | ||
231 | void clockevents_config_and_register(struct clock_event_device *dev, | ||
232 | u32 freq, unsigned long min_delta, | ||
233 | unsigned long max_delta) | ||
234 | { | ||
235 | dev->min_delta_ticks = min_delta; | ||
236 | dev->max_delta_ticks = max_delta; | ||
237 | clockevents_config(dev, freq); | ||
238 | clockevents_register_device(dev); | ||
239 | } | ||
240 | |||
241 | /** | ||
242 | * clockevents_update_freq - Update frequency and reprogram a clock event device. | ||
243 | * @dev: device to modify | ||
244 | * @freq: new device frequency | ||
245 | * | ||
246 | * Reconfigure and reprogram a clock event device in oneshot | ||
247 | * mode. Must be called on the cpu for which the device delivers per | ||
248 | * cpu timer events with interrupts disabled! Returns 0 on success, | ||
249 | * -ETIME when the event is in the past. | ||
250 | */ | ||
251 | int clockevents_update_freq(struct clock_event_device *dev, u32 freq) | ||
252 | { | ||
253 | clockevents_config(dev, freq); | ||
254 | |||
255 | if (dev->mode != CLOCK_EVT_MODE_ONESHOT) | ||
256 | return 0; | ||
257 | |||
258 | return clockevents_program_event(dev, dev->next_event, ktime_get()); | ||
259 | } | ||
260 | |||
197 | /* | 261 | /* |
198 | * Noop handler when we shut down an event device | 262 | * Noop handler when we shut down an event device |
199 | */ | 263 | */ |
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 6519cf62d9cd..1c95fd677328 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c | |||
@@ -626,19 +626,6 @@ static void clocksource_enqueue(struct clocksource *cs) | |||
626 | list_add(&cs->list, entry); | 626 | list_add(&cs->list, entry); |
627 | } | 627 | } |
628 | 628 | ||
629 | |||
630 | /* | ||
631 | * Maximum time we expect to go between ticks. This includes idle | ||
632 | * tickless time. It provides the trade off between selecting a | ||
633 | * mult/shift pair that is very precise but can only handle a short | ||
634 | * period of time, vs. a mult/shift pair that can handle long periods | ||
635 | * of time but isn't as precise. | ||
636 | * | ||
637 | * This is a subsystem constant, and actual hardware limitations | ||
638 | * may override it (ie: clocksources that wrap every 3 seconds). | ||
639 | */ | ||
640 | #define MAX_UPDATE_LENGTH 5 /* Seconds */ | ||
641 | |||
642 | /** | 629 | /** |
643 | * __clocksource_updatefreq_scale - Used update clocksource with new freq | 630 | * __clocksource_updatefreq_scale - Used update clocksource with new freq |
644 | * @t: clocksource to be registered | 631 | * @t: clocksource to be registered |
@@ -652,15 +639,28 @@ static void clocksource_enqueue(struct clocksource *cs) | |||
652 | */ | 639 | */ |
653 | void __clocksource_updatefreq_scale(struct clocksource *cs, u32 scale, u32 freq) | 640 | void __clocksource_updatefreq_scale(struct clocksource *cs, u32 scale, u32 freq) |
654 | { | 641 | { |
642 | u64 sec; | ||
643 | |||
655 | /* | 644 | /* |
656 | * Ideally we want to use some of the limits used in | 645 | * Calc the maximum number of seconds which we can run before |
657 | * clocksource_max_deferment, to provide a more informed | 646 | * wrapping around. For clocksources which have a mask > 32bit |
658 | * MAX_UPDATE_LENGTH. But for now this just gets the | 647 | * we need to limit the max sleep time to have a good |
659 | * register interface working properly. | 648 | * conversion precision. 10 minutes is still a reasonable |
649 | * amount. That results in a shift value of 24 for a | ||
650 | * clocksource with mask >= 40bit and f >= 4GHz. That maps to | ||
651 | * ~ 0.06ppm granularity for NTP. We apply the same 12.5% | ||
652 | * margin as we do in clocksource_max_deferment() | ||
660 | */ | 653 | */ |
654 | sec = (cs->mask - (cs->mask >> 5)); | ||
655 | do_div(sec, freq); | ||
656 | do_div(sec, scale); | ||
657 | if (!sec) | ||
658 | sec = 1; | ||
659 | else if (sec > 600 && cs->mask > UINT_MAX) | ||
660 | sec = 600; | ||
661 | |||
661 | clocks_calc_mult_shift(&cs->mult, &cs->shift, freq, | 662 | clocks_calc_mult_shift(&cs->mult, &cs->shift, freq, |
662 | NSEC_PER_SEC/scale, | 663 | NSEC_PER_SEC / scale, sec * scale); |
663 | MAX_UPDATE_LENGTH*scale); | ||
664 | cs->max_idle_ns = clocksource_max_deferment(cs); | 664 | cs->max_idle_ns = clocksource_max_deferment(cs); |
665 | } | 665 | } |
666 | EXPORT_SYMBOL_GPL(__clocksource_updatefreq_scale); | 666 | EXPORT_SYMBOL_GPL(__clocksource_updatefreq_scale); |
@@ -685,8 +685,8 @@ int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) | |||
685 | /* Add clocksource to the clcoksource list */ | 685 | /* Add clocksource to the clcoksource list */ |
686 | mutex_lock(&clocksource_mutex); | 686 | mutex_lock(&clocksource_mutex); |
687 | clocksource_enqueue(cs); | 687 | clocksource_enqueue(cs); |
688 | clocksource_select(); | ||
689 | clocksource_enqueue_watchdog(cs); | 688 | clocksource_enqueue_watchdog(cs); |
689 | clocksource_select(); | ||
690 | mutex_unlock(&clocksource_mutex); | 690 | mutex_unlock(&clocksource_mutex); |
691 | return 0; | 691 | return 0; |
692 | } | 692 | } |
@@ -706,8 +706,8 @@ int clocksource_register(struct clocksource *cs) | |||
706 | 706 | ||
707 | mutex_lock(&clocksource_mutex); | 707 | mutex_lock(&clocksource_mutex); |
708 | clocksource_enqueue(cs); | 708 | clocksource_enqueue(cs); |
709 | clocksource_select(); | ||
710 | clocksource_enqueue_watchdog(cs); | 709 | clocksource_enqueue_watchdog(cs); |
710 | clocksource_select(); | ||
711 | mutex_unlock(&clocksource_mutex); | 711 | mutex_unlock(&clocksource_mutex); |
712 | return 0; | 712 | return 0; |
713 | } | 713 | } |
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c index 827e0f862da4..c7218d132738 100644 --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c | |||
@@ -524,10 +524,11 @@ static void tick_broadcast_init_next_event(struct cpumask *mask, | |||
524 | */ | 524 | */ |
525 | void tick_broadcast_setup_oneshot(struct clock_event_device *bc) | 525 | void tick_broadcast_setup_oneshot(struct clock_event_device *bc) |
526 | { | 526 | { |
527 | int cpu = smp_processor_id(); | ||
528 | |||
527 | /* Set it up only once ! */ | 529 | /* Set it up only once ! */ |
528 | if (bc->event_handler != tick_handle_oneshot_broadcast) { | 530 | if (bc->event_handler != tick_handle_oneshot_broadcast) { |
529 | int was_periodic = bc->mode == CLOCK_EVT_MODE_PERIODIC; | 531 | int was_periodic = bc->mode == CLOCK_EVT_MODE_PERIODIC; |
530 | int cpu = smp_processor_id(); | ||
531 | 532 | ||
532 | bc->event_handler = tick_handle_oneshot_broadcast; | 533 | bc->event_handler = tick_handle_oneshot_broadcast; |
533 | clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT); | 534 | clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT); |
@@ -553,6 +554,15 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc) | |||
553 | tick_broadcast_set_event(tick_next_period, 1); | 554 | tick_broadcast_set_event(tick_next_period, 1); |
554 | } else | 555 | } else |
555 | bc->next_event.tv64 = KTIME_MAX; | 556 | bc->next_event.tv64 = KTIME_MAX; |
557 | } else { | ||
558 | /* | ||
559 | * The first cpu which switches to oneshot mode sets | ||
560 | * the bit for all other cpus which are in the general | ||
561 | * (periodic) broadcast mask. So the bit is set and | ||
562 | * would prevent the first broadcast enter after this | ||
563 | * to program the bc device. | ||
564 | */ | ||
565 | tick_broadcast_clear_oneshot(cpu); | ||
556 | } | 566 | } |
557 | } | 567 | } |
558 | 568 | ||