svn commit: r201276 - head/sys/kern
John Baldwin
jhb at FreeBSD.org
Wed Dec 30 19:44:31 UTC 2009
Author: jhb
Date: Wed Dec 30 19:44:31 2009
New Revision: 201276
URL: http://svn.freebsd.org/changeset/base/201276
Log:
- 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.
Modified:
head/sys/kern/subr_bus.c
Modified: head/sys/kern/subr_bus.c
==============================================================================
--- head/sys/kern/subr_bus.c Wed Dec 30 19:42:27 2009 (r201275)
+++ head/sys/kern/subr_bus.c Wed Dec 30 19:44:31 2009 (r201276)
@@ -2898,8 +2898,11 @@ resource_list_busy(struct resource_list
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
{
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 d
{
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);
More information about the svn-src-head
mailing list