Re: ISA PnP resource allocation
Warner Losh schrieb: In message [EMAIL PROTECTED] Daniel Rock writes: : I already filed a PR for this problem but my first solution was a real : hack (kern/21461). : : [another solution would be to introduce another flag for : rman_reserve_resource() not to search for alternate regions. Would the alignment stuff I added for cardbus help any? I think, my patch basically uses now the same alignment options from the resource manager like cardbus does now. I have cleaned up the code a little bit: Now the code uses the rman_get_XXX() macros and also checks if the region returned is below the end mark. Daniel Index: sys/isa/isa_common.c === RCS file: /data/cvs/src/sys/isa/isa_common.c,v retrieving revision 1.18 diff -u -r1.18 isa_common.c --- sys/isa/isa_common.c2000/07/12 00:42:08 1.18 +++ sys/isa/isa_common.c2000/11/14 21:27:34 @@ -133,31 +133,30 @@ result-ic_nmem = config-ic_nmem; for (i = 0; i config-ic_nmem; i++) { u_int32_t start, end, size, align; - for (start = config-ic_mem[i].ir_start, -end = config-ic_mem[i].ir_end, -size = config-ic_mem[i].ir_size, -align = config-ic_mem[i].ir_align; -start + size - 1 = end; -start += align) { - bus_set_resource(child, SYS_RES_MEMORY, i, -start, size); - res[i] = bus_alloc_resource(child, - SYS_RES_MEMORY, i, - 0, ~0, 1, 0 /* !RF_ACTIVE */); - if (res[i]) { - result-ic_mem[i].ir_start = start; - result-ic_mem[i].ir_end = start + size - 1; - result-ic_mem[i].ir_size = size; - result-ic_mem[i].ir_align = align; + + start = config-ic_mem[i].ir_start; + end = config-ic_mem[i].ir_end; + size = config-ic_mem[i].ir_size; + align = config-ic_mem[i].ir_align; + if(!align) + align = 1; + bus_set_resource(child, SYS_RES_MEMORY, i, +start, size); + res[i] = bus_alloc_resource(child, + SYS_RES_MEMORY, i, + 0, ~0, 1, + rman_make_alignment_flags(align)); + if (res[i]) { + if(rman_get_start(res[i]) end) { + success = 0; break; } + result-ic_mem[i].ir_start = rman_get_start(res[i]); + result-ic_mem[i].ir_end = rman_get_end(res[i]); + result-ic_mem[i].ir_size = rman_get_size(res[i]); + result-ic_mem[i].ir_align = align; } - - /* -* If we didn't find a place for memory range i, then -* give up now. -*/ - if (!res[i]) { + else { success = 0; break; } @@ -197,31 +196,31 @@ result-ic_nport = config-ic_nport; for (i = 0; i config-ic_nport; i++) { u_int32_t start, end, size, align; - for (start = config-ic_port[i].ir_start, -end = config-ic_port[i].ir_end, -size = config-ic_port[i].ir_size, -align = config-ic_port[i].ir_align; -start + size - 1 = end; -start += align) { - bus_set_resource(child, SYS_RES_IOPORT, i, -start, size); - res[i] = bus_alloc_resource(child, - SYS_RES_IOPORT, i, - 0, ~0, 1, 0 /* !RF_ACTIVE */); - if (res[i]) { - result-ic_port[i].ir_start = start; - result-ic_port[i].ir_end = start + size - 1; - result-ic_port[i].ir_size = size; - result-ic_port[i].ir_align = align; + + start = config-ic_port[i].ir_start; + end = config-ic_port[i].ir_end; + size = config-ic_port[i].ir_size; + align = config-ic_port[i].ir_align; + if(!align) + align = 1; + + bus_set_resource(child, SYS_RES_IOPORT, i, +start, size); +
Re: ISA PnP resource allocation
In message [EMAIL PROTECTED] Daniel Rock writes: : I already filed a PR for this problem but my first solution was a real : hack (kern/21461). : : [another solution would be to introduce another flag for : rman_reserve_resource() not to search for alternate regions. Would the alignment stuff I added for cardbus help any? Warner To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
Re: ISA PnP resource allocation
Now that someone has implementented resource alignment in the resource allocator, someone could review and integrate the attached patch. This looks fine to me. I assume you'd want the same changes applied to aligning memory regions? Background: I do have an old system with several PnP devices. Two of the request the following IO ports: first device: port range 0x100-0x3ff size=1 align=1 second device: port range 0x100-0x3f0 size=8 align=8 The first device gets port 0x100-0x100 allocated. Then the code in isa_common.c tries to allocate the ports for the second device. 0x100 is already used, so it gets the next free range: 0x101-0x108, ignoring the alignment constraints. The general problem in the code /sys/isa_common.c isa_find_port(), isa_find_memory(), etc. The loops in these routines try to honor the alignment constraints but the real work is done in /sys/subr_rman.c. Regardless of resource usage the for(...)-look in above functions is only run once. I already filed a PR for this problem but my first solution was a real hack (kern/21461). [another solution would be to introduce another flag for rman_reserve_resource() not to search for alternate regions. Daniel Index: isa/isa_common.c === RCS file: /data/cvs/src/sys/isa/isa_common.c,v retrieving revision 1.18 diff -u -r1.18 isa_common.c --- isa/isa_common.c 2000/07/12 00:42:08 1.18 +++ isa/isa_common.c 2000/11/09 20:11:31 @@ -207,10 +207,10 @@ start, size); res[i] = bus_alloc_resource(child, SYS_RES_IOPORT, i, - 0, ~0, 1, 0 /* !RF_ACTIVE */); + 0, ~0, 1, rman_make_alignment_flags(align)/* !RF_ACTIVE */); if (res[i]) { - result-ic_port[i].ir_start = start; - result-ic_port[i].ir_end = start + size - 1; + result-ic_port[i].ir_start = res[i]-r_start; + result-ic_port[i].ir_end = res[i]-r_start + size - 1; result-ic_port[i].ir_size = size; result-ic_port[i].ir_align = align; break; -- ... every activity meets with opposition, everyone who acts has his rivals and unfortunately opponents also. But not because people want to be opponents, rather because the tasks and relationships force people to take different points of view. [Dr. Fritz Todt] V I C T O R Y N O T V E N G E A N C E To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
Re: ISA PnP resource allocation
Mike Smith schrieb: Now that someone has implementented resource alignment in the resource allocator, someone could review and integrate the attached patch. This looks fine to me. I assume you'd want the same changes applied to aligning memory regions? I didn't run in this problem, but maybe some other person will, so: yes! I don't know the code in /sys/kern/subr_rman.c well. Does it only find nearby regions or also other as well. If it does find any region with the alignment constraints, the for(...) loop in /sys/isa/isa_common.c is completely meaningless and should be eliminated. The code then should look like this below (works at least for me). Daniel Index: isa/isa_common.c === RCS file: /data/cvs/src/sys/isa/isa_common.c,v retrieving revision 1.18 diff -u -r1.18 isa_common.c --- isa/isa_common.c2000/07/12 00:42:08 1.18 +++ isa/isa_common.c2000/11/10 18:05:42 @@ -133,31 +133,26 @@ result-ic_nmem = config-ic_nmem; for (i = 0; i config-ic_nmem; i++) { u_int32_t start, end, size, align; - for (start = config-ic_mem[i].ir_start, -end = config-ic_mem[i].ir_end, -size = config-ic_mem[i].ir_size, -align = config-ic_mem[i].ir_align; -start + size - 1 = end; -start += align) { - bus_set_resource(child, SYS_RES_MEMORY, i, -start, size); - res[i] = bus_alloc_resource(child, - SYS_RES_MEMORY, i, - 0, ~0, 1, 0 /* !RF_ACTIVE */); - if (res[i]) { - result-ic_mem[i].ir_start = start; - result-ic_mem[i].ir_end = start + size - 1; - result-ic_mem[i].ir_size = size; - result-ic_mem[i].ir_align = align; - break; - } - } - /* -* If we didn't find a place for memory range i, then -* give up now. -*/ - if (!res[i]) { + start = config-ic_mem[i].ir_start; + end = config-ic_mem[i].ir_end; + size = config-ic_mem[i].ir_size; + align = config-ic_mem[i].ir_align; + if(!align) + align = 1; + bus_set_resource(child, SYS_RES_MEMORY, i, +start, size); + res[i] = bus_alloc_resource(child, + SYS_RES_MEMORY, i, + 0, ~0, 1, + rman_make_alignment_flags(align)); + if (res[i]) { + result-ic_mem[i].ir_start = res[i]-r_start; + result-ic_mem[i].ir_end = res[i]-r_end; + result-ic_mem[i].ir_size = res[i]-r_end - res[i]-r_start + +1; + result-ic_mem[i].ir_align = align; + } + else { success = 0; break; } @@ -197,31 +192,27 @@ result-ic_nport = config-ic_nport; for (i = 0; i config-ic_nport; i++) { u_int32_t start, end, size, align; - for (start = config-ic_port[i].ir_start, -end = config-ic_port[i].ir_end, -size = config-ic_port[i].ir_size, -align = config-ic_port[i].ir_align; -start + size - 1 = end; -start += align) { - bus_set_resource(child, SYS_RES_IOPORT, i, -start, size); - res[i] = bus_alloc_resource(child, - SYS_RES_IOPORT, i, - 0, ~0, 1, 0 /* !RF_ACTIVE */); - if (res[i]) { - result-ic_port[i].ir_start = start; - result-ic_port[i].ir_end = start + size - 1; - result-ic_port[i].ir_size = size; - result-ic_port[i].ir_align = align; - break; - } - } - /* -* If we didn't find a place for port range i, then -* give up now. -*/ - if (!res[i]) { + start = config-ic_port[i].ir_start; + end = config-ic_port[i].ir_end; + size = config-ic_port[i].ir_size; + align =
ISA PnP resource allocation
Now that someone has implementented resource alignment in the resource allocator, someone could review and integrate the attached patch. Background: I do have an old system with several PnP devices. Two of the request the following IO ports: first device: port range 0x100-0x3ff size=1 align=1 second device: port range 0x100-0x3f0 size=8 align=8 The first device gets port 0x100-0x100 allocated. Then the code in isa_common.c tries to allocate the ports for the second device. 0x100 is already used, so it gets the next free range: 0x101-0x108, ignoring the alignment constraints. The general problem in the code /sys/isa_common.c isa_find_port(), isa_find_memory(), etc. The loops in these routines try to honor the alignment constraints but the real work is done in /sys/subr_rman.c. Regardless of resource usage the for(...)-look in above functions is only run once. I already filed a PR for this problem but my first solution was a real hack (kern/21461). [another solution would be to introduce another flag for rman_reserve_resource() not to search for alternate regions. Daniel Index: isa/isa_common.c === RCS file: /data/cvs/src/sys/isa/isa_common.c,v retrieving revision 1.18 diff -u -r1.18 isa_common.c --- isa/isa_common.c2000/07/12 00:42:08 1.18 +++ isa/isa_common.c2000/11/09 20:11:31 @@ -207,10 +207,10 @@ start, size); res[i] = bus_alloc_resource(child, SYS_RES_IOPORT, i, - 0, ~0, 1, 0 /* !RF_ACTIVE */); + 0, ~0, 1, +rman_make_alignment_flags(align)/* !RF_ACTIVE */); if (res[i]) { - result-ic_port[i].ir_start = start; - result-ic_port[i].ir_end = start + size - 1; + result-ic_port[i].ir_start = res[i]-r_start; + result-ic_port[i].ir_end = res[i]-r_start + size - 1; result-ic_port[i].ir_size = size; result-ic_port[i].ir_align = align; break;