diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2009-12-04 19:44:48 +0100 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2009-12-10 23:27:51 -0700 |
commit | cfe4f2751ef1a5390b56c5d263f90b6ff138ba31 (patch) | |
tree | 05eb71e6046cde60a728b792b9b44918e9b1c210 /drivers/dma/dmatest.c | |
parent | ddb4f0f0e05871c7ac540cc778993c06ff53b765 (diff) | |
download | lwn-cfe4f2751ef1a5390b56c5d263f90b6ff138ba31.tar.gz lwn-cfe4f2751ef1a5390b56c5d263f90b6ff138ba31.zip |
dmaengine: fix dmatest to verify minimum transfer length and test buffer size
Transfers and the test buffer have to be at least align bytes long.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/dma/dmatest.c')
-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) total_tests++; - len = dmatest_random() % test_buf_size + 1; - src_off = dmatest_random() % (test_buf_size - len + 1); - dst_off = dmatest_random() % (test_buf_size - len + 1); - /* honor alignment restrictions */ if (thread->type == DMA_MEMCPY) align = dev->copy_align; @@ -310,7 +306,19 @@ static int dmatest_func(void *data) else if (thread->type == DMA_PQ) align = dev->pq_align; + if (1 << align > test_buf_size) { + pr_err("%u-byte buffer too small for %d-byte alignment\n", + test_buf_size, 1 << align); + break; + } + + len = dmatest_random() % test_buf_size + 1; len = (len >> align) << align; + if (!len) + len = 1 << align; + src_off = dmatest_random() % (test_buf_size - len + 1); + dst_off = dmatest_random() % (test_buf_size - len + 1); + src_off = (src_off >> align) << align; dst_off = (dst_off >> align) << align; |