public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Anders Torger <torger@ludd.luth.se>
To: aprasad@in.ibm.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: How to transfer memory from PCI memory directly to user space safely and portable?
Date: Sun, 26 Nov 2000 14:54:08 +0100	[thread overview]
Message-ID: <00112614540807.05228@paganini> (raw)
In-Reply-To: <CA2569A3.004A8A41.00@d73mta05.au.ibm.com>
In-Reply-To: <CA2569A3.004A8A41.00@d73mta05.au.ibm.com>

On Mon, 27 Nov 2000, you wrote:
> >have an intermediate buffer in kernel memory. I have implemented the copy
> >functions like this:
> >
> >From user space to the sound card:
> >
> >    if (verify_area(VERIFY_READ, user_space_src, count) != 0) {
> >        return -EFAULT;
> >    }
> >    memcpy_toio(iobase, user_space_src, count);
> >    return 0;
> >
> >From the sound card to user space:
> >
> >    if (verify_area(VERIFY_WRITE, user_space_dst, count) != 0) {
> >        return -EFAULT;
> >    }
> >    memcpy_fromio(user_space_dst, iobase, count);
> >    return 0;
> >
> >
> >These functions are called on the behalf of the user, so the current
>
> process
>
> >should be the correct one. The iobase is ioremapped:
> >
> >    iobase = ioremap(sound_card_port, sound_card_io_size);

> The best solution will be to let the user mmap the device memory to his
> address space.The driver need to provide the interface through ioctl cmd or
> mmap file operations.

I have learnt that it is not portable to mmap the IO memory, since some 
architectures (for example Alpha) cannot access IO memory the same was as 
physical RAM. That is why I am using memcpy_to/fromio instead of 
copy_to/from_user. If I am correctly informed, when mmaping is used, the card 
use to have some sort of DMA mechanism, so the mmaping is done on ordinary 
RAM, not IO memory. Unfortunately, on this sound card (RME Audio Digi96), I 
have to access the on-board buffers directly, using the CPU. Thus, to be 
portable, I cannot use mmap directly on the ioremap'd memory, right?

/Anders Torger
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

  reply	other threads:[~2000-11-26 14:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-27 13:27 How to transfer memory from PCI memory directly to user space safely and portable? aprasad
2000-11-26 13:54 ` Anders Torger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-11-26 13:21 Anders Torger
2000-11-26 15:11 ` Philipp Rumpf
2000-11-26 15:36   ` Anders Torger
2000-11-27 18:36   ` H. Peter Anvin
2000-11-27 19:29     ` Philipp Rumpf
2000-11-27 19:30       ` H. Peter Anvin
2000-11-27 13:51 ` Richard B. Johnson

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=00112614540807.05228@paganini \
    --to=torger@ludd.luth.se \
    --cc=aprasad@in.ibm.com \
    --cc=linux-kernel@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