Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 48588
b: refs/heads/master
c: d316c57
h: refs/heads/master
v: v3
  • Loading branch information
Thomas Gleixner authored and Linus Torvalds committed Feb 16, 2007
1 parent 77ba173 commit 1a0747a
Show file tree
Hide file tree
Showing 7 changed files with 498 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e05d723f98595b2f4d368f63636a997d98703304
refs/heads/master: d316c57ff6bfad9557462b9100f25c6260d2b774
142 changes: 142 additions & 0 deletions trunk/include/linux/clockchips.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/* linux/include/linux/clockchips.h
*
* This file contains the structure definitions for clockchips.
*
* If you are not a clockchip, or the time of day code, you should
* not be including this file!
*/
#ifndef _LINUX_CLOCKCHIPS_H
#define _LINUX_CLOCKCHIPS_H

#ifdef CONFIG_GENERIC_CLOCKEVENTS

#include <linux/clocksource.h>
#include <linux/cpumask.h>
#include <linux/ktime.h>
#include <linux/notifier.h>

struct clock_event_device;

/* Clock event mode commands */
enum clock_event_mode {
CLOCK_EVT_MODE_UNUSED = 0,
CLOCK_EVT_MODE_SHUTDOWN,
CLOCK_EVT_MODE_PERIODIC,
CLOCK_EVT_MODE_ONESHOT,
};

/* Clock event notification values */
enum clock_event_nofitiers {
CLOCK_EVT_NOTIFY_ADD,
CLOCK_EVT_NOTIFY_BROADCAST_ON,
CLOCK_EVT_NOTIFY_BROADCAST_OFF,
CLOCK_EVT_NOTIFY_BROADCAST_ENTER,
CLOCK_EVT_NOTIFY_BROADCAST_EXIT,
CLOCK_EVT_NOTIFY_SUSPEND,
CLOCK_EVT_NOTIFY_RESUME,
CLOCK_EVT_NOTIFY_CPU_DEAD,
};

/*
* Clock event features
*/
#define CLOCK_EVT_FEAT_PERIODIC 0x000001
#define CLOCK_EVT_FEAT_ONESHOT 0x000002
/*
* x86(64) specific misfeatures:
*
* - Clockevent source stops in C3 State and needs broadcast support.
* - Local APIC timer is used as a dummy device.
*/
#define CLOCK_EVT_FEAT_C3STOP 0x000004
#define CLOCK_EVT_FEAT_DUMMY 0x000008

/**
* struct clock_event_device - clock event device descriptor
* @name: ptr to clock event name
* @hints: usage hints
* @max_delta_ns: maximum delta value in ns
* @min_delta_ns: minimum delta value in ns
* @mult: nanosecond to cycles multiplier
* @shift: nanoseconds to cycles divisor (power of two)
* @rating: variable to rate clock event devices
* @irq: irq number (only for non cpu local devices)
* @cpumask: cpumask to indicate for which cpus this device works
* @set_next_event: set next event
* @set_mode: set mode function
* @evthandler: Assigned by the framework to be called by the low
* level handler of the event source
* @broadcast: function to broadcast events
* @list: list head for the management code
* @mode: operating mode assigned by the management code
* @next_event: local storage for the next event in oneshot mode
*/
struct clock_event_device {
const char *name;
unsigned int features;
unsigned long max_delta_ns;
unsigned long min_delta_ns;
unsigned long mult;
int shift;
int rating;
int irq;
cpumask_t cpumask;
int (*set_next_event)(unsigned long evt,
struct clock_event_device *);
void (*set_mode)(enum clock_event_mode mode,
struct clock_event_device *);
void (*event_handler)(struct clock_event_device *);
void (*broadcast)(cpumask_t mask);
struct list_head list;
enum clock_event_mode mode;
ktime_t next_event;
};

/*
* Calculate a multiplication factor for scaled math, which is used to convert
* nanoseconds based values to clock ticks:
*
* clock_ticks = (nanoseconds * factor) >> shift.
*
* div_sc is the rearranged equation to calculate a factor from a given clock
* ticks / nanoseconds ratio:
*
* factor = (clock_ticks << shift) / nanoseconds
*/
static inline unsigned long div_sc(unsigned long ticks, unsigned long nsec,
int shift)
{
uint64_t tmp = ((uint64_t)ticks) << shift;

do_div(tmp, nsec);
return (unsigned long) tmp;
}

/* Clock event layer functions */
extern unsigned long clockevent_delta2ns(unsigned long latch,
struct clock_event_device *evt);
extern void clockevents_register_device(struct clock_event_device *dev);

extern void clockevents_exchange_device(struct clock_event_device *old,
struct clock_event_device *new);
extern
struct clock_event_device *clockevents_request_device(unsigned int features,
cpumask_t cpumask);
extern void clockevents_release_device(struct clock_event_device *dev);
extern void clockevents_set_mode(struct clock_event_device *dev,
enum clock_event_mode mode);
extern int clockevents_register_notifier(struct notifier_block *nb);
extern void clockevents_unregister_notifier(struct notifier_block *nb);
extern int clockevents_program_event(struct clock_event_device *dev,
ktime_t expires, ktime_t now);

extern void clockevents_notify(unsigned long reason, void *arg);

#else

static inline void clockevents_resume_events(void) { }
#define clockevents_notify(reason, arg) do { } while (0)

#endif

#endif
5 changes: 2 additions & 3 deletions trunk/include/linux/hrtimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ struct hrtimer_cpu_base {
* is expired in the next softirq when the clock was advanced.
*/
#define clock_was_set() do { } while (0)
extern ktime_t ktime_get(void);
extern ktime_t ktime_get_real(void);

/* Exported timer functions: */

Expand Down Expand Up @@ -196,9 +198,6 @@ extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
/* Soft interrupt function to run the hrtimer queues: */
extern void hrtimer_run_queues(void);

/* Resume notification */
void hrtimer_notify_resume(void);

/* Bootup initialization: */
extern void __init hrtimers_init(void);

Expand Down
13 changes: 3 additions & 10 deletions trunk/kernel/hrtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*
* returns the time in ktime_t format
*/
static ktime_t ktime_get(void)
ktime_t ktime_get(void)
{
struct timespec now;

Expand All @@ -60,7 +60,7 @@ static ktime_t ktime_get(void)
*
* returns the time in ktime_t format
*/
static ktime_t ktime_get_real(void)
ktime_t ktime_get_real(void)
{
struct timespec now;

Expand Down Expand Up @@ -310,14 +310,6 @@ static unsigned long ktime_divns(const ktime_t kt, s64 div)
# define ktime_divns(kt, div) (unsigned long)((kt).tv64 / (div))
#endif /* BITS_PER_LONG >= 64 */

/*
* Timekeeping resumed notification
*/
void hrtimer_notify_resume(void)
{
clock_was_set();
}

/*
* Counterpart to lock_timer_base above:
*/
Expand Down Expand Up @@ -889,6 +881,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,

#ifdef CONFIG_HOTPLUG_CPU
case CPU_DEAD:
clockevents_notify(CLOCK_EVT_NOTIFY_CPU_DEAD, &cpu);
migrate_hrtimers(cpu);
break;
#endif
Expand Down
2 changes: 2 additions & 0 deletions trunk/kernel/time/Makefile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
obj-y += ntp.o clocksource.o jiffies.o

obj-$(CONFIG_GENERIC_CLOCKEVENTS) += clockevents.o
Loading

0 comments on commit 1a0747a

Please sign in to comment.