From owner-freebsd-drivers@freebsd.org Tue Aug 15 14:59:09 2017 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 61B55DD90EB for ; Tue, 15 Aug 2017 14:59:09 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 40DCA72D6F for ; Tue, 15 Aug 2017 14:59:09 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 437F510AF07; Tue, 15 Aug 2017 10:59:07 -0400 (EDT) From: John Baldwin To: freebsd-drivers@freebsd.org Subject: Re: Driver crash detaches entire PCI bus? Date: Tue, 15 Aug 2017 07:59:03 -0700 Message-ID: <3743762.5XtXr8DZrt@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Tue, 15 Aug 2017 10:59:07 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Aug 2017 14:59:09 -0000 On Thursday, August 03, 2017 09:52:54 PM Farhan Khan wrote: > Hi all, I am trying to write the Realtek 8188e (pci) driver for FreeBSD. I > am > making slow incremental progress, and having the driver safely exit out (as > opposed to a segfault). I noticed that when the device detaches, due to an > error > in the driver, the entire pci bus will also detach! For example, here is my > kernel output: > > rtwn0: rtwn_load_firmware: failed to upload firmware rtwn-rtl8188eefw > (error 60) > rtwn0: detached > pci2: detached > > The first line is where the code crashes: sys/dev/rtwn/if_rtwn_fw.c line 129 > https://github.com/khanzf/freebsd/blob/103c05369b1ced770a2cadc9468e0134c8d9421b/sys/dev/rtwn/if_rtwn_fw.c#L129 > > Why would this result in the entire pci2 bus detatching? Strangely enough, > I did > not have this problem a few months ago, then it suddenly began. This is > significantly slowing down my workflow, and would be nice to have it > resolved. > Otherwise, I have to reboot to bring pci2 back up. You should be able to 'devctl attach pci2' I think without having to reboot. I would perhaps use dtrace to figure out why the PCI bus is detaching by just doing something like 'dtrace -n 'fbt::pci_detach:entry { stack(); }' to get a stack trace when pci_detach is called. We might be able to figure out the bug from there. -- John Baldwin