From owner-p4-projects@FreeBSD.ORG Tue Sep 29 18:17:41 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5C1AA1065679; Tue, 29 Sep 2009 18:17:41 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 20AA6106566C for ; Tue, 29 Sep 2009 18:17:41 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 0F85C8FC13 for ; Tue, 29 Sep 2009 18:17:41 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n8TIHeel013505 for ; Tue, 29 Sep 2009 18:17:40 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n8TIHe7X013503 for perforce@freebsd.org; Tue, 29 Sep 2009 18:17:40 GMT (envelope-from jhb@freebsd.org) Date: Tue, 29 Sep 2009 18:17:40 GMT Message-Id: <200909291817.n8TIHe7X013503@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 169022 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: Tue, 29 Sep 2009 18:17:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=169022 Change 169022 by jhb@jhb_jhbbsd on 2009/09/29 18:17:38 - Simplify resource_list_unreserve() to just read the resource out of the resource list entry. - Add a resource_list_busy() that returns true if a given resource entry is "busy". A resource entry is not busy if it has no associated resource, or if the resource is a "reserved" resource that is not allocated by the child device. Otherwise the resource entry is busy. Affected files ... .. //depot/projects/multipass/sys/dev/pci/pci.c#8 edit .. //depot/projects/multipass/sys/kern/subr_bus.c#9 edit .. //depot/projects/multipass/sys/sys/bus.h#6 edit Differences ... ==== //depot/projects/multipass/sys/dev/pci/pci.c#8 (text+ko) ==== @@ -3641,12 +3641,11 @@ if (rle->res) { if (rman_get_flags(rle->res) & RF_ACTIVE || - rle->flags & RLE_ALLOCATED) { + resource_list_busy(rl, type, rid)) { device_printf(dev, "delete_resource: " "Resource still owned by child, oops. " "(type=%d, rid=%d, addr=%lx)\n", - rle->type, rle->rid, - rman_get_start(rle->res)); + type, rid, rman_get_start(rle->res)); return; } @@ -3662,7 +3661,7 @@ break; } #endif - resource_list_unreserve(rl, dev, child, type, rid, rle->res); + resource_list_unreserve(rl, dev, child, type, rid); } resource_list_delete(rl, type, rid); } ==== //depot/projects/multipass/sys/kern/subr_bus.c#9 (text+ko) ==== @@ -2820,6 +2820,31 @@ } /** + * @brief Determine if a resource entry is busy. + * + * Returns true if a resource entry is busy meaning that it has an + * associated resource that is not an unallocated "reserved" resource. + * + * @param rl the resource list to search + * @param type the resource entry type (e.g. SYS_RES_MEMORY) + * @param rid the resource identifier + * + * @returns Non-zero if the entry is busy, zero otherwise. + */ +int +resource_list_busy(struct resource_list *rl, int type, int rid) +{ + struct resource_list_entry *rle; + + rle = resource_list_find(rl, type, rid); + if (rle == NULL || rle->res == NULL) + return (0); + if ((rle->flags & (RLE_RESERVED | RLE_ALLOCATED)) == RLE_RESERVED) + return (0); + return (1); +} + +/** * @brief Find a resource entry by type and rid. * * @param rl the resource list to search @@ -3077,7 +3102,7 @@ */ int resource_list_unreserve(struct resource_list *rl, device_t bus, device_t child, - int type, int rid, struct resource *res) + int type, int rid) { struct resource_list_entry *rle = NULL; int passthrough = (device_get_parent(child) != bus); @@ -3095,7 +3120,7 @@ if (rle->flags & RLE_ALLOCATED) return (EBUSY); rle->flags &= ~RLE_RESERVED; - return (resource_list_release(rl, bus, child, type, rid, res)); + return (resource_list_release(rl, bus, child, type, rid, rle->res)); } /** ==== //depot/projects/multipass/sys/sys/bus.h#6 (text+ko) ==== @@ -251,6 +251,8 @@ int resource_list_add_next(struct resource_list *rl, int type, u_long start, u_long end, u_long count); +int resource_list_busy(struct resource_list *rl, + int type, int rid); struct resource_list_entry* resource_list_find(struct resource_list *rl, int type, int rid); @@ -273,7 +275,7 @@ u_long count, u_int flags); int resource_list_unreserve(struct resource_list *rl, device_t bus, device_t child, - int type, int rid, struct resource *res); + int type, int rid); void resource_list_purge(struct resource_list *rl); int resource_list_print_type(struct resource_list *rl, const char *name, int type,