From owner-svn-src-all@freebsd.org Fri Jan 19 22:22:04 2018 Return-Path: Delivered-To: svn-src-all@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 18A94ECC02F; Fri, 19 Jan 2018 22:22:04 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E7E0B791AE; Fri, 19 Jan 2018 22:22:03 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 438CF13856; Fri, 19 Jan 2018 22:22:03 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0JMM3P3042432; Fri, 19 Jan 2018 22:22:03 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0JMM3gk042431; Fri, 19 Jan 2018 22:22:03 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201801192222.w0JMM3gk042431@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Fri, 19 Jan 2018 22:22:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328180 - head/sys/dev/bhnd/bhndb X-SVN-Group: head X-SVN-Commit-Author: landonf X-SVN-Commit-Paths: head/sys/dev/bhnd/bhndb X-SVN-Commit-Revision: 328180 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jan 2018 22:22:04 -0000 Author: landonf Date: Fri Jan 19 22:22:02 2018 New Revision: 328180 URL: https://svnweb.freebsd.org/changeset/base/328180 Log: bhndb_pci(4): Implement bridge support for CardBus-attached devices. - Extend the probe method to accept devclasses that inherit from the pci devclass (e.g. cardbus). - Some BCM4306-based CardBus adapters appear to advertise 4K SPROM, but only the first 2K is mapped into BAR0. We can safely assume that the SPROM data fits within the first 2K of the SPROM, rather than rejecting the SPROM mapping as invalid. Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/bhndb/bhndb_pci.c Modified: head/sys/dev/bhnd/bhndb/bhndb_pci.c ============================================================================== --- head/sys/dev/bhnd/bhndb/bhndb_pci.c Fri Jan 19 22:19:50 2018 (r328179) +++ head/sys/dev/bhnd/bhndb/bhndb_pci.c Fri Jan 19 22:22:02 2018 (r328180) @@ -264,8 +264,8 @@ bhndb_pci_probe(device_t dev) struct bhndb_pci_probe *probe; struct bhndb_pci_core *entry; bhnd_devclass_t hostb_devclass; - device_t parent; - devclass_t parent_bus, pci; + device_t parent, parent_bus; + devclass_t pci, bus_devclass; int error; probe = NULL; @@ -273,9 +273,20 @@ bhndb_pci_probe(device_t dev) /* Our parent must be a PCI/PCIe device. */ pci = devclass_find("pci"); parent = device_get_parent(dev); - parent_bus = device_get_devclass(device_get_parent(parent)); + parent_bus = device_get_parent(parent); + if (parent_bus == NULL) + return (ENXIO); - if (parent_bus != pci) + /* The bus device class may inherit from 'pci' */ + for (bus_devclass = device_get_devclass(parent_bus); + bus_devclass != NULL; + bus_devclass = devclass_get_parent(bus_devclass)) + { + if (bus_devclass == pci) + break; + } + + if (bus_devclass != pci) return (ENXIO); /* Enable clocks */ @@ -629,12 +640,10 @@ bhndb_pci_sprom_size(struct bhndb_pci_softc *sc) return (0); } - if (sprom_sz > sprom_win->win_size) { - device_printf(sc->dev, - "PCI sprom size (0x%x) overruns defined register window\n", - sctl); - return (0); - } + /* If the device has a larger SPROM than can be addressed via our SPROM + * register window, the SPROM image data will still be located within + * the window's addressable range */ + sprom_sz = MIN(sprom_sz, sprom_win->win_size); return (sprom_sz); }