Date: Tue, 29 Sep 2009 18:17:40 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 169022 for review Message-ID: <200909291817.n8TIHe7X013503@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909291817.n8TIHe7X013503>