Skip to content

Commit

Permalink
dmaengine: fix dmatest to verify minimum transfer length and test buf…
Browse files Browse the repository at this point in the history
…fer 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>
  • Loading branch information
Guennadi Liakhovetski authored and Dan Williams committed Dec 11, 2009
1 parent ddb4f0f commit cfe4f27
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions drivers/dma/dmatest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit cfe4f27

Please sign in to comment.