Changeset View
Standalone View
sys/kern/subr_rman.c
Show First 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct resource_i *r, *s, *t; | struct resource_i *r, *s, *t; | ||||
int rv = 0; | int rv = 0; | ||||
DPRINTF(("rman_manage_region: <%s> request: start %#jx, end %#jx\n", | DPRINTF(("rman_manage_region: <%s> request: start %#jx, end %#jx\n", | ||||
rm->rm_descr, start, end)); | rm->rm_descr, start, end)); | ||||
if (start < rm->rm_start || end > rm->rm_end) | if (start < rm->rm_start || end > rm->rm_end) | ||||
return EINVAL; | return EINVAL; | ||||
#if defined(INVARIANTS) || defined(_STANDALONE) | |||||
jhb: I don't know if we are ready for this yet. Keep in mind this is PA's, not VA's. x86's nexus… | |||||
Done Inline ActionsI disagree with not being ready for this. This is merely a warning (even though it says "ERROR") in debug builds. The issue is right now the x86 nexus is the only one which actually bothers to loads its rman_mem with the actual range of valid physical addresses. My goal is to generate a scary error message to hopefully push the users of the resource manager code to fix their uses of resource managers. I've got mixed feelings on the interrupt resource managers. True, they're pretty much cookie values, but leaving them unbounded feels like missing a chance for an early warning of something going wrong. One other note here. I'm wondering about the conditional above. Does it really make sense to return EINVAL if start or end exceed the rm_start .. rm_end range? Might it make more sense to clamp start and end to the rm_start .. rm_end range? ehem_freebsd_m5p.com: I disagree with not being ready for //this//. This is merely a warning (even though it says… | |||||
Not Done Inline ActionsSome platforms don't have a standardized way to query the maximum physical memory address (RISC-V is an example of this), and thus no path forward for "fixing" their use of nexus rmans. Without one, this printf can only create unactionable noise on these platforms, not the useful warning you are hoping for. mhorne: Some platforms don't have a standardized way to query the maximum physical memory address (RISC… | |||||
Done Inline ActionsThat must be rather interesting to work with. Sounds like that could end up a major issue for the RISC-V port of Xen. Guess that suggests this may need to be marked abandoned if action is going to remain impossible for the time being. ehem_freebsd_m5p.com: That must be rather //interesting// to work with. Sounds like that could end up a major issue… | |||||
if (RMAN_IS_DEFAULT_RANGE(start, end)) | |||||
printf("ERROR: %s: <%s> attempting to manage default range\n", | |||||
__func__, rm->rm_descr); | |||||
#endif | |||||
r = int_alloc_resource(M_NOWAIT); | r = int_alloc_resource(M_NOWAIT); | ||||
if (r == NULL) | if (r == NULL) | ||||
return ENOMEM; | return ENOMEM; | ||||
r->r_start = start; | r->r_start = start; | ||||
r->r_end = end; | r->r_end = end; | ||||
r->r_rm = rm; | r->r_rm = rm; | ||||
mtx_lock(rm->rm_mtx); | mtx_lock(rm->rm_mtx); | ||||
▲ Show 20 Lines • Show All 271 Lines • ▼ Show 20 Lines | rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, | ||||
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((flags & RF_FIRSTSHARE) == 0, | KASSERT((flags & RF_FIRSTSHARE) == 0, | ||||
("invalid flags %#x", flags)); | ("invalid flags %#x", flags)); | ||||
KASSERT(count != 0, ("%s(): attempting to allocate empty range", | |||||
Done Inline ActionsThis is good. jhb: This is good. | |||||
__func__)); | |||||
mhorneUnsubmitted Not Done Inline ActionsI would suggest this be squashed into D30280 when it is committed. mhorne: I would suggest this be squashed into D30280 when it is committed. | |||||
ehem_freebsd_m5p.comUnsubmitted Done Inline ActionsFine by me. ehem_freebsd_m5p.com: Fine by me. | |||||
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) { | ||||
DPRINTF(("NULL list head\n")); | DPRINTF(("NULL list head\n")); | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 679 Lines • Show Last 20 Lines |
I don't know if we are ready for this yet. Keep in mind this is PA's, not VA's. x86's nexus queries the max PA supported for its mem_rman which is probably what other platforms should do. IRQ rmans though can effectively be unbounded as they are just cookie values and not associated with a hardware resource.