Only set bus tag/handles in activate_resource() methods

John Baldwin jhb at freebsd.org
Thu Dec 20 11:55:14 PST 2007


This patch (untested) tries to fix an issue on powerpc I fixed on the
ACPI-using platforms a while back.  It fixes the top-level bus drivers to
activate resources (assign bus tags and handles so you can use bus_space_*())
in bus_activate_resource() methods instead of in bus_alloc_resource().  This
is important for any drivers that want do what ACPI does: allocate a resource
and then subdivide it to hand it out to child devices.  A driver that does
this can still pass the bus_activate_resource() request up the tree to
actually bet bus_space setup with this fix.

--- //depot/vendor/freebsd/src/sys/powerpc/powermac/grackle.c	2007/12/19 18:06:08
+++ //depot/user/jhb/acpipci/powerpc/powermac/grackle.c	2007/12/20 18:53:20
@@ -398,8 +398,6 @@
 	}
 
 	rman_set_rid(rv, *rid);
-	rman_set_bustag(rv, &bs_le_tag);
-	rman_set_bushandle(rv, rman_get_start(rv));
 
 	if (needactivate) {
 		if (bus_activate_resource(child, type, *rid, rv) != 0) {
@@ -459,6 +457,7 @@
 			return (ENOMEM);
 
 		rman_set_virtual(res, p);
+		rman_set_bustag(rv, &bs_le_tag);
 		rman_set_bushandle(res, (u_long)p);
 	}
 
--- //depot/vendor/freebsd/src/sys/powerpc/powermac/macio.c	2007/12/19 18:06:08
+++ //depot/user/jhb/acpipci/powerpc/powermac/macio.c	2007/12/20 18:42:26
@@ -445,8 +445,6 @@
 	}
 
 	rman_set_rid(rv, *rid);
-	rman_set_bustag(rv, &bs_le_tag);
-	rman_set_bushandle(rv, rman_get_start(rv));
 
 	if (needactivate) {
 		if (bus_activate_resource(child, type, *rid, rv) != 0) {
@@ -494,6 +492,7 @@
 		if (p == NULL)
 			return (ENOMEM);
 		rman_set_virtual(res, p);
+		rman_set_bustag(rv, &bs_le_tag);
 		rman_set_bushandle(res, (u_long)p);
 	}
 
--- //depot/vendor/freebsd/src/sys/powerpc/powermac/uninorth.c	2007/12/19 18:06:08
+++ //depot/user/jhb/acpipci/powerpc/powermac/uninorth.c	2007/12/20 18:42:26
@@ -382,8 +382,6 @@
 	}
 
 	rman_set_rid(rv, *rid);
-	rman_set_bustag(rv, &bs_le_tag);
-	rman_set_bushandle(rv, rman_get_start(rv));
 
 	if (needactivate) {
 		if (bus_activate_resource(child, type, *rid, rv) != 0) {
@@ -429,6 +427,7 @@
 		if (p == NULL)
 			return (ENOMEM);
 		rman_set_virtual(res, p);
+		rman_set_bustag(rv, &bs_le_tag);
 		rman_set_bushandle(res, (u_long)p);
 	}
 
--- //depot/vendor/freebsd/src/sys/powerpc/psim/iobus.c	2007/12/19 18:06:08
+++ //depot/user/jhb/acpipci/powerpc/psim/iobus.c	2007/12/20 18:42:26
@@ -339,8 +339,6 @@
 	}
 
 	rman_set_rid(rv, *rid);
-	rman_set_bustag(rv, &bs_le_tag);
-	rman_set_bushandle(rv, rman_get_start(rv));
 
 	if (needactivate) {
 		if (bus_activate_resource(child, type, *rid, rv) != 0) {
@@ -388,6 +386,7 @@
 		if (p == NULL)
 			return (ENOMEM);
 		rman_set_virtual(res, p);
+		rman_set_bustag(rv, &bs_le_tag);
 		rman_set_bushandle(res, (u_long)p);
 	}
 

-- 
John Baldwin


More information about the freebsd-ppc mailing list