contiguous memory allocation problem
Ian Dowse
iedowse at iedowse.com
Sun Jul 2 13:23:56 UTC 2006
In message <200607021433.32278.hselasky at c2i.net>, Hans Petter Selasky writes:
>On Sunday 02 July 2006 14:05, Ian Dowse wrote:
>> This data structure requires the associated data buffer to be
>> contiguous (relative to virtual memory), but allows the physical
>> memory pages to be non-contiguous. Seven page pointers are provided
>> to support the expression of 8 isochronous transfers. The seven
>> pointers allow for 3 (transactions) * 1024 (maximum packet size)
>> * 8 (transaction records) (24576 bytes) to be moved with this
>> data structure, regardless of the alignment offset of the first
>> page.
>
>3 * 1024 bytes = 0xC00 bytes
>
>8 * 0xC00 = 0x6000 bytes maximum
>
>According to this you need "6" "EHCI pages", because "6 * 0x1000 = 0x6000".
>The seventh "EHCI page" is just there to allow one to start at any page
>offset. There is no eight "EHCI page".
>
>The only solution I see, is to have a double layer ITD. The first layer have
>the 4 first transfers activated, and the second layer have the 4 last
>transfers activated.
>
>A little more complicated, but not impossible.
The trick is that if the 0x6000 bytes are contiguous in virtual
memory then they never span more than 6 pages so one iTD is enough.
i.e. you can just do malloc(0x6000) and you don't need multi-page
physically contiguous buffers or extra memory-memory copies regardless
of how the virtual buffer maps to physical pages. This seems to be
the general extent of scatter-gather support offered by the various
USB host controllers (modulo various caveats such as assuming pages
are >= 4k, handling physical addresses > 4GB on non-IOMMU hardware
and UHCI's lack of support for mid-packet non-contiguous page
boundaries).
Ian
More information about the freebsd-hackers
mailing list