Re: mmap() implementation for pci_alloc_consistent() memory?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

On Thu, May 19, 2011 at 12:14 AM, Leon Woestenberg
<leon.woestenberg@xxxxxxxxx> wrote:
>
> int ringbuffer_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
> {
>        /* the buffer allocated with pci_alloc_consistent() */
>        void *vaddr = ringbuffer_virt;
>        int ret;
>
>        /* find the struct page that describes vaddr, the buffer
>         * allocated with pci_alloc_consistent() */
>        struct page *page = virt_to_page(lro_char->engine->ringbuffer_virt);
>        vmf->page = page;
>
>        /*** I have verified that vaddr, page, and the pfn correspond
> with vaddr = pci_alloc_consistent() ***/
>        ret = vm_insert_pfn(vma, address, page_to_pfn(page));
>        return ret;
> }
>

Some further debugging insights:

I found that pfn_valid is 0 on page_to_pfn(page). Isn't
pci_alloc_consistent() memory backed by a real struct page?

I found that when I use the allocation/mapping below instead of
pci_alloc_consistent(), the fault handler does the mapping correctly.

	vaddr = __get_free_pages(GFP_KERNEL, 4);
	busaddr = dma_map_single(lro->pci_dev, vaddr,
		psize, dir_to_dev? DMA_TO_DEVICE: DMA_FROM_DEVICE);

Still no clue why the mmap fails on pci_alloc_consistent() memory.

Regards,
-- 
Leon

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]