From patchwork Wed Mar 22 14:50:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Whitchurch X-Patchwork-Id: 73495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2399168wrt; Wed, 22 Mar 2023 08:20:22 -0700 (PDT) X-Google-Smtp-Source: AK7set/1sIzEbqLl1k55pj2Xc2yl7tU9X34c0An/Hiu5LNMhYP2HBeL66KpO3ZK5QfBx/DZclNjV X-Received: by 2002:a17:902:f38b:b0:1a1:595a:8e3b with SMTP id f11-20020a170902f38b00b001a1595a8e3bmr2486783ple.34.1679498422256; Wed, 22 Mar 2023 08:20:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679498422; cv=none; d=google.com; s=arc-20160816; b=MjOJhcpSr7mmZJfsO7jwBs+s5Llah6Sjmq6dEtXT/SQRcc6fFIGm2w7QraQIgMIJjz ZErQJenld3Z/QoAGUs1aiePYBgAUcsVuLFyNejEwa3io637DzvtBLE1MK95c2R6c9Mr7 lX1rV2cSYYNHAutWWfnw7w7eN0r0H5tNbX6ZS+PAEfpVX62KebxjoghTJSOsGVUVR9x2 dXZJ8dweAl+wVVciL3/Lf+GhHBW+/lQ0Kup4cL/o0j7kjg2xyyMtwsPLR5oXFR1rGmrx VPzQFyBJIt71MtS98wtzJ4sLaGz62wJGtLrQOyMAj4enYrl3bpzdt65WHl6N4HOOqmmD eeFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=Y8cEMk+xHf0dXxZXxCsRBUDEAJjt0BP553Xavc3rKbk=; b=jkmaGx5c3Afz+R+ulDbbz+wiZRozepXnMg7kebYI6J8K9v0NclPwOucryCvdxbTTzj ZUHOUXtj/gjcr7Keqn0rCqK3zMaoodCEWzZYBZqSqBFtdx0ESgboKntt9priZh+qkfnE UVzNq2s0mNsc2i7SUbm0D26crTbA9WXPML0HabBqAkGB3uQK7SFI8dQJBgiWsh0FuGsi 9vC6ofEl1mHdiXGJdArsej3btmjFoxrxRPS1Za8kHig32P9gQ2gzTKetMZvw1VEua8hs VvPM3BZT/iGrvdH2Zk85lZKVWckq300i0BeMHmUXCUnp9Ebcr3CUBIrIWCogCM7meIsT 0UdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=KE2oYPnV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ky3-20020a170902f98300b001a068523000si14853995plb.231.2023.03.22.08.20.09; Wed, 22 Mar 2023 08:20:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=KE2oYPnV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231251AbjCVOwg (ORCPT + 99 others); Wed, 22 Mar 2023 10:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230303AbjCVOwN (ORCPT ); Wed, 22 Mar 2023 10:52:13 -0400 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E49B664F3; Wed, 22 Mar 2023 07:50:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1679496639; x=1711032639; h=from:date:subject:mime-version:content-transfer-encoding: message-id:to:cc; bh=Y8cEMk+xHf0dXxZXxCsRBUDEAJjt0BP553Xavc3rKbk=; b=KE2oYPnV0PdaO845x+fE32lE2DK6wxp57M4jTLbMqPqTvKhY1NG+++nd eCPWwPDRwjSFHSy9XhDllrIzB3W/AiFTfH3pB1GAuVk5sMpdHqA5K6zrd RYdmy2KhjcScMHQ4FoGLIuM3w9CbSyykU63lKhgIs4oGWw//rgaGIe8IK SIzwODMpTbAVTYZ0S+UKkC3AFoCWfyAPhTpdRZSGR4XgJ/j9AIAoSSPoW C6Qj1I2mTE4ZVA14kGi1YT9IF/Zj8ZQZA1kO4Od3Ss+e2GpDixvNLBYhh Kg9OgPPZQhF0Kxnee40tUbQGAKkAfonZDauuLmBs4SkSX6T7bXFKhygOG A==; From: Vincent Whitchurch Date: Wed, 22 Mar 2023 15:50:23 +0100 Subject: [PATCH] dmaengine: dmatest: Add option to exercise transfer termination MIME-Version: 1.0 Message-ID: <20230322-dmatest-terminate-v1-1-2dc6bfaa018b@axis.com> X-B4-Tracking: v=1; b=H4sIAK4VG2QC/x2NwQrDMAxDf6X4vECW9jD2K6MHN3EaH5IVO4xB6 b/X7U3Sk9AOSsKk8B52EPqx8reZeT4GiAXbSo6TeQg+jH4MwaWKnbS7TlK5mXYLpsmQf2GOYLs F1ULBFsu1rKjWvcAmlPl/n33m4zgBvkv+bHwAAAA= To: Vinod Koul CC: , , , Vincent Whitchurch X-Mailer: b4 0.12.1 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761081737128612075?= X-GMAIL-MSGID: =?utf-8?q?1761081737128612075?= 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 --- drivers/dma/dmatest.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) --- base-commit: e8d018dd0257f744ca50a729e3d042cf2ec9da65 change-id: 20230322-dmatest-terminate-bad403208afc Best regards, 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; }