Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp880189pxk; Thu, 17 Sep 2020 20:11:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHM4MvC+ykdmZoi9rR2w09ZSYtUkr3gHOuFYRnaQg2X/jE3lqAdcELDfDYTO9UKHvx/v6x X-Received: by 2002:a17:906:af53:: with SMTP id ly19mr32911991ejb.503.1600398664059; Thu, 17 Sep 2020 20:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398664; cv=none; d=google.com; s=arc-20160816; b=NX71sWmHPq5Rwfn2q+MSssZEPu9DcLFDxS2b8ZY6fjfV7JPXKq6zdhrzsJzk2m6Dxi SS0SWSrxuRKHZSsKLhToE8M/6eK3x4lgqIxpmwAqoG3Wsq43Fw5Mdz4e2x03XjLI+jua IQiGVBps7gnd9xi6bJ4hSF9q1dVRcCmfibTTaSohrKXz9Gmc+yn2ryyFx0dkbyYGeUVp L/cLPJS11JNJG4wyXqO6u1gXMg/WYMeKPCAWl3jt3aF+uLGjIXlaSBqpGk1k0HqFcy+V 4QewZkDeGG+30J7n2ZojTzQ3Mhi20TRzUBze5g5enxms77xgf7j2/FwIJO7hKOvRHM8p H/mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cxIKtWzz0tzLizQhfRIqplQL3US+JfrHcWox0xQ99Ls=; b=02PuenuOSxNSEOvYs/rTnL4NZiGu4hwokdPvZVpjoJJNtZG8YUorsEchzknWHkqY87 mMu03++7Zpsv4m+nCEDZU0o2zHw/C0URGVNDW6I3FlpjfO8wGMqTloP3tudShpOHyZbt /G8WZ6oVK46NzpWCYaiYYUT1EXW3k1p7DmrM7PYUpp9CBBbcMUs5vJ0U0yKOjIWSWYKp YncVL/0/P8JWym68h3nxBJh6OJbrKgPD5sr4TuEJmDfgSuU7wjjcZ1ikr5MNNR0bmZV/ +kUgWATPgTvwBd3eONttZKpRnqYrqjOEBiAUKQfUc++5ghZl+JC6B4/PRdVT9xHIuD4X 2FoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zegF19mH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id os2si1253972ejb.112.2020.09.17.20.10.41; Thu, 17 Sep 2020 20:11:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zegF19mH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728312AbgIRDGf (ORCPT + 99 others); Thu, 17 Sep 2020 23:06:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:50936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727210AbgIRCEC (ORCPT ); Thu, 17 Sep 2020 22:04:02 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 250CE23600; Fri, 18 Sep 2020 02:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394641; bh=66wCMHHAgYvFPF/NiM4KDxXT/ObaN+P40iilFXq/40w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zegF19mH9Col/8Ty8e6K90Zjg7UkDgUKAGm4aitD3lIl9rp/Amd4ECPWs/fubWXnE K8wXXWwyGpR0cXPt4k2WTIg4sxDlUMNgNnUTtZXKIkbJCOWG1lz1Db6zGkNpl+VOhn BWsag8LBmEjnfXv+Gn8tYdKIQ4WpIjA3Qx4RyLwE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Amelie Delaunay , Vinod Koul , Sasha Levin , dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.4 140/330] dmaengine: stm32-dma: use vchan_terminate_vdesc() in .terminate_all Date: Thu, 17 Sep 2020 21:58:00 -0400 Message-Id: <20200918020110.2063155-140-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; } -- 2.25.1