While trying to do single segment operations (out of LinuxKPI) I found that
we keep failing as we are not returning contiguous bounce pages.
That seemed silly given we did have enough of them available matching the
criteria (size and 1 seg).
This is a quick hacked-up prototype doing two things:
- it keeps the bounce_page_list sorted by busaddr upon pages being freed; this increases the likelyhood of (quickly) finding enough contiguous pages. (probably should ensure order with alloc as well?)
- It adds a special add_bounce_pages() function which will go out of its way and try to find enough contiguous segments in the bounce_page_list (they have to be in order there) to fullfill the special requirement of pagesneeded. It will return the first and queue up the remaining pages in order in the map. The add_bounce_page() called for further iterations will then take the bpages from there rather than the bounce_page_list allowing us to fullfill the entire request in bounce_bus_dmamap_load_phys() with the single segment. We only call into this logic there if the segments are limited to 1 and we need more than 1 page.
As said, this is a prototype, probably also applying elsewhere, and is
hackish. The alogrithms could be improved, etc.
A quick looked showed that this might equally apply to other architectures
but we may not need it there/see the problem there due to less bouncing.