Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Nov 2018 03:43:10 +0000 (UTC)
From:      "Jayachandran C." <jchandra@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r340601 - head/sys/dev/pci
Message-ID:  <201811190343.wAJ3hAdN039226@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jchandra
Date: Mon Nov 19 03:43:10 2018
New Revision: 340601
URL: https://svnweb.freebsd.org/changeset/base/340601

Log:
  pci_host_generic : move activate/release to generic code
  
  Now that the ACPI and FDT implementations for activating and
  deactivating resources are the same, we can move it to
  pci_host_generic.c.  No functional changes.
  
  Reviewed by:	andrew
  Differential Revision:	https://reviews.freebsd.org/D17793

Modified:
  head/sys/dev/pci/pci_host_generic.c
  head/sys/dev/pci/pci_host_generic_acpi.c
  head/sys/dev/pci/pci_host_generic_fdt.c

Modified: head/sys/dev/pci/pci_host_generic.c
==============================================================================
--- head/sys/dev/pci/pci_host_generic.c	Mon Nov 19 03:34:15 2018	(r340600)
+++ head/sys/dev/pci/pci_host_generic.c	Mon Nov 19 03:43:10 2018	(r340601)
@@ -341,6 +341,82 @@ fail:
 }
 
 static int
+generic_pcie_activate_resource(device_t dev, device_t child, int type,
+    int rid, struct resource *r)
+{
+	struct generic_pcie_core_softc *sc;
+	uint64_t phys_base;
+	uint64_t pci_base;
+	uint64_t size;
+	int found;
+	int res;
+	int i;
+
+	sc = device_get_softc(dev);
+
+	if ((res = rman_activate_resource(r)) != 0)
+		return (res);
+
+	switch (type) {
+	case SYS_RES_IOPORT:
+		found = 0;
+		for (i = 0; i < MAX_RANGES_TUPLES; i++) {
+			pci_base = sc->ranges[i].pci_base;
+			phys_base = sc->ranges[i].phys_base;
+			size = sc->ranges[i].size;
+
+			if ((rid > pci_base) && (rid < (pci_base + size))) {
+				found = 1;
+				break;
+			}
+		}
+		if (found) {
+			rman_set_start(r, rman_get_start(r) + phys_base);
+			rman_set_end(r, rman_get_end(r) + phys_base);
+			res = BUS_ACTIVATE_RESOURCE(device_get_parent(dev),
+			    child, type, rid, r);
+		} else {
+			device_printf(dev,
+			    "Failed to activate IOPORT resource\n");
+			res = 0;
+		}
+		break;
+	case SYS_RES_MEMORY:
+	case SYS_RES_IRQ:
+		res = BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child,
+		    type, rid, r);
+		break;
+	default:
+		break;
+	}
+
+	return (res);
+}
+
+static int
+generic_pcie_deactivate_resource(device_t dev, device_t child, int type,
+    int rid, struct resource *r)
+{
+	int res;
+
+	if ((res = rman_deactivate_resource(r)) != 0)
+		return (res);
+
+	switch (type) {
+	case SYS_RES_IOPORT:
+	case SYS_RES_MEMORY:
+	case SYS_RES_IRQ:
+		res = BUS_DEACTIVATE_RESOURCE(device_get_parent(dev), child,
+		    type, rid, r);
+		break;
+	default:
+		break;
+	}
+
+	return (res);
+}
+
+static int
 generic_pcie_adjust_resource(device_t dev, device_t child, int type,
     struct resource *res, rman_res_t start, rman_res_t end)
 {
@@ -375,6 +451,8 @@ static device_method_t generic_pcie_methods[] = {
 	DEVMETHOD(bus_write_ivar,		generic_pcie_write_ivar),
 	DEVMETHOD(bus_alloc_resource,		pci_host_generic_core_alloc_resource),
 	DEVMETHOD(bus_adjust_resource,		generic_pcie_adjust_resource),
+	DEVMETHOD(bus_activate_resource,	generic_pcie_activate_resource),
+	DEVMETHOD(bus_deactivate_resource,	generic_pcie_deactivate_resource),
 	DEVMETHOD(bus_release_resource,		pci_host_generic_core_release_resource),
 	DEVMETHOD(bus_setup_intr,		bus_generic_setup_intr),
 	DEVMETHOD(bus_teardown_intr,		bus_generic_teardown_intr),

Modified: head/sys/dev/pci/pci_host_generic_acpi.c
==============================================================================
--- head/sys/dev/pci/pci_host_generic_acpi.c	Mon Nov 19 03:34:15 2018	(r340600)
+++ head/sys/dev/pci/pci_host_generic_acpi.c	Mon Nov 19 03:43:10 2018	(r340601)
@@ -348,86 +348,7 @@ generic_pcie_acpi_route_interrupt(device_t bus, device
 	return (acpi_pcib_route_interrupt(bus, dev, pin, &sc->ap_prt));
 }
 
-/*
- * Follow logic of FDT activate
- */
 static int
-generic_pcie_acpi_activate_resource(device_t dev, device_t child, int type,
-    int rid, struct resource *r)
-{
-	struct generic_pcie_acpi_softc *sc;
-	uint64_t phys_base;
-	uint64_t pci_base;
-	uint64_t size;
-	int found;
-	int res;
-	int i;
-
-	sc = device_get_softc(dev);
-
-	if ((res = rman_activate_resource(r)) != 0)
-		return (res);
-
-	switch (type) {
-	case SYS_RES_IOPORT:
-		found = 0;
-		for (i = 0; i < MAX_RANGES_TUPLES; i++) {
-			pci_base = sc->base.ranges[i].pci_base;
-			phys_base = sc->base.ranges[i].phys_base;
-			size = sc->base.ranges[i].size;
-
-			if ((rid > pci_base) && (rid < (pci_base + size))) {
-				found = 1;
-				break;
-			}
-		}
-		if (found) {
-			rman_set_start(r, rman_get_start(r) + phys_base);
-			rman_set_end(r, rman_get_end(r) + phys_base);
-			res = BUS_ACTIVATE_RESOURCE(device_get_parent(dev),
-			    child, type, rid, r);
-		} else {
-			device_printf(dev,
-			    "Failed to activate IOPORT resource\n");
-			res = 0;
-		}
-		break;
-	case SYS_RES_MEMORY:
-	case SYS_RES_IRQ:
-		res = BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child,
-		    type, rid, r);
-		break;
-	default:
-		break;
-	}
-
-	return (res);
-}
-
-static int
-generic_pcie_acpi_deactivate_resource(device_t dev, device_t child, int type,
-    int rid, struct resource *r)
-{
-	int res;
-
-	if ((res = rman_deactivate_resource(r)) != 0)
-		return (res);
-
-	switch (type) {
-	case SYS_RES_IOPORT:
-	case SYS_RES_MEMORY:
-	case SYS_RES_IRQ:
-		res = BUS_DEACTIVATE_RESOURCE(device_get_parent(dev), child,
-		    type, rid, r);
-		break;
-	default:
-		break;
-	}
-
-	return (res);
-}
-
-static int
 generic_pcie_acpi_alloc_msi(device_t pci, device_t child, int count,
     int maxcount, int *irqs)
 {
@@ -507,8 +428,6 @@ static device_method_t generic_pcie_acpi_methods[] = {
 	DEVMETHOD(device_probe,		generic_pcie_acpi_probe),
 	DEVMETHOD(device_attach,	pci_host_generic_acpi_attach),
 	DEVMETHOD(bus_read_ivar,	generic_pcie_acpi_read_ivar),
-	DEVMETHOD(bus_activate_resource, generic_pcie_acpi_activate_resource),
-	DEVMETHOD(bus_deactivate_resource,generic_pcie_acpi_deactivate_resource),
 
 	/* pcib interface */
 	DEVMETHOD(pcib_route_interrupt,	generic_pcie_acpi_route_interrupt),

Modified: head/sys/dev/pci/pci_host_generic_fdt.c
==============================================================================
--- head/sys/dev/pci/pci_host_generic_fdt.c	Mon Nov 19 03:34:15 2018	(r340600)
+++ head/sys/dev/pci/pci_host_generic_fdt.c	Mon Nov 19 03:43:10 2018	(r340601)
@@ -385,82 +385,6 @@ pci_host_generic_alloc_resource(device_t dev, device_t
 }
 
 static int
-generic_pcie_fdt_activate_resource(device_t dev, device_t child, int type,
-    int rid, struct resource *r)
-{
-	struct generic_pcie_fdt_softc *sc;
-	uint64_t phys_base;
-	uint64_t pci_base;
-	uint64_t size;
-	int found;
-	int res;
-	int i;
-
-	sc = device_get_softc(dev);
-
-	if ((res = rman_activate_resource(r)) != 0)
-		return (res);
-
-	switch(type) {
-	case SYS_RES_IOPORT:
-		found = 0;
-		for (i = 0; i < MAX_RANGES_TUPLES; i++) {
-			pci_base = sc->base.ranges[i].pci_base;
-			phys_base = sc->base.ranges[i].phys_base;
-			size = sc->base.ranges[i].size;
-
-			if ((rid > pci_base) && (rid < (pci_base + size))) {
-				found = 1;
-				break;
-			}
-		}
-		if (found) {
-			rman_set_start(r, rman_get_start(r) + phys_base);
-			rman_set_end(r, rman_get_end(r) + phys_base);
-			res = BUS_ACTIVATE_RESOURCE(device_get_parent(dev),
-			    child, type, rid, r);
-		} else {
-			device_printf(dev,
-			    "Failed to activate IOPORT resource\n");
-			res = 0;
-		}
-		break;
-	case SYS_RES_MEMORY:
-	case SYS_RES_IRQ:
-		res = BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child,
-		    type, rid, r);
-		break;
-	default:
-		break;
-	}
-
-	return (res);
-}
-
-static int
-generic_pcie_fdt_deactivate_resource(device_t dev, device_t child, int type,
-    int rid, struct resource *r)
-{
-	int res;
-
-	if ((res = rman_deactivate_resource(r)) != 0)
-		return (res);
-
-	switch(type) {
-	case SYS_RES_IOPORT:
-	case SYS_RES_MEMORY:
-	case SYS_RES_IRQ:
-		res = BUS_DEACTIVATE_RESOURCE(device_get_parent(dev), child,
-		    type, rid, r);
-		break;
-	default:
-		break;
-	}
-
-	return (res);
-}
-
-static int
 generic_pcie_fdt_alloc_msi(device_t pci, device_t child, int count,
     int maxcount, int *irqs)
 {
@@ -630,8 +554,6 @@ static device_method_t generic_pcie_fdt_methods[] = {
 	DEVMETHOD(device_attach,	pci_host_generic_attach),
 	DEVMETHOD(bus_alloc_resource,	pci_host_generic_alloc_resource),
 	DEVMETHOD(bus_release_resource,	generic_pcie_fdt_release_resource),
-	DEVMETHOD(bus_activate_resource, generic_pcie_fdt_activate_resource),
-	DEVMETHOD(bus_deactivate_resource,generic_pcie_fdt_deactivate_resource),
 
 	/* pcib interface */
 	DEVMETHOD(pcib_route_interrupt,	generic_pcie_fdt_route_interrupt),



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