From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 14 17:23:16 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7881216A41F for ; Mon, 14 Nov 2005 17:23:16 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (66-23-216-219.clients.speedfactory.net [66.23.216.219]) by mx1.FreeBSD.org (Postfix) with ESMTP id F186643D46 for ; Mon, 14 Nov 2005 17:23:15 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.5b3) with ESMTP id 1948898 for multiple; Mon, 14 Nov 2005 12:23:02 -0500 Received: from localhost (john@localhost [127.0.0.1]) by server.baldwin.cx (8.13.1/8.13.1) with ESMTP id jAEHMmcn079034; Mon, 14 Nov 2005 12:22:50 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Mon, 14 Nov 2005 12:19:48 -0500 User-Agent: KMail/1.8.2 References: <200511121400.02075.sebastien.bourdeauducq@gmail.com> In-Reply-To: <200511121400.02075.sebastien.bourdeauducq@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200511141219.49573.jhb@freebsd.org> X-Spam-Status: No, score=-2.8 required=4.2 tests=ALL_TRUSTED autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on server.baldwin.cx X-Server: High Performance Mail Server - http://surgemail.com r=1653887525 Cc: Sebastien Subject: Re: Trigerring a taskqueue from the if_start routine crashes FreeBSD6 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Nov 2005 17:23:16 -0000 On Saturday 12 November 2005 08:00 am, Sebastien wrote: > Hello, > > My 802.11 driver queues frames to send to the device in a tailq and then > triggers a taskqueue to actually send them. The taskqueue is required > because I need to do two USB transfers, and wait for the first one to > complete before I start the second : doing this asynchronously would be a > pain. > > This used to work fine under FreeBSD 5, but with 6, the system randomly > freezes without any error message, and doesn't respond to anything else > than the big red button. The crash seems more likely to happen when there > are 3 or more frames in the tailq when the taskqueue runs. > > My code is online at > http://svnweb.tuxfamily.org/listing.php?repname=p54u+%28prism54%29&path=%2F >&sc=0 > > The taskqueue-related code is all in output_layer.c, and the interface with > the 802.11 and network stack, from which the taskqueue is triggered, is in > netif.c. > > The taskqueue is also trigerred from the thread created to bring the device > up when it's detected, but it doesn't crash there (but the frames are > queued one by one there). > > Any ideas ? I don't see anything in output_layer.c Note that it's ok to hold locks over a call to free() so that your output_free() routine could be simplified somewhat: mtx_lock(&sc->output_lock); while (!TAILQ_EMPTY(&sc->output_queue) { bf = TAILQ_FIRST(&sc->output_queue); TAILQ_REMOVE(&sc->output_queue, bf, bf_list); m_freem(bf->m); free(bf, M_USBDEV); } mtx_destroy(&sc->output_lock); but that is just a suggestion, I don't think it would affect your problem. Are you able to add KDB into your kernel and break into the debugger when the machine hangs (either via Ctrl-Alt-Esc or via a serial break over a serial console)? -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org