Blame view
kernel/time/tick-oneshot.c
2.82 KB
79bf2bb33 [PATCH] tick-mana... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
/* * linux/kernel/time/tick-oneshot.c * * This file contains functions which manage high resolution tick * related events. * * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de> * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar * Copyright(C) 2006-2007, Timesys Corp., Thomas Gleixner * * This code is licenced under the GPL version 2. For details see * kernel-base/COPYING. */ #include <linux/cpu.h> #include <linux/err.h> #include <linux/hrtimer.h> |
d7b906897 [S390] genirq/clo... |
17 |
#include <linux/interrupt.h> |
79bf2bb33 [PATCH] tick-mana... |
18 19 20 |
#include <linux/percpu.h> #include <linux/profile.h> #include <linux/sched.h> |
79bf2bb33 [PATCH] tick-mana... |
21 22 |
#include "tick-internal.h" |
79bf2bb33 [PATCH] tick-mana... |
23 |
/** |
7205656ab clockevents: enfo... |
24 25 26 27 |
* tick_program_event */ int tick_program_event(ktime_t expires, int force) { |
909ea9646 core: Replace __g... |
28 |
struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); |
7205656ab clockevents: enfo... |
29 |
|
d1748302f clockevents: Make... |
30 |
return clockevents_program_event(dev, expires, force); |
7205656ab clockevents: enfo... |
31 32 33 |
} /** |
cd05a1f81 [PATCH] clockeven... |
34 35 36 37 |
* tick_resume_onshot - resume oneshot mode */ void tick_resume_oneshot(void) { |
d1748302f clockevents: Make... |
38 |
struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); |
cd05a1f81 [PATCH] clockeven... |
39 40 |
clockevents_set_mode(dev, CLOCK_EVT_MODE_ONESHOT); |
d1748302f clockevents: Make... |
41 |
clockevents_program_event(dev, ktime_get(), true); |
cd05a1f81 [PATCH] clockeven... |
42 43 44 |
} /** |
79bf2bb33 [PATCH] tick-mana... |
45 46 47 48 49 50 51 52 |
* tick_setup_oneshot - setup the event device for oneshot mode (hres or nohz) */ void tick_setup_oneshot(struct clock_event_device *newdev, void (*handler)(struct clock_event_device *), ktime_t next_event) { newdev->event_handler = handler; clockevents_set_mode(newdev, CLOCK_EVT_MODE_ONESHOT); |
d1748302f clockevents: Make... |
53 |
clockevents_program_event(newdev, next_event, true); |
79bf2bb33 [PATCH] tick-mana... |
54 55 56 57 58 59 60 61 62 63 64 |
} /** * tick_switch_to_oneshot - switch to oneshot mode */ int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *)) { struct tick_device *td = &__get_cpu_var(tick_cpu_device); struct clock_event_device *dev = td->evtdev; if (!dev || !(dev->features & CLOCK_EVT_FEAT_ONESHOT) || |
820de5c39 highres: improve ... |
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
!tick_device_is_functional(dev)) { printk(KERN_INFO "Clockevents: " "could not switch to one-shot mode:"); if (!dev) { printk(" no tick device "); } else { if (!tick_device_is_functional(dev)) printk(" %s is not functional. ", dev->name); else printk(" %s does not support one-shot mode. ", dev->name); } |
79bf2bb33 [PATCH] tick-mana... |
81 |
return -EINVAL; |
820de5c39 highres: improve ... |
82 |
} |
79bf2bb33 [PATCH] tick-mana... |
83 84 85 86 87 88 89 |
td->mode = TICKDEV_MODE_ONESHOT; dev->event_handler = handler; clockevents_set_mode(dev, CLOCK_EVT_MODE_ONESHOT); tick_broadcast_switch_to_oneshot(); return 0; } |
cd6d95d84 clocksource: prev... |
90 91 92 93 94 95 96 97 98 99 100 |
/** * tick_check_oneshot_mode - check whether the system is in oneshot mode * * returns 1 when either nohz or highres are enabled. otherwise 0. */ int tick_oneshot_mode_active(void) { unsigned long flags; int ret; local_irq_save(flags); |
909ea9646 core: Replace __g... |
101 |
ret = __this_cpu_read(tick_cpu_device.mode) == TICKDEV_MODE_ONESHOT; |
cd6d95d84 clocksource: prev... |
102 103 104 105 |
local_irq_restore(flags); return ret; } |
79bf2bb33 [PATCH] tick-mana... |
106 107 108 109 110 111 112 113 114 115 116 |
#ifdef CONFIG_HIGH_RES_TIMERS /** * tick_init_highres - switch to high resolution mode * * Called with interrupts disabled. */ int tick_init_highres(void) { return tick_switch_to_oneshot(hrtimer_interrupt); } #endif |