From owner-p4-projects@FreeBSD.ORG Wed Dec 19 20:12:47 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2D43216A41A; Wed, 19 Dec 2007 20:12:47 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B5BFE16A418 for ; Wed, 19 Dec 2007 20:12:46 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.freebsd.org (Postfix) with ESMTP id 7E92013C447 for ; Wed, 19 Dec 2007 20:12:46 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.8q) with ESMTP id 225165660-1834499 for multiple; Wed, 19 Dec 2007 15:10:37 -0500 Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.8/8.13.8) with ESMTP id lBJKCT8f065584; Wed, 19 Dec 2007 15:12:31 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: Hans Petter Selasky Date: Wed, 19 Dec 2007 14:33:13 -0500 User-Agent: KMail/1.9.6 References: <200712190137.lBJ1b8sJ006586@repoman.freebsd.org> In-Reply-To: <200712190137.lBJ1b8sJ006586@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200712191433.13837.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Wed, 19 Dec 2007 15:12:31 -0500 (EST) X-Virus-Scanned: ClamAV 0.91.2/5182/Wed Dec 19 12:36:58 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Perforce Change Reviews Subject: Re: PERFORCE change 131191 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Dec 2007 20:12:47 -0000 On Tuesday 18 December 2007 08:37:08 pm Hans Petter Selasky wrote: > http://perforce.freebsd.org/chv.cgi?CH=131191 > > Change 131191 by hselasky@hselasky_laptop001 on 2007/12/19 01:36:11 > > > Bugfix: > It looks like you need to call "intr_event_destroy" and > not just "swi_remove". This was not well documented. > Else you get a memory leak. Looked through the sources > and I think others have made the same mistake aswell. That's because all other SWI's are owned by the system. You probably should just create plain old kernel threads via kthread_*() or kproc_*() instead of using the swi stuff. swi_add/swi_remove are for adding and removing handlers, not for managing the backing threads. swi_add() just happens to create the thread if it doesn't already exist. > Affected files ... > > .. //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#76 edit > > Differences ... > > ==== //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#76 (text+ko) ==== > > @@ -835,9 +835,11 @@ > LIST_INIT(&(info->done_head)); > > /* create our interrupt thread */ > - if (swi_add(NULL, "usbcb", &usbd_callback_intr_td, > - info, SWI_CAMBIO, INTR_MPSAFE, &(info->done_cookie))) { > + if (swi_add(&(info->done_event), "usbcb", > + &usbd_callback_intr_td, info, SWI_CAMBIO, > + INTR_MPSAFE, &(info->done_cookie))) { > info->done_cookie = NULL; > + info->done_event = NULL; > parm.err = USBD_NO_INTR_THREAD; > goto done; > } > @@ -1073,6 +1075,7 @@ > /* teardown the interrupt thread, if any */ > if (info->done_cookie) { > swi_remove(info->done_cookie); > + intr_event_destroy(info->done_event); > } > /* > * free the "memory_base" last, > @@ -2434,7 +2437,7 @@ > type = (xfer->pipe->edesc->bmAttributes & UE_XFERTYPE); > if (type != UE_ISOCHRONOUS) { > xfer->pipe->is_stalled = 1; > - (xfer->pipe->methods->set_stall) ( > + (xfer->udev->bus->methods->set_stall) ( > xfer->udev, NULL, xfer->pipe); > goto done; > } > @@ -2823,11 +2826,11 @@ > * complete the USB transfer like in case of a timeout > * setting the error code "USBD_STALLED". > */ > - (pipe->methods->set_stall) (udev, xfer, pipe); > + (udev->bus->methods->set_stall) (udev, xfer, pipe); > } else { > pipe->toggle_next = 0; /* reset data toggle */ > > - (pipe->methods->clear_stall) (udev, pipe); > + (udev->bus->methods->clear_stall) (udev, pipe); > > /* start up the first transfer, if any */ > if (xfer) { > -- John Baldwin