<br><br><div class="gmail_quote">On Sun, Mar 10, 2013 at 11:30 PM, Christoph Seitz <span dir="ltr"><<a href="mailto:c.seitz@tu-bs.de" target="_blank">c.seitz@tu-bs.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
I have some problems allocation Memory the right way and use it in my<br>
kernel module.<br>
<br>
I use a char device for reading and writing from/to a pcie dma card.<br>
Especially the read function makes me some headache. The user allocates<br>
some memory with posix_memalign and call the read function on the<br>
device, so that the devices knows where to write to. My driver now uses<br>
get_user_pages() to pin the user pages. The memory has never been<br>
written or read by the user, so it's not yet in the RAM, right? And<br>
get_user_pages returns a valid number of pages, but for every page the<br>
same struct. (respectively the same pointer). Is there any way to ensure<br>
that the user pages are in the ram and get_user_pages returns a valid<br>
page array? <br></blockquote><div><br>If you know the RAM physical address range you can figure out by doing the following<br> <b>page_to_pfn(page_ptr) << 12</b>;<br> where page_ptr is a struct page * returned by get_user_pages().<br>
<b> page_to_pfn()</b> will return the pfn of the corresponding page frame and left shifting by 12 bits will give you page frame base address.<br><br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Regards<br>
Chris<br>
<br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</blockquote></div><br>-- <br>Regards,<br>Prabhunath G<br>Linux Trainer<br>Bangalore<br>