Groups | Search | Server Info | Login | Register


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

Re: mmap dma buffer

From Pavel Borzenkov <pavel@devio.us>
Newsgroups comp.os.linux.development.system
Subject Re: mmap dma buffer
Date 2011-07-07 13:27 +0000
Organization Aioe.org NNTP Server
Message-ID <slrnj1bd1l.94v.pavel@wolfman.devio.us> (permalink)
References <b1c8cc05-4b93-4b07-a041-c8a597965aa7@b39g2000prd.googlegroups.com> <slrnj1b0sk.6ff.pavel@wolfman.devio.us> <slrnj1b122.6ff.pavel@wolfman.devio.us> <dd10c6f9-8362-45ea-b024-81b82740926e@29g2000yqb.googlegroups.com>

Show all headers | View raw


On 2011-07-07, new <luvraghu@gmail.com> wrote:
>
> Thanks Pavel for the reply.
> I shall use the physical return addr returned by
> pci_alloc_consistent() and assign it to pfn argument.
> Do you think rest of the code looks good? how should i proceed for the
> read operation? i'm writing the PCIe driver for the fpga board.

I don't understand what are you trying to achieve with this code:

{{{
mmap_buf = mmap(NULL, regdma.dmabuffsize, PROT_READ | PROT_WRITE,
MAP_SHARED, deviceHandle, 0);

if (mmap_buf == (unsigned char *)MAP_FAILED) {
printf("MMAP FAILED\n");
return 0;
}
/* call the write function*/
write(deviceHandle,mmap_buf,regdma.dmabuffsize);
}}}

You mapped a physical memory region into process' address space and then
you're trying to write data from this memory region into your driver. But you
haven't filled it with any valid data. What does .write callback in your
driver do?

If you want to copy data from somewhere into this buffer you can use memcpy:

memcpy(mmap_buf, somewhere, regdma.dmabuffsize);

-- 
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