167761Smsmith/*- 280070Smsmith * Copyright (c) 2000, 2001 Michael Smith 367761Smsmith * Copyright (c) 2000 BSDi 467761Smsmith * All rights reserved. 567761Smsmith * 667761Smsmith * Redistribution and use in source and binary forms, with or without 767761Smsmith * modification, are permitted provided that the following conditions 867761Smsmith * are met: 967761Smsmith * 1. Redistributions of source code must retain the above copyright 1067761Smsmith * notice, this list of conditions and the following disclaimer. 1167761Smsmith * 2. Redistributions in binary form must reproduce the above copyright 1267761Smsmith * notice, this list of conditions and the following disclaimer in the 1367761Smsmith * documentation and/or other materials provided with the distribution. 1467761Smsmith * 1567761Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1667761Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1767761Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1867761Smsmith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1967761Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2067761Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2167761Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2267761Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2367761Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2467761Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2567761Smsmith * SUCH DAMAGE. 2667761Smsmith */ 27143002Sobrien 28143002Sobrien#include <sys/cdefs.h> 29143002Sobrien__FBSDID("$FreeBSD: releng/10.3/sys/dev/acpica/acpi_timer.c 255726 2013-09-20 05:06:03Z gibbs $"); 30143002Sobrien 3167761Smsmith#include "opt_acpi.h" 3267761Smsmith#include <sys/param.h> 3380070Smsmith#include <sys/bus.h> 34231226Sjkim#include <sys/eventhandler.h> 3567761Smsmith#include <sys/kernel.h> 36129879Sphk#include <sys/module.h> 3780070Smsmith#include <sys/sysctl.h> 3880070Smsmith#include <sys/timetc.h> 3967761Smsmith 4080070Smsmith#include <machine/bus.h> 4180070Smsmith#include <machine/resource.h> 4280070Smsmith#include <sys/rman.h> 4380070Smsmith 44193530Sjkim#include <contrib/dev/acpica/include/acpi.h> 45193530Sjkim#include <contrib/dev/acpica/include/accommon.h> 46193530Sjkim 47104726Sjhb#include <dev/acpica/acpivar.h> 48119281Simp#include <dev/pci/pcivar.h> 4967761Smsmith 5069744Smsmith/* 5180070Smsmith * A timecounter based on the free-running ACPI timer. 5280070Smsmith * 5380070Smsmith * Based on the i386-only mp_clock.c by <phk@FreeBSD.ORG>. 5480070Smsmith */ 5580070Smsmith 56119529Snjl/* Hooks for the ACPI CA debugging infrastructure */ 57126517Snjl#define _COMPONENT ACPI_TIMER 5891128SmsmithACPI_MODULE_NAME("TIMER") 5969744Smsmith 60128528Snjlstatic device_t acpi_timer_dev; 61128528Snjlstatic struct resource *acpi_timer_reg; 62128543Snjlstatic bus_space_handle_t acpi_timer_bsh; 63128543Snjlstatic bus_space_tag_t acpi_timer_bst; 64231226Sjkimstatic eventhandler_tag acpi_timer_eh; 6567761Smsmith 66119529Snjlstatic u_int acpi_timer_frequency = 14318182 / 4; 6767761Smsmith 6867761Smsmithstatic void acpi_timer_identify(driver_t *driver, device_t parent); 6967761Smsmithstatic int acpi_timer_probe(device_t dev); 7067761Smsmithstatic int acpi_timer_attach(device_t dev); 71231226Sjkimstatic void acpi_timer_resume_handler(struct timecounter *); 72231295Sjkimstatic void acpi_timer_suspend_handler(struct timecounter *); 73128506Snjlstatic u_int acpi_timer_get_timecount(struct timecounter *tc); 74128506Snjlstatic u_int acpi_timer_get_timecount_safe(struct timecounter *tc); 7580070Smsmithstatic int acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS); 76128543Snjlstatic void acpi_timer_boot_test(void); 7767761Smsmith 78128543Snjlstatic int acpi_timer_test(void); 79114277Smarcel 8067761Smsmithstatic device_method_t acpi_timer_methods[] = { 8167761Smsmith DEVMETHOD(device_identify, acpi_timer_identify), 8267761Smsmith DEVMETHOD(device_probe, acpi_timer_probe), 8367761Smsmith DEVMETHOD(device_attach, acpi_timer_attach), 8467761Smsmith 85246128Ssbz DEVMETHOD_END 8667761Smsmith}; 8767761Smsmith 8867761Smsmithstatic driver_t acpi_timer_driver = { 8967761Smsmith "acpi_timer", 9067761Smsmith acpi_timer_methods, 9180070Smsmith 0, 9267761Smsmith}; 9367761Smsmith 9489054Smsmithstatic devclass_t acpi_timer_devclass; 9567761SmsmithDRIVER_MODULE(acpi_timer, acpi, acpi_timer_driver, acpi_timer_devclass, 0, 0); 96128071SnjlMODULE_DEPEND(acpi_timer, acpi, 1, 1, 1); 9767761Smsmith 9880070Smsmithstatic struct timecounter acpi_timer_timecounter = { 99128543Snjl acpi_timer_get_timecount_safe, /* get_timecount function */ 100128543Snjl 0, /* no poll_pps */ 101128543Snjl 0, /* no default counter_mask */ 102128543Snjl 0, /* no default frequency */ 103128543Snjl "ACPI", /* name */ 104171657Snjl -1 /* quality (chosen later) */ 10580070Smsmith}; 10680070Smsmith 107220331Sjkimstatic __inline uint32_t 108220331Sjkimacpi_timer_read(void) 109114277Smarcel{ 110220331Sjkim 111128607Snjl return (bus_space_read_4(acpi_timer_bst, acpi_timer_bsh, 0)); 112114277Smarcel} 113114277Smarcel 11480070Smsmith/* 11580070Smsmith * Locate the ACPI timer using the FADT, set up and allocate the I/O resources 11680070Smsmith * we will be using. 11780070Smsmith */ 11867761Smsmithstatic void 11967761Smsmithacpi_timer_identify(driver_t *driver, device_t parent) 12067761Smsmith{ 121132527Snjl device_t dev; 122132527Snjl u_long rlen, rstart; 123132527Snjl int rid, rtype; 12467761Smsmith 12596926Speter ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 12669744Smsmith 127136270Snjl if (acpi_disabled("timer") || (acpi_quirks & ACPI_Q_TIMER) || 128167814Sjkim acpi_timer_dev) 12969744Smsmith return_VOID; 130128506Snjl 131231161Sjkim if ((dev = BUS_ADD_CHILD(parent, 2, "acpi_timer", 0)) == NULL) { 13267761Smsmith device_printf(parent, "could not add acpi_timer0\n"); 13369744Smsmith return_VOID; 13467761Smsmith } 13580070Smsmith acpi_timer_dev = dev; 136114277Smarcel 137220805Sjkim switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) { 138220805Sjkim case ACPI_ADR_SPACE_SYSTEM_MEMORY: 139220805Sjkim rtype = SYS_RES_MEMORY; 140220805Sjkim break; 141220805Sjkim case ACPI_ADR_SPACE_SYSTEM_IO: 142220805Sjkim rtype = SYS_RES_IOPORT; 143220805Sjkim break; 144220805Sjkim default: 145220805Sjkim return_VOID; 146220805Sjkim } 14780070Smsmith rid = 0; 148167814Sjkim rlen = AcpiGbl_FADT.PmTimerLength; 149167814Sjkim rstart = AcpiGbl_FADT.XPmTimerBlock.Address; 150132527Snjl if (bus_set_resource(dev, rtype, rid, rstart, rlen)) 151132527Snjl device_printf(dev, "couldn't set resource (%s 0x%lx+0x%lx)\n", 152132527Snjl (rtype == SYS_RES_IOPORT) ? "port" : "mem", rstart, rlen); 153132527Snjl return_VOID; 154132527Snjl} 155132527Snjl 156132527Snjlstatic int 157132527Snjlacpi_timer_probe(device_t dev) 158132527Snjl{ 159132527Snjl char desc[40]; 160132527Snjl int i, j, rid, rtype; 161132527Snjl 162132527Snjl ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 163132527Snjl 164132527Snjl if (dev != acpi_timer_dev) 165132527Snjl return (ENXIO); 166132527Snjl 167220805Sjkim switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) { 168220805Sjkim case ACPI_ADR_SPACE_SYSTEM_MEMORY: 169220805Sjkim rtype = SYS_RES_MEMORY; 170220805Sjkim break; 171220805Sjkim case ACPI_ADR_SPACE_SYSTEM_IO: 172220805Sjkim rtype = SYS_RES_IOPORT; 173220805Sjkim break; 174220805Sjkim default: 175220805Sjkim return (ENXIO); 176220805Sjkim } 177132527Snjl rid = 0; 178127135Snjl acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE); 179114277Smarcel if (acpi_timer_reg == NULL) { 180132527Snjl device_printf(dev, "couldn't allocate resource (%s 0x%lx)\n", 181132527Snjl (rtype == SYS_RES_IOPORT) ? "port" : "mem", 182167814Sjkim (u_long)AcpiGbl_FADT.XPmTimerBlock.Address); 183132527Snjl return (ENXIO); 18467761Smsmith } 185132528Snjl acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg); 186132528Snjl acpi_timer_bst = rman_get_bustag(acpi_timer_reg); 187167814Sjkim if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) 188128506Snjl acpi_timer_timecounter.tc_counter_mask = 0xffffffff; 189128506Snjl else 190128506Snjl acpi_timer_timecounter.tc_counter_mask = 0x00ffffff; 191128506Snjl acpi_timer_timecounter.tc_frequency = acpi_timer_frequency; 192255726Sgibbs acpi_timer_timecounter.tc_flags = TC_FLAGS_SUSPEND_SAFE; 19394936Smux if (testenv("debug.acpi.timer_test")) 194128543Snjl acpi_timer_boot_test(); 19567761Smsmith 196128528Snjl /* 197128528Snjl * If all tests of the counter succeed, use the ACPI-fast method. If 198128528Snjl * at least one failed, default to using the safe routine, which reads 199128528Snjl * the timer multiple times to get a consistent value before returning. 200128528Snjl */ 20191237Sphk j = 0; 202137151Sphk if (bootverbose) 203137151Sphk printf("ACPI timer:"); 204128506Snjl for (i = 0; i < 10; i++) 205128543Snjl j += acpi_timer_test(); 206137151Sphk if (bootverbose) 207137151Sphk printf(" -> %d\n", j); 20891237Sphk if (j == 10) { 20991237Sphk acpi_timer_timecounter.tc_name = "ACPI-fast"; 21091237Sphk acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount; 211222222Sjkim acpi_timer_timecounter.tc_quality = 900; 21291237Sphk } else { 21391237Sphk acpi_timer_timecounter.tc_name = "ACPI-safe"; 21491237Sphk acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount_safe; 215171657Snjl acpi_timer_timecounter.tc_quality = 850; 21691237Sphk } 21780070Smsmith tc_init(&acpi_timer_timecounter); 21880070Smsmith 219220805Sjkim sprintf(desc, "%d-bit timer at %u.%06uMHz", 220220805Sjkim (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) != 0 ? 32 : 24, 221220805Sjkim acpi_timer_frequency / 1000000, acpi_timer_frequency % 1000000); 22267761Smsmith device_set_desc_copy(dev, desc); 22369744Smsmith 224132527Snjl /* Release the resource, we'll allocate it again during attach. */ 225132527Snjl bus_release_resource(dev, rtype, rid, acpi_timer_reg); 226132527Snjl return (0); 22767761Smsmith} 22867761Smsmith 22967761Smsmithstatic int 230132527Snjlacpi_timer_attach(device_t dev) 23167761Smsmith{ 232132527Snjl int rid, rtype; 233119529Snjl 234132527Snjl ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 23567761Smsmith 236220805Sjkim switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) { 237220805Sjkim case ACPI_ADR_SPACE_SYSTEM_MEMORY: 238220805Sjkim rtype = SYS_RES_MEMORY; 239220805Sjkim break; 240220805Sjkim case ACPI_ADR_SPACE_SYSTEM_IO: 241220805Sjkim rtype = SYS_RES_IOPORT; 242220805Sjkim break; 243220805Sjkim default: 244220805Sjkim return (ENXIO); 245220805Sjkim } 246132527Snjl rid = 0; 247132527Snjl acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE); 248132527Snjl if (acpi_timer_reg == NULL) 249132527Snjl return (ENXIO); 250132527Snjl acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg); 251132527Snjl acpi_timer_bst = rman_get_bustag(acpi_timer_reg); 252231295Sjkim 253231295Sjkim /* Register suspend event handler. */ 254231295Sjkim if (EVENTHANDLER_REGISTER(power_suspend, acpi_timer_suspend_handler, 255231295Sjkim &acpi_timer_timecounter, EVENTHANDLER_PRI_LAST) == NULL) 256231295Sjkim device_printf(dev, "failed to register suspend event handler\n"); 257231295Sjkim 258119529Snjl return (0); 25980070Smsmith} 26067761Smsmith 261231226Sjkimstatic void 262231226Sjkimacpi_timer_resume_handler(struct timecounter *newtc) 263231226Sjkim{ 264231226Sjkim struct timecounter *tc; 265231226Sjkim 266231226Sjkim tc = timecounter; 267231226Sjkim if (tc != newtc) { 268231226Sjkim if (bootverbose) 269231226Sjkim device_printf(acpi_timer_dev, 270231226Sjkim "restoring timecounter, %s -> %s\n", 271231226Sjkim tc->tc_name, newtc->tc_name); 272231226Sjkim (void)newtc->tc_get_timecount(newtc); 273231226Sjkim (void)newtc->tc_get_timecount(newtc); 274231226Sjkim timecounter = newtc; 275231226Sjkim } 276231226Sjkim} 277231226Sjkim 278231295Sjkimstatic void 279231295Sjkimacpi_timer_suspend_handler(struct timecounter *newtc) 280231226Sjkim{ 281231295Sjkim struct timecounter *tc; 282231226Sjkim 283231295Sjkim /* Deregister existing resume event handler. */ 284231226Sjkim if (acpi_timer_eh != NULL) { 285231226Sjkim EVENTHANDLER_DEREGISTER(power_resume, acpi_timer_eh); 286231226Sjkim acpi_timer_eh = NULL; 287231226Sjkim } 288231295Sjkim 289255726Sgibbs if ((timecounter->tc_flags & TC_FLAGS_SUSPEND_SAFE) != 0) { 290255726Sgibbs /* 291255726Sgibbs * If we are using a suspend safe timecounter, don't 292255726Sgibbs * save/restore it across suspend/resume. 293255726Sgibbs */ 294255726Sgibbs return; 295255726Sgibbs } 296255726Sgibbs 297231295Sjkim KASSERT(newtc == &acpi_timer_timecounter, 298231295Sjkim ("acpi_timer_suspend_handler: wrong timecounter")); 299231295Sjkim 300231226Sjkim tc = timecounter; 301231226Sjkim if (tc != newtc) { 302231226Sjkim if (bootverbose) 303231295Sjkim device_printf(acpi_timer_dev, 304231295Sjkim "switching timecounter, %s -> %s\n", 305231226Sjkim tc->tc_name, newtc->tc_name); 306231226Sjkim (void)acpi_timer_read(); 307231226Sjkim (void)acpi_timer_read(); 308231226Sjkim timecounter = newtc; 309231226Sjkim acpi_timer_eh = EVENTHANDLER_REGISTER(power_resume, 310231226Sjkim acpi_timer_resume_handler, tc, EVENTHANDLER_PRI_LAST); 311231226Sjkim } 312231226Sjkim} 313231226Sjkim 31480070Smsmith/* 31581096Smsmith * Fetch current time value from reliable hardware. 31680070Smsmith */ 317128506Snjlstatic u_int 31880070Smsmithacpi_timer_get_timecount(struct timecounter *tc) 31980070Smsmith{ 320128543Snjl return (acpi_timer_read()); 32167761Smsmith} 32280070Smsmith 32380070Smsmith/* 32481096Smsmith * Fetch current time value from hardware that may not correctly 325128528Snjl * latch the counter. We need to read until we have three monotonic 326128528Snjl * samples and then use the middle one, otherwise we are not protected 327128528Snjl * against the fact that the bits can be wrong in two directions. If 328128528Snjl * we only cared about monosity, two reads would be enough. 32981096Smsmith */ 330128506Snjlstatic u_int 33181096Smsmithacpi_timer_get_timecount_safe(struct timecounter *tc) 33281096Smsmith{ 333128506Snjl u_int u1, u2, u3; 33481096Smsmith 335128543Snjl u2 = acpi_timer_read(); 336128543Snjl u3 = acpi_timer_read(); 33781096Smsmith do { 33881096Smsmith u1 = u2; 33981096Smsmith u2 = u3; 340128543Snjl u3 = acpi_timer_read(); 341128543Snjl } while (u1 > u2 || u2 > u3); 342119529Snjl 34381096Smsmith return (u2); 34481096Smsmith} 34581096Smsmith 34681096Smsmith/* 34780070Smsmith * Timecounter freqency adjustment interface. 34880070Smsmith */ 34980070Smsmithstatic int 35080070Smsmithacpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS) 35180070Smsmith{ 35280070Smsmith int error; 35380070Smsmith u_int freq; 35480070Smsmith 35580070Smsmith if (acpi_timer_timecounter.tc_frequency == 0) 35680070Smsmith return (EOPNOTSUPP); 35780070Smsmith freq = acpi_timer_frequency; 358170289Sdwmalone error = sysctl_handle_int(oidp, &freq, 0, req); 35980070Smsmith if (error == 0 && req->newptr != NULL) { 36080070Smsmith acpi_timer_frequency = freq; 36180070Smsmith acpi_timer_timecounter.tc_frequency = acpi_timer_frequency; 36280070Smsmith } 363119529Snjl 36480070Smsmith return (error); 36580070Smsmith} 36680070Smsmith 36780070SmsmithSYSCTL_PROC(_machdep, OID_AUTO, acpi_timer_freq, CTLTYPE_INT | CTLFLAG_RW, 368220613Sjkim 0, sizeof(u_int), acpi_timer_sysctl_freq, "I", "ACPI timer frequency"); 36980070Smsmith 37080070Smsmith/* 371128528Snjl * Some ACPI timers are known or believed to suffer from implementation 372128528Snjl * problems which can lead to erroneous values being read. This function 373128528Snjl * tests for consistent results from the timer and returns 1 if it believes 374128528Snjl * the timer is consistent, otherwise it returns 0. 375128528Snjl * 376128528Snjl * It appears the cause is that the counter is not latched to the PCI bus 377128528Snjl * clock when read: 378128528Snjl * 379128528Snjl * ] 20. ACPI Timer Errata 380128528Snjl * ] 381128528Snjl * ] Problem: The power management timer may return improper result when 382128528Snjl * ] read. Although the timer value settles properly after incrementing, 383128528Snjl * ] while incrementing there is a 3nS window every 69.8nS where the 384128528Snjl * ] timer value is indeterminate (a 4.2% chance that the data will be 385128528Snjl * ] incorrect when read). As a result, the ACPI free running count up 386128528Snjl * ] timer specification is violated due to erroneous reads. Implication: 387128528Snjl * ] System hangs due to the "inaccuracy" of the timer when used by 388128528Snjl * ] software for time critical events and delays. 389128528Snjl * ] 390128528Snjl * ] Workaround: Read the register twice and compare. 391128528Snjl * ] Status: This will not be fixed in the PIIX4 or PIIX4E, it is fixed 392128528Snjl * ] in the PIIX4M. 393128528Snjl */ 394128528Snjl#define N 2000 395128528Snjlstatic int 396128543Snjlacpi_timer_test() 397128528Snjl{ 398220369Sjkim uint32_t last, this; 399220369Sjkim int delta, max, max2, min, n; 400220369Sjkim register_t s; 401128528Snjl 402220336Sjkim min = INT32_MAX; 403220369Sjkim max = max2 = 0; 404128607Snjl 405128607Snjl /* Test the timer with interrupts disabled to get accurate results. */ 406128607Snjl s = intr_disable(); 407128543Snjl last = acpi_timer_read(); 408128528Snjl for (n = 0; n < N; n++) { 409128543Snjl this = acpi_timer_read(); 410128528Snjl delta = acpi_TimerDelta(this, last); 411220369Sjkim if (delta > max) { 412220369Sjkim max2 = max; 413128528Snjl max = delta; 414220369Sjkim } else if (delta > max2) 415220369Sjkim max2 = delta; 416220336Sjkim if (delta < min) 417128528Snjl min = delta; 418128528Snjl last = this; 419128528Snjl } 420128607Snjl intr_restore(s); 421128607Snjl 422220369Sjkim delta = max2 - min; 423220369Sjkim if ((max - min > 8 || delta > 3) && vm_guest == VM_GUEST_NO) 424128528Snjl n = 0; 425220369Sjkim else if (min < 0 || max == 0 || max2 == 0) 426128528Snjl n = 0; 427128528Snjl else 428128528Snjl n = 1; 429137151Sphk if (bootverbose) 430220333Sjkim printf(" %d/%d", n, delta); 431128528Snjl 432128528Snjl return (n); 433128528Snjl} 434128528Snjl#undef N 435128528Snjl 436128528Snjl/* 43780070Smsmith * Test harness for verifying ACPI timer behaviour. 43880070Smsmith * Boot with debug.acpi.timer_test set to invoke this. 43980070Smsmith */ 44080070Smsmithstatic void 441128543Snjlacpi_timer_boot_test(void) 44280070Smsmith{ 443128506Snjl uint32_t u1, u2, u3; 444128506Snjl 445128543Snjl u1 = acpi_timer_read(); 446128543Snjl u2 = acpi_timer_read(); 447128543Snjl u3 = acpi_timer_read(); 448128506Snjl 44980070Smsmith device_printf(acpi_timer_dev, "timer test in progress, reboot to quit.\n"); 45080070Smsmith for (;;) { 45180070Smsmith /* 452119529Snjl * The failure case is where u3 > u1, but u2 does not fall between 453119529Snjl * the two, ie. it contains garbage. 45480070Smsmith */ 45580070Smsmith if (u3 > u1) { 456119529Snjl if (u2 < u1 || u2 > u3) 457119529Snjl device_printf(acpi_timer_dev, 458119529Snjl "timer is not monotonic: 0x%08x,0x%08x,0x%08x\n", 45980070Smsmith u1, u2, u3); 46080070Smsmith } 46180070Smsmith u1 = u2; 46280070Smsmith u2 = u3; 463128543Snjl u3 = acpi_timer_read(); 46480070Smsmith } 46580070Smsmith} 466