Re: umass panic when connecting camera

From: John Hay <jhay_at_icomtek.csir.co.za>
Date: Tue, 7 Oct 2003 20:02:02 +0200
> 
> I have decided to upgrade my home box from a March -current to the latest
> stuff and now when I connect my HP850 digital camera to the usb port, it
> panics the machine. I got a dump and according to the instruction pointer
> and kldstat, it must be inside the umass, but I think something confuse
> gdb a little because that doesn't show up in the backtrace or maybe it is
> just me not knowing how to convince gdb to tell me:
> 
> ###########
> ---
> Fatal trap 12: page fault while in kernel mode
> fault virtual address   = 0x10
> fault code              = supervisor read, page not present
> instruction pointer     = 0x8:0xc0729c26
> stack pointer           = 0x10:0xc6317cbc
> frame pointer           = 0x10:0xc6317cd0
> 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         = 13 (swi8: tty:sio clock)
> trap number             = 12
> panic: page fault

Ok, it seems that when plugging in a device, the contacts can have some
"noise" and you get a disconnect inbetween. If that happens before the
timeout() in umass, bad things can happen. I have added an untimeout()
and now everything seems ok. Patch at the end.

Any comments from people a little more knowledgable in the umass/usb
area?

John
-- 
John Hay -- John.Hay_at_icomtek.csir.co.za / jhay_at_FreeBSD.org


Index: umass.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/usb/umass.c,v
retrieving revision 1.91
diff -u -r1.91 umass.c
--- umass.c	20 Sep 2003 08:18:16 -0000	1.91
+++ umass.c	7 Oct 2003 16:35:45 -0000
_at__at_ -396,6 +396,7 _at__at_
 	usbd_device_handle	sc_udev;	/* USB device */
 
 	struct cam_sim		*umass_sim;	/* SCSI Interface Module */
+	struct callout_handle	rescanh;	/* timeout handle */
 
 	unsigned char		flags;		/* various device flags */
 #	define UMASS_FLAGS_GONE		0x01	/* devices is no more */
_at__at_ -2165,7 +2166,7 _at__at_
 		/* XXX This will bomb if the driver is unloaded between attach
 		 * and execution of umass_cam_rescan.
 		 */
-		timeout(umass_cam_rescan, sc, MS_TO_TICKS(200));
+		sc->rescanh = timeout(umass_cam_rescan, sc, MS_TO_TICKS(200));
 	}
 
 	return(0);	/* always succesfull */
_at__at_ -2179,6 +2180,7 _at__at_
 umass_cam_detach_sim(struct umass_softc *sc)
 {
 	if (sc->umass_sim) {
+		untimeout(umass_cam_rescan, sc, sc->rescanh);
 		if (xpt_bus_deregister(cam_sim_path(sc->umass_sim)))
 			cam_sim_free(sc->umass_sim, /*free_devq*/TRUE);
 		else
Received on Tue Oct 07 2003 - 09:02:12 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:24 UTC