NetBSD Problem Report #43156

From gson@gson.org  Tue Apr 13 12:37:19 2010
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 71C8B63B8BC
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 13 Apr 2010 12:37:19 +0000 (UTC)
Message-Id: <20100413123716.8174375E8A@guava.gson.org>
Date: Tue, 13 Apr 2010 15:37:16 +0300 (EEST)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@gnats.NetBSD.org
Subject: NetBSD bootloader countdown runs at 1/20 speed in qemu 0.12
X-Send-Pr-Version: 3.95

>Number:         43156
>Category:       port-i386
>Synopsis:       NetBSD bootloader countdown runs at 1/20 speed in qemu 0.12
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    tsutsui
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 13 12:40:00 +0000 2010
>Closed-Date:    Thu Jul 01 17:00:18 +0000 2010
>Last-Modified:  Thu Jul 01 17:00:18 +0000 2010
>Originator:     Andreas Gustafsson
>Release:        NetBSD 5.0.1
>Organization:
>Environment:
System: NetBSD guava.gson.org 5.0.1 NetBSD 5.0.1 (GENERIC) #0: Thu Jul 30 01:39:11 UTC 2009 builds@b8.netbsd.org:/home/builds/ab/netbsd-5-0-1-RELEASE/i386/200907292356Z-obj/home/builds/ab/netbsd-5-0-1-RELEASE/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:

After upgrading the qemu package to version 0.12, the bootloader
countdown in a qemu emulated NetBSD system takes about 20 times longer
than it should, counting down by one every 20 seconds instead of every
second, taking a total of 100 seconds to count down from five.

>How-To-Repeat:

Install the emulators/qemu and misc/py-anita packages by building from
the current pkgsrc (there is no binary package of qemu 0.12 yet).
Type 

  anita interact http://ftp.netbsd.org/pub/NetBSD/NetBSD-5.0.2/i386/

Wait for the packages to download and then keep an eye on the
bootloader countdown.

>Fix:

>Release-Note:

>Audit-Trail:
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: pkg-manager@NetBSD.org, gnats-admin@NetBSD.org, pkgsrc-bugs@NetBSD.org,
        tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/43156: NetBSD bootloader countdown runs at 1/20 speed in qemu
	 0.12
Date: Sun, 9 May 2010 23:07:47 +0900

 > >Synopsis:       NetBSD bootloader countdown runs at 1/20 speed in qemu 0.12

 > After upgrading the qemu package to version 0.12, the bootloader
 > countdown in a qemu emulated NetBSD system takes about 20 times longer
 > than it should, counting down by one every 20 seconds instead of every
 > second, taking a total of 100 seconds to count down from five.

 Probably BIOS in the new QEMU distribution implements a BIOS function call
 INT 15h/AH=86h (WAIT), but the emulation takes more time than it should
 on long delays.

 Fixing BIOS package in QEMU is not so easy so it would be better
 to apply workaround using INT 1Ah/AH=00h (GET SYSTEMTIME)
 as used to fix the similar countdown speed issue:
 http://mail-index.NetBSD.org/source-changes/2009/08/26/msg000190.html

 The attached diff seems working for me but I wonder if we should have
 more common API to wait specified seconds in libsa...

 Index: lib/biosdisk.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/i386/stand/lib/biosdisk.c,v
 retrieving revision 1.30
 diff -u -r1.30 biosdisk.c
 --- lib/biosdisk.c	20 Oct 2009 14:49:03 -0000	1.30
 +++ lib/biosdisk.c	9 May 2010 10:31:14 -0000
 @@ -509,7 +509,7 @@

  	/* let the floppy drive go off */
  	if (d->ll.type == BIOSDISK_TYPE_FD)
 -		delay(3000000);	/* 2s is enough on all PCs I found */
 +		wait_sec(3);	/* 2s is enough on all PCs I found */

  	dealloc(d, sizeof(struct biosdisk));
  	f->f_devdata = NULL;
 Index: lib/exec.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/i386/stand/lib/exec.c,v
 retrieving revision 1.42
 diff -u -r1.42 exec.c
 --- lib/exec.c	14 Sep 2009 11:56:27 -0000	1.42
 +++ lib/exec.c	9 May 2010 10:31:14 -0000
 @@ -125,7 +125,7 @@
  #define	PAGE_SIZE	4096
  #endif

 -#define MODULE_WARNING_DELAY	5000000
 +#define MODULE_WARNING_SEC	5

  extern struct btinfo_console btinfo_console;

 @@ -486,7 +486,7 @@
  	btinfo_modulelist = alloc(len);
  	if (btinfo_modulelist == NULL) {
  		printf("WARNING: couldn't allocate module list\n");
 -		delay(MODULE_WARNING_DELAY);
 +		wait_sec(MODULE_WARNING_SEC);
  		return;
  	}
  	memset(btinfo_modulelist, 0, len);
 @@ -530,7 +530,7 @@
  		printf("WARNING: %d module%s failed to load\n",
  		    nfail, nfail == 1 ? "" : "s");
  #if notyet
 -		delay(MODULE_WARNING_DELAY);
 +		wait_sec(MODULE_WARNING_SEC);
  #endif
  	}
  }
 Index: lib/libi386.h
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/i386/stand/lib/libi386.h,v
 retrieving revision 1.32
 diff -u -r1.32 libi386.h
 --- lib/libi386.h	13 Sep 2009 22:45:27 -0000	1.32
 +++ lib/libi386.h	9 May 2010 10:31:14 -0000
 @@ -69,6 +69,7 @@
  #define CONSDEV_AUTO (-1)
  int iskey(int);
  char awaitkey(int, int);
 +void wait_sec(int);

  /* this is in "user code"! */
  int parsebootfile(const char *, char **, char **, int *, int *, const char **);
 Index: lib/pcio.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/i386/stand/lib/pcio.c,v
 retrieving revision 1.27
 diff -u -r1.27 pcio.c
 --- lib/pcio.c	26 Aug 2009 13:28:48 -0000	1.27
 +++ lib/pcio.c	9 May 2010 10:31:14 -0000
 @@ -371,3 +371,10 @@

  	return c;
  }
 +
 +void
 +wait_sec(int sec)
 +{
 +
 +	wait(sec * 1000000);
 +}
 Index: lib/vbe.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/i386/stand/lib/vbe.c,v
 retrieving revision 1.5
 diff -u -r1.5 vbe.c
 --- lib/vbe.c	20 Oct 2009 14:47:33 -0000	1.5
 +++ lib/vbe.c	9 May 2010 10:31:14 -0000
 @@ -172,7 +172,7 @@
  		if (ret) {
  			printf("WARNING: failed to set VBE mode 0x%x\n",
  			    vbestate.modenum);
 -			delay(5000000);
 +			wait_sec(5);
  		}
  	}
  	return ret;

 ---

State-Changed-From-To: open->analyzed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 09 May 2010 23:12:02 +0900
State-Changed-Why:
Problem identified, but probably needs discussion for proper solution.


Responsible-Changed-From-To: pkg-manager->port-i386-maintainer
Responsible-Changed-By: tsutsui@NetBSD.org
Responsible-Changed-When: Sun, 23 May 2010 00:37:49 +0900
Responsible-Changed-Why:
It's unlikely to handle realtime emulation in microsecond order
in BIOS emulations. Probably we have to handle it in our bootloader
as attached patch.


From: Izumi Tsutsui <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/43156 CVS commit: src/sys/arch/i386/stand/lib
Date: Fri, 25 Jun 2010 15:35:08 +0000

 Module Name:	src
 Committed By:	tsutsui
 Date:		Fri Jun 25 15:35:08 UTC 2010

 Modified Files:
 	src/sys/arch/i386/stand/lib: biosdisk.c exec.c libi386.h pcio.c vbe.c

 Log Message:
 Add wait_sec() which uses BIOS function call INT 1Ah/AH=00h (GET SYSTEMTIME)
 and use it for large delays (in seconds) instead of delay() that uses
 INT 15h/AH=86h (WAIT) in microsecond because the latter one can't provide
 precise delays on emulators.
 Fixes PR port-i386/43156 (NetBSD bootloader countdown runs at 1/20 speed
 in qemu 0.12).

 No particular comments on the PR and port-i386@.


 To generate a diff of this commit:
 cvs rdiff -u -r1.30 -r1.31 src/sys/arch/i386/stand/lib/biosdisk.c
 cvs rdiff -u -r1.42 -r1.43 src/sys/arch/i386/stand/lib/exec.c
 cvs rdiff -u -r1.32 -r1.33 src/sys/arch/i386/stand/lib/libi386.h
 cvs rdiff -u -r1.27 -r1.28 src/sys/arch/i386/stand/lib/pcio.c
 cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/vbe.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

Responsible-Changed-From-To: port-i386-maintainer->tsutsui
Responsible-Changed-By: tsutsui@NetBSD.org
Responsible-Changed-When: Sat, 26 Jun 2010 01:08:09 +0900
Responsible-Changed-Why:
I committed a fix.


State-Changed-From-To: analyzed->feedback
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sat, 26 Jun 2010 01:08:09 +0900
State-Changed-Why:
Could you try the committed fix?


From: Andreas Gustafsson <gson@gson.org>
To: gnats-bugs@NetBSD.org
Cc: tsutsui@NetBSD.org,
    port-i386-maintainer@netbsd.org,
    netbsd-bugs@netbsd.org,
    gnats-admin@netbsd.org
Subject: Re: port-i386/43156 (NetBSD bootloader countdown runs at 1/20 speed in qemu 0.12)
Date: Wed, 30 Jun 2010 14:29:04 +0300

 tsutsui@NetBSD.org wrote:
 > Could you try the committed fix?

 I did, and I have both good news and bad news.  The good news is that
 the bug is fixed.  The bad news is that it wasn't fixed by your
 commit, but was already fixed by src/sys/arch/i386/stand/lib/pcio.c
 revision 1.27.
 -- 
 Andreas Gustafsson, gson@gson.org

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gson@gson.org
Cc: gnats-bugs@NetBSD.org, tsutsui@NetBSD.org, port-i386-maintainer@NetBSD.org,
        netbsd-bugs@NetBSD.org, gnats-admin@NetBSD.org,
        tsutsui@ceres.dti.ne.jp
Subject: Re: port-i386/43156 (NetBSD bootloader countdown runs at 1/20 speed
	 in qemu 0.12)
Date: Wed, 30 Jun 2010 22:42:38 +0900

 > > Could you try the committed fix?
 > 
 > I did, and I have both good news and bad news.  The good news is that
 > the bug is fixed.  The bad news is that it wasn't fixed by your
 > commit, but was already fixed by src/sys/arch/i386/stand/lib/pcio.c
 > revision 1.27.

 The rev 1.27 should fix delays on countdown.
 Mine should fix delays on other places, on floppy boot,
 module wanings etc.
 Did you try floppy boot without my fixes?
 ---
 Izumi Tsutsui

From: Andreas Gustafsson <gson@gson.org>
To: gnats-bugs@NetBSD.org
Cc: tsutsui@NetBSD.org,
    gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org
Subject: Re: port-i386/43156 (NetBSD bootloader countdown runs at 1/20 speed
	 in qemu 0.12)
Date: Wed, 30 Jun 2010 20:36:42 +0300

 Izumi Tsutsui wrote:
 >  The rev 1.27 should fix delays on countdown.
 >  Mine should fix delays on other places, on floppy boot,
 >  module wanings etc.
 >  Did you try floppy boot without my fixes?

 I can confirm that your recent commits eliminate some major delays
 during the floppy boot process (before printing the very first boot
 messages, and between loading the kernel and starting it).  I consider
 those to be separate bugs from the boot countdown speed issue that was
 the subject of PR 43156, but thanks for fixing them in any case.
 -- 
 Andreas Gustafsson, gson@gson.org

State-Changed-From-To: feedback->closed
State-Changed-By: gson@NetBSD.org
State-Changed-When: Thu, 01 Jul 2010 17:00:18 +0000
State-Changed-Why:
Feedback given, bug was fixed in pcio.c 1.27.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.