diff options
-rw-r--r-- | drivers/dma/dmatest.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index a32a4cf7b1e0..8b905161fbf4 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c | |||
@@ -298,10 +298,6 @@ static int dmatest_func(void *data) | |||
298 | 298 | ||
299 | total_tests++; | 299 | total_tests++; |
300 | 300 | ||
301 | len = dmatest_random() % test_buf_size + 1; | ||
302 | src_off = dmatest_random() % (test_buf_size - len + 1); | ||
303 | dst_off = dmatest_random() % (test_buf_size - len + 1); | ||
304 | |||
305 | /* honor alignment restrictions */ | 301 | /* honor alignment restrictions */ |
306 | if (thread->type == DMA_MEMCPY) | 302 | if (thread->type == DMA_MEMCPY) |
307 | align = dev->copy_align; | 303 | align = dev->copy_align; |
@@ -310,7 +306,19 @@ static int dmatest_func(void *data) | |||
310 | else if (thread->type == DMA_PQ) | 306 | else if (thread->type == DMA_PQ) |
311 | align = dev->pq_align; | 307 | align = dev->pq_align; |
312 | 308 | ||
309 | if (1 << align > test_buf_size) { | ||
310 | pr_err("%u-byte buffer too small for %d-byte alignment\n", | ||
311 | test_buf_size, 1 << align); | ||
312 | break; | ||
313 | } | ||
314 | |||
315 | len = dmatest_random() % test_buf_size + 1; | ||
313 | len = (len >> align) << align; | 316 | len = (len >> align) << align; |
317 | if (!len) | ||
318 | len = 1 << align; | ||
319 | src_off = dmatest_random() % (test_buf_size - len + 1); | ||
320 | dst_off = dmatest_random() % (test_buf_size - len + 1); | ||
321 | |||
314 | src_off = (src_off >> align) << align; | 322 | src_off = (src_off >> align) << align; |
315 | dst_off = (dst_off >> align) << align; | 323 | dst_off = (dst_off >> align) << align; |
316 | 324 | ||