[openib-general] [PATCH v2 1/7] IB/core - Add DMA mapping functions to allow device drivers to interpose
Or Gerlitz
ogerlitz at voltaire.com
Sun Dec 3 00:36:35 PST 2006
Ralph Campbell wrote:
> Basically, use a hash table to store the kmap result.
> See attached for 90% of the code.
> static u64 ipath_dma_map_page(struct ib_device *dev,
> struct page *page,
> unsigned long offset,
> size_t size,
> enum dma_data_direction direction)
> {
> u64 addr;
>
> BUG_ON(!valid_dma_direction(direction));
>
> if (offset + size > PAGE_SIZE) {
> addr = BAD_DMA_ADDRESS;
> goto done;
> }
>
> #ifdef CONFIG_HIGHMEM
> /* handle highmem pages */
> if (PageHighMem(page)) {
> void *v = kmap(page);
another comment we have got on iser, is that this code can be called
context that requires kmap_atomic (and xxx_dma_unmap_page in a context
that requires kunmap_atomic). This imposes another problem, since the
kmap_atomic slots are somehow limited and with this patch the ipath
driver would hold those mapping for relatively long time (ie it does not
kmap/copy/kunmap).
>
> if (!v)
> addr = BAD_DMA_ADDRESS;
> else {
> addr = (u64) v + offset;
> hash_insert(dev, v + offset, page);
> }
> goto done;
> }
> #endif
> addr = (u64) page_address(page);
> if (addr)
> addr += offset;
>
> done:
> return addr;
> }
More information about the general
mailing list