Deleted Added
full compact
kern_clocksource.c (247454) kern_clocksource.c (247463)
1/*-
2 * Copyright (c) 2010-2012 Alexander Motin <mav@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2010-2012 Alexander Motin <mav@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/kern/kern_clocksource.c 247454 2013-02-28 10:46:54Z davide $");
28__FBSDID("$FreeBSD: head/sys/kern/kern_clocksource.c 247463 2013-02-28 13:46:03Z mav $");
29
30/*
31 * Common routines to manage event timers hardware.
32 */
33
34#include "opt_device_polling.h"
35#include "opt_kdtrace.h"
36

--- 111 unchanged lines hidden (view full) ---

148{ \
149 (bt)->sec = 0; \
150 (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \
151}
152#define BT2FREQ(bt) \
153 (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \
154 ((bt)->frac >> 1))
155
29
30/*
31 * Common routines to manage event timers hardware.
32 */
33
34#include "opt_device_polling.h"
35#include "opt_kdtrace.h"
36

--- 111 unchanged lines hidden (view full) ---

148{ \
149 (bt)->sec = 0; \
150 (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \
151}
152#define BT2FREQ(bt) \
153 (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \
154 ((bt)->frac >> 1))
155
156#define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt))
157
156/*
157 * Timer broadcast IPI handler.
158 */
159int
160hardclockintr(void)
161{
162 struct bintime now;
163 struct pcpu_state *state;

--- 273 unchanged lines hidden (view full) ---

437 new.frac = timerperiod.frac - tmp;
438 if (new.frac < tmp) /* Left less then passed. */
439 bintime_addx(&new, timerperiod.frac);
440 CTR5(KTR_SPARE2, "load p at %d: now %d.%08x first in %d.%08x",
441 curcpu, now->sec, (u_int)(now->frac >> 32),
442 new.sec, (u_int)(new.frac >> 32));
443 *next = new;
444 bintime_add(next, now);
158/*
159 * Timer broadcast IPI handler.
160 */
161int
162hardclockintr(void)
163{
164 struct bintime now;
165 struct pcpu_state *state;

--- 273 unchanged lines hidden (view full) ---

439 new.frac = timerperiod.frac - tmp;
440 if (new.frac < tmp) /* Left less then passed. */
441 bintime_addx(&new, timerperiod.frac);
442 CTR5(KTR_SPARE2, "load p at %d: now %d.%08x first in %d.%08x",
443 curcpu, now->sec, (u_int)(now->frac >> 32),
444 new.sec, (u_int)(new.frac >> 32));
445 *next = new;
446 bintime_add(next, now);
445 et_start(timer, &new, &timerperiod);
447 et_start(timer, bttosbt(new), bttosbt(timerperiod));
446 }
447 } else {
448 getnextevent(&new);
449 eq = bintime_cmp(&new, next, ==);
450 CTR5(KTR_SPARE2, "load at %d: next %d.%08x%08x eq %d",
451 curcpu, new.sec, (u_int)(new.frac >> 32),
452 (u_int)(new.frac & 0xffffffff),
453 eq);
454 if (!eq) {
455 *next = new;
456 bintime_sub(&new, now);
448 }
449 } else {
450 getnextevent(&new);
451 eq = bintime_cmp(&new, next, ==);
452 CTR5(KTR_SPARE2, "load at %d: next %d.%08x%08x eq %d",
453 curcpu, new.sec, (u_int)(new.frac >> 32),
454 (u_int)(new.frac & 0xffffffff),
455 eq);
456 if (!eq) {
457 *next = new;
458 bintime_sub(&new, now);
457 et_start(timer, &new, NULL);
459 et_start(timer, bttosbt(new), 0);
458 }
459 }
460}
461
462/*
463 * Prepare event timer parameters after configuration changes.
464 */
465static void

--- 132 unchanged lines hidden (view full) ---

598 uint64_t div;
599
600 if (et->et_frequency != 0) {
601 div = lmax((et->et_frequency + freq / 2) / freq, 1);
602 if (et->et_flags & ET_FLAGS_POW2DIV)
603 div = 1 << (flsl(div + div / 2) - 1);
604 freq = (et->et_frequency + div / 2) / div;
605 }
460 }
461 }
462}
463
464/*
465 * Prepare event timer parameters after configuration changes.
466 */
467static void

--- 132 unchanged lines hidden (view full) ---

600 uint64_t div;
601
602 if (et->et_frequency != 0) {
603 div = lmax((et->et_frequency + freq / 2) / freq, 1);
604 if (et->et_flags & ET_FLAGS_POW2DIV)
605 div = 1 << (flsl(div + div / 2) - 1);
606 freq = (et->et_frequency + div / 2) / div;
607 }
606 if (et->et_min_period.sec > 0)
608 if (et->et_min_period > SBT_1S)
607 panic("Event timer \"%s\" doesn't support sub-second periods!",
608 et->et_name);
609 panic("Event timer \"%s\" doesn't support sub-second periods!",
610 et->et_name);
609 else if (et->et_min_period.frac != 0)
610 freq = min(freq, BT2FREQ(&et->et_min_period));
611 if (et->et_max_period.sec == 0 && et->et_max_period.frac != 0)
612 freq = max(freq, BT2FREQ(&et->et_max_period));
611 else if (et->et_min_period != 0)
612 freq = min(freq, SBT2FREQ(et->et_min_period));
613 if (et->et_max_period < SBT_1S && et->et_max_period != 0)
614 freq = max(freq, SBT2FREQ(et->et_max_period));
613 return (freq);
614}
615
616/*
617 * Configure and start event timers (BSP part).
618 */
619void
620cpu_initclocks_bsp(void)

--- 359 unchanged lines hidden ---
615 return (freq);
616}
617
618/*
619 * Configure and start event timers (BSP part).
620 */
621void
622cpu_initclocks_bsp(void)

--- 359 unchanged lines hidden ---