From owner-svn-src-stable-12@freebsd.org Sat Oct 31 16:18:56 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2D0A04503B2; Sat, 31 Oct 2020 16:18:56 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNkrc0Nspz4dWH; Sat, 31 Oct 2020 16:18:56 +0000 (UTC) (envelope-from mmel@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 E556AA598; Sat, 31 Oct 2020 16:18:55 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09VGItlf030636; Sat, 31 Oct 2020 16:18:55 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VGItr5030635; Sat, 31 Oct 2020 16:18:55 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311618.09VGItr5030635@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 16:18:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367219 - stable/12/sys/dev/pci X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/dev/pci X-SVN-Commit-Revision: 367219 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 16:18:56 -0000 Author: mmel Date: Sat Oct 31 16:18:55 2020 New Revision: 367219 URL: https://svnweb.freebsd.org/changeset/base/367219 Log: MFC r362387: Improve DesignWare PCIe driver: - only normal memory window is mandatory, prefetchable memory and I/O windows should be optional - full PCIe configuration space is supported - remove duplicated check from function for accessing configuration space. It is already contained in pci_dw_check_dev() Modified: stable/12/sys/dev/pci/pci_dw.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/pci/pci_dw.c ============================================================================== --- stable/12/sys/dev/pci/pci_dw.c Sat Oct 31 16:15:19 2020 (r367218) +++ stable/12/sys/dev/pci/pci_dw.c Sat Oct 31 16:18:55 2020 (r367219) @@ -156,7 +156,7 @@ pci_dw_check_dev(struct pci_dw_softc *sc, u_int bus, u int rv; if (bus < sc->bus_start || bus > sc->bus_end || slot > PCI_SLOTMAX || - func > PCI_FUNCMAX || reg > PCI_REGMAX) + func > PCI_FUNCMAX || reg > PCIE_REGMAX) return (false); /* link is needed for access to all non-root busses */ @@ -234,7 +234,7 @@ pci_dw_setup_hw(struct pci_dw_softc *sc) return (rv); /* If we have enouht viewports ..*/ - if (sc->num_viewport >= 3) { + if (sc->num_viewport >= 3 && sc->io_range.size != 0) { /* Setup outbound I/O window */ rv = pci_dw_map_out_atu(sc, 0, IATU_CTRL1_TYPE_MEM, sc->io_range.host, sc->io_range.pci, sc->io_range.size); @@ -345,7 +345,7 @@ pci_dw_decode_ranges(struct pci_dw_softc *sc, struct o } } } - if ((sc->io_range.size == 0) || (sc->mem_range.size == 0)) { + if (sc->mem_range.size == 0) { device_printf(sc->dev, " Not all required ranges are found in DT\n"); return (ENXIO); @@ -375,10 +375,6 @@ pci_dw_read_config(device_t dev, u_int bus, u_int slot if (!pci_dw_check_dev(sc, bus, slot, func, reg)) return (0xFFFFFFFFU); - if ((slot > PCI_SLOTMAX) || (func > PCI_FUNCMAX) || - (reg > PCI_REGMAX)) - return (0xFFFFFFFFU); - if (bus == sc->root_bus) { res = (sc->dbi_res); } else { @@ -424,10 +420,6 @@ pci_dw_write_config(device_t dev, u_int bus, u_int slo sc = device_get_softc(dev); if (!pci_dw_check_dev(sc, bus, slot, func, reg)) - return; - - if ((slot > PCI_SLOTMAX) || (func > PCI_FUNCMAX) || - (reg > PCI_REGMAX)) return; if (bus == sc->root_bus) {