[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BANLkTinZJUWMc39TLP28M5=cRvqev+0QWg@mail.gmail.com>
Date: Thu, 19 May 2011 03:04:38 +0200
From: Leon Woestenberg <leon.woestenberg@...il.com>
To: linux-pci@...r.kernel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: mmap() implementation for pci_alloc_consistent() memory?
Hello,
On Thu, May 19, 2011 at 12:14 AM, Leon Woestenberg
<leon.woestenberg@...il.com> 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-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists