From 8d2a9e1d3c36dbd1d69e79aeb5fa5ba9f0356de0 Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 30 Dec 2009 19:44:31 +0000 Subject: - Assert that a reserved resource returned via resource_list_alloc() is not active. - Fix bus_generic_rl_(alloc|release)_resource() to not attempt to fetch a resource list for grandchild devices, but just pass those requests up to the parent directly. This worked by accident previously, but it is better to not let bus drivers try to operate on devices they do not manage. --- sys/kern/subr_bus.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'sys/kern/subr_bus.c') diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 8c2db32..1689505 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -2898,8 +2898,11 @@ resource_list_busy(struct resource_list *rl, int type, int rid) rle = resource_list_find(rl, type, rid); if (rle == NULL || rle->res == NULL) return (0); - if ((rle->flags & (RLE_RESERVED | RLE_ALLOCATED)) == RLE_RESERVED) + if ((rle->flags & (RLE_RESERVED | RLE_ALLOCATED)) == RLE_RESERVED) { + KASSERT(!(rman_get_flags(rle->res) & RF_ACTIVE), + ("reserved resource is active")); return (0); + } return (1); } @@ -3801,6 +3804,10 @@ bus_generic_rl_release_resource(device_t dev, device_t child, int type, { struct resource_list * rl = NULL; + if (device_get_parent(child) != dev) + return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, + type, rid, r)); + rl = BUS_GET_RESOURCE_LIST(dev, child); if (!rl) return (EINVAL); @@ -3821,6 +3828,10 @@ bus_generic_rl_alloc_resource(device_t dev, device_t child, int type, { struct resource_list * rl = NULL; + if (device_get_parent(child) != dev) + return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child, + type, rid, start, end, count, flags)); + rl = BUS_GET_RESOURCE_LIST(dev, child); if (!rl) return (NULL); -- cgit v1.1