Groups | Search | Server Info | Login | Register


Groups > comp.os.linux.development.system > #212

Re: mmap dma buffer

From Pavel Borzenkov <pavel@devio.us>
Newsgroups comp.os.linux.development.system
Subject Re: mmap dma buffer
Date 2011-07-08 07:01 +0000
Organization Aioe.org NNTP Server
Message-ID <slrnj1daqa.6ek.pavel@wolfman.devio.us> (permalink)
References (1 earlier) <slrnj1b0sk.6ff.pavel@wolfman.devio.us> <slrnj1b122.6ff.pavel@wolfman.devio.us> <dd10c6f9-8362-45ea-b024-81b82740926e@29g2000yqb.googlegroups.com> <slrnj1bd1l.94v.pavel@wolfman.devio.us> <ccccc47f-54c5-4b40-92ad-945e75154871@p6g2000vbj.googlegroups.com>

Show all headers | View raw


On 2011-07-07, new <luvraghu@gmail.com> wrote:
> okay.. the mmap_buf is filled with data and passed to write() call,the
> write callback in driver creates the descriptor chain and initiates
> the DMA engine.

If you are using mmap, don't use write to trigger DMA (it's very confusing).
Better style is to add new ioctl for this:

buf = mmap(....);
memcpy(buf, <data to be written to device>, <data size>);
ioctl(fd, START_DMA_WRITE, <data size>);

> Now to verify if the data is written properly to the device, i need to
> read the data, this is where i'm a bit struck. For reading the data,
> do I need to mmap and call read() function? where the read callback in
> driver will create the descriptor chain and initiate the DMA.
> Is this the correct way to read the data?

You don't need to do mmap again, the buffer is already mapped to the process'
address space. You may verify the data like this:

memset(buf, 0, <buf size>); /* required to verify that we actually read
                               something from the device */
ioctl(fd, START_DMA_READ, <data size>);

After that you can compare data like this:
memcmp(buf, <data that was written to device>, <data size>);

You may want to add 'poll' support into your driver to notify userspace process
that DMA read/write has completed.

-- 
Pavel

Back to comp.os.linux.development.system | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

mmap dma buffer new <luvraghu@gmail.com> - 2011-07-06 08:12 -0700
  Re: mmap dma buffer Pavel Borzenkov <pavel@devio.us> - 2011-07-07 09:59 +0000
    Re: mmap dma buffer Pavel Borzenkov <pavel@devio.us> - 2011-07-07 10:02 +0000
      Re: mmap dma buffer new <luvraghu@gmail.com> - 2011-07-07 05:42 -0700
        Re: mmap dma buffer Pavel Borzenkov <pavel@devio.us> - 2011-07-07 13:27 +0000
          Re: mmap dma buffer new <luvraghu@gmail.com> - 2011-07-07 07:46 -0700
            Re: mmap dma buffer Pavel Borzenkov <pavel@devio.us> - 2011-07-08 07:01 +0000
              Re: mmap dma buffer new <luvraghu@gmail.com> - 2011-07-08 03:31 -0700

csiph-web