Commit cfe4f275 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Dan Williams

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: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent ddb4f0f0
...@@ -298,10 +298,6 @@ static int dmatest_func(void *data) ...@@ -298,10 +298,6 @@ static int dmatest_func(void *data)
total_tests++; 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 */ /* honor alignment restrictions */
if (thread->type == DMA_MEMCPY) if (thread->type == DMA_MEMCPY)
align = dev->copy_align; align = dev->copy_align;
...@@ -310,7 +306,19 @@ static int dmatest_func(void *data) ...@@ -310,7 +306,19 @@ static int dmatest_func(void *data)
else if (thread->type == DMA_PQ) else if (thread->type == DMA_PQ)
align = dev->pq_align; 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; 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; src_off = (src_off >> align) << align;
dst_off = (dst_off >> align) << align; dst_off = (dst_off >> align) << align;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment