aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2011-08-23 09:29:43 -0400
committerThomas Gleixner <tglx@linutronix.de>2011-09-08 05:10:56 -0400
commit65516f8a7c2028381f0dae4c16ddb621c96158cc (patch)
tree1f6192832c77e25499331b074398e165c1220197
parentd1748302f70be7469809809283fe164156a34231 (diff)
clockevents: Add direct ktime programming function
There is at least one architecture (s390) with a sane clockevent device that can be programmed with the equivalent of a ktime. No need to create a delta against the current time, the ktime can be used directly. A new clock device function 'set_next_ktime' is introduced that is called with the unmodified ktime for the timer if the clock event device has the CLOCK_EVT_FEAT_KTIME bit set. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: john stultz <johnstul@us.ibm.com> Link: http://lkml.kernel.org/r/20110823133142.815350967@de.ibm.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--include/linux/clockchips.h10
-rw-r--r--kernel/time/clockevents.c4
2 files changed, 11 insertions, 3 deletions
diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index 39bb050bdbb2..81e803e90aa4 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -45,20 +45,22 @@ enum clock_event_nofitiers {
45 */ 45 */
46#define CLOCK_EVT_FEAT_PERIODIC 0x000001 46#define CLOCK_EVT_FEAT_PERIODIC 0x000001
47#define CLOCK_EVT_FEAT_ONESHOT 0x000002 47#define CLOCK_EVT_FEAT_ONESHOT 0x000002
48#define CLOCK_EVT_FEAT_KTIME 0x000004
48/* 49/*
49 * x86(64) specific misfeatures: 50 * x86(64) specific misfeatures:
50 * 51 *
51 * - Clockevent source stops in C3 State and needs broadcast support. 52 * - Clockevent source stops in C3 State and needs broadcast support.
52 * - Local APIC timer is used as a dummy device. 53 * - Local APIC timer is used as a dummy device.
53 */ 54 */
54#define CLOCK_EVT_FEAT_C3STOP 0x000004 55#define CLOCK_EVT_FEAT_C3STOP 0x000008
55#define CLOCK_EVT_FEAT_DUMMY 0x000008 56#define CLOCK_EVT_FEAT_DUMMY 0x000010
56 57
57/** 58/**
58 * struct clock_event_device - clock event device descriptor 59 * struct clock_event_device - clock event device descriptor
59 * @event_handler: Assigned by the framework to be called by the low 60 * @event_handler: Assigned by the framework to be called by the low
60 * level handler of the event source 61 * level handler of the event source
61 * @set_next_event: set next event function 62 * @set_next_event: set next event function using a clocksource delta
63 * @set_next_ktime: set next event function using a direct ktime value
62 * @next_event: local storage for the next event in oneshot mode 64 * @next_event: local storage for the next event in oneshot mode
63 * @max_delta_ns: maximum delta value in ns 65 * @max_delta_ns: maximum delta value in ns
64 * @min_delta_ns: minimum delta value in ns 66 * @min_delta_ns: minimum delta value in ns
@@ -81,6 +83,8 @@ struct clock_event_device {
81 void (*event_handler)(struct clock_event_device *); 83 void (*event_handler)(struct clock_event_device *);
82 int (*set_next_event)(unsigned long evt, 84 int (*set_next_event)(unsigned long evt,
83 struct clock_event_device *); 85 struct clock_event_device *);
86 int (*set_next_ktime)(ktime_t expires,
87 struct clock_event_device *);
84 ktime_t next_event; 88 ktime_t next_event;
85 u64 max_delta_ns; 89 u64 max_delta_ns;
86 u64 min_delta_ns; 90 u64 min_delta_ns;
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 713ef94eceef..1ecd6ba36d6c 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -216,6 +216,10 @@ int clockevents_program_event(struct clock_event_device *dev, ktime_t expires,
216 if (dev->mode == CLOCK_EVT_MODE_SHUTDOWN) 216 if (dev->mode == CLOCK_EVT_MODE_SHUTDOWN)
217 return 0; 217 return 0;
218 218
219 /* Shortcut for clockevent devices that can deal with ktime. */
220 if (dev->features & CLOCK_EVT_FEAT_KTIME)
221 return dev->set_next_ktime(expires, dev);
222
219 delta = ktime_to_ns(ktime_sub(expires, ktime_get())); 223 delta = ktime_to_ns(ktime_sub(expires, ktime_get()));
220 if (delta <= 0) 224 if (delta <= 0)
221 return force ? clockevents_program_min_delta(dev) : -ETIME; 225 return force ? clockevents_program_min_delta(dev) : -ETIME;