svn commit: r247260 - in projects/calloutng: share/man/man4 share/man/man9 sys/arm/allwinner sys/arm/arm sys/arm/broadcom/bcm2835 sys/arm/lpc sys/arm/mv sys/arm/ti/am335x sys/arm/versatile sys/dev/...
Alexander Motin
mav at FreeBSD.org
Mon Feb 25 10:07:58 UTC 2013
Author: mav
Date: Mon Feb 25 10:07:54 2013
New Revision: 247260
URL: http://svnweb.freebsd.org/changeset/base/247260
Log:
Switch eventtimers(4/9) from using struct bintime to sbintime_t.
By the way do some minor optimizations and drop support for activetick
sysctl, that in incompatible with the new callout code.
Modified:
projects/calloutng/share/man/man4/eventtimers.4
projects/calloutng/share/man/man9/eventtimers.9
projects/calloutng/sys/arm/allwinner/timer.c
projects/calloutng/sys/arm/arm/mpcore_timer.c
projects/calloutng/sys/arm/broadcom/bcm2835/bcm2835_systimer.c
projects/calloutng/sys/arm/lpc/lpc_timer.c
projects/calloutng/sys/arm/mv/timer.c
projects/calloutng/sys/arm/ti/am335x/am335x_dmtimer.c
projects/calloutng/sys/arm/versatile/sp804.c
projects/calloutng/sys/dev/acpica/acpi_hpet.c
projects/calloutng/sys/i386/xen/clock.c
projects/calloutng/sys/ia64/ia64/clock.c
projects/calloutng/sys/kern/kern_clock.c
projects/calloutng/sys/kern/kern_clocksource.c
projects/calloutng/sys/kern/kern_et.c
projects/calloutng/sys/kern/kern_timeout.c
projects/calloutng/sys/kern/subr_param.c
projects/calloutng/sys/mips/mips/tick.c
projects/calloutng/sys/mips/nlm/tick.c
projects/calloutng/sys/mips/rmi/tick.c
projects/calloutng/sys/powerpc/aim/clock.c
projects/calloutng/sys/powerpc/booke/clock.c
projects/calloutng/sys/sparc64/sparc64/tick.c
projects/calloutng/sys/sys/callout.h
projects/calloutng/sys/sys/time.h
projects/calloutng/sys/sys/timeet.h
projects/calloutng/sys/x86/isa/atrtc.c
projects/calloutng/sys/x86/isa/clock.c
projects/calloutng/sys/x86/x86/local_apic.c
Modified: projects/calloutng/share/man/man4/eventtimers.4
==============================================================================
--- projects/calloutng/share/man/man4/eventtimers.4 Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/share/man/man4/eventtimers.4 Mon Feb 25 10:07:54 2013 (r247260)
@@ -143,14 +143,6 @@ By default this options is disabled.
If chosen timer is per-CPU
and runs in periodic mode, this option has no effect - all interrupts are
always generating.
-.It Va kern.eventtimer.activetick
-makes each CPU to receive all kinds of timer interrupts when they are busy.
-Disabling it allows to skip some
-.Fn hardclock
-calls in some cases.
-By default this options is enabled.
-If chosen timer is per-CPU, this option has no effect - all interrupts are
-always generating, as timer reprogramming is too expensive for that case.
.El
.Sh SEE ALSO
.Xr apic 4 ,
Modified: projects/calloutng/share/man/man9/eventtimers.9
==============================================================================
--- projects/calloutng/share/man/man9/eventtimers.9 Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/share/man/man9/eventtimers.9 Mon Feb 25 10:07:54 2013 (r247260)
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 2011 Alexander Motin <mav at FreeBSD.org>
+.\" Copyright (c) 2011-2013 Alexander Motin <mav at FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 14, 2011
+.Dd February 25, 2013
.Dt EVENTTIMERS 9
.Os
.Sh NAME
@@ -36,7 +36,7 @@
struct eventtimer;
typedef int et_start_t(struct eventtimer *et,
- struct bintime *first, struct bintime *period);
+ sbintime_t first, sbintime_t period);
typedef int et_stop_t(struct eventtimer *et);
typedef void et_event_cb_t(struct eventtimer *et, void *arg);
typedef int et_deregister_cb_t(struct eventtimer *et, void *arg);
@@ -53,8 +53,8 @@ struct eventtimer {
int et_quality;
int et_active;
uint64_t et_frequency;
- struct bintime et_min_period;
- struct bintime et_max_period;
+ sbintime_t et_min_period;
+ sbintime_t et_max_period;
et_start_t *et_start;
et_stop_t *et_stop;
et_event_cb_t *et_event_cb;
@@ -75,7 +75,7 @@ struct eventtimer {
.Ft int
.Fn et_init "struct eventtimer *et" "et_event_cb_t *event" "et_deregister_cb_t *deregister" "void *arg"
.Ft int
-.Fn et_start "struct eventtimer *et" "struct bintime *first" "struct bintime *period"
+.Fn et_start "struct eventtimer *et" "sbintime_t first" "sbintime_t period"
.Ft int
.Fn et_stop "struct eventtimer *et"
.Ft int
Modified: projects/calloutng/sys/arm/allwinner/timer.c
==============================================================================
--- projects/calloutng/sys/arm/allwinner/timer.c Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/sys/arm/allwinner/timer.c Mon Feb 25 10:07:54 2013 (r247260)
@@ -95,7 +95,7 @@ int a10_timer_get_timerfreq(struct a10_t
static u_int a10_timer_get_timecount(struct timecounter *);
static int a10_timer_timer_start(struct eventtimer *,
- struct bintime *, struct bintime *);
+ sbintime_t first, sbintime_t period);
static int a10_timer_timer_stop(struct eventtimer *);
static uint64_t timer_read_counter64(void);
@@ -193,12 +193,8 @@ a10_timer_attach(device_t dev)
sc->et.et_name = "a10_timer Eventtimer";
sc->et.et_flags = ET_FLAGS_ONESHOT | ET_FLAGS_PERIODIC;
sc->et.et_quality = 1000;
- sc->et.et_min_period.sec = 0;
- sc->et.et_min_period.frac =
- ((0x00000005LLU << 32) / sc->et.et_frequency) << 32;
- sc->et.et_max_period.sec = 0xfffffff0U / sc->et.et_frequency;
- sc->et.et_max_period.frac =
- ((0xfffffffeLLU << 32) / sc->et.et_frequency) << 32;
+ sc->et.et_min_period = (0x00000005LLU << 32) / sc->et.et_frequency;
+ sc->et.et_max_period = (0xfffffffeLLU << 32) / sc->et.et_frequency;
sc->et.et_start = a10_timer_timer_start;
sc->et.et_stop = a10_timer_timer_stop;
sc->et.et_priv = sc;
@@ -225,8 +221,8 @@ a10_timer_attach(device_t dev)
}
static int
-a10_timer_timer_start(struct eventtimer *et, struct bintime *first,
- struct bintime *period)
+a10_timer_timer_start(struct eventtimer *et, sbintime_t first,
+ sbintime_t period)
{
struct a10_timer_softc *sc;
uint32_t count;
@@ -234,26 +230,21 @@ a10_timer_timer_start(struct eventtimer
sc = (struct a10_timer_softc *)et->et_priv;
- sc->sc_period = 0;
-
- if (period != NULL) {
- sc->sc_period = (sc->et.et_frequency * (period->frac >> 32)) >> 32;
- sc->sc_period += sc->et.et_frequency * period->sec;
- }
- if (first == NULL)
+ if (period != 0)
+ sc->sc_period = ((uint32_t)et->et_frequency * period) >> 32;
+ else
+ sc->sc_period = 0;
+ if (first != 0)
+ count = ((uint32_t)et->et_frequency * first) >> 32;
+ else
count = sc->sc_period;
- else {
- count = (sc->et.et_frequency * (first->frac >> 32)) >> 32;
- if (first->sec != 0)
- count += sc->et.et_frequency * first->sec;
- }
/* Update timer values */
timer_write_4(sc, SW_TIMER0_INT_VALUE_REG, sc->sc_period);
timer_write_4(sc, SW_TIMER0_CUR_VALUE_REG, count);
val = timer_read_4(sc, SW_TIMER0_CTRL_REG);
- if (first == NULL) {
+ if (period != 0) {
/* periodic */
val |= TIMER_AUTORELOAD;
} else {
Modified: projects/calloutng/sys/arm/arm/mpcore_timer.c
==============================================================================
--- projects/calloutng/sys/arm/arm/mpcore_timer.c Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/sys/arm/arm/mpcore_timer.c Mon Feb 25 10:07:54 2013 (r247260)
@@ -167,31 +167,23 @@ arm_tmr_get_timecount(struct timecounter
* Always returns 0
*/
static int
-arm_tmr_start(struct eventtimer *et, struct bintime *first,
- struct bintime *period)
+arm_tmr_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
- struct arm_tmr_softc *sc = (struct arm_tmr_softc *)et->et_priv;
uint32_t load, count;
uint32_t ctrl;
ctrl = PRV_TIMER_CTRL_IRQ_ENABLE | PRV_TIMER_CTRL_TIMER_ENABLE;
- if (period != NULL) {
- load = (et->et_frequency * (period->frac >> 32)) >> 32;
- if (period->sec > 0)
- load += et->et_frequency * period->sec;
+ if (period != 0) {
+ load = ((uint32_t)et->et_frequency * period) >> 32;
ctrl |= PRV_TIMER_CTRL_AUTO_RELOAD;
- } else {
+ } else
load = 0;
- }
- if (first != NULL) {
- count = (sc->et.et_frequency * (first->frac >> 32)) >> 32;
- if (first->sec != 0)
- count += sc->et.et_frequency * first->sec;
- } else {
+ if (first != 0)
+ count = ((uint32_t)et->et_frequency * first) >> 32;
+ else
count = load;
- }
tmr_prv_write_4(PRV_TIMER_LOAD, load);
tmr_prv_write_4(PRV_TIMER_COUNT, count);
@@ -330,12 +322,8 @@ arm_tmr_attach(device_t dev)
sc->et.et_quality = 1000;
sc->et.et_frequency = sc->clkfreq;
- sc->et.et_min_period.sec = 0;
- sc->et.et_min_period.frac =
- ((0x00000002LLU << 32) / sc->et.et_frequency) << 32;
- sc->et.et_max_period.sec = 0xfffffff0U / sc->et.et_frequency;
- sc->et.et_max_period.frac =
- ((0xfffffffeLLU << 32) / sc->et.et_frequency) << 32;
+ sc->et.et_min_period = (0x00000002LLU << 32) / sc->et.et_frequency;
+ sc->et.et_max_period = (0xfffffffeLLU << 32) / sc->et.et_frequency;
sc->et.et_start = arm_tmr_start;
sc->et.et_stop = arm_tmr_stop;
sc->et.et_priv = sc;
Modified: projects/calloutng/sys/arm/broadcom/bcm2835/bcm2835_systimer.c
==============================================================================
--- projects/calloutng/sys/arm/broadcom/bcm2835/bcm2835_systimer.c Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/sys/arm/broadcom/bcm2835/bcm2835_systimer.c Mon Feb 25 10:07:54 2013 (r247260)
@@ -118,19 +118,16 @@ bcm_systimer_tc_get_timecount(struct tim
}
static int
-bcm_systimer_start(struct eventtimer *et, struct bintime *first,
- struct bintime *period)
+bcm_systimer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
struct systimer *st = et->et_priv;
uint32_t clo;
uint32_t count;
register_t s;
- if (first != NULL) {
+ if (first != 0) {
- count = (st->et.et_frequency * (first->frac >> 32)) >> 32;
- if (first->sec != 0)
- count += st->et.et_frequency * first->sec;
+ count = ((uint32_t)et->et_frequency * first) >> 32;
s = intr_disable();
clo = bcm_systimer_tc_read_4(SYSTIMER_CLO);
@@ -238,12 +235,10 @@ bcm_systimer_attach(device_t dev)
sc->st[DEFAULT_TIMER].et.et_flags = ET_FLAGS_ONESHOT;
sc->st[DEFAULT_TIMER].et.et_quality = 1000;
sc->st[DEFAULT_TIMER].et.et_frequency = sc->sysclk_freq;
- sc->st[DEFAULT_TIMER].et.et_min_period.sec = 0;
- sc->st[DEFAULT_TIMER].et.et_min_period.frac =
- ((MIN_PERIOD << 32) / sc->st[DEFAULT_TIMER].et.et_frequency) << 32;
- sc->st[DEFAULT_TIMER].et.et_max_period.sec = 0xfffffff0U / sc->st[DEFAULT_TIMER].et.et_frequency;
- sc->st[DEFAULT_TIMER].et.et_max_period.frac =
- ((0xfffffffeLLU << 32) / sc->st[DEFAULT_TIMER].et.et_frequency) << 32;
+ sc->st[DEFAULT_TIMER].et.et_min_period =
+ (MIN_PERIOD << 32) / sc->st[DEFAULT_TIMER].et.et_frequency;
+ sc->st[DEFAULT_TIMER].et.et_max_period =
+ (0xfffffffeLLU << 32) / sc->st[DEFAULT_TIMER].et.et_frequency;
sc->st[DEFAULT_TIMER].et.et_start = bcm_systimer_start;
sc->st[DEFAULT_TIMER].et.et_stop = bcm_systimer_stop;
sc->st[DEFAULT_TIMER].et.et_priv = &sc->st[DEFAULT_TIMER];
Modified: projects/calloutng/sys/arm/lpc/lpc_timer.c
==============================================================================
--- projects/calloutng/sys/arm/lpc/lpc_timer.c Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/sys/arm/lpc/lpc_timer.c Mon Feb 25 10:07:54 2013 (r247260)
@@ -72,8 +72,8 @@ static struct lpc_timer_softc *timer_sof
static int lpc_timer_initialized = 0;
static int lpc_timer_probe(device_t);
static int lpc_timer_attach(device_t);
-static int lpc_timer_start(struct eventtimer *, struct bintime *first,
- struct bintime *);
+static int lpc_timer_start(struct eventtimer *,
+ sbintime_t first, sbintime_t period);
static int lpc_timer_stop(struct eventtimer *et);
static unsigned lpc_get_timecount(struct timecounter *);
static int lpc_hardclock(void *);
@@ -173,12 +173,8 @@ lpc_timer_attach(device_t dev)
sc->lt_et.et_name = "LPC32x0 Timer0";
sc->lt_et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT;
sc->lt_et.et_quality = 1000;
- sc->lt_et.et_min_period.sec = 0;
- sc->lt_et.et_min_period.frac =
- ((0x00000002LLU << 32) / sc->lt_et.et_frequency) << 32;
- sc->lt_et.et_max_period.sec = 0xfffffff0U / sc->lt_et.et_frequency;
- sc->lt_et.et_max_period.frac =
- ((0xfffffffeLLU << 32) / sc->lt_et.et_frequency) << 32;
+ sc->lt_et.et_min_period = (0x00000002LLU << 32) / sc->lt_et.et_frequency;
+ sc->lt_et.et_max_period = (0xfffffffeLLU << 32) / sc->lt_et.et_frequency;
sc->lt_et.et_start = lpc_timer_start;
sc->lt_et.et_stop = lpc_timer_stop;
sc->lt_et.et_priv = sc;
@@ -199,27 +195,23 @@ lpc_timer_attach(device_t dev)
}
static int
-lpc_timer_start(struct eventtimer *et, struct bintime *first,
- struct bintime *period)
+lpc_timer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
struct lpc_timer_softc *sc = (struct lpc_timer_softc *)et->et_priv;
uint32_t ticks;
- if (period == NULL)
+ if (period == 0) {
sc->lt_oneshot = 1;
- else {
+ sc->lt_period = 0;
+ } else {
sc->lt_oneshot = 0;
- sc->lt_period = (sc->lt_et.et_frequency * (first->frac >> 32)) >> 32;
- sc->lt_period += sc->lt_et.et_frequency * first->sec;
+ sc->lt_period = ((uint32_t)et->et_frequency * period) >> 32;
}
- if (first == NULL)
+ if (first == 0)
ticks = sc->lt_period;
- else {
- ticks = (sc->lt_et.et_frequency * (first->frac >> 32)) >> 32;
- if (first->sec != 0)
- ticks += sc->lt_et.et_frequency * first->sec;
- }
+ else
+ ticks = ((uint32_t)et->et_frequency * first) >> 32;
/* Reset timer */
timer0_write_4(sc, LPC_TIMER_TCR, LPC_TIMER_TCR_RESET);
Modified: projects/calloutng/sys/arm/mv/timer.c
==============================================================================
--- projects/calloutng/sys/arm/mv/timer.c Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/sys/arm/mv/timer.c Mon Feb 25 10:07:54 2013 (r247260)
@@ -93,7 +93,7 @@ static void mv_watchdog_enable(void);
static void mv_watchdog_disable(void);
static void mv_watchdog_event(void *, unsigned int, int *);
static int mv_timer_start(struct eventtimer *et,
- struct bintime *first, struct bintime *period);
+ sbintime_t first, sbintime_t period);
static int mv_timer_stop(struct eventtimer *et);
static void mv_setup_timers(void);
@@ -168,12 +168,8 @@ mv_timer_attach(device_t dev)
sc->et.et_quality = 1000;
sc->et.et_frequency = MV_CLOCK_SRC;
- sc->et.et_min_period.sec = 0;
- sc->et.et_min_period.frac =
- ((0x00000002LLU << 32) / sc->et.et_frequency) << 32;
- sc->et.et_max_period.sec = 0xfffffff0U / sc->et.et_frequency;
- sc->et.et_max_period.frac =
- ((0xfffffffeLLU << 32) / sc->et.et_frequency) << 32;
+ sc->et.et_min_period = (0x00000002LLU << 32) / sc->et.et_frequency;
+ sc->et.et_max_period = (0xfffffffeLLU << 32) / sc->et.et_frequency;
sc->et.et_start = mv_timer_start;
sc->et.et_stop = mv_timer_stop;
sc->et.et_priv = sc;
@@ -394,25 +390,20 @@ mv_watchdog_event(void *arg, unsigned in
}
static int
-mv_timer_start(struct eventtimer *et,
- struct bintime *first, struct bintime *period)
+mv_timer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
struct mv_timer_softc *sc;
uint32_t val, val1;
/* Calculate dividers. */
sc = (struct mv_timer_softc *)et->et_priv;
- if (period != NULL) {
- val = (sc->et.et_frequency * (period->frac >> 32)) >> 32;
- if (period->sec != 0)
- val += sc->et.et_frequency * period->sec;
- } else
+ if (period != 0)
+ val = ((uint32_t)sc->et.et_frequency * period) >> 32;
+ else
val = 0;
- if (first != NULL) {
- val1 = (sc->et.et_frequency * (first->frac >> 32)) >> 32;
- if (first->sec != 0)
- val1 += sc->et.et_frequency * first->sec;
- } else
+ if (first != 0)
+ val1 = ((uint32_t)sc->et.et_frequency * first) >> 32;
+ else
val1 = val;
/* Apply configuration. */
@@ -420,7 +411,7 @@ mv_timer_start(struct eventtimer *et,
mv_set_timer(0, val1);
val = mv_get_timer_control();
val |= CPU_TIMER0_EN;
- if (period != NULL)
+ if (period != 0)
val |= CPU_TIMER0_AUTO;
else
val &= ~CPU_TIMER0_AUTO;
Modified: projects/calloutng/sys/arm/ti/am335x/am335x_dmtimer.c
==============================================================================
--- projects/calloutng/sys/arm/ti/am335x/am335x_dmtimer.c Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/sys/arm/ti/am335x/am335x_dmtimer.c Mon Feb 25 10:07:54 2013 (r247260)
@@ -143,30 +143,24 @@ am335x_dmtimer_tc_get_timecount(struct t
}
static int
-am335x_dmtimer_start(struct eventtimer *et, struct bintime *first,
- struct bintime *period)
+am335x_dmtimer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
struct am335x_dmtimer *tmr = (struct am335x_dmtimer *)et->et_priv;
uint32_t load, count;
uint32_t tclr = 0;
- if (period != NULL) {
- load = (et->et_frequency * (period->frac >> 32)) >> 32;
- if (period->sec > 0)
- load += et->et_frequency * period->sec;
+ if (period != 0) {
+ load = ((uint32_t)et->et_frequency * period) >> 32;
tclr |= 2; /* autoreload bit */
panic("periodic timer not implemented\n");
} else {
load = 0;
}
- if (first != NULL) {
- count = (tmr->et.et_frequency * (first->frac >> 32)) >> 32;
- if (first->sec != 0)
- count += tmr->et.et_frequency * first->sec;
- } else {
+ if (first != 0)
+ count = ((uint32_t)et->et_frequency * first) >> 32;
+ else
count = load;
- }
/* Reset Timer */
am335x_dmtimer_et_write_4(DMTIMER_TSICR, 2);
@@ -316,12 +310,10 @@ am335x_dmtimer_attach(device_t dev)
sc->t[3].et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT;
sc->t[3].et.et_quality = 1000;
sc->t[3].et.et_frequency = sc->sysclk_freq;
- sc->t[3].et.et_min_period.sec = 0;
- sc->t[3].et.et_min_period.frac =
- ((0x00000002LLU << 32) / sc->t[3].et.et_frequency) << 32;
- sc->t[3].et.et_max_period.sec = 0xfffffff0U / sc->t[3].et.et_frequency;
- sc->t[3].et.et_max_period.frac =
- ((0xfffffffeLLU << 32) / sc->t[3].et.et_frequency) << 32;
+ sc->t[3].et.et_min_period =
+ (0x00000002LLU << 32) / sc->t[3].et.et_frequency;
+ sc->t[3].et.et_max_period =
+ (0xfffffffeLLU << 32) / sc->t[3].et.et_frequency;
sc->t[3].et.et_start = am335x_dmtimer_start;
sc->t[3].et.et_stop = am335x_dmtimer_stop;
sc->t[3].et.et_priv = &sc->t[3];
Modified: projects/calloutng/sys/arm/versatile/sp804.c
==============================================================================
--- projects/calloutng/sys/arm/versatile/sp804.c Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/sys/arm/versatile/sp804.c Mon Feb 25 10:07:54 2013 (r247260)
@@ -120,18 +120,15 @@ sp804_timer_tc_get_timecount(struct time
}
static int
-sp804_timer_start(struct eventtimer *et, struct bintime *first,
- struct bintime *period)
+sp804_timer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
struct sp804_timer_softc *sc = et->et_priv;
uint32_t count, reg;
- if (first != NULL) {
+ if (first != 0) {
sc->et_enabled = 1;
- count = (sc->et.et_frequency * (first->frac >> 32)) >> 32;
- if (first->sec != 0)
- count += sc->et.et_frequency * first->sec;
+ count = ((uint32_t)et->et_frequency * first) >> 32;
sp804_timer_tc_write_4(SP804_TIMER2_LOAD, count);
reg = TIMER_CONTROL_32BIT | TIMER_CONTROL_INTREN |
@@ -142,7 +139,7 @@ sp804_timer_start(struct eventtimer *et,
return (0);
}
- if (period != NULL) {
+ if (period != 0) {
panic("period");
}
@@ -264,12 +261,8 @@ sp804_timer_attach(device_t dev)
sc->et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT;
sc->et.et_quality = 1000;
sc->et.et_frequency = sc->sysclk_freq / DEFAULT_DIVISOR;
- sc->et.et_min_period.sec = 0;
- sc->et.et_min_period.frac =
- ((0x00000002LLU << 32) / sc->et.et_frequency) << 32;
- sc->et.et_max_period.sec = 0xfffffff0U / sc->et.et_frequency;
- sc->et.et_max_period.frac =
- ((0xfffffffeLLU << 32) / sc->et.et_frequency) << 32;
+ sc->et.et_min_period = (0x00000002LLU << 32) / sc->et.et_frequency;
+ sc->et.et_max_period = (0xfffffffeLLU << 32) / sc->et.et_frequency;
sc->et.et_start = sp804_timer_start;
sc->et.et_stop = sp804_timer_stop;
sc->et.et_priv = sc;
Modified: projects/calloutng/sys/dev/acpica/acpi_hpet.c
==============================================================================
--- projects/calloutng/sys/dev/acpica/acpi_hpet.c Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/sys/dev/acpica/acpi_hpet.c Mon Feb 25 10:07:54 2013 (r247260)
@@ -147,8 +147,7 @@ hpet_disable(struct hpet_softc *sc)
}
static int
-hpet_start(struct eventtimer *et,
- struct bintime *first, struct bintime *period)
+hpet_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
struct hpet_timer *mt = (struct hpet_timer *)et->et_priv;
struct hpet_timer *t;
@@ -156,20 +155,16 @@ hpet_start(struct eventtimer *et,
uint32_t fdiv, now;
t = (mt->pcpu_master < 0) ? mt : &sc->t[mt->pcpu_slaves[curcpu]];
- if (period != NULL) {
+ if (period != 0) {
t->mode = 1;
- t->div = (sc->freq * (period->frac >> 32)) >> 32;
- if (period->sec != 0)
- t->div += sc->freq * period->sec;
+ t->div = (sc->freq * period) >> 32;
} else {
t->mode = 2;
t->div = 0;
}
- if (first != NULL) {
- fdiv = (sc->freq * (first->frac >> 32)) >> 32;
- if (first->sec != 0)
- fdiv += sc->freq * first->sec;
- } else
+ if (first != 0)
+ fdiv = (sc->freq * first) >> 32;
+ else
fdiv = t->div;
if (t->irq < 0)
bus_write_4(sc->mem_res, HPET_ISR, 1 << t->num);
@@ -684,12 +679,9 @@ hpet_attach(device_t dev)
if ((t->caps & HPET_TCAP_PER_INT) == 0)
t->et.et_quality -= 10;
t->et.et_frequency = sc->freq;
- t->et.et_min_period.sec = 0;
- t->et.et_min_period.frac =
- (((uint64_t)(HPET_MIN_CYCLES * 2) << 32) / sc->freq) << 32;
- t->et.et_max_period.sec = 0xfffffffeLLU / sc->freq;
- t->et.et_max_period.frac =
- ((0xfffffffeLLU << 32) / sc->freq) << 32;
+ t->et.et_min_period =
+ ((uint64_t)(HPET_MIN_CYCLES * 2) << 32) / sc->freq;
+ t->et.et_max_period = (0xfffffffeLLU << 32) / sc->freq;
t->et.et_start = hpet_start;
t->et.et_stop = hpet_stop;
t->et.et_priv = &sc->t[i];
Modified: projects/calloutng/sys/i386/xen/clock.c
==============================================================================
--- projects/calloutng/sys/i386/xen/clock.c Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/sys/i386/xen/clock.c Mon Feb 25 10:07:54 2013 (r247260)
@@ -768,8 +768,7 @@ resettodr()
#endif
static int
-xen_et_start(struct eventtimer *et,
- struct bintime *first, struct bintime *period)
+xen_et_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
struct xen_et_state *state = DPCPU_PTR(et_state);
struct shadow_time_info *shadow;
@@ -777,21 +776,16 @@ xen_et_start(struct eventtimer *et,
__get_time_values_from_xen();
- if (period != NULL) {
+ if (period != 0) {
state->mode = MODE_PERIODIC;
- state->period = (1000000000LL *
- (uint32_t)(period->frac >> 32)) >> 32;
- if (period->sec != 0)
- state->period += 1000000000LL * period->sec;
+ state->period = (1000000000LLU * period) >> 32;
} else {
state->mode = MODE_ONESHOT;
state->period = 0;
}
- if (first != NULL) {
- fperiod = (1000000000LL * (uint32_t)(first->frac >> 32)) >> 32;
- if (first->sec != 0)
- fperiod += 1000000000LL * first->sec;
- } else
+ if (first != 0)
+ fperiod = (1000000000LLU * first) >> 32;
+ else
fperiod = state->period;
shadow = &per_cpu(shadow_time, smp_processor_id());
@@ -832,11 +826,9 @@ cpu_initclocks(void)
xen_et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT |
ET_FLAGS_PERCPU;
xen_et.et_quality = 600;
- xen_et.et_frequency = 0;
- xen_et.et_min_period.sec = 0;
- xen_et.et_min_period.frac = 0x00400000LL << 32;
- xen_et.et_max_period.sec = 2;
- xen_et.et_max_period.frac = 0;
+ xen_et.et_frequency = 1000000000;
+ xen_et.et_min_period = 0x00400000LL;
+ xen_et.et_max_period = (0xfffffffeLLU << 32) / xen_et.et_frequency;
xen_et.et_start = xen_et_start;
xen_et.et_stop = xen_et_stop;
xen_et.et_priv = NULL;
Modified: projects/calloutng/sys/ia64/ia64/clock.c
==============================================================================
--- projects/calloutng/sys/ia64/ia64/clock.c Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/sys/ia64/ia64/clock.c Mon Feb 25 10:07:54 2013 (r247260)
@@ -105,17 +105,14 @@ ia64_ih_clock(struct thread *td, u_int x
* Event timer start method.
*/
static int
-ia64_clock_start(struct eventtimer *et, struct bintime *first,
- struct bintime *period)
+ia64_clock_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
u_long itc, load;
register_t is;
- if (period != NULL) {
+ if (period != 0) {
PCPU_SET(md.clock_mode, CLOCK_ET_PERIODIC);
- load = (et->et_frequency * (period->frac >> 32)) >> 32;
- if (period->sec > 0)
- load += et->et_frequency * period->sec;
+ load = (et->et_frequency * period) >> 32;
} else {
PCPU_SET(md.clock_mode, CLOCK_ET_ONESHOT);
load = 0;
@@ -123,11 +120,8 @@ ia64_clock_start(struct eventtimer *et,
PCPU_SET(md.clock_load, load);
- if (first != NULL) {
- load = (et->et_frequency * (first->frac >> 32)) >> 32;
- if (first->sec > 0)
- load += et->et_frequency * first->sec;
- }
+ if (first != 0)
+ load = (et->et_frequency * first) >> 32;
is = intr_disable();
itc = ia64_get_itc();
@@ -185,10 +179,8 @@ clock_configure(void *dummy)
et->et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT | ET_FLAGS_PERCPU;
et->et_quality = 1000;
et->et_frequency = itc_freq;
- et->et_min_period.sec = 0;
- et->et_min_period.frac = (0x8000000000000000ul / (u_long)(10*hz)) << 1;
- et->et_max_period.sec = 0xffffffff;
- et->et_max_period.frac = ((0xfffffffeul << 32) / itc_freq) << 32;
+ et->et_min_period = SBT_1S / (10 * hz);
+ et->et_max_period = (0xfffffffeul << 32) / itc_freq;
et->et_start = ia64_clock_start;
et->et_stop = ia64_clock_stop;
et->et_priv = NULL;
Modified: projects/calloutng/sys/kern/kern_clock.c
==============================================================================
--- projects/calloutng/sys/kern/kern_clock.c Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/sys/kern/kern_clock.c Mon Feb 25 10:07:54 2013 (r247260)
@@ -425,7 +425,7 @@ initclocks(dummy)
void
hardclock_cpu(int usermode)
{
- struct bintime now;
+ sbintime_t now;
struct pstats *pstats;
struct thread *td = curthread;
struct proc *p = td->td_proc;
@@ -460,8 +460,8 @@ hardclock_cpu(int usermode)
if (td->td_intr_frame != NULL)
PMC_SOFT_CALL_TF( , , clock, hard, td->td_intr_frame);
#endif
- binuptime(&now);
- callout_process(&now);
+ sbinuptime(&now);
+ callout_process(now);
}
/*
Modified: projects/calloutng/sys/kern/kern_clocksource.c
==============================================================================
--- projects/calloutng/sys/kern/kern_clocksource.c Mon Feb 25 09:33:48 2013 (r247259)
+++ projects/calloutng/sys/kern/kern_clocksource.c Mon Feb 25 10:07:54 2013 (r247260)
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2010-2012 Alexander Motin <mav at FreeBSD.org>
+ * Copyright (c) 2010-2013 Alexander Motin <mav at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,16 +65,16 @@ int cpu_can_deep_sleep = 0; /* C3 stat
int cpu_disable_deep_sleep = 0; /* Timer dies in C3. */
static void setuptimer(void);
-static void loadtimer(struct bintime *now, int first);
+static void loadtimer(sbintime_t now, int first);
static int doconfigtimer(void);
static void configtimer(int start);
static int round_freq(struct eventtimer *et, int freq);
-static void getnextcpuevent(struct bintime *event, int idle);
-static void getnextevent(struct bintime *event);
-static int handleevents(struct bintime *now, int fake);
-static void cpu_new_callout(int cpu, struct bintime bt,
- struct bintime bt_opt);
+static sbintime_t getnextcpuevent(int idle);
+static sbintime_t getnextevent(void);
+static int handleevents(sbintime_t now, int fake);
+static void cpu_new_callout(int cpu, sbintime_t bt,
+ sbintime_t bt_opt);
static struct mtx et_hw_mtx;
@@ -95,11 +95,10 @@ static struct mtx et_hw_mtx;
}
static struct eventtimer *timer = NULL;
-static struct bintime timerperiod; /* Timer period for periodic mode. */
-static struct bintime statperiod; /* statclock() events period. */
-static struct bintime profperiod; /* profclock() events period. */
-static struct bintime nexttick; /* Next global timer tick time. */
-static struct bintime nexthard; /* Next global hardlock() event. */
+static sbintime_t timerperiod; /* Timer period for periodic mode. */
+static sbintime_t statperiod; /* statclock() events period. */
+static sbintime_t profperiod; /* profclock() events period. */
+static sbintime_t nexttick; /* Next global timer tick time. */
static u_int busy = 0; /* Reconfiguration is in progress. */
static int profiling = 0; /* Profiling events enabled. */
@@ -116,11 +115,6 @@ TUNABLE_INT("kern.eventtimer.idletick",
SYSCTL_UINT(_kern_eventtimer, OID_AUTO, idletick, CTLFLAG_RW, &idletick,
0, "Run periodic events when idle");
-static u_int activetick = 1; /* Run all periodic events when active. */
-TUNABLE_INT("kern.eventtimer.activetick", &activetick);
-SYSCTL_UINT(_kern_eventtimer, OID_AUTO, activetick, CTLFLAG_RW, &activetick,
- 0, "Run all periodic events when active");
-
static int periodic = 0; /* Periodic or one-shot mode. */
static int want_periodic = 0; /* What mode to prefer. */
TUNABLE_INT("kern.eventtimer.periodic", &want_periodic);
@@ -129,23 +123,23 @@ struct pcpu_state {
struct mtx et_hw_mtx; /* Per-CPU timer mutex. */
u_int action; /* Reconfiguration requests. */
u_int handle; /* Immediate handle resuests. */
- struct bintime now; /* Last tick time. */
- struct bintime nextevent; /* Next scheduled event on this CPU. */
- struct bintime nexttick; /* Next timer tick time. */
- struct bintime nexthard; /* Next hardlock() event. */
- struct bintime nextstat; /* Next statclock() event. */
- struct bintime nextprof; /* Next profclock() event. */
- struct bintime nextcall; /* Next callout event. */
- struct bintime nextcallopt; /* Next optional callout event. */
+ sbintime_t now; /* Last tick time. */
+ sbintime_t nextevent; /* Next scheduled event on this CPU. */
+ sbintime_t nexttick; /* Next timer tick time. */
+ sbintime_t nexthard; /* Next hardlock() event. */
+ sbintime_t nextstat; /* Next statclock() event. */
+ sbintime_t nextprof; /* Next profclock() event. */
+ sbintime_t nextcall; /* Next callout event. */
+ sbintime_t nextcallopt; /* Next optional callout event. */
#ifdef KDTRACE_HOOKS
- struct bintime nextcyc; /* Next OpenSolaris cyclics event. */
+ sbintime_t nextcyc; /* Next OpenSolaris cyclics event. */
#endif
int ipi; /* This CPU needs IPI. */
int idle; /* This CPU is in idle mode. */
};
static DPCPU_DEFINE(struct pcpu_state, timerstate);
-DPCPU_DEFINE(struct bintime, hardclocktime);
+DPCPU_DEFINE(sbintime_t, hardclocktime);
/*
* Timer broadcast IPI handler.
@@ -153,7 +147,7 @@ DPCPU_DEFINE(struct bintime, hardclockti
int
hardclockintr(void)
{
- struct bintime now;
+ sbintime_t now;
struct pcpu_state *state;
int done;
@@ -161,10 +155,9 @@ hardclockintr(void)
return (FILTER_HANDLED);
state = DPCPU_PTR(timerstate);
now = state->now;
- CTR4(KTR_SPARE2, "ipi at %d: now %d.%08x%08x",
- curcpu, now.sec, (u_int)(now.frac >> 32),
- (u_int)(now.frac & 0xffffffff));
- done = handleevents(&now, 0);
+ CTR3(KTR_SPARE2, "ipi at %d: now %d.%08x",
+ curcpu, (int)(now >> 32), (u_int)(now & 0xffffffff));
+ done = handleevents(now, 0);
return (done ? FILTER_HANDLED : FILTER_STRAY);
}
@@ -172,18 +165,17 @@ hardclockintr(void)
* Handle all events for specified time on this CPU
*/
static int
-handleevents(struct bintime *now, int fake)
+handleevents(sbintime_t now, int fake)
{
- struct bintime t, *hct;
+ sbintime_t t, *hct;
struct trapframe *frame;
struct pcpu_state *state;
uintfptr_t pc;
int usermode;
int done, runs;
- CTR4(KTR_SPARE2, "handle at %d: now %d.%08x%08x",
- curcpu, now->sec, (u_int)(now->frac >> 32),
- (u_int)(now->frac & 0xffffffff));
+ CTR3(KTR_SPARE2, "handle at %d: now %d.%08x",
+ curcpu, (int)(now >> 32), (u_int)(now & 0xffffffff));
done = 0;
if (fake) {
frame = NULL;
@@ -198,25 +190,21 @@ handleevents(struct bintime *now, int fa
state = DPCPU_PTR(timerstate);
runs = 0;
- while (bintime_cmp(now, &state->nexthard, >=)) {
- bintime_addx(&state->nexthard, tick_bt.frac);
+ while (now >= state->nexthard) {
+ state->nexthard += tick_sbt;
runs++;
}
if (runs) {
hct = DPCPU_PTR(hardclocktime);
- *hct = state->nexthard;
- bintime_sub(hct, &tick_bt);
- if ((timer->et_flags & ET_FLAGS_PERCPU) == 0 &&
- bintime_cmp(&state->nexthard, &nexthard, >))
- nexthard = state->nexthard;
+ *hct = state->nexthard - tick_sbt;
if (fake < 2) {
hardclock_cnt(runs, usermode);
done = 1;
}
}
runs = 0;
- while (bintime_cmp(now, &state->nextstat, >=)) {
- bintime_addx(&state->nextstat, statperiod.frac);
+ while (now >= state->nextstat) {
+ state->nextstat += statperiod;
runs++;
}
if (runs && fake < 2) {
@@ -225,8 +213,8 @@ handleevents(struct bintime *now, int fa
}
if (profiling) {
runs = 0;
- while (bintime_cmp(now, &state->nextprof, >=)) {
- bintime_addx(&state->nextprof, profperiod.frac);
+ while (now >= state->nextprof) {
+ state->nextprof += profperiod;
runs++;
}
if (runs && !fake) {
@@ -235,23 +223,21 @@ handleevents(struct bintime *now, int fa
}
} else
state->nextprof = state->nextstat;
- if (bintime_cmp(now, &state->nextcallopt, >=) &&
- (state->nextcallopt.sec != -1)) {
- state->nextcall.sec = -1;
- state->nextcallopt.sec = -1;
+ if (now >= state->nextcallopt && state->nextcallopt != -1) {
+ state->nextcall = -1;
+ state->nextcallopt = -1;
callout_process(now);
}
#ifdef KDTRACE_HOOKS
if (fake == 0 && cyclic_clock_func != NULL &&
- state->nextcyc.sec != -1 &&
- bintime_cmp(now, &state->nextcyc, >=)) {
- state->nextcyc.sec = -1;
+ state->nextcyc != -1 && now >= state->nextcyc) {
+ state->nextcyc = -1;
(*cyclic_clock_func)(frame);
}
#endif
- getnextcpuevent(&t, 0);
+ t = getnextcpuevent(0);
if (fake == 2) {
state->nextevent = t;
return (done);
@@ -269,88 +255,81 @@ handleevents(struct bintime *now, int fa
/*
* Schedule binuptime of the next event on current CPU.
*/
-static void
-getnextcpuevent(struct bintime *event, int idle)
+static sbintime_t
+getnextcpuevent(int idle)
{
+ sbintime_t event;
struct pcpu_state *state;
- struct bintime tmp;
- int hardfreq;
+ u_int hardfreq;
state = DPCPU_PTR(timerstate);
/* Handle hardclock() events, skipping some is CPU is idle. */
- *event = state->nexthard;
- if (idle || (!activetick && !profiling &&
- (timer->et_flags & ET_FLAGS_PERCPU) == 0)) {
- hardfreq = 2;
- if (curcpu == CPU_FIRST() && tc_min_ticktock_freq > hardfreq)
- hardfreq = tc_min_ticktock_freq;
- if (hz > hardfreq) {
- tmp = tick_bt;
- bintime_mul(&tmp, hz / hardfreq - 1);
- bintime_add(event, &tmp);
- }
+ event = state->nexthard;
+ if (idle) {
+ hardfreq = (u_int)hz / 2;
+ if (tc_min_ticktock_freq > 2
+#ifdef SMP
+ && curcpu == CPU_FIRST()
+#endif
+ )
+ hardfreq = hz / tc_min_ticktock_freq;
+ if (hardfreq > 1)
+ event += tick_sbt * (hardfreq - 1);
}
/* Handle callout events. */
- if (state->nextcall.sec != -1 &&
- bintime_cmp(event, &state->nextcall, >))
- *event = state->nextcall;
+ if (state->nextcall != -1 && event > state->nextcall)
+ event = state->nextcall;
if (!idle) { /* If CPU is active - handle other types of events. */
- if (bintime_cmp(event, &state->nextstat, >))
- *event = state->nextstat;
- if (profiling && bintime_cmp(event, &state->nextprof, >))
- *event = state->nextprof;
+ if (event > state->nextstat)
+ event = state->nextstat;
+ if (profiling && event > state->nextprof)
+ event = state->nextprof;
}
#ifdef KDTRACE_HOOKS
- if (state->nextcyc.sec != -1 && bintime_cmp(event, &state->nextcyc, >))
- *event = state->nextcyc;
+ if (state->nextcyc != -1 && event > state->nextcyc)
+ event = state->nextcyc;
#endif
+ return (event);
}
/*
* Schedule binuptime of the next event on all CPUs.
*/
-static void
-getnextevent(struct bintime *event)
+static sbintime_t
+getnextevent(void)
{
struct pcpu_state *state;
+ sbintime_t event;
#ifdef SMP
int cpu;
#endif
- int c, nonidle;
+ int c;
state = DPCPU_PTR(timerstate);
- *event = state->nextevent;
+ event = state->nextevent;
c = curcpu;
- nonidle = !state->idle;
- if ((timer->et_flags & ET_FLAGS_PERCPU) == 0) {
#ifdef SMP
- if (smp_started) {
- CPU_FOREACH(cpu) {
- if (curcpu == cpu)
- continue;
- state = DPCPU_ID_PTR(cpu, timerstate);
- nonidle += !state->idle;
- if (bintime_cmp(event, &state->nextevent, >)) {
- *event = state->nextevent;
- c = cpu;
- }
+ if ((timer->et_flags & ET_FLAGS_PERCPU) == 0 && smp_started) {
+ CPU_FOREACH(cpu) {
+ state = DPCPU_ID_PTR(cpu, timerstate);
+ if (event > state->nextevent) {
+ event = state->nextevent;
+ c = cpu;
}
}
-#endif
- if (nonidle != 0 && bintime_cmp(event, &nexthard, >))
- *event = nexthard;
}
- CTR5(KTR_SPARE2, "next at %d: next %d.%08x%08x by %d",
- curcpu, event->sec, (u_int)(event->frac >> 32),
- (u_int)(event->frac & 0xffffffff), c);
+#endif
+ CTR4(KTR_SPARE2, "next at %d: next %d.%08x by %d",
+ curcpu, (int)(event >> 32), (u_int)(event & 0xffffffff), c);
+ return (event);
}
/* Hardware timer callback function. */
static void
timercb(struct eventtimer *et, void *arg)
{
- struct bintime now;
- struct bintime *next;
+ sbintime_t now;
+ sbintime_t *next;
struct pcpu_state *state;
#ifdef SMP
int cpu, bcast;
@@ -365,16 +344,14 @@ timercb(struct eventtimer *et, void *arg
next = &state->nexttick;
} else
next = &nexttick;
- binuptime(&now);
- if (periodic) {
- *next = now;
- bintime_addx(next, timerperiod.frac); /* Next tick in 1 period. */
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-projects
mailing list