summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_rman.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2005-03-15 20:28:51 +0000
committerimp <imp@FreeBSD.org>2005-03-15 20:28:51 +0000
commit2417261e252b909cce452871a26e2922eae97e8d (patch)
tree50a593714926090f20d329247ee60570fffabb9b /sys/kern/subr_rman.c
parenta5a3d20d0037b1a7f6bbaa8f088f76cd4cfcab2f (diff)
downloadFreeBSD-src-2417261e252b909cce452871a26e2922eae97e8d.zip
FreeBSD-src-2417261e252b909cce452871a26e2922eae97e8d.tar.gz
Sometimes, when asked to return region A..C, we'd return A+N..C+N
instead of failing. When looking for a region to allocate, we used to check to see if the start address was < end. In the case where A..B is allocated already, and one wants to allocate A..C (B < C), then this test would improperly fail (which means we'd examine that region as a possible one), and we'd return the region B+1..C+(B-A+1) rather than NULL. Since C+(B-A+1) is necessarily larger than C (end argument), this is incorrect behavior for rman_reserve_resource_bound(). The fix is to exclude those regions where r->r_start + count - 1 > end rather than r->r_start > end. This bug has been in this code for a very long time. I believe that all other tests against end are correctly done. This is why sio0 generated a message about interrupts not being enabled properly for the device. When fdc had a bug that allocated from 0x3f7 to 0x3fb, sio0 was then given 0x3fc-0x404 rather than the 0x3f8-0x3ff that it wanted. Now when fdc has the same bug, sio0 fails to allocate its ports, which is the proper behavior. Since the probe failed, we never saw the messed up resources reported. I suspect that there are other places in the tree that have weird looping or other odd work arounds to try to cope with the observed weirdness this bug can introduce. These workarounds should be located and eliminated. Minor debug write fix to match the above test done as well. 'nice' by: mdodd Sponsored by: timing solutions (http://www.timing.com/)
Diffstat (limited to 'sys/kern/subr_rman.c')
-rw-r--r--sys/kern/subr_rman.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c
index aa1812a..9901c41 100644
--- a/sys/kern/subr_rman.c
+++ b/sys/kern/subr_rman.c
@@ -217,8 +217,9 @@ rman_reserve_resource_bound(struct rman *rm, u_long start, u_long end,
*/
for (s = r; s; s = TAILQ_NEXT(s, r_link)) {
DPRINTF(("considering [%#lx, %#lx]\n", s->r_start, s->r_end));
- if (s->r_start > end) {
- DPRINTF(("s->r_start (%#lx) > end (%#lx)\n", s->r_start, end));
+ if (s->r_start + count - 1 > end) {
+ DPRINTF(("s->r_start (%#lx) + count - 1> end (%#lx)\n",
+ s->r_start, end));
break;
}
if (s->r_flags & RF_ALLOCATED) {
OpenPOWER on IntegriCloud