From owner-freebsd-current Sun Feb 17 14:39:23 2002 Delivered-To: freebsd-current@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id CC6F437B405; Sun, 17 Feb 2002 14:39:02 -0800 (PST) Received: (from dillon@localhost) by apollo.backplane.com (8.11.6/8.9.1) id g1HMd2r94356; Sun, 17 Feb 2002 14:39:02 -0800 (PST) (envelope-from dillon) Date: Sun, 17 Feb 2002 14:39:02 -0800 (PST) From: Matthew Dillon Message-Id: <200202172239.g1HMd2r94356@apollo.backplane.com> To: Michael Smith Cc: Poul-Henning Kamp , Bruce Evans , freebsd-current@FreeBSD.ORG Subject: Re: 'microuptime() went backwards ...' using ACPI timer. Shouldn't that be impossible? References: <200202172225.g1HMPKA01422@mass.dis.org> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG :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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message