From owner-freebsd-current@FreeBSD.ORG Sun Jul 8 04:14:42 2007 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6A04216A421; Sun, 8 Jul 2007 04:14:42 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 1014513C480; Sun, 8 Jul 2007 04:14:41 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.13.8/8.13.4) with ESMTP id l684E2lt099333; Sat, 7 Jul 2007 22:14:02 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sat, 07 Jul 2007 22:14:44 -0600 (MDT) Message-Id: <20070707.221444.-1816826594.imp@bsdimp.com> To: xistence@0x58.com From: "M. Warner Losh" In-Reply-To: <20070707.220203.776519881.imp@bsdimp.com> References: <9496044C-3275-4D9C-8FFF-FD1FCE1F6728@0x58.com> <20070707.220203.776519881.imp@bsdimp.com> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Sat_Jul__7_22_14_44_2007_946)--" Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Sat, 07 Jul 2007 22:14:03 -0600 (MDT) Cc: usb@freebsd.org, hackers@freebsd.org, current@freebsd.org Subject: Re: device rue causes kernel panic X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2007 04:14:42 -0000 ----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" writes: : In message: <9496044C-3275-4D9C-8FFF-FD1FCE1F6728@0x58.com> : Bert JW Regeer 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)----