diff options
Diffstat (limited to 'kernel/hrtimer.c')
| -rw-r--r-- | kernel/hrtimer.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 18324305724a..d0ba190dfeb6 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
| @@ -98,7 +98,6 @@ static DEFINE_PER_CPU(struct hrtimer_base, hrtimer_bases[MAX_HRTIMER_BASES]) = | |||
| 98 | 98 | ||
| 99 | /** | 99 | /** |
| 100 | * ktime_get_ts - get the monotonic clock in timespec format | 100 | * ktime_get_ts - get the monotonic clock in timespec format |
| 101 | * | ||
| 102 | * @ts: pointer to timespec variable | 101 | * @ts: pointer to timespec variable |
| 103 | * | 102 | * |
| 104 | * The function calculates the monotonic clock from the realtime | 103 | * The function calculates the monotonic clock from the realtime |
| @@ -188,7 +187,7 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_base *base) | |||
| 188 | { | 187 | { |
| 189 | struct hrtimer_base *new_base; | 188 | struct hrtimer_base *new_base; |
| 190 | 189 | ||
| 191 | new_base = &__get_cpu_var(hrtimer_bases[base->index]); | 190 | new_base = &__get_cpu_var(hrtimer_bases)[base->index]; |
| 192 | 191 | ||
| 193 | if (base != new_base) { | 192 | if (base != new_base) { |
| 194 | /* | 193 | /* |
| @@ -238,7 +237,6 @@ lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) | |||
| 238 | # ifndef CONFIG_KTIME_SCALAR | 237 | # ifndef CONFIG_KTIME_SCALAR |
| 239 | /** | 238 | /** |
| 240 | * ktime_add_ns - Add a scalar nanoseconds value to a ktime_t variable | 239 | * ktime_add_ns - Add a scalar nanoseconds value to a ktime_t variable |
| 241 | * | ||
| 242 | * @kt: addend | 240 | * @kt: addend |
| 243 | * @nsec: the scalar nsec value to add | 241 | * @nsec: the scalar nsec value to add |
| 244 | * | 242 | * |
| @@ -299,7 +297,6 @@ void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) | |||
| 299 | 297 | ||
| 300 | /** | 298 | /** |
| 301 | * hrtimer_forward - forward the timer expiry | 299 | * hrtimer_forward - forward the timer expiry |
| 302 | * | ||
| 303 | * @timer: hrtimer to forward | 300 | * @timer: hrtimer to forward |
| 304 | * @now: forward past this time | 301 | * @now: forward past this time |
| 305 | * @interval: the interval to forward | 302 | * @interval: the interval to forward |
| @@ -411,7 +408,6 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_base *base) | |||
| 411 | 408 | ||
| 412 | /** | 409 | /** |
| 413 | * hrtimer_start - (re)start an relative timer on the current CPU | 410 | * hrtimer_start - (re)start an relative timer on the current CPU |
| 414 | * | ||
| 415 | * @timer: the timer to be added | 411 | * @timer: the timer to be added |
| 416 | * @tim: expiry time | 412 | * @tim: expiry time |
| 417 | * @mode: expiry mode: absolute (HRTIMER_ABS) or relative (HRTIMER_REL) | 413 | * @mode: expiry mode: absolute (HRTIMER_ABS) or relative (HRTIMER_REL) |
| @@ -460,14 +456,13 @@ EXPORT_SYMBOL_GPL(hrtimer_start); | |||
| 460 | 456 | ||
| 461 | /** | 457 | /** |
| 462 | * hrtimer_try_to_cancel - try to deactivate a timer | 458 | * hrtimer_try_to_cancel - try to deactivate a timer |
| 463 | * | ||
| 464 | * @timer: hrtimer to stop | 459 | * @timer: hrtimer to stop |
| 465 | * | 460 | * |
| 466 | * Returns: | 461 | * Returns: |
| 467 | * 0 when the timer was not active | 462 | * 0 when the timer was not active |
| 468 | * 1 when the timer was active | 463 | * 1 when the timer was active |
| 469 | * -1 when the timer is currently excuting the callback function and | 464 | * -1 when the timer is currently excuting the callback function and |
| 470 | * can not be stopped | 465 | * cannot be stopped |
| 471 | */ | 466 | */ |
| 472 | int hrtimer_try_to_cancel(struct hrtimer *timer) | 467 | int hrtimer_try_to_cancel(struct hrtimer *timer) |
| 473 | { | 468 | { |
| @@ -489,7 +484,6 @@ EXPORT_SYMBOL_GPL(hrtimer_try_to_cancel); | |||
| 489 | 484 | ||
| 490 | /** | 485 | /** |
| 491 | * hrtimer_cancel - cancel a timer and wait for the handler to finish. | 486 | * hrtimer_cancel - cancel a timer and wait for the handler to finish. |
| 492 | * | ||
| 493 | * @timer: the timer to be cancelled | 487 | * @timer: the timer to be cancelled |
| 494 | * | 488 | * |
| 495 | * Returns: | 489 | * Returns: |
| @@ -510,7 +504,6 @@ EXPORT_SYMBOL_GPL(hrtimer_cancel); | |||
| 510 | 504 | ||
| 511 | /** | 505 | /** |
| 512 | * hrtimer_get_remaining - get remaining time for the timer | 506 | * hrtimer_get_remaining - get remaining time for the timer |
| 513 | * | ||
| 514 | * @timer: the timer to read | 507 | * @timer: the timer to read |
| 515 | */ | 508 | */ |
| 516 | ktime_t hrtimer_get_remaining(const struct hrtimer *timer) | 509 | ktime_t hrtimer_get_remaining(const struct hrtimer *timer) |
| @@ -564,7 +557,6 @@ ktime_t hrtimer_get_next_event(void) | |||
| 564 | 557 | ||
| 565 | /** | 558 | /** |
| 566 | * hrtimer_init - initialize a timer to the given clock | 559 | * hrtimer_init - initialize a timer to the given clock |
| 567 | * | ||
| 568 | * @timer: the timer to be initialized | 560 | * @timer: the timer to be initialized |
| 569 | * @clock_id: the clock to be used | 561 | * @clock_id: the clock to be used |
| 570 | * @mode: timer mode abs/rel | 562 | * @mode: timer mode abs/rel |
| @@ -576,7 +568,7 @@ void hrtimer_init(struct hrtimer *timer, clockid_t clock_id, | |||
| 576 | 568 | ||
| 577 | memset(timer, 0, sizeof(struct hrtimer)); | 569 | memset(timer, 0, sizeof(struct hrtimer)); |
| 578 | 570 | ||
| 579 | bases = per_cpu(hrtimer_bases, raw_smp_processor_id()); | 571 | bases = __raw_get_cpu_var(hrtimer_bases); |
| 580 | 572 | ||
| 581 | if (clock_id == CLOCK_REALTIME && mode != HRTIMER_ABS) | 573 | if (clock_id == CLOCK_REALTIME && mode != HRTIMER_ABS) |
| 582 | clock_id = CLOCK_MONOTONIC; | 574 | clock_id = CLOCK_MONOTONIC; |
| @@ -588,7 +580,6 @@ EXPORT_SYMBOL_GPL(hrtimer_init); | |||
| 588 | 580 | ||
| 589 | /** | 581 | /** |
| 590 | * hrtimer_get_res - get the timer resolution for a clock | 582 | * hrtimer_get_res - get the timer resolution for a clock |
| 591 | * | ||
| 592 | * @which_clock: which clock to query | 583 | * @which_clock: which clock to query |
| 593 | * @tp: pointer to timespec variable to store the resolution | 584 | * @tp: pointer to timespec variable to store the resolution |
| 594 | * | 585 | * |
| @@ -599,7 +590,7 @@ int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp) | |||
| 599 | { | 590 | { |
| 600 | struct hrtimer_base *bases; | 591 | struct hrtimer_base *bases; |
| 601 | 592 | ||
| 602 | bases = per_cpu(hrtimer_bases, raw_smp_processor_id()); | 593 | bases = __raw_get_cpu_var(hrtimer_bases); |
| 603 | *tp = ktime_to_timespec(bases[which_clock].resolution); | 594 | *tp = ktime_to_timespec(bases[which_clock].resolution); |
| 604 | 595 | ||
| 605 | return 0; | 596 | return 0; |
| @@ -678,7 +669,7 @@ static int hrtimer_wakeup(struct hrtimer *timer) | |||
| 678 | return HRTIMER_NORESTART; | 669 | return HRTIMER_NORESTART; |
| 679 | } | 670 | } |
| 680 | 671 | ||
| 681 | void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, task_t *task) | 672 | void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, struct task_struct *task) |
| 682 | { | 673 | { |
| 683 | sl->timer.function = hrtimer_wakeup; | 674 | sl->timer.function = hrtimer_wakeup; |
| 684 | sl->task = task; | 675 | sl->task = task; |
| @@ -702,7 +693,7 @@ static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mod | |||
| 702 | return t->task == NULL; | 693 | return t->task == NULL; |
| 703 | } | 694 | } |
| 704 | 695 | ||
| 705 | static long __sched nanosleep_restart(struct restart_block *restart) | 696 | long __sched hrtimer_nanosleep_restart(struct restart_block *restart) |
| 706 | { | 697 | { |
| 707 | struct hrtimer_sleeper t; | 698 | struct hrtimer_sleeper t; |
| 708 | struct timespec __user *rmtp; | 699 | struct timespec __user *rmtp; |
| @@ -711,13 +702,13 @@ static long __sched nanosleep_restart(struct restart_block *restart) | |||
| 711 | 702 | ||
| 712 | restart->fn = do_no_restart_syscall; | 703 | restart->fn = do_no_restart_syscall; |
| 713 | 704 | ||
| 714 | hrtimer_init(&t.timer, restart->arg3, HRTIMER_ABS); | 705 | hrtimer_init(&t.timer, restart->arg0, HRTIMER_ABS); |
| 715 | t.timer.expires.tv64 = ((u64)restart->arg1 << 32) | (u64) restart->arg0; | 706 | t.timer.expires.tv64 = ((u64)restart->arg3 << 32) | (u64) restart->arg2; |
| 716 | 707 | ||
| 717 | if (do_nanosleep(&t, HRTIMER_ABS)) | 708 | if (do_nanosleep(&t, HRTIMER_ABS)) |
| 718 | return 0; | 709 | return 0; |
| 719 | 710 | ||
| 720 | rmtp = (struct timespec __user *) restart->arg2; | 711 | rmtp = (struct timespec __user *) restart->arg1; |
| 721 | if (rmtp) { | 712 | if (rmtp) { |
| 722 | time = ktime_sub(t.timer.expires, t.timer.base->get_time()); | 713 | time = ktime_sub(t.timer.expires, t.timer.base->get_time()); |
| 723 | if (time.tv64 <= 0) | 714 | if (time.tv64 <= 0) |
| @@ -727,7 +718,7 @@ static long __sched nanosleep_restart(struct restart_block *restart) | |||
| 727 | return -EFAULT; | 718 | return -EFAULT; |
| 728 | } | 719 | } |
| 729 | 720 | ||
| 730 | restart->fn = nanosleep_restart; | 721 | restart->fn = hrtimer_nanosleep_restart; |
| 731 | 722 | ||
| 732 | /* The other values in restart are already filled in */ | 723 | /* The other values in restart are already filled in */ |
| 733 | return -ERESTART_RESTARTBLOCK; | 724 | return -ERESTART_RESTARTBLOCK; |
| @@ -760,11 +751,11 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp, | |||
| 760 | } | 751 | } |
| 761 | 752 | ||
| 762 | restart = ¤t_thread_info()->restart_block; | 753 | restart = ¤t_thread_info()->restart_block; |
| 763 | restart->fn = nanosleep_restart; | 754 | restart->fn = hrtimer_nanosleep_restart; |
| 764 | restart->arg0 = t.timer.expires.tv64 & 0xFFFFFFFF; | 755 | restart->arg0 = (unsigned long) t.timer.base->index; |
| 765 | restart->arg1 = t.timer.expires.tv64 >> 32; | 756 | restart->arg1 = (unsigned long) rmtp; |
| 766 | restart->arg2 = (unsigned long) rmtp; | 757 | restart->arg2 = t.timer.expires.tv64 & 0xFFFFFFFF; |
| 767 | restart->arg3 = (unsigned long) t.timer.base->index; | 758 | restart->arg3 = t.timer.expires.tv64 >> 32; |
| 768 | 759 | ||
| 769 | return -ERESTART_RESTARTBLOCK; | 760 | return -ERESTART_RESTARTBLOCK; |
| 770 | } | 761 | } |
| @@ -791,8 +782,10 @@ static void __devinit init_hrtimers_cpu(int cpu) | |||
| 791 | struct hrtimer_base *base = per_cpu(hrtimer_bases, cpu); | 782 | struct hrtimer_base *base = per_cpu(hrtimer_bases, cpu); |
| 792 | int i; | 783 | int i; |
| 793 | 784 | ||
| 794 | for (i = 0; i < MAX_HRTIMER_BASES; i++, base++) | 785 | for (i = 0; i < MAX_HRTIMER_BASES; i++, base++) { |
| 795 | spin_lock_init(&base->lock); | 786 | spin_lock_init(&base->lock); |
| 787 | lockdep_set_class(&base->lock, &base->lock_key); | ||
| 788 | } | ||
| 796 | } | 789 | } |
| 797 | 790 | ||
| 798 | #ifdef CONFIG_HOTPLUG_CPU | 791 | #ifdef CONFIG_HOTPLUG_CPU |
| @@ -842,7 +835,7 @@ static void migrate_hrtimers(int cpu) | |||
| 842 | } | 835 | } |
| 843 | #endif /* CONFIG_HOTPLUG_CPU */ | 836 | #endif /* CONFIG_HOTPLUG_CPU */ |
| 844 | 837 | ||
| 845 | static int hrtimer_cpu_notify(struct notifier_block *self, | 838 | static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self, |
| 846 | unsigned long action, void *hcpu) | 839 | unsigned long action, void *hcpu) |
| 847 | { | 840 | { |
| 848 | long cpu = (long)hcpu; | 841 | long cpu = (long)hcpu; |
| @@ -866,7 +859,7 @@ static int hrtimer_cpu_notify(struct notifier_block *self, | |||
| 866 | return NOTIFY_OK; | 859 | return NOTIFY_OK; |
| 867 | } | 860 | } |
| 868 | 861 | ||
| 869 | static struct notifier_block hrtimers_nb = { | 862 | static struct notifier_block __cpuinitdata hrtimers_nb = { |
| 870 | .notifier_call = hrtimer_cpu_notify, | 863 | .notifier_call = hrtimer_cpu_notify, |
| 871 | }; | 864 | }; |
| 872 | 865 | ||
