From winfried@miranda.expro.pl  Wed Oct  1 09:44:50 2003
Return-Path: <winfried@miranda.expro.pl>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 6747A16A4B3
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  1 Oct 2003 09:44:50 -0700 (PDT)
Received: from miranda.expro.pl (miranda.expro.pl [81.210.76.12])
	by mx1.FreeBSD.org (Postfix) with SMTP id D970F43F85
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  1 Oct 2003 09:44:48 -0700 (PDT)
	(envelope-from winfried@miranda.expro.pl)
Received: (qmail 69471 invoked by uid 1001); 1 Oct 2003 16:44:47 -0000
Message-Id: <20031001164447.69262.qmail@miranda.expro.pl>
Date: 1 Oct 2003 16:44:47 -0000
From: Jan Srzednicki <w@expro.pl>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: kldunload rtc.ko causes a panic; yet it's in rc.d script
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         57465
>Category:       ports
>Synopsis:       kldunload rtc.ko causes a panic; yet it's in rc.d script
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    silby
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 01 09:50:17 PDT 2003
>Closed-Date:    Fri Jan 23 01:08:23 PST 2004
>Last-Modified:  Fri Jan 23 01:08:23 PST 2004
>Originator:     Jan Srzednicki
>Release:        FreeBSD 5.1-RELEASE-p2 i386
>Organization:
>Environment:

System: FreeBSD mizantrop 5.1-RELEASE-p2 FreeBSD 5.1-RELEASE-p2 #1: Mon Sep  1 19:57:29 CEST 2003     root@mizantrop:/usr/obj/usr/src/sys/MIZERIA  i386

	
>Description:

ports/emulators/rtc is a real time clock port, which is used by vmware
(and instaled as a dependency for a emulators/vmware3 port).

Along with the module, there comes a rc.d script, namely rtc.sh. It
loads the module on start and unloads it on stop.

The module however, is somewhat broken. After using vmware and
"kldunload rtc.ko" I get a panic. Well, I know kldunloading modules is
always tricky and I should not play with this when I don't have to, but
this kldunload is enabled by default via the port!

The rtc.ko also causes a panic after a reboot when it wasn't
kldunloaded, but this panic is not so severe, as the buffers are flushed
first and the filesystems are synced.

	
>How-To-Repeat:

Install ports/emulators/rtc and ports/emulators/vmware3.

Configure a vmware guest system, turn it on, play with it, then turn off.

Reboot the system.

	
>Fix:

First of all, remove the kldunload thing from rc.d script
(ports/emulators/rtc/files/rtc.sh).

VMware says that rtc.ko is only needed for some windows stuff. As the
port is broken (at least on 5.1-R) and not so-needed, maybe it would be
better to remove the dependency (or make it an option, with a warning).

The best fix would be fixing the module itself, of course. ;)

	


>Release-Note:
>Audit-Trail:

From: Philipp Mergenthaler <philipp.mergenthaler@stud.uni-karlsruhe.de>
To: freebsd-gnats-submit@freebsd.org, w@expro.pl
Cc:  
Subject: Re: ports/57465: kldunload rtc.ko causes a panic; yet it's in rc.d script
Date: Thu, 2 Oct 2003 10:24:41 +0200

 The bug is that the module, on unloading, calls destroy_dev() twice
 for its device. Doing this causes a panic.
 
 Fix:
 --- ports/emulators/rtc/files/rtc.c_orig	Thu Oct  2 10:20:17 2003
 +++ ports/emulators/rtc/files/rtc.c	Thu Oct  2 09:58:13 2003
 @@ -168,7 +168,6 @@
  	if (sc->var.flags.opened) {
  		return EBUSY;
  	}
 -	destroy_dev(sc->dev);
  	FREE(sc, M_DEVBUF);
  	return error;
  }
Responsible-Changed-From-To: freebsd-ports-bugs->freebsd-emulation 
Responsible-Changed-By: roam 
Responsible-Changed-When: Thu Oct 2 04:46:09 PDT 2003 
Responsible-Changed-Why:  
Over to the maintainer group. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=57465 

From: =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= <mbsd@pacbell.net>
To: freebsd-gnats-submit@FreeBSD.org, w@expro.pl
Cc:  
Subject: Re: ports/57465 kldunload rtc.ko causes a panic; yet it's in rc.d
 script
Date: Thu, 2 Oct 2003 08:45:19 -0700 (PDT)

 I ran into this some time ago, and found that you get different
 results depending on whether the device has been opened or not.
 
 Have you tried kldunloading "rtc" w/o using it first, e.g. directly
 after boot?
 
 I've been using the following patch for a while:
 
 --- rtc.c.org   Wed Aug 20 20:41:50 2003
 +++ rtc.c       Thu Oct  2 08:40:37 2003
 @@ -299,7 +299,8 @@
                 DLog(Lfail, "%p busy", sc);
                 return error;
         }
 -       destroy_dev(rtc_dev);
 +       if (sc == NULL)
 +               destroy_dev(rtc_dev);
  #if __FreeBSD_version < 500104
         error = cdevsw_remove(&rtc_cdevsw);
  #endif
 
 Which seems to work find for me in all cases.  I made a mental note to
 submit a PR once I've tested out the fix, and then of course, I forgot
 all about it... :)
 
    $.02,
    /Mikko

From: Jan Srzednicki <w@expro.pl>
To: Mikko =?iso-8859-2?Q?Ty=F6l=E4j=E4rvi?= <mbsd@pacbell.net>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: ports/57465 kldunload rtc.ko causes a panic; yet it's in rc.d script
Date: Mon, 6 Oct 2003 18:49:11 +0200

 On Thu, Oct 02, 2003 at 08:45:19AM -0700, Mikko Tyljrvi wrote:
 > 
 > I ran into this some time ago, and found that you get different
 > results depending on whether the device has been opened or not.
 > 
 > Have you tried kldunloading "rtc" w/o using it first, e.g. directly
 > after boot?
 > 
 > I've been using the following patch for a while:
 [snip]
 > Which seems to work find for me in all cases.  I made a mental note to
 > submit a PR once I've tested out the fix, and then of course, I forgot
 > all about it... :)
 
 This patch doesn't work for me; kldunload rtc still causes a panic.
 
 -- 
 Jan 'Winfried' Srzednicki
 w@expro.pl
 

From: Jan Srzednicki <w@expro.pl>
To: Philipp Mergenthaler <philipp.mergenthaler@stud.uni-karlsruhe.de>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: ports/57465: kldunload rtc.ko causes a panic; yet it's in rc.d script
Date: Mon, 6 Oct 2003 18:51:14 +0200

 On Thu, Oct 02, 2003 at 10:24:41AM +0200, Philipp Mergenthaler wrote:
 > The bug is that the module, on unloading, calls destroy_dev() twice
 > for its device. Doing this causes a panic.
 > 
 > Fix:
 > --- ports/emulators/rtc/files/rtc.c_orig	Thu Oct  2 10:20:17 2003
 > +++ ports/emulators/rtc/files/rtc.c	Thu Oct  2 09:58:13 2003
 > @@ -168,7 +168,6 @@
 >  	if (sc->var.flags.opened) {
 >  		return EBUSY;
 >  	}
 > -	destroy_dev(sc->dev);
 >  	FREE(sc, M_DEVBUF);
 >  	return error;
 >  }
 
 This one seems to work fine. Thanks. ;)
 
 -- 
 Jan 'Winfried' Srzednicki
 w@expro.pl
 
Responsible-Changed-From-To: freebsd-emulation->emulation 
Responsible-Changed-By: gerald 
Responsible-Changed-When: Mon Oct 13 11:25:45 PDT 2003 
Responsible-Changed-Why:  
Change freebsd-emulation to emulation so that the list only receives 
one list of open PRs. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=57465 
Responsible-Changed-From-To: emulation->silby 
Responsible-Changed-By: silby 
Responsible-Changed-When: Sat Jan 17 10:15:19 PST 2004 
Responsible-Changed-Why:  
I will fix this and a bunch of other things in the rtc driver in the 
next week or two. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=57465 
State-Changed-From-To: open->closed 
State-Changed-By: silby 
State-Changed-When: Fri Jan 23 01:08:07 PST 2004 
State-Changed-Why:  
Suggested fix committed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=57465 
>Unformatted:
