From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
To: haavard.skinnemoen@atmel.com
Cc: linux-kernel@vger.kernel.org, hskinnemoen@atmel.com,
maciej.sosnowski@intel.com, dan.j.williams@intel.com,
ralf@linux-mips.org
Subject: Re: [PATCH] dmatest: flush and invalidate destination buffer before DMA
Date: Mon, 29 Dec 2008 02:53:52 +0900 (JST) [thread overview]
Message-ID: <20081229.025352.01917409.anemo@mba.ocn.ne.jp> (raw)
In-Reply-To: <20081227111037.3bd13adc@hskinnemoen-d830>
On Sat, 27 Dec 2008 11:10:37 +0100, Haavard Skinnemoen <haavard.skinnemoen@atmel.com> wrote:
> Atsushi Nemoto wrote:
> > @@ -226,6 +227,12 @@ static int dmatest_func(void *data)
> >
> > dmatest_init_srcbuf(thread->srcbuf, src_off, len);
> > dmatest_init_dstbuf(thread->dstbuf, dst_off, len);
> > + /* flush and invalidate caches for whole dstbuf */
> > + dma_dest = dma_map_single(chan->device->dev,
> > + thread->dstbuf,
> > + test_buf_size, DMA_BIDIRECTIONAL);
> > + dma_unmap_single(chan->device->dev, dma_dest,
> > + test_buf_size, DMA_BIDIRECTIONAL);
>
> You're supposed to unmap after the DMA operation is done, not before
> it's submitted.
>
> In this case, the DMA engine framework will do the unmapping for you
> (probably using the wrong primitive, but they're really all the same in
> practice, right?) so you can just drop the unmap call.
Well, let me explain more.
On nono-coherent MIPS platforms, dma_map_single() for DMA_TO_DEVICE
writeback the cache, dma_map_single() for DMA_FROM_DEVICE invalidated
(without writeback) the cache. dma_unmap_simgle() is a nop.
If dst_off was not cacheline aligned, dma_map_single(...,
DMA_FROM_DEVICE) in dma_async_memcpy_buf_to_buf() invalidate whole
cachelines including dst_off. So, for example, the initialized data
at dst_off - 1 will be just discarded. This result mismatch error of
course. Same error can be happen at end of the real DMA area.
I added dma_map_single/dma_unmap_single to just flush all dstbuf to
main memory.
> Now, I suspect the dw_dmac driver maps the buffer when it's not
> supposed to, masking this kind of error...should probably get that
> fixed too.
I don't think so. But I'm not sure dma_map_sg() case in
dwc_prep_slave_sg().
---
Atsushi Nemoto
next prev parent reply other threads:[~2008-12-28 17:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-26 15:31 Atsushi Nemoto
2008-12-27 10:10 ` Haavard Skinnemoen
2008-12-28 17:53 ` Atsushi Nemoto [this message]
2009-01-05 18:31 ` Dan Williams
2009-01-06 1:14 ` Atsushi Nemoto
2009-01-06 1:29 ` Dan Williams
2009-01-06 2:06 ` Atsushi Nemoto
2009-01-08 4:43 ` Atsushi Nemoto
2009-01-08 8:36 ` Haavard Skinnemoen
2009-01-08 17:20 ` Dan Williams
2009-01-09 8:30 ` Atsushi Nemoto
2009-01-10 0:39 ` Dan Williams
2009-01-09 11:19 ` Ralf Baechle
2009-01-09 22:27 ` Russell King
2009-01-11 18:44 ` Ralf Baechle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081229.025352.01917409.anemo@mba.ocn.ne.jp \
--to=anemo@mba.ocn.ne.jp \
--cc=dan.j.williams@intel.com \
--cc=haavard.skinnemoen@atmel.com \
--cc=hskinnemoen@atmel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.sosnowski@intel.com \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®