From 2bf12d0c7ceced74a813d6940dd07310a11d6a2a Mon Sep 17 00:00:00 2001 From: davide Date: Thu, 28 Feb 2013 10:46:54 +0000 Subject: MFcalloutng: When CPU becomes idle, cpu_idleclock() calculates time to the next timer event in order to reprogram hw timer. Return that time in sbintime_t to the caller and pass it to acpi_cpu_idle(), where it can be used as one more factor (quite precise) to extimate furter sleep time and choose optimal sleep state. This is a preparatory change for further callout improvements will be committed in the next days. The commmit is not targeted for MFC. --- sys/ia64/ia64/machdep.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sys/ia64/ia64') diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index 98bcf44..ac6a829 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -171,7 +171,7 @@ extern vm_offset_t ksym_start, ksym_end; struct msgbuf *msgbufp = NULL; /* Other subsystems (e.g., ACPI) can hook this later. */ -void (*cpu_idle_hook)(void) = NULL; +void (*cpu_idle_hook)(sbintime_t) = NULL; struct kva_md_info kmi; @@ -408,10 +408,11 @@ void cpu_idle(int busy) { register_t ie; + sbintime_t sbt = -1; if (!busy) { critical_enter(); - cpu_idleclock(); + sbt = cpu_idleclock(); } ie = intr_disable(); @@ -420,7 +421,7 @@ cpu_idle(int busy) if (sched_runnable()) ia64_enable_intr(); else if (cpu_idle_hook != NULL) { - (*cpu_idle_hook)(); + (*cpu_idle_hook)(sbt); /* The hook must enable interrupts! */ } else { ia64_call_pal_static(PAL_HALT_LIGHT, 0, 0, 0); -- cgit v1.1 From 6cf7cc6e4d8da1cf9aba1c481b914e4ca5e9f38f Mon Sep 17 00:00:00 2001 From: mav Date: Thu, 28 Feb 2013 13:46:03 +0000 Subject: MFcalloutng: Switch eventtimers(9) from using struct bintime to sbintime_t. Even before this not a single driver really supported full dynamic range of struct bintime even in theory, not speaking about practical inexpediency. This change legitimates the status quo and cleans up the code. --- sys/ia64/ia64/clock.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'sys/ia64/ia64') diff --git a/sys/ia64/ia64/clock.c b/sys/ia64/ia64/clock.c index 24623c5..37a99a1 100644 --- a/sys/ia64/ia64/clock.c +++ b/sys/ia64/ia64/clock.c @@ -105,17 +105,14 @@ ia64_ih_clock(struct thread *td, u_int xiv, struct trapframe *tf) * 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, struct bintime *first, 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; -- cgit v1.1