Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Feb 2002 14:39:02 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Michael Smith <msmith@FreeBSD.ORG>
Cc:        Poul-Henning Kamp <phk@critter.freebsd.dk>, Bruce Evans <bde@zeta.org.au>, freebsd-current@FreeBSD.ORG
Subject:   Re: 'microuptime() went backwards ...' using ACPI timer. Shouldn't that be impossible? 
Message-ID:  <200202172239.g1HMd2r94356@apollo.backplane.com>
References:   <200202172225.g1HMPKA01422@mass.dis.org>

next in thread | previous in thread | raw e-mail | index | archive | help

:I would like to see "the PIIX problem" caught on camera, personally.  
:We're aware of one errata for it already, and we work around it.  If 
:there's another problem, or ideally if someone has some relatively quick 
:code to test it, that would be much better.

    If the _safe version works I'll reinstrument the code to catch and
    print the problem counter values.

    Is the ACPI on a 16 or 32 bit bus?  Idiot chip designers have made
    'non-atomic counter carry' bugs endemic in the PC world.  The standard
    solution is to just read the counter twice and and loop if the top
    17 bits have changed in order to avoid the carry problem entirely.
    Something like this:

	u_int32_t u1;
	u_int32_t u2;

	u1 = TIMER_READ;
	u2 = TIMER_READ;
	while ((u1 ^ u2) & 0xFFFF8000) {
	    u1 = u2;
	    u2 = TIMER_READ;
	}
	return(u2);

    The solution you have in there will theoretically work as long as the
    16-bit carry itself is synchronized (which it probably is), but it should
    be possible to do it with only two timer reads in the best-case instead of
    three.

    I'll investigate further.

    					-Matt
					Matthew Dillon 
					<dillon@backplane.com>

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200202172239.g1HMd2r94356>