Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: dmatest: Add support for completion polling

With the polled parameter the DMA drivers can be tested if they can work
correctly when no completion is requested (no DMA_PREP_INTERRUPT and no
callback is provided).

If polled mode is selected then use dma_sync_wait() to execute the test
iteration instead of relying on the completion callback.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20190731071438.24075-1-peter.ujfalusi@ti.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Peter Ujfalusi and committed by
Vinod Koul
fb9816f9 9fa2df6e

+28 -7
+28 -7
drivers/dma/dmatest.c
··· 72 72 module_param(norandom, bool, 0644); 73 73 MODULE_PARM_DESC(norandom, "Disable random offset setup (default: random)"); 74 74 75 + static bool polled; 76 + module_param(polled, bool, S_IRUGO | S_IWUSR); 77 + MODULE_PARM_DESC(polled, "Use polling for completion instead of interrupts"); 78 + 75 79 static bool verbose; 76 80 module_param(verbose, bool, S_IRUGO | S_IWUSR); 77 81 MODULE_PARM_DESC(verbose, "Enable \"success\" result messages (default: off)"); ··· 114 110 bool norandom; 115 111 int alignment; 116 112 unsigned int transfer_size; 113 + bool polled; 117 114 }; 118 115 119 116 /** ··· 656 651 /* 657 652 * src and dst buffers are freed by ourselves below 658 653 */ 659 - flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT; 654 + if (params->polled) 655 + flags = DMA_CTRL_ACK; 656 + else 657 + flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT; 660 658 661 659 ktime = ktime_get(); 662 660 while (!kthread_should_stop() ··· 788 780 } 789 781 790 782 done->done = false; 791 - tx->callback = dmatest_callback; 792 - tx->callback_param = done; 783 + if (!params->polled) { 784 + tx->callback = dmatest_callback; 785 + tx->callback_param = done; 786 + } 793 787 cookie = tx->tx_submit(tx); 794 788 795 789 if (dma_submit_error(cookie)) { ··· 800 790 msleep(100); 801 791 goto error_unmap_continue; 802 792 } 803 - dma_async_issue_pending(chan); 804 793 805 - wait_event_freezable_timeout(thread->done_wait, done->done, 806 - msecs_to_jiffies(params->timeout)); 794 + if (params->polled) { 795 + status = dma_sync_wait(chan, cookie); 796 + dmaengine_terminate_sync(chan); 797 + if (status == DMA_COMPLETE) 798 + done->done = true; 799 + } else { 800 + dma_async_issue_pending(chan); 807 801 808 - status = dma_async_is_tx_complete(chan, cookie, NULL, NULL); 802 + wait_event_freezable_timeout(thread->done_wait, 803 + done->done, 804 + msecs_to_jiffies(params->timeout)); 805 + 806 + status = dma_async_is_tx_complete(chan, cookie, NULL, 807 + NULL); 808 + } 809 809 810 810 if (!done->done) { 811 811 result("test timed out", total_tests, src->off, dst->off, ··· 1085 1065 params->norandom = norandom; 1086 1066 params->alignment = alignment; 1087 1067 params->transfer_size = transfer_size; 1068 + params->polled = polled; 1088 1069 1089 1070 request_channels(info, DMA_MEMCPY); 1090 1071 request_channels(info, DMA_MEMSET);