Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Jun 2011 17:29:41 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r223509 - in stable/8/sys: amd64/amd64 amd64/pci dev/acpica dev/pci i386/i386 i386/pci x86/x86
Message-ID:  <201106241729.p5OHTfii063846@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Jun 24 17:29:41 2011
New Revision: 223509
URL: http://svn.freebsd.org/changeset/base/223509

Log:
  MFC 221324,221324:
  Add implementations of BUS_ADJUST_RESOURCE() to the PCI bus driver,
  generic PCI-PCI bridge driver, x86 nexus driver, x86 Host to PCI bridge
  drivers, and the drivers that sit between the x86 Host-PCI bridge drivers
  and nexus.

Modified:
  stable/8/sys/amd64/amd64/legacy.c
  stable/8/sys/amd64/pci/pci_bus.c
  stable/8/sys/dev/acpica/acpi.c
  stable/8/sys/dev/acpica/acpi_pcib_acpi.c
  stable/8/sys/dev/pci/pci.c
  stable/8/sys/dev/pci/pci_pci.c
  stable/8/sys/i386/i386/legacy.c
  stable/8/sys/i386/pci/pci_bus.c
  stable/8/sys/x86/x86/mptable_pci.c
  stable/8/sys/x86/x86/nexus.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/amd64/amd64/legacy.c
==============================================================================
--- stable/8/sys/amd64/amd64/legacy.c	Fri Jun 24 16:35:40 2011	(r223508)
+++ stable/8/sys/amd64/amd64/legacy.c	Fri Jun 24 17:29:41 2011	(r223509)
@@ -80,6 +80,7 @@ static device_method_t legacy_methods[] 
 	DEVMETHOD(bus_read_ivar,	legacy_read_ivar),
 	DEVMETHOD(bus_write_ivar,	legacy_write_ivar),
 	DEVMETHOD(bus_alloc_resource,	bus_generic_alloc_resource),
+	DEVMETHOD(bus_adjust_resource,	bus_generic_adjust_resource),
 	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
 	DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
 	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),

Modified: stable/8/sys/amd64/pci/pci_bus.c
==============================================================================
--- stable/8/sys/amd64/pci/pci_bus.c	Fri Jun 24 16:35:40 2011	(r223508)
+++ stable/8/sys/amd64/pci/pci_bus.c	Fri Jun 24 17:29:41 2011	(r223509)
@@ -348,6 +348,7 @@ static device_method_t legacy_pcib_metho
 	DEVMETHOD(bus_read_ivar,	legacy_pcib_read_ivar),
 	DEVMETHOD(bus_write_ivar,	legacy_pcib_write_ivar),
 	DEVMETHOD(bus_alloc_resource,	legacy_pcib_alloc_resource),
+	DEVMETHOD(bus_adjust_resource,	bus_generic_adjust_resource),
 	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
 	DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
 	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),

Modified: stable/8/sys/dev/acpica/acpi.c
==============================================================================
--- stable/8/sys/dev/acpica/acpi.c	Fri Jun 24 16:35:40 2011	(r223508)
+++ stable/8/sys/dev/acpica/acpi.c	Fri Jun 24 17:29:41 2011	(r223509)
@@ -124,6 +124,8 @@ static int	acpi_sysres_alloc(device_t de
 static struct resource *acpi_alloc_resource(device_t bus, device_t child,
 			int type, int *rid, u_long start, u_long end,
 			u_long count, u_int flags);
+static int	acpi_adjust_resource(device_t bus, device_t child, int type,
+			struct resource *r, u_long start, u_long end);
 static int	acpi_release_resource(device_t bus, device_t child, int type,
 			int rid, struct resource *r);
 static void	acpi_delete_resource(device_t bus, device_t child, int type,
@@ -197,6 +199,7 @@ static device_method_t acpi_methods[] = 
     DEVMETHOD(bus_set_resource,		bus_generic_rl_set_resource),
     DEVMETHOD(bus_get_resource,		bus_generic_rl_get_resource),
     DEVMETHOD(bus_alloc_resource,	acpi_alloc_resource),
+    DEVMETHOD(bus_adjust_resource,	acpi_adjust_resource),
     DEVMETHOD(bus_release_resource,	acpi_release_resource),
     DEVMETHOD(bus_delete_resource,	acpi_delete_resource),
     DEVMETHOD(bus_child_pnpinfo_str,	acpi_child_pnpinfo_str_method),
@@ -1231,23 +1234,34 @@ out:
 }
 
 static int
-acpi_release_resource(device_t bus, device_t child, int type, int rid,
-    struct resource *r)
+acpi_is_resource_managed(int type, struct resource *r)
 {
-    struct rman *rm;
-    int ret;
 
     /* We only handle memory and IO resources through rman. */
     switch (type) {
     case SYS_RES_IOPORT:
-	rm = &acpi_rman_io;
-	break;
+	return (rman_is_region_manager(r, &acpi_rman_io));
     case SYS_RES_MEMORY:
-	rm = &acpi_rman_mem;
-	break;
-    default:
-	rm = NULL;
+	return (rman_is_region_manager(r, &acpi_rman_mem));
     }
+    return (0);
+}
+
+static int
+acpi_adjust_resource(device_t bus, device_t child, int type, struct resource *r,
+    u_long start, u_long end)
+{
+
+    if (acpi_is_resource_managed(type, r))
+	return (rman_adjust_resource(r, start, end));
+    return (bus_generic_adjust_resource(bus, child, type, r, start, end));
+}
+
+static int
+acpi_release_resource(device_t bus, device_t child, int type, int rid,
+    struct resource *r)
+{
+    int ret;
 
     ACPI_SERIAL_BEGIN(acpi);
 
@@ -1256,7 +1270,7 @@ acpi_release_resource(device_t bus, devi
      * deactivate it and release it to the local pool.  If it doesn't,
      * pass this request up to the parent.
      */
-    if (rm != NULL && rman_is_region_manager(r, rm)) {
+    if (acpi_is_resource_managed(type, r)) {
 	if (rman_get_flags(r) & RF_ACTIVE) {
 	    ret = bus_deactivate_resource(child, type, rid, r);
 	    if (ret != 0)

Modified: stable/8/sys/dev/acpica/acpi_pcib_acpi.c
==============================================================================
--- stable/8/sys/dev/acpica/acpi_pcib_acpi.c	Fri Jun 24 16:35:40 2011	(r223508)
+++ stable/8/sys/dev/acpica/acpi_pcib_acpi.c	Fri Jun 24 17:29:41 2011	(r223509)
@@ -100,6 +100,7 @@ static device_method_t acpi_pcib_acpi_me
     DEVMETHOD(bus_read_ivar,		acpi_pcib_read_ivar),
     DEVMETHOD(bus_write_ivar,		acpi_pcib_write_ivar),
     DEVMETHOD(bus_alloc_resource,	acpi_pcib_acpi_alloc_resource),
+    DEVMETHOD(bus_adjust_resource,	bus_generic_adjust_resource),
     DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
     DEVMETHOD(bus_activate_resource,	bus_generic_activate_resource),
     DEVMETHOD(bus_deactivate_resource,	bus_generic_deactivate_resource),

Modified: stable/8/sys/dev/pci/pci.c
==============================================================================
--- stable/8/sys/dev/pci/pci.c	Fri Jun 24 16:35:40 2011	(r223508)
+++ stable/8/sys/dev/pci/pci.c	Fri Jun 24 17:29:41 2011	(r223509)
@@ -142,6 +142,7 @@ static device_method_t pci_methods[] = {
 	DEVMETHOD(bus_get_resource,	bus_generic_rl_get_resource),
 	DEVMETHOD(bus_delete_resource,	pci_delete_resource),
 	DEVMETHOD(bus_alloc_resource,	pci_alloc_resource),
+	DEVMETHOD(bus_adjust_resource,	bus_generic_adjust_resource),
 	DEVMETHOD(bus_release_resource,	bus_generic_rl_release_resource),
 	DEVMETHOD(bus_activate_resource, pci_activate_resource),
 	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),

Modified: stable/8/sys/dev/pci/pci_pci.c
==============================================================================
--- stable/8/sys/dev/pci/pci_pci.c	Fri Jun 24 16:35:40 2011	(r223508)
+++ stable/8/sys/dev/pci/pci_pci.c	Fri Jun 24 17:29:41 2011	(r223509)
@@ -68,6 +68,7 @@ static device_method_t pcib_methods[] = 
     DEVMETHOD(bus_read_ivar,		pcib_read_ivar),
     DEVMETHOD(bus_write_ivar,		pcib_write_ivar),
     DEVMETHOD(bus_alloc_resource,	pcib_alloc_resource),
+    DEVMETHOD(bus_adjust_resource,	bus_generic_adjust_resource),
     DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
     DEVMETHOD(bus_activate_resource,	bus_generic_activate_resource),
     DEVMETHOD(bus_deactivate_resource,	bus_generic_deactivate_resource),

Modified: stable/8/sys/i386/i386/legacy.c
==============================================================================
--- stable/8/sys/i386/i386/legacy.c	Fri Jun 24 16:35:40 2011	(r223508)
+++ stable/8/sys/i386/i386/legacy.c	Fri Jun 24 17:29:41 2011	(r223509)
@@ -85,6 +85,7 @@ static device_method_t legacy_methods[] 
 	DEVMETHOD(bus_read_ivar,	legacy_read_ivar),
 	DEVMETHOD(bus_write_ivar,	legacy_write_ivar),
 	DEVMETHOD(bus_alloc_resource,	bus_generic_alloc_resource),
+	DEVMETHOD(bus_adjust_resource,	bus_generic_adjust_resource),
 	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
 	DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
 	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),

Modified: stable/8/sys/i386/pci/pci_bus.c
==============================================================================
--- stable/8/sys/i386/pci/pci_bus.c	Fri Jun 24 16:35:40 2011	(r223508)
+++ stable/8/sys/i386/pci/pci_bus.c	Fri Jun 24 17:29:41 2011	(r223509)
@@ -565,6 +565,7 @@ static device_method_t legacy_pcib_metho
 	DEVMETHOD(bus_read_ivar,	legacy_pcib_read_ivar),
 	DEVMETHOD(bus_write_ivar,	legacy_pcib_write_ivar),
 	DEVMETHOD(bus_alloc_resource,	legacy_pcib_alloc_resource),
+	DEVMETHOD(bus_adjust_resource,	bus_generic_adjust_resource),
 	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
 	DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
 	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),

Modified: stable/8/sys/x86/x86/mptable_pci.c
==============================================================================
--- stable/8/sys/x86/x86/mptable_pci.c	Fri Jun 24 16:35:40 2011	(r223508)
+++ stable/8/sys/x86/x86/mptable_pci.c	Fri Jun 24 17:29:41 2011	(r223509)
@@ -116,6 +116,7 @@ static device_method_t mptable_hostb_met
 	DEVMETHOD(bus_read_ivar,	legacy_pcib_read_ivar),
 	DEVMETHOD(bus_write_ivar,	legacy_pcib_write_ivar),
 	DEVMETHOD(bus_alloc_resource,	legacy_pcib_alloc_resource),
+	DEVMETHOD(bus_adjust_resource,	bus_generic_adjust_resource),
 	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
 	DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
 	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),

Modified: stable/8/sys/x86/x86/nexus.c
==============================================================================
--- stable/8/sys/x86/x86/nexus.c	Fri Jun 24 16:35:40 2011	(r223508)
+++ stable/8/sys/x86/x86/nexus.c	Fri Jun 24 17:29:41 2011	(r223509)
@@ -110,6 +110,8 @@ static device_t nexus_add_child(device_t
 				int unit);
 static	struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
 					      u_long, u_long, u_long, u_int);
+static	int nexus_adjust_resource(device_t, device_t, int, struct resource *,
+				  u_long, u_long);
 #ifdef SMP
 static	int nexus_bind_intr(device_t, device_t, struct resource *, int);
 #endif
@@ -154,6 +156,7 @@ static device_method_t nexus_methods[] =
 	DEVMETHOD(bus_print_child,	nexus_print_child),
 	DEVMETHOD(bus_add_child,	nexus_add_child),
 	DEVMETHOD(bus_alloc_resource,	nexus_alloc_resource),
+	DEVMETHOD(bus_adjust_resource,	nexus_adjust_resource),
 	DEVMETHOD(bus_release_resource,	nexus_release_resource),
 	DEVMETHOD(bus_activate_resource, nexus_activate_resource),
 	DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
@@ -342,6 +345,23 @@ nexus_add_child(device_t bus, u_int orde
 	return(child);
 }
 
+static struct rman *
+nexus_rman(int type)
+{
+	switch (type) {
+	case SYS_RES_IRQ:
+		return (&irq_rman);
+	case SYS_RES_DRQ:
+		return (&drq_rman);
+	case SYS_RES_IOPORT:
+		return (&port_rman);
+	case SYS_RES_MEMORY:
+		return (&mem_rman);
+	default:
+		return (NULL);
+	}
+}
+
 /*
  * Allocate a resource on behalf of child.  NB: child is usually going to be a
  * child of one of our descendants, not a direct child of nexus0.
@@ -374,27 +394,9 @@ nexus_alloc_resource(device_t bus, devic
 	}
 
 	flags &= ~RF_ACTIVE;
-
-	switch (type) {
-	case SYS_RES_IRQ:
-		rm = &irq_rman;
-		break;
-
-	case SYS_RES_DRQ:
-		rm = &drq_rman;
-		break;
-
-	case SYS_RES_IOPORT:
-		rm = &port_rman;
-		break;
-
-	case SYS_RES_MEMORY:
-		rm = &mem_rman;
-		break;
-
-	default:
-		return 0;
-	}
+	rm = nexus_rman(type);
+	if (rm == NULL)
+		return (NULL);
 
 	rv = rman_reserve_resource(rm, start, end, count, flags, child);
 	if (rv == 0)
@@ -412,6 +414,20 @@ nexus_alloc_resource(device_t bus, devic
 }
 
 static int
+nexus_adjust_resource(device_t bus, device_t child, int type,
+    struct resource *r, u_long start, u_long end)
+{
+	struct rman *rm;
+
+	rm = nexus_rman(type);
+	if (rm == NULL)
+		return (ENXIO);
+	if (!rman_is_region_manager(r, rm))
+		return (EINVAL);
+	return (rman_adjust_resource(r, start, end));
+}
+
+static int
 nexus_activate_resource(device_t bus, device_t child, int type, int rid,
 			struct resource *r)
 {



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