diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-19 20:11:10 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-19 20:11:10 -0400 |
| commit | 164d44fd92e79d5bce54d0d62df9f856f7b23925 (patch) | |
| tree | 9f21607849b7e684b255578ffdf41951bc31787e /kernel/time/clocksource.c | |
| parent | 5bfec46baa3a752393433b8d89d3b2c70820f61d (diff) | |
| parent | d7e81c269db899b800e0963dc4aceece1f82a680 (diff) | |
Merge branch 'timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
clocksource: Add clocksource_register_hz/khz interface
posix-cpu-timers: Optimize run_posix_cpu_timers()
time: Remove xtime_cache
mqueue: Convert message queue timeout to use hrtimers
hrtimers: Provide schedule_hrtimeout for CLOCK_REALTIME
timers: Introduce the concept of timer slack for legacy timers
ntp: Remove tickadj
ntp: Make time_adjust static
time: Add xtime, wall_to_monotonic to feature-removal-schedule
timer: Try to survive timer callback preempt_count leak
timer: Split out timer function call
timer: Print function name for timer callbacks modifying preemption count
time: Clean up warp_clock()
cpu-timers: Avoid iterating over all threads in fastpath_timer_check()
cpu-timers: Change SIGEV_NONE timer implementation
cpu-timers: Return correct previous timer reload value
cpu-timers: Cleanup arm_timer()
cpu-timers: Simplify RLIMIT_CPU handling
Diffstat (limited to 'kernel/time/clocksource.c')
| -rw-r--r-- | kernel/time/clocksource.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 1f5dde637457..f08e99c1d561 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c | |||
| @@ -625,6 +625,54 @@ static void clocksource_enqueue(struct clocksource *cs) | |||
| 625 | list_add(&cs->list, entry); | 625 | list_add(&cs->list, entry); |
| 626 | } | 626 | } |
| 627 | 627 | ||
| 628 | |||
| 629 | /* | ||
| 630 | * Maximum time we expect to go between ticks. This includes idle | ||
| 631 | * tickless time. It provides the trade off between selecting a | ||
| 632 | * mult/shift pair that is very precise but can only handle a short | ||
| 633 | * period of time, vs. a mult/shift pair that can handle long periods | ||
| 634 | * of time but isn't as precise. | ||
| 635 | * | ||
| 636 | * This is a subsystem constant, and actual hardware limitations | ||
| 637 | * may override it (ie: clocksources that wrap every 3 seconds). | ||
| 638 | */ | ||
| 639 | #define MAX_UPDATE_LENGTH 5 /* Seconds */ | ||
| 640 | |||
| 641 | /** | ||
| 642 | * __clocksource_register_scale - Used to install new clocksources | ||
| 643 | * @t: clocksource to be registered | ||
| 644 | * @scale: Scale factor multiplied against freq to get clocksource hz | ||
| 645 | * @freq: clocksource frequency (cycles per second) divided by scale | ||
| 646 | * | ||
| 647 | * Returns -EBUSY if registration fails, zero otherwise. | ||
| 648 | * | ||
| 649 | * This *SHOULD NOT* be called directly! Please use the | ||
| 650 | * clocksource_register_hz() or clocksource_register_khz helper functions. | ||
| 651 | */ | ||
| 652 | int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) | ||
| 653 | { | ||
| 654 | |||
| 655 | /* | ||
| 656 | * Ideally we want to use some of the limits used in | ||
| 657 | * clocksource_max_deferment, to provide a more informed | ||
| 658 | * MAX_UPDATE_LENGTH. But for now this just gets the | ||
| 659 | * register interface working properly. | ||
| 660 | */ | ||
| 661 | clocks_calc_mult_shift(&cs->mult, &cs->shift, freq, | ||
| 662 | NSEC_PER_SEC/scale, | ||
| 663 | MAX_UPDATE_LENGTH*scale); | ||
| 664 | cs->max_idle_ns = clocksource_max_deferment(cs); | ||
| 665 | |||
| 666 | mutex_lock(&clocksource_mutex); | ||
| 667 | clocksource_enqueue(cs); | ||
| 668 | clocksource_select(); | ||
| 669 | clocksource_enqueue_watchdog(cs); | ||
| 670 | mutex_unlock(&clocksource_mutex); | ||
| 671 | return 0; | ||
| 672 | } | ||
| 673 | EXPORT_SYMBOL_GPL(__clocksource_register_scale); | ||
| 674 | |||
| 675 | |||
| 628 | /** | 676 | /** |
| 629 | * clocksource_register - Used to install new clocksources | 677 | * clocksource_register - Used to install new clocksources |
| 630 | * @t: clocksource to be registered | 678 | * @t: clocksource to be registered |
