Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Oct 2020 16:18:55 +0000 (UTC)
From:      Michal Meloun <mmel@FreeBSD.org>
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
Message-ID:  <202010311618.09VGItr5030635@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010311618.09VGItr5030635>