Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_rman.c
Show First 20 Lines • Show All 439 Lines • ▼ Show 20 Lines | rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, | ||||
rman_res_t rstart, rend, amask, bmask; | rman_res_t rstart, rend, amask, bmask; | ||||
rv = NULL; | rv = NULL; | ||||
DPRINTF(("rman_reserve_resource_bound: <%s> request: [%#jx, %#jx], " | DPRINTF(("rman_reserve_resource_bound: <%s> request: [%#jx, %#jx], " | ||||
"length %#jx, flags %x, device %s\n", rm->rm_descr, start, end, | "length %#jx, flags %x, device %s\n", rm->rm_descr, start, end, | ||||
count, flags, | count, flags, | ||||
dev == NULL ? "<null>" : device_get_nameunit(dev))); | dev == NULL ? "<null>" : device_get_nameunit(dev))); | ||||
KASSERT(count != 0, ("%s: attempted to allocate an empty range", | |||||
__func__)); | |||||
KASSERT((flags & RF_FIRSTSHARE) == 0, | KASSERT((flags & RF_FIRSTSHARE) == 0, | ||||
("invalid flags %#x", flags)); | ("invalid flags %#x", flags)); | ||||
new_rflags = (flags & ~RF_FIRSTSHARE) | RF_ALLOCATED; | new_rflags = (flags & ~RF_FIRSTSHARE) | RF_ALLOCATED; | ||||
mtx_lock(rm->rm_mtx); | mtx_lock(rm->rm_mtx); | ||||
r = TAILQ_FIRST(&rm->rm_list); | r = TAILQ_FIRST(&rm->rm_list); | ||||
if (r == NULL) { | if (r == NULL) { | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | for (s = r; s; s = TAILQ_NEXT(s, r_link)) { | ||||
rend = ummin(s->r_end, ummax(rstart + count - 1, end)); | rend = ummin(s->r_end, ummax(rstart + count - 1, end)); | ||||
if (rstart > rend) { | if (rstart > rend) { | ||||
DPRINTF(("adjusted start exceeds end\n")); | DPRINTF(("adjusted start exceeds end\n")); | ||||
continue; | continue; | ||||
} | } | ||||
DPRINTF(("truncated region: [%#jx, %#jx]; size %#jx (requested %#jx)\n", | DPRINTF(("truncated region: [%#jx, %#jx]; size %#jx (requested %#jx)\n", | ||||
rstart, rend, (rend - rstart + 1), count)); | rstart, rend, (rend - rstart + 1), count)); | ||||
if ((rend - rstart + 1) >= count) { | if ((rend - rstart) >= (count - 1)) { | ||||
DPRINTF(("candidate region: [%#jx, %#jx], size %#jx\n", | DPRINTF(("candidate region: [%#jx, %#jx], size %#jx\n", | ||||
rstart, rend, (rend - rstart + 1))); | rstart, rend, (rend - rstart + 1))); | ||||
if ((s->r_end - s->r_start + 1) == count) { | if ((s->r_end - s->r_start + 1) == count) { | ||||
DPRINTF(("candidate region is entire chunk\n")); | DPRINTF(("candidate region is entire chunk\n")); | ||||
rv = s; | rv = s; | ||||
rv->r_flags = new_rflags; | rv->r_flags = new_rflags; | ||||
rv->r_dev = dev; | rv->r_dev = dev; | ||||
goto out; | goto out; | ||||
▲ Show 20 Lines • Show All 605 Lines • Show Last 20 Lines |