From owner-svn-src-all@FreeBSD.ORG Wed Dec 21 16:47:01 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C744B106566B; Wed, 21 Dec 2011 16:47:01 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B68978FC0C; Wed, 21 Dec 2011 16:47:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pBLGl1kH077442; Wed, 21 Dec 2011 16:47:01 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBLGl1G1077440; Wed, 21 Dec 2011 16:47:01 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201112211647.pBLGl1G1077440@svn.freebsd.org> From: Ed Schouten Date: Wed, 21 Dec 2011 16:47:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228782 - head/sys/boot/i386/libi386 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Dec 2011 16:47:01 -0000 Author: ed Date: Wed Dec 21 16:47:01 2011 New Revision: 228782 URL: http://svn.freebsd.org/changeset/base/228782 Log: Make the RTC checking for QEMU even more aggressive. At work, where we use use KVM+QEMU, we notice that pxeboot is pratically impossible because of network timeouts. This is due to the fact that the RTC code makes aggressive jumps. Two RTC reads does not seem to be sufficient. Change the code to check for 8 identical RTC values. Sponsored by: Kumina bv Modified: head/sys/boot/i386/libi386/time.c Modified: head/sys/boot/i386/libi386/time.c ============================================================================== --- head/sys/boot/i386/libi386/time.c Wed Dec 21 16:38:37 2011 (r228781) +++ head/sys/boot/i386/libi386/time.c Wed Dec 21 16:47:01 2011 (r228782) @@ -62,7 +62,7 @@ bios_seconds(void) * Some BIOSes (notably qemu) don't correctly read the RTC * registers in an atomic way, sometimes returning bogus values. * Therefore we "debounce" the reading by accepting it only when - * we got two identical values in succession. + * we got 8 identical values in succession. * * If we pass midnight, don't wrap back to 0. */ @@ -71,14 +71,16 @@ time(time_t *t) { static time_t lasttime; time_t now, check; - int try; + int same, try; - try = 0; + same = try = 0; check = bios_seconds(); do { now = check; check = bios_seconds(); - } while (now != check && ++try < 1000); + if (check != now) + same = 0; + } while (++same < 8 && ++try < 1000); if (now < lasttime) now += 24 * 3600;