mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-28 16:43:09 +00:00
- 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.
This commit is contained in:
parent
ef36004841
commit
0eb9893a80
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=201276
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user