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 from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux