Messages in this thread | | | Date | Tue, 18 Apr 2006 21:51:45 +1000 | From | Nick Piggin <> | Subject | Re: PCI Device Driver / remap_pfn_range() |
| |
Alan Cox wrote: > On Maw, 2006-04-18 at 04:18 +1000, Nick Piggin wrote: > >>I'm pretty sure you can't remap_pfn_range vmalloced memory because >>it doesn't use contiguous page frames. > > > To remap vmalloc memory you need something like this. Note that vmalloc > memory may not be DMA accessible, vmalloc_32 memory maybe. Alternatively > you can build your own scatter gather lists from pages subject to > hardware limits. > > The following GPL code from various drivers shows how to do vmalloc > mapping into an application. Having a common helper for this is a > discussion/todo item when that area of the vm gets future adjustments > but for now this code should do the trick:
Yep, that would be a good option, thanks Alan.
You can look through the tree at how drivers remap their rvmalloced memory -- (here's a snippet from drivers/media/video/meye.c):
while (size > 0) { page = vmalloc_to_pfn((void *)pos); if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { mutex_unlock(&meye.lock); return -EAGAIN; } start += PAGE_SIZE; pos += PAGE_SIZE; if (size > PAGE_SIZE) size -= PAGE_SIZE; else size = 0; }
The trick is to get the underlying pfns and remap one at a time.
You could also tinker with vmalloc_to_page+vm_insert_page, although that might not yet be the best option for an out of tree driver.
-- SUSE Labs, Novell Inc. Send instant messages to your online friends http://au.messenger.yahoo.com
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |