Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 07 Jul 2007 22:14:44 -0600 (MDT)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        xistence@0x58.com
Cc:        usb@freebsd.org, hackers@freebsd.org, current@freebsd.org
Subject:   Re: device rue causes kernel panic
Message-ID:  <20070707.221444.-1816826594.imp@bsdimp.com>
In-Reply-To: <20070707.220203.776519881.imp@bsdimp.com>
References:  <9496044C-3275-4D9C-8FFF-FD1FCE1F6728@0x58.com> <20070707.220203.776519881.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
----Next_Part(Sat_Jul__7_22_14_44_2007_946)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

In message: <20070707.220203.776519881.imp@bsdimp.com>
            "M. Warner Losh" <imp@bsdimp.com> writes:
: In message: <9496044C-3275-4D9C-8FFF-FD1FCE1F6728@0x58.com>
:             Bert JW Regeer <xistence@0x58.com> writes:
: : I have a USB 10/100 FastEthernet device, that is identified as a  
: : RealTek device. On 6.2-RELEASE it works without any issues, and some  
: : older versions of CURRENT it worked perfectly as well. I csup'ed to  
: : CURRENT today (2007-07-07 at 16:30 MST), rebuild my kernel and it  
: : failed:
: : panic (fmt=0xc0a94933 "Trying sleep, but thread marked as sleeping prohibited")
: : _sleep (ident=0xc2322c00...) at /usr/src/sys/kern/kern_synch.c:201
: : usbd_transfer (xfer=0xc2322c00) at /usr/src/sys/dev/usb/usbdi.c:333
: : usbd_sync_transfer (xfer=0xc2322c00) at /usr/src/sys/dev/usb/usbdi.c:406
: : usbd_do_request_flags_pipe ... at /usr/src/sys/dev/usb/usbdi.c:1098
: : usbd_do_request_flags ...at /usr/src/sys/dev/usb/usbdi.c:1068
: : usbd_do_request at /usr/src/sys/dev/usb/usbdi.c:1060
: : rue_read_mem at /usr/src/sys/dev/usb/if_rue.c:227
: : rue_csr_read_1 at /usr/src/sys/dev/usb/if_rue.c:276
: : rue_miibus_readreg at /usr/src/sys/dev/usb/if_rue.c:376
: ...
: : ruephy_service at miibus_if.h:26	/* Likely wrong */
: : mii_tick at /usr/src/sys/dev/mii/mii.c:390
: : rue_tick at /usr/src/sys/dev/usb/if_rue.c:935
: : softclock at /usr/src/sys/kern/kern_timeout.c:281
: ...
: 
: This driver needs to be re-written ala aue, axe, kue and udav to use a
: taskqueue for the mii ticking.  It appears to be the only usb driver
: in the tree to still do stuff directly in a callout.  This context
: can't sleep...

You might try this patch.

Warner

----Next_Part(Sat_Jul__7_22_14_44_2007_946)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="rue-task.diff"

Index: if_rue.c
===================================================================
RCS file: /cache/ncvs/src/sys/dev/usb/if_rue.c,v
retrieving revision 1.39
diff -u -r1.39 if_rue.c
--- if_rue.c	20 Jun 2007 05:10:52 -0000	1.39
+++ if_rue.c	8 Jul 2007 04:13:16 -0000
@@ -142,6 +142,7 @@
 static void rue_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
 static void rue_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
 static void rue_tick(void *);
+static void rue_tick_task(void *);
 static void rue_rxstart(struct ifnet *);
 static void rue_start(struct ifnet *);
 static int rue_ioctl(struct ifnet *, u_long, caddr_t);
@@ -594,6 +595,8 @@
 		goto error;
 	}
 
+	usb_init_task(&sc->rue_tick_task, rue_tick_task, sc);
+
 	err = usbd_device2interface_handle(uaa->device, RUE_IFACE_IDX, &iface);
 	if (err) {
 		device_printf(sc->rue_dev, "getting interface handle failed\n");
@@ -704,6 +707,7 @@
 
 	sc->rue_dying = 1;
 	untimeout(rue_tick, sc, sc->rue_stat_ch);
+	usb_rem_task(sc->rue_udev, &sc->rue_tick_task);
 	ether_ifdetach(ifp);
 	if_free(ifp);
 
@@ -916,6 +920,20 @@
 static void
 rue_tick(void *xsc)
 {
+	struct rue_softc *sc = xsc;
+
+	if (sc == NULL)
+		return;
+	if (sc->rue_dying)
+		return;
+
+	/* Perform periodic stuff in process context */
+	usb_add_task(sc->rue_udev, &sc->rue_tick_task, USB_TASKQ_DRIVER);
+}
+
+static void
+rue_tick_task(void *xsc)
+{
 	struct rue_softc	*sc = xsc;
 	struct ifnet		*ifp;
 	struct mii_data		*mii;
Index: if_ruereg.h
===================================================================
RCS file: /cache/ncvs/src/sys/dev/usb/if_ruereg.h,v
retrieving revision 1.7
diff -u -r1.7 if_ruereg.h
--- if_ruereg.h	12 May 2007 05:53:53 -0000	1.7
+++ if_ruereg.h	8 Jul 2007 04:11:39 -0000
@@ -204,6 +204,7 @@
 	char			rue_dying;
 	struct timeval		rue_rx_notice;
 	struct usb_qdat		rue_qdat;
+	struct usb_task		rue_tick_task;
 };
 
 #if defined(__FreeBSD__)

----Next_Part(Sat_Jul__7_22_14_44_2007_946)----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070707.221444.-1816826594.imp>