From nobody@FreeBSD.org  Thu Sep 16 11:38:42 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 40E4C16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 16 Sep 2004 11:38:42 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 353D943D1D
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 16 Sep 2004 11:38:42 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i8GBcfen075380
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 16 Sep 2004 11:38:41 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.11/8.12.11/Submit) id i8GBcf1N075379;
	Thu, 16 Sep 2004 11:38:41 GMT
	(envelope-from nobody)
Message-Id: <200409161138.i8GBcf1N075379@www.freebsd.org>
Date: Thu, 16 Sep 2004 11:38:41 GMT
From: Claudio Destro <o1b6@tiscali.it>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Fatal trap 12: page fault while in kernel mode
X-Send-Pr-Version: www-2.3

>Number:         71791
>Category:       kern
>Synopsis:       [panic] [umass] Fatal trap 12: page fault while in kernel mode
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    gavin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 16 11:40:25 GMT 2004
>Closed-Date:    Thu May 08 22:53:28 UTC 2008
>Last-Modified:  Thu May 08 22:53:28 UTC 2008
>Originator:     Claudio Destro
>Release:        FreeBSD 5.3-BETA4 i386
>Organization:
>Environment:
>Description:
I receive a fatal trap 12 *every* time I disconnect my usb mass storage.

Inserting is ok:
..
uhub1: Sony USB Embedded Hub, class 9/0, rev. 2.00/0.01, addr3
uhub1: 1 port with 0 removable, self powered
umass0: Sony USB Mass Storage Denic, rev 2.00/0.01, addr 4
da1: at umass-sim0 bus 0 target 0 lun 0
da1: <Sony Storage Media 1.00> Removable Direct Access SCSI-0 device
da1: 1.000MB/s transfers
da1: 125MB (256000 512 bytes sectors; 64H 32/T 125LI)
..

Removing results in a kernel panic:

uhub1: at ubhub0 port 1 (addr 3) disconnected
(da:umass-sim0:0:0:0): lost device
(da:umass-sim0:0:0:0): removing device entry
umass0: detached
(null): at uhub1 port 1 (addr 4) disconnected

Fatal trap 12: page fault while in kernel mode
fault virtual address   = 0x400
fault code              = supervisor read, page not present
instruction pointer     = 0x84 0xc0690904
stack pointer           = 0x10 0xcc746bd4
frame pointer           = 0x10 0xcc746bf4
code segment            = base 0x0, limit 0xfffff, type 0x1b
                        = DPL 0, pres 1, def32 1, gran 1
processor eflags        = interrupt enabled, resume, IOPL = 0
current process         = 37 (usb0)
trap number             = 12
..

I dumped these info by hand this morning, but I think there are no errors...

hope this helps.
>How-To-Repeat:

>Fix:
      
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: roam 
State-Changed-When: Thu Sep 16 11:48:24 GMT 2004 
State-Changed-Why:  
This looks awfully similar to the USB panics that I discussed with 
Warner Losh last week; he committed the fixes to -CURRENT 6 days ago, 
but merged them into 5.x about two days after 5.3-BETA4 was tagged. 
Can you apply the following patches to your kernel source, then 
recompile/reinstall the kernel, reboot and try again? 

The patches are actually taken directly from the 5.x source tree - 
src/sys/dev/usb/uhub.c revision 1.62.2.1 and src/sys/dev/usb/usb_subr.c 
revision 1.69.2.1.  If you do not feel comfortable applying patches, you 
could simply fetch those two files from 
http://cvsweb.FreeBSD.org/src/sys/dev/usb/ and place them in your 
src/sys/dev/usb/ directory. 

Index: src/sys/dev/usb/uhub.c 
=================================================================== 
RCS file: /home/ncvs/src/sys/dev/usb/uhub.c,v 
retrieving revision 1.62 
retrieving revision 1.62.2.1 
diff -u -r1.62 -r1.62.2.1 
--- src/sys/dev/usb/uhub.c	15 Aug 2004 23:39:18 -0000	1.62 
+++ src/sys/dev/usb/uhub.c	13 Sep 2004 03:00:06 -0000	1.62.2.1 
@@ -38,7 +38,7 @@ 
*/ 

#include <sys/cdefs.h> 
-__FBSDID("$FreeBSD: src/sys/dev/usb/uhub.c,v 1.62 2004/08/15 23:39:18 imp Exp $"); 
+__FBSDID("$FreeBSD: src/sys/dev/usb/uhub.c,v 1.62.2.1 2004/09/13 03:00:06 imp Exp $"); 

/* 
* USB spec: http://www.usb.org/developers/docs/usbspec.zip 
@@ -90,7 +90,6 @@ 
Static void uhub_intr(usbd_xfer_handle, usbd_private_handle,usbd_status); 

#if defined(__FreeBSD__) 
-Static bus_child_detached_t uhub_child_detached; 
Static bus_child_location_str_t uhub_child_location_str; 
Static bus_child_pnpinfo_str_t uhub_child_pnpinfo_str; 
#endif 
@@ -110,7 +109,6 @@ 
uhub_match, uhub_attach, uhub_detach, uhub_activate); 
#elif defined(__FreeBSD__) 
USB_DECLARE_DRIVER_INIT(uhub, 
-	DEVMETHOD(bus_child_detached, uhub_child_detached), 
DEVMETHOD(bus_child_pnpinfo_str, uhub_child_pnpinfo_str), 
DEVMETHOD(bus_child_location_str, uhub_child_location_str), 
DEVMETHOD(bus_driver_added, bus_generic_driver_added), 
@@ -123,7 +121,6 @@ 
devclass_t uhubroot_devclass; 

Static device_method_t uhubroot_methods[] = { 
-	DEVMETHOD(bus_child_detached, uhub_child_detached), 
DEVMETHOD(bus_child_location_str, uhub_child_location_str), 
DEVMETHOD(bus_child_pnpinfo_str, uhub_child_pnpinfo_str), 
DEVMETHOD(bus_driver_added, bus_generic_driver_added), 
@@ -378,7 +375,7 @@ 
DPRINTFN(3,("uhub_explore: %s port %d status 0x%04x 0x%04xn", 
USBDEVNAME(sc->sc_dev), port, status, change)); 
if (change & UPS_C_PORT_ENABLED) { 
-			DPRINTF(("uhub_explore: C_PORT_ENABLEDn")); 
+			DPRINTF(("uhub_explore: C_PORT_ENABLED 0x%xn", change)); 
usbd_clear_port_feature(dev, port, UHF_C_PORT_ENABLE); 
if (change & UPS_C_CONNECT_STATUS) { 
/* Ignore the port error if the device 
@@ -398,7 +395,7 @@ 
else 
printf("%s: port error, giving up " 
"port %dn", 
-					       USBDEVNAME(sc->sc_dev), port); 
+					  USBDEVNAME(sc->sc_dev), port); 
} 
} 
if (!(change & UPS_C_CONNECT_STATUS)) { 
@@ -684,35 +681,6 @@ 
} 
return (0); 
} 
- 
-/* Called when a device has been detached from it */ 
-Static void 
-uhub_child_detached(device_t self, device_t child) 
-{ 
-	struct uhub_softc *sc = device_get_softc(self); 
-	usbd_device_handle devhub = sc->sc_hub; 
-	usbd_device_handle dev; 
-	int nports; 
-	int port; 
-	int i; 
- 
-	if (!devhub->hub) 
-		/* should never happen; children are only created after init */ 
-		panic("hub not fully initialised, but child deleted?"); 
- 
-	nports = devhub->hub->hubdesc.bNbrPorts; 
-	for (port = 0; port < nports; port++) { 
-		dev = devhub->hub->ports[port].device; 
-		if (dev == NULL || dev->subdevs == NULL) 
-			continue; 
-		for (i = 0; dev->subdevs[i]; i++) { 
-			if (dev->subdevs[i] == child) { 
-				dev->subdevs[i] = NULL; 
-				return; 
-			} 
-		} 
-	} 
-} 
#endif 


Index: src/sys/dev/usb/usb_subr.c 
=================================================================== 
RCS file: /home/ncvs/src/sys/dev/usb/usb_subr.c,v 
retrieving revision 1.69 
retrieving revision 1.69.2.1 
diff -u -r1.69 -r1.69.2.1 
--- src/sys/dev/usb/usb_subr.c	15 Aug 2004 23:39:18 -0000	1.69 
+++ src/sys/dev/usb/usb_subr.c	13 Sep 2004 03:01:56 -0000	1.69.2.1 
@@ -10,7 +10,7 @@ 
*/ 

#include <sys/cdefs.h> 
-__FBSDID("$FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.69 2004/08/15 23:39:18 imp Exp $"); 
+__FBSDID("$FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.69.2.1 2004/09/13 03:01:56 imp Exp $"); 

/* 
* Copyright (c) 1998 The NetBSD Foundation, Inc. 
@@ -905,6 +905,10 @@ 
if (dv) { 
return (USBD_NORMAL_COMPLETION); 
} 
+	/* 
+	 * Free subdevs so we can reallocate it larger for the number of 
+	 * interfaces  
+	 */ 
tmpdv = dev->subdevs; 
dev->subdevs = NULL; 
free(tmpdv, M_USB); 
@@ -1016,9 +1020,6 @@ 
if (dv != NULL) { 
return (USBD_NORMAL_COMPLETION); 
} 
-	tmpdv = dev->subdevs; 
-	dev->subdevs = 0; 
-	free(tmpdv, M_USB); 

/* 
* The generic attach failed, but leave the device as it is. 
@@ -1346,11 +1347,13 @@ 
di->udi_speed = dev->speed; 

if (dev->subdevs != NULL) { 
-		for (i = 0; dev->subdevs[i] && 
-			     i < USB_MAX_DEVNAMES; i++) { 
-			strncpy(di->udi_devnames[i], USBDEVPTRNAME(dev->subdevs[i]), 
-				USB_MAX_DEVNAMELEN); 
-			di->udi_devnames[i][USB_MAX_DEVNAMELEN-1] = '0'; 
+		for (i = 0; dev->subdevs[i] && i < USB_MAX_DEVNAMES; i++) { 
+			if (device_is_attached(dev->subdevs[i])) 
+				strlcpy(di->udi_devnames[i], 
+				    USBDEVPTRNAME(dev->subdevs[i]), 
+				    USB_MAX_DEVNAMELEN); 
+			else 
+				di->udi_devnames[i][0] = 0; 
} 
} else { 
i = 0; 

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

From: o1b6@tiscali.it
To: freebsd-gnats-submit@freebsd.org, o1b6@tiscali.it
Cc:  
Subject: Re: kern/71791: Fatal trap 12: page fault while in kernel mode
Date: Thu, 16 Sep 2004 21:49:36 +0100

 Sorry for delay. No, it didn't work :(
 
 I updated my sources on 2004-09-15 14:29:09, and downloaded uhub.c + usb_=
 subr.c
 from your repository this morning.
 They are the same version.
 
 I can say just under <=3DBETA3 all worked correctly...
 
 
 __________________________________________________________________
 Tiscali Adsl 640 Free: fino al 15 novembre i consumi sono GRATIS!
 Se sottoscrivi un'Adsl Free 640 entro il 30 settembre avrai gratis tutti
 i consumi fino al 15/11/04 compreso! In piu' sono gratis il modem in como=
 dato
 e l'attivazione. Cosa aspetti? Prima attivi, piu' risparmi. Attivala subi=
 to!
 http://abbonati.tiscali.it/adsl/
 
 
 
Responsible-Changed-From-To: freebsd-bugs->gavin 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Mon Feb 4 18:46:19 UTC 2008 
Responsible-Changed-Why:  
To submitter:  Are you able to recreate this problem with a more recent  
version of FreeBSD?  I'm very sorry this PR has sat around for so long 
without being looked at. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=71791 
State-Changed-From-To: feedback->closed 
State-Changed-By: vwe 
State-Changed-When: Thu May 8 22:53:20 UTC 2008 
State-Changed-Why:  

We're sorry to not see any feedback received for quite some time. 
If you think this is still an issue that should be worked on, 
please provide the requested information and we'll be happy to 
re-open this ticket. 
Thank you for bringing this problem to attention! 

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