Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/x86 PR/53984: Partial revert of modify lapic_ca...



details:   https://anonhg.NetBSD.org/src/rev/836563eadaec
branches:  trunk
changeset: 448979:836563eadaec
user:      nonaka <nonaka%NetBSD.org@localhost>
date:      Sun Feb 17 05:06:16 2019 +0000

description:
PR/53984: Partial revert of modify lapic_calibrate_timer() in lapic.c r1.69.

diffstat:

 sys/arch/x86/x86/lapic.c |  41 +++++++++++++----------------------------
 1 files changed, 13 insertions(+), 28 deletions(-)

diffs (84 lines):

diff -r 13916f35d8c1 -r 836563eadaec sys/arch/x86/x86/lapic.c
--- a/sys/arch/x86/x86/lapic.c  Sun Feb 17 04:57:09 2019 +0000
+++ b/sys/arch/x86/x86/lapic.c  Sun Feb 17 05:06:16 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lapic.c,v 1.69 2019/02/15 08:54:01 nonaka Exp $        */
+/*     $NetBSD: lapic.c,v 1.70 2019/02/17 05:06:16 nonaka Exp $        */
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.69 2019/02/15 08:54:01 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.70 2019/02/17 05:06:16 nonaka Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -604,11 +604,9 @@
 void
 lapic_calibrate_timer(struct cpu_info *ci)
 {
-       struct timecounter *tc;
-       timecounter_get_t *tick_func;
-       unsigned int tval, mask, delta, initial_counter, initial_lapic;
-       unsigned int cur_counter, cur_lapic;
-       uint64_t seen, end, tmp, freq;
+       unsigned int seen, delta, initial_i8254, initial_lapic;
+       unsigned int cur_i8254, cur_lapic;
+       uint64_t tmp;
        int i;
        char tbuf[9];
 
@@ -617,19 +615,6 @@
 
        aprint_debug_dev(ci->ci_dev, "calibrating local timer\n");
 
-       tc = timecounter;
-       if (tc->tc_quality <= 0) {
-               tick_func = (timecounter_get_t *)gettick;
-               tval = rtclock_tval;
-               mask = ~0u;
-               freq = TIMER_FREQ;
-       } else {
-               tick_func = tc->tc_get_timecount;
-               tval = mask = tc->tc_counter_mask;
-               freq = tc->tc_frequency;
-       }
-       end = freq / 100;
-
        /*
         * Configure timer to one-shot, interrupt masked,
         * large positive number.
@@ -641,22 +626,22 @@
        x86_disable_intr();
 
        initial_lapic = lapic_gettick();
-       initial_counter = tick_func(tc) & mask;
+       initial_i8254 = gettick();
 
-       for (seen = 0; seen < end; seen += delta) {
-               cur_counter = tick_func(tc) & mask;
-               if (cur_counter > initial_counter)
-                       delta = tval - (cur_counter - initial_counter);
+       for (seen = 0; seen < TIMER_FREQ / 100; seen += delta) {
+               cur_i8254 = gettick();
+               if (cur_i8254 > initial_i8254)
+                       delta = rtclock_tval - (cur_i8254 - initial_i8254);
                else
-                       delta = initial_counter - cur_counter;
-               initial_counter = cur_counter;
+                       delta = initial_i8254 - cur_i8254;
+               initial_i8254 = cur_i8254;
        }
        cur_lapic = lapic_gettick();
 
        x86_enable_intr();
 
        tmp = initial_lapic - cur_lapic;
-       lapic_per_second = (tmp * freq + seen / 2) / seen;
+       lapic_per_second = (tmp * TIMER_FREQ + seen / 2) / seen;
 
 calibrate_done:
        humanize_number(tbuf, sizeof(tbuf), lapic_per_second, "Hz", 1000);



Home | Main Index | Thread Index | Old Index