aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/dmatest.txt4
-rw-r--r--drivers/dma/dmatest.c35
2 files changed, 37 insertions, 2 deletions
diff --git a/Documentation/dmatest.txt b/Documentation/dmatest.txt
index e6e16a7f3706..0beb4b68d81f 100644
--- a/Documentation/dmatest.txt
+++ b/Documentation/dmatest.txt
@@ -77,5 +77,9 @@ the parens represents additional information, e.g. error code, error counter,
77or status. A test thread also emits a summary line at completion listing the 77or status. A test thread also emits a summary line at completion listing the
78number of tests executed, number that failed, and a result code. 78number of tests executed, number that failed, and a result code.
79 79
80Example:
81 % dmesg | tail -n 1
82 dmatest: dma3chan0-copy0: summary 400000 tests, 0 failures iops: 61524 KB/s 246098 (0)
83
80The details of a data miscompare error are also emitted, but do not follow the 84The details of a data miscompare error are also emitted, but do not follow the
81above format. 85above format.
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index d07b73275d0f..26b502069638 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -325,6 +325,29 @@ static void dbg_result(const char *err, unsigned int n, unsigned int src_off,
325 current->comm, n, err, src_off, dst_off, len, data); 325 current->comm, n, err, src_off, dst_off, len, data);
326} 326}
327 327
328static unsigned long long dmatest_persec(s64 runtime, unsigned int val)
329{
330 unsigned long long per_sec = 1000000;
331
332 if (runtime <= 0)
333 return 0;
334
335 /* drop precision until runtime is 32-bits */
336 while (runtime > UINT_MAX) {
337 runtime >>= 1;
338 per_sec <<= 1;
339 }
340
341 per_sec *= val;
342 do_div(per_sec, runtime);
343 return per_sec;
344}
345
346static unsigned long long dmatest_KBs(s64 runtime, unsigned long long len)
347{
348 return dmatest_persec(runtime, len >> 10);
349}
350
328/* 351/*
329 * This function repeatedly tests DMA transfers of various lengths and 352 * This function repeatedly tests DMA transfers of various lengths and
330 * offsets for a given operation type until it is told to exit by 353 * offsets for a given operation type until it is told to exit by
@@ -360,6 +383,9 @@ static int dmatest_func(void *data)
360 int src_cnt; 383 int src_cnt;
361 int dst_cnt; 384 int dst_cnt;
362 int i; 385 int i;
386 ktime_t ktime;
387 s64 runtime = 0;
388 unsigned long long total_len = 0;
363 389
364 set_freezable(); 390 set_freezable();
365 391
@@ -417,6 +443,7 @@ static int dmatest_func(void *data)
417 */ 443 */
418 flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT; 444 flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
419 445
446 ktime = ktime_get();
420 while (!kthread_should_stop() 447 while (!kthread_should_stop()
421 && !(params->iterations && total_tests >= params->iterations)) { 448 && !(params->iterations && total_tests >= params->iterations)) {
422 struct dma_async_tx_descriptor *tx = NULL; 449 struct dma_async_tx_descriptor *tx = NULL;
@@ -464,6 +491,7 @@ static int dmatest_func(void *data)
464 len = (len >> align) << align; 491 len = (len >> align) << align;
465 if (!len) 492 if (!len)
466 len = 1 << align; 493 len = 1 << align;
494 total_len += len;
467 495
468 for (i = 0; i < src_cnt; i++) { 496 for (i = 0; i < src_cnt; i++) {
469 u8 *buf = thread->srcs[i] + src_off; 497 u8 *buf = thread->srcs[i] + src_off;
@@ -607,6 +635,7 @@ static int dmatest_func(void *data)
607 len, 0); 635 len, 0);
608 } 636 }
609 } 637 }
638 runtime = ktime_us_delta(ktime_get(), ktime);
610 639
611 ret = 0; 640 ret = 0;
612 for (i = 0; thread->dsts[i]; i++) 641 for (i = 0; thread->dsts[i]; i++)
@@ -621,8 +650,10 @@ err_srcbuf:
621err_srcs: 650err_srcs:
622 kfree(pq_coefs); 651 kfree(pq_coefs);
623err_thread_type: 652err_thread_type:
624 pr_info("%s: terminating after %u tests, %u failures (status %d)\n", 653 pr_info("%s: summary %u tests, %u failures %llu iops %llu KB/s (%d)\n",
625 current->comm, total_tests, failed_tests, ret); 654 current->comm, total_tests, failed_tests,
655 dmatest_persec(runtime, total_tests),
656 dmatest_KBs(runtime, total_len), ret);
626 657
627 /* terminate all transfers on specified channels */ 658 /* terminate all transfers on specified channels */
628 if (ret) 659 if (ret)