From owner-freebsd-current@FreeBSD.ORG Thu Feb 27 10:54:08 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0F38B142 for ; Thu, 27 Feb 2014 10:54:08 +0000 (UTC) Received: from mta05.bitpro.no (mta05.bitpro.no [92.42.64.202]) by mx1.freebsd.org (Postfix) with ESMTP id B5D3518DE for ; Thu, 27 Feb 2014 10:54:07 +0000 (UTC) Received: from mail.lockless.no (mail.lockless.no [46.29.221.38]) by mta05.bitpro.no (Postfix) with ESMTPS id B1CDB17FFF8; Thu, 27 Feb 2014 11:54:04 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.lockless.no (Postfix) with ESMTP id 013DB181B0B; Thu, 27 Feb 2014 11:55:02 +0100 (CET) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at lockless.no Received: from mail.lockless.no ([127.0.0.1]) by localhost (mail.lockless.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id r297iNR9t1x5; Thu, 27 Feb 2014 11:55:02 +0100 (CET) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) by mail.lockless.no (Postfix) with ESMTPSA id ECE12181AF3; Thu, 27 Feb 2014 11:55:01 +0100 (CET) Message-ID: <530F197D.6040004@bitfrost.no> Date: Thu, 27 Feb 2014 11:54:53 +0100 From: Hans Petter Selasky Organization: Bitfrost A/S User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Kohji Okuno Subject: Re: kqueue for usb_dev References: <530EFEAD.2090502@bitfrost.no> <530F02CA.2030206@bitfrost.no> <20140227.190128.1827840697797583715.okuno.kohji@jp.panasonic.com> <20140227.193914.1745107579233813450.okuno.kohji@jp.panasonic.com> In-Reply-To: <20140227.193914.1745107579233813450.okuno.kohji@jp.panasonic.com> Content-Type: multipart/mixed; boundary="------------010206010003030103080803" Cc: jmg@funkthat.com, freebsd-current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 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: Thu, 27 Feb 2014 10:54:08 -0000 This is a multi-part message in MIME format. --------------010206010003030103080803 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 02/27/14 11:39, Kohji Okuno wrote: > Hi HPS and John-Mark, > > After I changed as the following, the kernel panic does not happen. > What do you think about this change? > > + knlist_clear(&f->selinfo.si_note, 0); > knlist_destroy(&f->selinfo.si_note); > > Regards, > Kohji Okuno > Can you try the attached patch instead? --HPS --------------010206010003030103080803 Content-Type: text/x-diff; name="usb_dev_knlist.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="usb_dev_knlist.diff" === usb_dev.c ================================================================== --- usb_dev.c (revision 262555) +++ usb_dev.c (local) @@ -561,8 +561,8 @@ return (0); } -void -usb_fifo_free(struct usb_fifo *f) +static void +usb_fifo_destroy(struct usb_fifo *f) { uint8_t n; @@ -618,7 +618,16 @@ /* take care of closing the device here, if any */ usb_fifo_close(f, 0); +} +static void +usb_fifo_free(struct usb_fifo *f) +{ + if (f == NULL) { + /* be NULL safe */ + return; + } + cv_destroy(&f->cv_io); cv_destroy(&f->cv_drain); @@ -1867,6 +1876,8 @@ f_rx = usb_fifo_alloc(priv_mtx); if ((f_tx == NULL) || (f_rx == NULL)) { + usb_fifo_destroy(f_tx); + usb_fifo_destroy(f_rx); usb_fifo_free(f_tx); usb_fifo_free(f_rx); return (ENOMEM); @@ -1989,6 +2000,13 @@ if (f_sc == NULL) { return; } + usb_fifo_destroy(f_sc->fp[USB_FIFO_TX]); + usb_fifo_destroy(f_sc->fp[USB_FIFO_RX]); + + usb_destroy_dev(f_sc->dev); + + f_sc->dev = NULL; + usb_fifo_free(f_sc->fp[USB_FIFO_TX]); usb_fifo_free(f_sc->fp[USB_FIFO_RX]); @@ -1995,10 +2013,6 @@ f_sc->fp[USB_FIFO_TX] = NULL; f_sc->fp[USB_FIFO_RX] = NULL; - usb_destroy_dev(f_sc->dev); - - f_sc->dev = NULL; - DPRINTFN(2, "detached %p\n", f_sc); } === usbdi.h ================================================================== --- usbdi.h (revision 262555) +++ usbdi.h (local) @@ -614,6 +614,5 @@ void *usb_fifo_softc(struct usb_fifo *fifo); void usb_fifo_set_close_zlp(struct usb_fifo *, uint8_t); void usb_fifo_set_write_defrag(struct usb_fifo *, uint8_t); -void usb_fifo_free(struct usb_fifo *f); #endif /* _KERNEL */ #endif /* _USB_USBDI_H_ */ --------------010206010003030103080803--