From patchwork Tue May 21 12:33:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 2598391 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 2BEA23FE81 for ; Tue, 21 May 2013 17:19:46 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UemgY-0001hZ-U9; Tue, 21 May 2013 13:33:04 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UellV-00025e-Rm; Tue, 21 May 2013 12:34:05 +0000 Received: from mga14.intel.com ([143.182.124.37]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UellE-00022K-9K for linux-arm-kernel@lists.infradead.org; Tue, 21 May 2013 12:33:49 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by azsmga102.ch.intel.com with ESMTP; 21 May 2013 05:33:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,714,1363158000"; d="scan'208";a="337585073" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.173]) by fmsmga001.fm.intel.com with ESMTP; 21 May 2013 05:33:24 -0700 Received: from andy by smile with local (Exim 4.80) (envelope-from ) id 1Uelkl-0006NW-NA; Tue, 21 May 2013 15:33:19 +0300 From: Andy Shevchenko To: Vinod Koul , "djbw @ fb . com" , "linux-kernel @ vger . kernel . org" , "linux-arm-kernel @ lists . infradead . org" , viresh.kumar@linaro.org, Will Deacon Subject: [PATCH] dmatest: abort transfers immediately when asked for Date: Tue, 21 May 2013 15:33:17 +0300 Message-Id: <1369139597-24446-1-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 1.8.2.rc0.22.gb3600c3 In-Reply-To: <20130516153553.GI11706@mudshark.cambridge.arm.com> References: <20130516153553.GI11706@mudshark.cambridge.arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130521_083348_408916_72E6F803 X-CRM114-Status: GOOD ( 14.40 ) X-Spam-Score: -8.0 (--------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-8.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [143.182.124.37 listed in list.dnswl.org] -1.1 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Andy Shevchenko X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When thread is going to be stopped we have to unconditionally terminate all ongoing transfers. Otherwise it would be possible that callback function will be called on the next interrupt and will try to access to already freed structures. The patch introduces specific error message for this, though it doesn't increase the counter of the failed tests. Signed-off-by: Andy Shevchenko Reported-by: Will Deacon --- drivers/dma/dmatest.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index d8ce4ec..f61bd55 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -92,6 +92,7 @@ enum dmatest_error_type { DMATEST_ET_MAP_DST, DMATEST_ET_PREP, DMATEST_ET_SUBMIT, + DMATEST_ET_ABORT, DMATEST_ET_TIMEOUT, DMATEST_ET_DMA_ERROR, DMATEST_ET_DMA_IN_PROGRESS, @@ -366,6 +367,7 @@ static char *thread_result_get(const char *name, [DMATEST_ET_MAP_DST] = "dst mapping error", [DMATEST_ET_PREP] = "prep error", [DMATEST_ET_SUBMIT] = "submit error", + [DMATEST_ET_ABORT] = "transfer aborted", [DMATEST_ET_TIMEOUT] = "test timed out", [DMATEST_ET_DMA_ERROR] = "got completion callback (DMA_ERROR)", @@ -720,6 +722,15 @@ static int dmatest_func(void *data) done.done || kthread_should_stop(), msecs_to_jiffies(params->timeout)); + /* terminate all transfers on specified channel if needed */ + if (kthread_should_stop()) { + dmaengine_terminate_all(chan); + thread_result_add(info, result, DMATEST_ET_ABORT, + total_tests, src_off, dst_off, + len, 0); + break; + } + status = dma_async_is_tx_complete(chan, cookie, NULL, NULL); if (!done.done) {