Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Jul 2007 17:20:04 GMT
From:      Maxim Zhuravlev <thioretic@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 123542 for review
Message-ID:  <200707151720.l6FHK492012548@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=123542

Change 123542 by thioretic@thioretic on 2007/07/15 17:19:41

	TODO: some cleanups, locking and IO requests handling.
	DONE: resource_* and bus_generic_* stuff.

Affected files ...

.. //depot/projects/soc2007/thioretic_gidl/TODO#14 edit
.. //depot/projects/soc2007/thioretic_gidl/kern/subr_bus.c#15 edit

Differences ...

==== //depot/projects/soc2007/thioretic_gidl/TODO#14 (text+ko) ====

@@ -135,4 +135,11 @@
 		# probed/attached/.. driver. If driver to be set to is DR_LOWEST not equal
 		# to that already in stack or is NULL, the whole driver configuration is
 		# destroyed. Device won't process any i/o requests till its state is set
-		# to DS_ATTACHED (i.e. there is no DS_RAW or other drivers in stack).+		# to DS_ATTACHED (i.e. there is no DS_RAW or other drivers in stack).
+	a.1.6 resorce_* and bus_generic_*
+		SOLUTION: use is_devie_parent() and deviec_get_parent() instead of using
+			dev->parent;
+		FILE(S) AFFECTED: kern/subr_bus.c
+		# I'm unsure about what to do with those, who have more than a single parent.
+		# Although it's highly unlikely that any devices, which have multiple parents
+		# (functional devices) will use the api. 
==== //depot/projects/soc2007/thioretic_gidl/kern/subr_bus.c#15 (text+ko) ====

@@ -1201,6 +1201,18 @@
 	return(FALSE);
 }
 
+static int
+is_device_parent (device_t dev, device_t parent){
+	devicelink_t dl;
+	if (TAILQ_EMPTY(&dev->parents))
+		return (FALSE);
+	TAILQ_FOREACH (dl, &dev->parents, link){
+		if (dl->device_ptr == parent)
+			break;
+	}
+	return ((dl) ? TRUE : FALSE);
+}
+
 
 /*
  * Devclass implementation
@@ -3580,7 +3592,7 @@
     int type, int *rid, u_long start, u_long end, u_long count, u_int flags)
 {
 	struct resource_list_entry *rle = 0;
-	int passthrough = (device_get_parent(child) != bus);
+	int passthrough = !is_device_parent (child, bus);
 	int isdefault = (start == 0UL && end == ~0UL);
 
 	if (passthrough) {
@@ -3639,7 +3651,7 @@
     int type, int rid, struct resource *res)
 {
 	struct resource_list_entry *rle = 0;
-	int passthrough = (device_get_parent(child) != bus);
+	int passthrough = !is_device_parent (child, bus);
 	int error;
 
 	if (passthrough) {
@@ -3969,8 +3981,8 @@
 
 	DEVICE_IDENTIFY(driver, dev);
 	TAILQ_FOREACH(child, &dev->children, link) {
-//		if (child->state == DS_NOTPRESENT ||
-//		    (child->flags & DF_REBID))
+		if (child->state == DS_NOTPRESENT ||
+		    (child->flags & DF_REBID))
 			device_probe_and_attach(child);
 	}
 }
@@ -4002,9 +4014,11 @@
 bus_generic_teardown_intr(device_t dev, device_t child, struct resource *irq,
     void *cookie)
 {
+	device_t parent;
+	parent = device_get_parent (dev);
 	/* Propagate up the bus hierarchy until someone handles it. */
-	if (dev->parent)
-		return (BUS_TEARDOWN_INTR(dev->parent, child, irq, cookie));
+	if (parent)
+		return (BUS_TEARDOWN_INTR(parent, child, irq, cookie));
 	return (EINVAL);
 }
 
@@ -4018,9 +4032,11 @@
 bus_generic_alloc_resource(device_t dev, device_t child, int type, int *rid,
     u_long start, u_long end, u_long count, u_int flags)
 {
+	device_t parent;
+	parent = device_get_parent (dev);
 	/* Propagate up the bus hierarchy until someone handles it. */
-	if (dev->parent)
-		return (BUS_ALLOC_RESOURCE(dev->parent, child, type, rid,
+	if (parent)
+		return (BUS_ALLOC_RESOURCE(parent, child, type, rid,
 		    start, end, count, flags));
 	return (NULL);
 }
@@ -4035,9 +4051,11 @@
 bus_generic_release_resource(device_t dev, device_t child, int type, int rid,
     struct resource *r)
 {
+	device_t parent;
+	parent = device_get_parent (dev);
 	/* Propagate up the bus hierarchy until someone handles it. */
-	if (dev->parent)
-		return (BUS_RELEASE_RESOURCE(dev->parent, child, type, rid,
+	if (parent)
+		return (BUS_RELEASE_RESOURCE(parent, child, type, rid,
 		    r));
 	return (EINVAL);
 }
@@ -4052,9 +4070,11 @@
 bus_generic_activate_resource(device_t dev, device_t child, int type, int rid,
     struct resource *r)
 {
+	device_t parent;
+	parent = device_get_parent (dev);
 	/* Propagate up the bus hierarchy until someone handles it. */
-	if (dev->parent)
-		return (BUS_ACTIVATE_RESOURCE(dev->parent, child, type, rid,
+	if (parent)
+		return (BUS_ACTIVATE_RESOURCE(parent, child, type, rid,
 		    r));
 	return (EINVAL);
 }
@@ -4069,9 +4089,11 @@
 bus_generic_deactivate_resource(device_t dev, device_t child, int type,
     int rid, struct resource *r)
 {
+	device_t parent;
+	parent = device_get_parent (dev);
 	/* Propagate up the bus hierarchy until someone handles it. */
-	if (dev->parent)
-		return (BUS_DEACTIVATE_RESOURCE(dev->parent, child, type, rid,
+	if (parent)
+		return (BUS_DEACTIVATE_RESOURCE(parent, child, type, rid,
 		    r));
 	return (EINVAL);
 }
@@ -4086,10 +4108,11 @@
 bus_generic_config_intr(device_t dev, int irq, enum intr_trigger trig,
     enum intr_polarity pol)
 {
-
+	device_t parent;
+	parent = device_get_parent (dev);
 	/* Propagate up the bus hierarchy until someone handles it. */
-	if (dev->parent)
-		return (BUS_CONFIG_INTR(dev->parent, irq, trig, pol));
+	if (parent)
+		return (BUS_CONFIG_INTR(parent, irq, trig, pol));
 	return (EINVAL);
 }
 
@@ -4240,9 +4263,11 @@
 bus_alloc_resource(device_t dev, int type, int *rid, u_long start, u_long end,
     u_long count, u_int flags)
 {
-	if (dev->parent == 0)
+	device_t parent;
+	parent = device_get_parent (dev);
+	if (!parent)
 		return (0);
-	return (BUS_ALLOC_RESOURCE(dev->parent, dev, type, rid, start, end,
+	return (BUS_ALLOC_RESOURCE(parent, dev, type, rid, start, end,
 	    count, flags));
 }
 
@@ -4255,9 +4280,11 @@
 int
 bus_activate_resource(device_t dev, int type, int rid, struct resource *r)
 {
-	if (dev->parent == 0)
+	device_t parent;
+	parent = device_get_parent (dev);
+	if (!parent)
 		return (EINVAL);
-	return (BUS_ACTIVATE_RESOURCE(dev->parent, dev, type, rid, r));
+	return (BUS_ACTIVATE_RESOURCE(parent, dev, type, rid, r));
 }
 
 /**
@@ -4269,9 +4296,11 @@
 int
 bus_deactivate_resource(device_t dev, int type, int rid, struct resource *r)
 {
-	if (dev->parent == 0)
+	device_t parent;
+	parent = device_get_parent (dev);
+	if (!parent)
 		return (EINVAL);
-	return (BUS_DEACTIVATE_RESOURCE(dev->parent, dev, type, rid, r));
+	return (BUS_DEACTIVATE_RESOURCE(parent, dev, type, rid, r));
 }
 
 /**
@@ -4283,9 +4312,11 @@
 int
 bus_release_resource(device_t dev, int type, int rid, struct resource *r)
 {
-	if (dev->parent == 0)
+	device_t parent;
+	parent = device_get_parent (dev);
+	if (!parent)
 		return (EINVAL);
-	return (BUS_RELEASE_RESOURCE(dev->parent, dev, type, rid, r));
+	return (BUS_RELEASE_RESOURCE(parent, dev, type, rid, r));
 }
 
 /**
@@ -4299,12 +4330,14 @@
     driver_intr_t handler, void *arg, void **cookiep)
 {
 	int error;
+	device_t parent;
 
-	if (dev->parent != 0) {
+	parent = device_get_parent (dev);
+	if (parent) {
 		if ((flags &~ INTR_ENTROPY) == (INTR_TYPE_NET | INTR_MPSAFE) &&
 		    !debug_mpsafenet)
 			flags &= ~INTR_MPSAFE;
-		error = BUS_SETUP_INTR(dev->parent, dev, r, flags,
+		error = BUS_SETUP_INTR(parent, dev, r, flags,
 		    handler, arg, cookiep);
 		if (error == 0) {
 			if (!(flags & (INTR_MPSAFE | INTR_FAST)))
@@ -4328,9 +4361,12 @@
 int
 bus_teardown_intr(device_t dev, struct resource *r, void *cookie)
 {
-	if (dev->parent == 0)
+	device_t parent;
+	
+	parent = device_get_parent (dev);
+	if (!parent)
 		return (EINVAL);
-	return (BUS_TEARDOWN_INTR(dev->parent, dev, r, cookie));
+	return (BUS_TEARDOWN_INTR(parent, dev, r, cookie));
 }
 
 /**



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