From owner-svn-src-head@freebsd.org Mon Jul 31 20:35:48 2017 Return-Path: Delivered-To: svn-src-head@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 AEB31DBD1CE; Mon, 31 Jul 2017 20:35:48 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (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 8CE5B678D4; Mon, 31 Jul 2017 20:35:48 +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 0149210AF01; Mon, 31 Jul 2017 16:35:42 -0400 (EDT) From: John Baldwin To: Alexander Motin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r321720 - head/sys/dev/ichwd Date: Mon, 31 Jul 2017 10:13:56 -0700 Message-ID: <21813108.1FpTYCymMM@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: <201707301519.v6UFJ7AT004183@repo.freebsd.org> References: <201707301519.v6UFJ7AT004183@repo.freebsd.org> 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); Mon, 31 Jul 2017 16:35:42 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Jul 2017 20:35:48 -0000 On Sunday, July 30, 2017 03:19:07 PM Alexander Motin wrote: > Author: mav > Date: Sun Jul 30 15:19:07 2017 > New Revision: 321720 > URL: https://svnweb.freebsd.org/changeset/base/321720 > > Log: > Attach ichwd(4) only to ISA bus of the LPC bridge. > > Resource allocation for parent device does not look good by itself, but > attempt to allocate them for unrelated device just does not end up good. > On Asus X99-E WS/USB3.1 system reporting ISA bridge via both PCI and ACPI > this reported to cause kernel panic on shutdown due to messed resources: > https://bugs.freenas.org/issues/25237. > > MFC after: 1 week > > Modified: > head/sys/dev/ichwd/ichwd.c > > Modified: head/sys/dev/ichwd/ichwd.c > ============================================================================== > --- head/sys/dev/ichwd/ichwd.c Sun Jul 30 11:50:16 2017 (r321719) > +++ head/sys/dev/ichwd/ichwd.c Sun Jul 30 15:19:07 2017 (r321720) > @@ -533,23 +533,26 @@ ichwd_event(void *arg, unsigned int cmd, int *error) > } > > static device_t > -ichwd_find_ich_lpc_bridge(struct ichwd_device **id_p) > +ichwd_find_ich_lpc_bridge(device_t isa, struct ichwd_device **id_p) > { > struct ichwd_device *id; > - device_t ich = NULL; > + device_t isab; > + uint16_t devid; > > - /* look for an ICH LPC interface bridge */ > - for (id = ichwd_devices; id->desc != NULL; ++id) > - if ((ich = pci_find_device(VENDORID_INTEL, id->device)) != NULL) > - break; > - > - if (ich == NULL) > + /* Check whether parent ISA bridge looks familiar. */ > + isab = device_get_parent(isa); > + if (pci_get_vendor(isab) != VENDORID_INTEL) > return (NULL); You probably need to do slightly more work to verify that the isab device is a PCI child before you use pci_get_vendor(). I believe isa0 can be a child of legacy0 for example (though I doubt we run on such hardware without PCI anymore). Seeing if the devclass of device_get_parent(isab) == devclass_find("pci") would be sufficient. It might also be nice to add a 'device_is_pci()' helper function as I think we probably have a similar check in some other places. The general change is definitely an improvement though. -- John Baldwin