Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Sep 2014 20:34:19 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r271484 - in head/sys/arm: arm xscale/ixp425
Message-ID:  <201409122034.s8CKYJSv046534@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Sep 12 20:34:19 2014
New Revision: 271484
URL: http://svnweb.freebsd.org/changeset/base/271484

Log:
  - Don't let rman_reserve_resource() activate the resource in
    nexus_alloc_resource() and don't set a bushandle.
    nexus_activate_resource() will set a proper bushandle.
  - Implement a proper nexus_release_resource().
  - Fix ixppcib_activate_resource() to call rman_activate_resource()
    before creating a mapping for the resource.
  
  Tested by:	jmg

Modified:
  head/sys/arm/arm/nexus.c
  head/sys/arm/xscale/ixp425/ixp425_pci.c

Modified: head/sys/arm/arm/nexus.c
==============================================================================
--- head/sys/arm/arm/nexus.c	Fri Sep 12 20:16:55 2014	(r271483)
+++ head/sys/arm/arm/nexus.c	Fri Sep 12 20:34:19 2014	(r271484)
@@ -90,6 +90,8 @@ static int nexus_config_intr(device_t de
     enum intr_polarity pol);
 static	int nexus_deactivate_resource(device_t, device_t, int, int,
     struct resource *);
+static int nexus_release_resource(device_t, device_t, int, int,
+    struct resource *);
 
 static int nexus_setup_intr(device_t dev, device_t child, struct resource *res,
     int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep);
@@ -111,6 +113,7 @@ static device_method_t nexus_methods[] =
 	DEVMETHOD(bus_activate_resource,	nexus_activate_resource),
 	DEVMETHOD(bus_config_intr,	nexus_config_intr),
 	DEVMETHOD(bus_deactivate_resource,	nexus_deactivate_resource),
+	DEVMETHOD(bus_release_resource,	nexus_release_resource),
 	DEVMETHOD(bus_setup_intr,	nexus_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	nexus_teardown_intr),
 #ifdef FDT
@@ -205,6 +208,8 @@ nexus_alloc_resource(device_t bus, devic
 	struct rman *rm;
 	int needactivate = flags & RF_ACTIVE;
 
+	flags &= ~RF_ACTIVE;
+
 	switch (type) {
 	case SYS_RES_MEMORY:
 	case SYS_RES_IOPORT:
@@ -212,15 +217,14 @@ nexus_alloc_resource(device_t bus, devic
 		break;
 
 	default:
-		return (0);
+		return (NULL);
 	}
 
 	rv = rman_reserve_resource(rm, start, end, count, flags, child);
 	if (rv == 0)
-		return (0);
+		return (NULL);
 
 	rman_set_rid(rv, *rid);
-	rman_set_bushandle(rv, rman_get_start(rv));
 
 	if (needactivate) {
 		if (bus_activate_resource(child, type, *rid, rv)) {
@@ -233,6 +237,20 @@ nexus_alloc_resource(device_t bus, devic
 }
 
 static int
+nexus_release_resource(device_t bus, device_t child, int type, int rid,
+    struct resource *res)
+{
+	int error;
+	
+	if (rman_get_flags(res) & RF_ACTIVE) {
+		error = bus_deactivate_resource(child, type, rid, res);
+		if (error)
+			return (error);
+	}
+	return (rman_release_resource(res));
+}
+
+static int
 nexus_config_intr(device_t dev, int irq, enum intr_trigger trig,
     enum intr_polarity pol)
 {

Modified: head/sys/arm/xscale/ixp425/ixp425_pci.c
==============================================================================
--- head/sys/arm/xscale/ixp425/ixp425_pci.c	Fri Sep 12 20:16:55 2014	(r271483)
+++ head/sys/arm/xscale/ixp425/ixp425_pci.c	Fri Sep 12 20:34:19 2014	(r271484)
@@ -320,9 +320,12 @@ static int
 ixppcib_activate_resource(device_t bus, device_t child, int type, int rid,
     struct resource *r)
 {
-
 	struct ixppcib_softc *sc = device_get_softc(bus);
+	int error;
 
+	error = rman_activate_resource(r);
+	if (error)
+		return (error);
 	switch (type) {
 	case SYS_RES_IOPORT:
 		rman_set_bustag(r, &sc->sc_pci_iot);
@@ -335,7 +338,7 @@ ixppcib_activate_resource(device_t bus, 
 		break;
 	}
 		
-	return (rman_activate_resource(r));
+	return (0);
 }
 
 static int



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