From: Leon Woestenberg <leon.woestenberg@gmail.com>
To: linux-pci@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: mmap() implementation for pci_alloc_consistent() memory?
Date: Thu, 19 May 2011 03:04:38 +0200 [thread overview]
Message-ID: <BANLkTinZJUWMc39TLP28M5=cRvqev+0QWg@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi==cinS1bZc_ARRbnYT3YD+FQr8gA@mail.gmail.com>
Hello,
On Thu, May 19, 2011 at 12:14 AM, Leon Woestenberg
<leon.woestenberg@gmail.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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. 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=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-05-19 1:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-18 22:14 mmap() implementation for pci_alloc_consistent() memory? Leon Woestenberg
2011-05-19 1:04 ` Leon Woestenberg [this message]
2011-05-19 14:59 ` Konrad Rzeszutek Wilk
2011-05-19 15:58 ` Clemens Ladisch
2011-05-19 22:10 ` Leon Woestenberg
2011-05-20 6:51 ` Clemens Ladisch
2011-05-20 8:17 ` Takashi Iwai
2011-05-21 10:59 ` Leon Woestenberg
2011-05-23 8:30 ` Clemens Ladisch
2011-05-24 14:18 ` Leon Woestenberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='BANLkTinZJUWMc39TLP28M5=cRvqev+0QWg@mail.gmail.com' \
--to=leon.woestenberg@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).