From: Leon Woestenberg <leon.woestenberg@gmail.com>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: Takashi Iwai <tiwai@suse.de>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
linux-pci@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: mmap() implementation for pci_alloc_consistent() memory?
Date: Tue, 24 May 2011 16:18:11 +0200 [thread overview]
Message-ID: <BANLkTikOEssVJ6mXOUxt=BUFX6ERqxMWwg@mail.gmail.com> (raw)
In-Reply-To: <4DDA1B18.3080201@ladisch.de>
Hello Clemens,
On Mon, May 23, 2011 at 10:30 AM, Clemens Ladisch <clemens@ladisch.de> wrote:
> Leon Woestenberg wrote:
>> Having dma_mmap_coherent() there is good for one or two archs, but how
>> can we built portable drivers if the others arch's are still missing?
>
> Easy: Resolve all issues, implement it for all the other arches, and add
> it to the official DMA API.
>
>> How would dma_mmap_coherent() look like on x86?
>
> X86 and some others are always coherent; just use vm_insert_page() or
> remap_page_range().
>
Hello Clemens,
On Mon, May 23, 2011 at 10:30 AM, Clemens Ladisch <clemens@ladisch.de> wrote:
> Leon Woestenberg wrote:
>> Having dma_mmap_coherent() there is good for one or two archs, but how
>> can we built portable drivers if the others arch's are still missing?
>
> Easy: Resolve all issues, implement it for all the other arches, and add
> it to the official DMA API.
>
I could send patches, but I would get bashed. Would be a learning
experience though (and a long email thread).
>> How would dma_mmap_coherent() look like on x86?
>
> X86 and some others are always coherent; just use vm_insert_page() or
> remap_page_range().
>
For x86 (my current test system) I tend to go with remap_page_range()
so that the mapping is done before the pages are actually touched.
With that I leave the work-in-progress (dma_mmap_coherent) aside for a
moment, I'll revisit that later on ARM.
However, I still feel I'm treading sandy waters, not familiar enough
with the VM internals.
Does memory allocated with pci_alloc_consistent() need a get_page() in
the driver before I remap_page_range() it?
Does memory allocated with __get_free_pages() need a get_page() in the
driver before I remap_page_range() it?
And how about set_bit(PG_reserved, ...) on those pages? Is that
something of the past?
#if 0
...
<vm_insert_page implementation here, disabled>
...
#else /* remap_pfn_range */
#warning Using remap_pfn_range
static int buffer_mmap(struct file *file, struct vm_area_struct *vma)
{
unsigned long vsize, vsize2;
void *vaddr, *vaddr2;
unsigned long start = vma->vm_start;
* VM_RESERVED: prevent the pages from being swapped out */
vma->vm_flags |= VM_RESERVED;
vma->vm_private_data = file->private_data;
/* allocated using __get_free_pages() or pci_alloc_consistent() */
vaddr = buffer_virt;
vsize = buffer_size;
/* iterate over pages */
vaddr2 = vaddr;
vsize2 = vsize;
while (vsize2 > 0) {
printk(KERN_DEBUG "get_page(page=%p)\n", virt_to_page(vaddr2));
get_page(virt_to_page(vaddr2));
//set_bit(PG_reserved, &(virt_to_page(vaddr2)->flags));
vaddr2 += PAGE_SIZE;
vsize2 -= PAGE_SIZE;
}
remap_pfn_range(vma, vma->vm_start,
page_to_pfn(virt_to_page(vaddr)), vsize, vma->vm_page_prot);
return 0;
}
#endif
Thanks for the explanation,
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>
prev parent reply other threads:[~2011-05-24 14:18 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
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 [this message]
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='BANLkTikOEssVJ6mXOUxt=BUFX6ERqxMWwg@mail.gmail.com' \
--to=leon.woestenberg@gmail.com \
--cc=clemens@ladisch.de \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pci@vger.kernel.org \
--cc=tiwai@suse.de \
/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).