linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: David Hawkins <dwh@ovro.caltech.edu>
To: Josef Angermeier <Josef.Angermeier@informatik.uni-erlangen.de>
Cc: linuxppc-embedded@ozlabs.org
Subject: Re: "lseek/write char driver" versus "usermode iomem access"
Date: Wed, 29 Mar 2006 08:46:22 -0800	[thread overview]
Message-ID: <442AB9DE.9080806@ovro.caltech.edu> (raw)
In-Reply-To: <442A43C6.5050605@cs.fau.de>


> besides adapting linux to my custom board, i now have to write a driver 
> for a special device. This device mainly consists of an up to 512 bytes 
> big IO memory. Because performance matters alot, i wonder if i shall 
> write a simple char driver offering a write/lseek-interface to access 
> this memory or if i shall do something new to me, mapping the IO-memory 
> to the userspace, so that the user-program can directly access the 
> device memory. Can anyone tell me how performance probably differs 
> between those two design.
> 
> Thanks, you probably save me alot of time to tryout!

Hi Josef,

Here's a couple of comments that may help:

lseek()/read()/write():

   - read and write need to use copy_to_user and copy_from_user
     commands to copy bytes from the registers into the user-space
     buffer.

mmap()

   - maps pages directly, so avoids the overhead of the copy_xx_user
     calls.

So, if you have a set of control *registers* that you want to
manipulate, then mmap would be recommended.

However, this 512-bytes of memory is just that, *memory*, and the
requirement is to move it off the device as fast as possible,
then you probably want to create a device that has a linked
list of 512-byte buffers internally, and use a DMA channel
to move data from the device into the buffer. Then the
'read' function of the driver would consume the contents of
the buffer.

So, as always, things are application dependent. If you
could describe things in more detail, I can help make
more suggestions and supply you with code.

Regards,
Dave

      reply	other threads:[~2006-03-29 16:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-29  8:22 "lseek/write char driver" versus "usermode iomem access" Josef Angermeier
2006-03-29 16:46 ` David Hawkins [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=442AB9DE.9080806@ovro.caltech.edu \
    --to=dwh@ovro.caltech.edu \
    --cc=Josef.Angermeier@informatik.uni-erlangen.de \
    --cc=linuxppc-embedded@ozlabs.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).