DMA Engine development
 help / color / mirror / Atom feed
* [PATCH v1 1/6] dmaengine: dmatest: Fix iteration non-stop logic
@ 2020-04-24 16:11 Andy Shevchenko
  2020-04-24 16:11 ` [PATCH v1 2/6] dmaengine: dmatest: Fix process hang when reading 'wait' parameter Andy Shevchenko
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Andy Shevchenko @ 2020-04-24 16:11 UTC (permalink / raw)
  To: Dan Williams, Vinod Koul, dmaengine; +Cc: Andy Shevchenko, Nicolas Ferre

Under some circumstances, i.e. when test is still running and about to
time out and user runs, for example,

	grep -H . /sys/module/dmatest/parameters/*

the iterations parameter is not respected and test is going on and on until
user gives

	echo 0 > /sys/module/dmatest/parameters/run

This is not what expected.

The history of this bug is interesting. I though that the commit
  2d88ce76eb98 ("dmatest: add a 'wait' parameter")
is a culprit, but looking closer to the code I think it simple revealed the
broken logic from the day one, i.e. in the commit
  0a2ff57d6fba ("dmaengine: dmatest: add a maximum number of test iterations")
which adds iterations parameter.

So, to the point, the conditional of checking the thread to be stopped being
first part of conjunction logic prevents to check iterations. Thus, we have to
always check both conditions to be able to stop after given iterations.

Since it wasn't visible before second commit appeared, I add a respective
Fixes tag.

Fixes: 2d88ce76eb98 ("dmatest: add a 'wait' parameter")
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dmatest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index a2cadfa2e6d78..4993e3e5c5b01 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -662,8 +662,8 @@ static int dmatest_func(void *data)
 		flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
 
 	ktime = ktime_get();
-	while (!kthread_should_stop()
-	       && !(params->iterations && total_tests >= params->iterations)) {
+	while (!(kthread_should_stop() ||
+	       (params->iterations && total_tests >= params->iterations))) {
 		struct dma_async_tx_descriptor *tx = NULL;
 		struct dmaengine_unmap_data *um;
 		dma_addr_t *dsts;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-04-27 16:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-24 16:11 [PATCH v1 1/6] dmaengine: dmatest: Fix iteration non-stop logic Andy Shevchenko
2020-04-24 16:11 ` [PATCH v1 2/6] dmaengine: dmatest: Fix process hang when reading 'wait' parameter Andy Shevchenko
2020-04-27 16:16   ` Vinod Koul
2020-04-24 16:11 ` [PATCH v1 3/6] Revert "dmaengine: dmatest: timeout value of -1 should specify infinite wait" Andy Shevchenko
2020-04-27 16:18   ` Vinod Koul
2020-04-24 16:11 ` [PATCH v1 4/6] dmaengine: dmatest: Allow negative timeout value to specify infinite wait Andy Shevchenko
2020-04-27 16:18   ` Vinod Koul
2020-04-24 16:11 ` [PATCH v1 5/6] dmaengine: dmatest: Describe members of struct dmatest_params Andy Shevchenko
2020-04-27 16:21   ` Vinod Koul
2020-04-24 16:11 ` [PATCH v1 6/6] dmaengine: dmatest: Describe members of struct dmatest_info Andy Shevchenko
2020-04-27 16:22   ` Vinod Koul
2020-04-27  8:09 ` [PATCH v1 1/6] dmaengine: dmatest: Fix iteration non-stop logic Nicolas Ferre
2020-04-27 16:16 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox