Re: device rue causes kernel panic

From: Bert JW Regeer <xistence_at_0x58.com>
Date: Sun, 8 Jul 2007 00:21:01 -0700
On Jul 7, 2007, at 9:14 PM, M. Warner Losh wrote:

> In message: <20070707.220203.776519881.imp_at_bsdimp.com>
>             "M. Warner Losh" <imp_at_bsdimp.com> writes:
> : In message: <9496044C-3275-4D9C-8FFF-FD1FCE1F6728_at_0x58.com>
> :             Bert JW Regeer <xistence_at_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
> 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
> _at__at_ -142,6 +142,7 _at__at_
>  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);
> _at__at_ -594,6 +595,8 _at__at_
>  		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");
> _at__at_ -704,6 +707,7 _at__at_
>
>  	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);
>
> _at__at_ -916,6 +920,20 _at__at_
>  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
> _at__at_ -204,6 +204,7 _at__at_
>  	char			rue_dying;
>  	struct timeval		rue_rx_notice;
>  	struct usb_qdat		rue_qdat;
> +	struct usb_task		rue_tick_task;
>  };
>
>  #if defined(__FreeBSD__)
> _______________________________________________
> freebsd-hackers_at_freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers- 
> unsubscribe_at_freebsd.org"

This patch works, in that no more Kernel panics are created, however  
the following did show up in dmesg//var/log/messages as I was using  
dhclient rue0:

Jul  7 16:15:53 FreeBSD-VMWare root: Unknown USB device: vendor  
0x0bda product 0x8150 bus uhub0
Jul  7 16:15:53 FreeBSD-VMWare kernel: rue0: <USBKR100 USB 10/100  
LAN, class 0/0, rev 1.10/1.00, addr 2> on uhub0
Jul  7 16:15:53 FreeBSD-VMWare kernel: miibus0: <MII bus> on rue0
Jul  7 16:15:53 FreeBSD-VMWare kernel: ruephy0: <RealTek RTL8150  
internal media interface> PHY 0 on miibus0
Jul  7 16:15:53 FreeBSD-VMWare kernel: ruephy0:  10baseT, 10baseT- 
FDX, 100baseTX, 100baseTX-FDX, auto
Jul  7 16:15:53 FreeBSD-VMWare kernel: rue0: using obsoleted  
if_watchdog interface
Jul  7 16:15:53 FreeBSD-VMWare kernel: rue0: Ethernet address:  
00:10:60:e0:ab:a8
Jul  7 16:15:53 FreeBSD-VMWare kernel: rue0: if_start running  
deferred for Giant
Jul  7 16:15:53 FreeBSD-VMWare kernel: rue0: link state changed to DOWN
Jul  7 16:15:54 FreeBSD-VMWare kernel: uhub2: <vendor 0x0e0f VMware  
Virtual USB Hub, class 9/0, rev 1.10/1.00, addr 3> on uhub0
Jul  7 16:15:54 FreeBSD-VMWare kernel: uhub2: 7 ports with 7  
removable, self powered
Jul  7 16:15:57 FreeBSD-VMWare kernel: rue0: link state changed to UP
Jul  7 16:15:57 FreeBSD-VMWare kernel: rue0: link state changed to DOWN
Jul  7 16:15:57 FreeBSD-VMWare kernel: rue0: link state changed to UP
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:09 FreeBSD-VMWare kernel: lock order reversal: (Giant  
after non-sleepable)
Jul  7 16:16:09 FreeBSD-VMWare kernel: 1st 0xc0bf334c in_multi_mtx  
(in_multi_mtx) _at_ /usr/src/sys/netinet/in_mcast.c:317
Jul  7 16:16:09 FreeBSD-VMWare kernel: 2nd 0xc0ba47a8 Giant (Giant)  
_at_ /usr/src/sys/kern/kern_synch.c:235
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/in.c:506
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/in.c:506
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/in.c:506
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/in.c:506
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/in.c:506
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/in.c:506
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:09 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:09 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:12 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:12 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/in.c:506
Jul  7 16:16:12 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:12 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/in.c:506
Jul  7 16:16:12 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:12 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/in.c:506
Jul  7 16:16:12 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:12 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/in.c:506
Jul  7 16:16:12 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:12 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/in.c:506
Jul  7 16:16:12 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:12 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/in.c:506
Jul  7 16:16:12 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:12 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:12 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:12 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:12 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:12 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:12 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:12 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:12 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:12 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:12 FreeBSD-VMWare kernel: Sleeping on "usbsyn" with the  
following non-sleepable locks held:
Jul  7 16:16:12 FreeBSD-VMWare kernel: exclusive sleep mutex  
in_multi_mtx r = 0 (0xc0bf334c) locked _at_ /usr/src/sys/netinet/ 
in_mcast.c:317
Jul  7 16:16:12 FreeBSD-VMWare dhclient: New IP Address (rue0):  
10.10.10.228
Jul  7 16:16:12 FreeBSD-VMWare dhclient: New Subnet Mask (rue0):  
255.255.255.0
Jul  7 16:16:12 FreeBSD-VMWare dhclient: New Broadcast Address  
(rue0): 10.10.10.255
Jul  7 16:16:12 FreeBSD-VMWare dhclient: New Routers (rue0): 10.10.10.11


Bert JW Regeer
Received on Sun Jul 08 2007 - 05:21:04 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:13 UTC