From: Vincent Whitchurch <vincent.whitchurch@axis.com>
To: Vinod Koul <vkoul@kernel.org>
Cc: <dmaengine@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<kernel@axis.com>,
Vincent Whitchurch <vincent.whitchurch@axis.com>
Subject: [PATCH] dmaengine: dmatest: Add option to exercise transfer termination
Date: Wed, 22 Mar 2023 15:50:23 +0100 [thread overview]
Message-ID: <20230322-dmatest-terminate-v1-1-2dc6bfaa018b@axis.com> (raw)
Add a module parameter to allow tests to terminate transfers after a
random delay. This can be used to try to provoke races in the handling
of ongoing transfers in drivers' implementations of
->device_terminate_all().
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
drivers/dma/dmatest.c | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index ffe621695e47..c3a7681efea8 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -88,6 +88,12 @@ static bool polled;
module_param(polled, bool, 0644);
MODULE_PARM_DESC(polled, "Use polling for completion instead of interrupts");
+/* Note that throughput stats can be misleading when this is used. */
+static unsigned int terminate_delay_us;
+module_param(terminate_delay_us, uint, 0644);
+MODULE_PARM_DESC(terminate_delay_us,
+ "Terminate transfers after randomly delaying up to the specified time in microseconds (default: no termination)");
+
/**
* struct dmatest_params - test parameters.
* @buf_size: size of the memcpy test buffer
@@ -684,6 +690,7 @@ static int dmatest_func(void *data)
(params->iterations && total_tests >= params->iterations))) {
struct dma_async_tx_descriptor *tx = NULL;
struct dmaengine_unmap_data *um;
+ bool terminated = false;
dma_addr_t *dsts;
unsigned int len;
@@ -827,19 +834,27 @@ static int dmatest_func(void *data)
} else {
dma_async_issue_pending(chan);
- wait_event_freezable_timeout(thread->done_wait,
- done->done,
- msecs_to_jiffies(params->timeout));
+ if (terminate_delay_us) {
+ fsleep(dmatest_random() % terminate_delay_us);
+
+ dmaengine_terminate_sync(chan);
+ terminated = true;
+ }
+
+ if (!terminated)
+ wait_event_freezable_timeout(thread->done_wait,
+ done->done,
+ msecs_to_jiffies(params->timeout));
status = dma_async_is_tx_complete(chan, cookie, NULL,
NULL);
}
- if (!done->done) {
+ if (!terminated && !done->done) {
result("test timed out", total_tests, src->off, dst->off,
len, 0);
goto error_unmap_continue;
- } else if (status != DMA_COMPLETE &&
+ } else if (!terminated && status != DMA_COMPLETE &&
!(dma_has_cap(DMA_COMPLETION_NO_ORDER,
dev->cap_mask) &&
status == DMA_OUT_OF_ORDER)) {
@@ -852,9 +867,11 @@ static int dmatest_func(void *data)
dmaengine_unmap_put(um);
- if (params->noverify) {
- verbose_result("test passed", total_tests, src->off,
- dst->off, len, 0);
+ if (params->noverify || terminated) {
+ const char *msg = terminated ? "test terminated" : "test passed";
+
+ verbose_result(msg, total_tests, src->off, dst->off,
+ len, 0);
continue;
}
---
base-commit: e8d018dd0257f744ca50a729e3d042cf2ec9da65
change-id: 20230322-dmatest-terminate-bad403208afc
Best regards,
--
Vincent Whitchurch <vincent.whitchurch@axis.com>
next reply other threads:[~2023-03-22 14:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 14:50 Vincent Whitchurch [this message]
2023-08-23 7:55 ` Vincent Whitchurch
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=20230322-dmatest-terminate-v1-1-2dc6bfaa018b@axis.com \
--to=vincent.whitchurch@axis.com \
--cc=dmaengine@vger.kernel.org \
--cc=kernel@axis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vkoul@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®