From owner-p4-projects@FreeBSD.ORG Sun Jul 15 17:20:05 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B387316A406; Sun, 15 Jul 2007 17:20:05 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5864516A404 for ; Sun, 15 Jul 2007 17:20:05 +0000 (UTC) (envelope-from thioretic@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 4809613C4B4 for ; Sun, 15 Jul 2007 17:20:05 +0000 (UTC) (envelope-from thioretic@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l6FHK5mO012556 for ; Sun, 15 Jul 2007 17:20:05 GMT (envelope-from thioretic@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6FHK492012548 for perforce@freebsd.org; Sun, 15 Jul 2007 17:20:04 GMT (envelope-from thioretic@FreeBSD.org) Date: Sun, 15 Jul 2007 17:20:04 GMT Message-Id: <200707151720.l6FHK492012548@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to thioretic@FreeBSD.org using -f From: Maxim Zhuravlev To: Perforce Change Reviews Cc: Subject: PERFORCE change 123542 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jul 2007 17:20:06 -0000 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)); } /**