Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


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

Re: mmap dma buffer

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From Pavel Borzenkov <pavel@devio.us>
Newsgroups comp.os.linux.development.system
Subject Re: mmap dma buffer
Date Thu, 7 Jul 2011 13:27:15 +0000 (UTC)
Organization Aioe.org NNTP Server
Lines 33
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>
NNTP-Posting-Host 5Bi2vCRq6cgjQObVvr9N+Q.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
User-Agent slrn/0.9.9p1 (OpenBSD)
X-Notice Filtered by postfilter v. 0.8.2
Xref x330-a1.tempe.blueboxinc.net comp.os.linux.development.system:209

Show key headers only | 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