diff mbox series

[V4,4/5] dmaengine: dmatest: Add transfer_size parameter

Message ID 1544431926-8662-5-git-send-email-seraj.alijan@sondrel.com (mailing list archive)
State Accepted
Headers show
Series dmaengine: dmatest: Add multi chan and new params | expand

Commit Message

Seraj Alijan Dec. 10, 2018, 8:52 a.m. UTC
Existing transfer size "len" is either generated randomly or set to the
size of test_buf_size. In some cases we need to explicitly specify a
transfer size that is different from the buffer size and non aligned to
test the target device's ability to handle unaligned transfers.

This patch adds optional parameter "transfer_size" to allow setting
explicit transfer size for dma transfers.

Signed-off-by: Seraj Alijan <seraj.alijan@sondrel.com>
---
 drivers/dma/dmatest.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 6302ebe..2eea4ef 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -83,6 +83,10 @@  static int alignment = -1;
 module_param(alignment, int, 0644);
 MODULE_PARM_DESC(alignment, "Custom data address alignment taken as 2^(alignment) (default: not used (-1))");
 
+static unsigned int transfer_size;
+module_param(transfer_size, uint, 0644);
+MODULE_PARM_DESC(transfer_size, "Optional custom transfer size in bytes (default: not used (0))");
+
 /**
  * struct dmatest_params - test parameters.
  * @buf_size:		size of the memcpy test buffer
@@ -108,6 +112,7 @@  struct dmatest_params {
 	bool		noverify;
 	bool		norandom;
 	int		alignment;
+	unsigned int	transfer_size;
 };
 
 /**
@@ -643,15 +648,25 @@  static int dmatest_func(void *data)
 
 		total_tests++;
 
-		if (params->norandom)
+		if (params->transfer_size) {
+			if (params->transfer_size >= params->buf_size) {
+				pr_err("%u-byte transfer size must be lower than %u-buffer size\n",
+				       params->transfer_size, params->buf_size);
+				break;
+			}
+			len = params->transfer_size;
+		} else if (params->norandom) {
 			len = params->buf_size;
-		else
+		} else {
 			len = dmatest_random() % params->buf_size + 1;
+		}
 
-		len = (len >> align) << align;
-		if (!len)
-			len = 1 << align;
-
+		/* Do not alter transfer size explicitly defined by user */
+		if (!params->transfer_size) {
+			len = (len >> align) << align;
+			if (!len)
+				len = 1 << align;
+		}
 		total_len += len;
 
 		if (params->norandom) {
@@ -1047,6 +1062,7 @@  static void add_threaded_test(struct dmatest_info *info)
 	params->noverify = noverify;
 	params->norandom = norandom;
 	params->alignment = alignment;
+	params->transfer_size = transfer_size;
 
 	request_channels(info, DMA_MEMCPY);
 	request_channels(info, DMA_MEMSET);