public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tom Brown <sa212+emis@cyconix.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>,
	Yong Zhang <yong.zhang@windriver.com>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: Question: how to copy to user space from a tasklet
Date: Mon, 18 Oct 2010 19:02:01 +0100	[thread overview]
Message-ID: <4CBC8B99.60806@cyconix.com> (raw)
In-Reply-To: <4CBC7D62.6040408@s5r6.in-berlin.de>

On 18/10/2010 18:01, Stefan Richter wrote:
> Tom Brown wrote:
>> Thanks, think I'm there:
>>
>> 1 - The user calls mmap() with a specific offset to flag that he wants a
>> DMA buffer
>>
>> 2 - I then 'vmalloc' the buffer, and call 'setPageReserved' for each page
>>
>> I then step over each page, and:
>>
>> 3 - call 'vmalloc_to_pfn' to get a PFN for each page, and then
>>
>> 4 - call 'remap_page_range' for that page (I instead call
>> 'remap_pfn_range' for kernels>= 2.6.10, but I'm on 2.6.9)
>>
>> This gives me the buffer, and the interrupt handler then just uses
>> 'memcpy' to copy data to the user.
>
> I would have thought of a bunch of alloc_page() and vm_insert_page() but I
> don't know if vm_insert_page exists in 2.6.9 and if it honors user limits.

It turns out that I'm getting occasional

"BUG: unable to handle kernel paging request at virtual address 
...[buffer address]"

oops when the driver attempts to 'memcpy' to the buffer, so I think 
'setPageReserved' is probably not the right thing to do.  This is 
strange - it's almost as if 'setPageReserved' stops the page being 
swapped out, but the kernel doesn't know this.

I'll look into alloc_page/vm_insert_page instead.

Thanks -

Tom

      reply	other threads:[~2010-10-18 18:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-14 10:43 Question: how to copy to user space from a tasklet Tom Brown
2010-10-15  2:15 ` Yong Zhang
2010-10-15  5:57 ` Stefan Richter
2010-10-15  8:59   ` Arnd Bergmann
2010-10-18 15:45   ` Tom Brown
2010-10-18 17:01     ` Stefan Richter
2010-10-18 18:02       ` Tom Brown [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=4CBC8B99.60806@cyconix.com \
    --to=sa212+emis@cyconix.com \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stefanr@s5r6.in-berlin.de \
    --cc=yong.zhang@windriver.com \
    /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