From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
To: linux-kernel@vger.kernel.org
Cc: Dan Williams <dan.j.williams@intel.com>, linux-sh@vger.kernel.org
Subject: [PATCH 2/5] dmaengine: fix dmatest to verify minimum transfer length and test buffer size
Date: Fri, 4 Dec 2009 19:44:48 +0100 (CET) [thread overview]
Message-ID: <Pine.LNX.4.64.0912041940580.3981@axis700.grange> (raw)
In-Reply-To: <Pine.LNX.4.64.0912041936541.3981@axis700.grange>
Transfers and the test buffer have to be at least align bytes long.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
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 a32a4cf..8b90516 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;
--
1.6.2.4
next prev parent reply other threads:[~2009-12-04 18:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-04 18:44 [PATCH 0/5] sh: fix the shdma driver, improve dmatest, support sh7724 Guennadi Liakhovetski
2009-12-04 18:44 ` [PATCH 1/5] sh: DMA driver has to specify its alignment requirements Guennadi Liakhovetski
2009-12-04 18:44 ` Guennadi Liakhovetski [this message]
2009-12-04 18:44 ` [PATCH 3/5] sh: fix DMA driver's descriptor chaining and cookie assignment Guennadi Liakhovetski
2009-12-08 0:58 ` Dan Williams
2009-12-12 2:11 ` Nobuhiro Iwamatsu
2009-12-04 18:45 ` [PATCH 4/5] sh: stylistic improvements for the DMA driver Guennadi Liakhovetski
2009-12-08 0:54 ` Dan Williams
2009-12-08 8:20 ` Guennadi Liakhovetski
2009-12-04 18:45 ` [PATCH 5/5] sh: dmaengine support for sh7724 Guennadi Liakhovetski
2009-12-08 1:02 ` Dan Williams
2009-12-08 7:13 ` Paul Mundt
2009-12-17 3:14 ` Nobuhiro Iwamatsu
2009-12-17 5:15 ` Paul Mundt
2009-12-17 7:42 ` Guennadi Liakhovetski
2009-12-17 7:47 ` Paul Mundt
2009-12-17 8:02 ` Guennadi Liakhovetski
2009-12-17 8:09 ` Paul Mundt
2009-12-08 1:09 ` [PATCH 0/5] sh: fix the shdma driver, improve dmatest, support sh7724 Dan Williams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0912041940580.3981@axis700.grange \
--to=g.liakhovetski@gmx.de \
--cc=dan.j.williams@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®