From patchwork Tue Sep 29 10:57:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 290961 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ED68C47425 for ; Tue, 29 Sep 2020 12:06:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C88BC20684 for ; Tue, 29 Sep 2020 12:06:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601381183; bh=66wCMHHAgYvFPF/NiM4KDxXT/ObaN+P40iilFXq/40w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Z1jHJyHm+QqSdjjG/Wub22IuG3LJoXe8LAxaQgTwx2Dlf2NbkOXWBTEr2AUE0g84L IX8r2NHFq/8IzT5eFPqbXjxvuaiRNKH8PbkEuaRJ/v7O0mHDNbwuLFdQ7boi+Hh0o7 Qpkwn5oWOJjfRPOkmDJ2os7p6e6M8sxPtZT8aykI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730273AbgI2Lhh (ORCPT ); Tue, 29 Sep 2020 07:37:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:52840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730229AbgI2Lhg (ORCPT ); Tue, 29 Sep 2020 07:37:36 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2BAA222207; Tue, 29 Sep 2020 11:36:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379372; bh=66wCMHHAgYvFPF/NiM4KDxXT/ObaN+P40iilFXq/40w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IXfnKZtT7UBn4d88wVMOML/SKSmmSJRgwp2OqkedAIkK03O6Uygeg0/aKM6Jz/hAF 67J5f1stSYDqWu3XnJpmAq6BzRVJx64mI6Q7pJ9eXdWEt3+18ojQSLuFxHOpbP9aIm lAWvke3CyxV9blW8kq75XwOpR1GgeAvH8FMLc8bc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amelie Delaunay , Vinod Koul , Sasha Levin Subject: [PATCH 5.4 134/388] dmaengine: stm32-dma: use vchan_terminate_vdesc() in .terminate_all Date: Tue, 29 Sep 2020 12:57:45 +0200 Message-Id: <20200929110016.959395797@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Amelie Delaunay [ Upstream commit d80cbef35bf89b763f06e03bb4ff8f933bf012c5 ] To avoid race with vchan_complete, use the race free way to terminate running transfer. Move vdesc->node list_del in stm32_dma_start_transfer instead of in stm32_mdma_chan_complete to avoid another race in vchan_dma_desc_free_list. Signed-off-by: Amelie Delaunay Link: https://lore.kernel.org/r/20200129153628.29329-9-amelie.delaunay@st.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/stm32-dma.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c index 5989b08935211..6c5771de32c67 100644 --- a/drivers/dma/stm32-dma.c +++ b/drivers/dma/stm32-dma.c @@ -488,8 +488,10 @@ static int stm32_dma_terminate_all(struct dma_chan *c) spin_lock_irqsave(&chan->vchan.lock, flags); - if (chan->busy) { - stm32_dma_stop(chan); + if (chan->desc) { + vchan_terminate_vdesc(&chan->desc->vdesc); + if (chan->busy) + stm32_dma_stop(chan); chan->desc = NULL; } @@ -545,6 +547,8 @@ static void stm32_dma_start_transfer(struct stm32_dma_chan *chan) if (!vdesc) return; + list_del(&vdesc->node); + chan->desc = to_stm32_dma_desc(vdesc); chan->next_sg = 0; } @@ -622,7 +626,6 @@ static void stm32_dma_handle_chan_done(struct stm32_dma_chan *chan) } else { chan->busy = false; if (chan->next_sg == chan->desc->num_sgs) { - list_del(&chan->desc->vdesc.node); vchan_cookie_complete(&chan->desc->vdesc); chan->desc = NULL; }