diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2009-01-13 11:22:20 -0500 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2009-01-13 11:22:20 -0500 |
commit | d86be86e9aab221089d72399072511f13fe2a771 (patch) | |
tree | 58da7322d8dfa58da5f03c117481df8ab93b7311 | |
parent | 6527de6d6d25ebfae7c7572cb7a4ed768e2e20a5 (diff) |
dmatest: Use custom map/unmap for destination buffer
The dmatest driver should use DMA_BIDIRECTIONAL on the destination buffer
to ensure that the poison values are written to RAM and not just written
to cache and discarded.
Acked-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Acked-by: Maciej Sosnowski <maciej.sosnowski@intel.com>
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/dma/dmatest.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 3603f1ea5b28..732fa1ec36ab 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c | |||
@@ -217,6 +217,10 @@ static int dmatest_func(void *data) | |||
217 | chan = thread->chan; | 217 | chan = thread->chan; |
218 | 218 | ||
219 | while (!kthread_should_stop()) { | 219 | while (!kthread_should_stop()) { |
220 | struct dma_device *dev = chan->device; | ||
221 | struct dma_async_tx_descriptor *tx; | ||
222 | dma_addr_t dma_src, dma_dest; | ||
223 | |||
220 | total_tests++; | 224 | total_tests++; |
221 | 225 | ||
222 | len = dmatest_random() % test_buf_size + 1; | 226 | len = dmatest_random() % test_buf_size + 1; |
@@ -226,10 +230,30 @@ static int dmatest_func(void *data) | |||
226 | dmatest_init_srcbuf(thread->srcbuf, src_off, len); | 230 | dmatest_init_srcbuf(thread->srcbuf, src_off, len); |
227 | dmatest_init_dstbuf(thread->dstbuf, dst_off, len); | 231 | dmatest_init_dstbuf(thread->dstbuf, dst_off, len); |
228 | 232 | ||
229 | cookie = dma_async_memcpy_buf_to_buf(chan, | 233 | dma_src = dma_map_single(dev->dev, thread->srcbuf + src_off, |
230 | thread->dstbuf + dst_off, | 234 | len, DMA_TO_DEVICE); |
231 | thread->srcbuf + src_off, | 235 | /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */ |
232 | len); | 236 | dma_dest = dma_map_single(dev->dev, thread->dstbuf, |
237 | test_buf_size, DMA_BIDIRECTIONAL); | ||
238 | |||
239 | tx = dev->device_prep_dma_memcpy(chan, dma_dest + dst_off, | ||
240 | dma_src, len, | ||
241 | DMA_CTRL_ACK | DMA_COMPL_SKIP_DEST_UNMAP); | ||
242 | if (!tx) { | ||
243 | dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE); | ||
244 | dma_unmap_single(dev->dev, dma_dest, | ||
245 | test_buf_size, DMA_BIDIRECTIONAL); | ||
246 | pr_warning("%s: #%u: prep error with src_off=0x%x " | ||
247 | "dst_off=0x%x len=0x%x\n", | ||
248 | thread_name, total_tests - 1, | ||
249 | src_off, dst_off, len); | ||
250 | msleep(100); | ||
251 | failed_tests++; | ||
252 | continue; | ||
253 | } | ||
254 | tx->callback = NULL; | ||
255 | cookie = tx->tx_submit(tx); | ||
256 | |||
233 | if (dma_submit_error(cookie)) { | 257 | if (dma_submit_error(cookie)) { |
234 | pr_warning("%s: #%u: submit error %d with src_off=0x%x " | 258 | pr_warning("%s: #%u: submit error %d with src_off=0x%x " |
235 | "dst_off=0x%x len=0x%x\n", | 259 | "dst_off=0x%x len=0x%x\n", |
@@ -253,6 +277,9 @@ static int dmatest_func(void *data) | |||
253 | failed_tests++; | 277 | failed_tests++; |
254 | continue; | 278 | continue; |
255 | } | 279 | } |
280 | /* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */ | ||
281 | dma_unmap_single(dev->dev, dma_dest, | ||
282 | test_buf_size, DMA_BIDIRECTIONAL); | ||
256 | 283 | ||
257 | error_count = 0; | 284 | error_count = 0; |
258 | 285 | ||