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: Fri, 8 Jul 2011 07:01:29 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 34 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:212 On 2011-07-07, new 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, , ); ioctl(fd, START_DMA_WRITE, ); > 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, ); /* required to verify that we actually read something from the device */ ioctl(fd, START_DMA_READ, ); After that you can compare data like this: memcmp(buf, , ); You may want to add 'poll' support into your driver to notify userspace process that DMA read/write has completed. -- Pavel