Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Pavel Borzenkov 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: References: 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 On 2011-07-07, new 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