Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp853447pxk; Thu, 17 Sep 2020 19:08:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbSDua/spghBAkAMH2hPbDe5nohLXpP1jWByl+WLuSf888Us+vxwfZ7i4NTkRMIoyxG53h X-Received: by 2002:aa7:d3da:: with SMTP id o26mr34989778edr.169.1600394908057; Thu, 17 Sep 2020 19:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394908; cv=none; d=google.com; s=arc-20160816; b=M1VKi03pNa8F4zZ3+JolG7H4+TZIcnhmwi6mG7tTVG5n9mRYceTtOq4iJJD5oGH/GK b00uPcc+6MB1oaqcBNZUQ6+0bujXA16849NF+hMVvzv5WsYU5o6/z1yR/S4QKEr0oq3P Z5LAa3oGrSoEj8bk3yyPz0KZDCCnFjdmbyGpaLZ2nBUKzdio9jQs3XrYDRhOR0LNegKr PRHAOdOlK8/yZxB/euuctVkuDrgSEszX06OIajaw+wJZeOjC90uzbXfyequ6AE0pgStK +O7/axxglr8Dl9e7Hf8hXhRWVJw9HKwkpqvZBX5/boUSRMXQlZsrBup+FNGvMnsiYTIk IDQA== 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=LhWfgdnlBXje/xEZvgcg3G9wDGraIUD9qECk2/X3edk=; b=RLg7Jq9MQERI1OfLaU0rmQe0I08QVZVbYsysoBbBKQbe3GaL6TrLAXqS9sjt8zRr53 Rlxa3Xy+nwtv6JwfOkII/HzygA0Z91t5dnrlmaMhhpfpu0Su8/1ZJJbmBNdXxwoGMRwG ZlgzMYI2xRu2lgIPkuv+NALZCE15Ac+v5W1QxpABXWL3GyvBm5ATunMm3E4BnspYVT1s T6+VVk/z+cYBQARFPUi+2A7z/oFZG7GMMMZh5Up7LoZHKGdcFiwgOGMuC5aYQhZR2zKk +z31zxFQCgy1aNFehFxOUaXSt/lKFz1iBjHJuKuqyC4foJ1SEwaKtru2dZ0HzT79POd+ Hbig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PHHrEa2L; 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 r12si1169189edq.93.2020.09.17.19.08.05; Thu, 17 Sep 2020 19:08:28 -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=PHHrEa2L; 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 S1727239AbgIRCEH (ORCPT + 99 others); Thu, 17 Sep 2020 22:04:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:50890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727199AbgIRCEB (ORCPT ); Thu, 17 Sep 2020 22:04:01 -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 3BFF823718; Fri, 18 Sep 2020 02:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394637; bh=Jb4b+5OTPSm0f+YOgcsf9eXrLB8ukGPqsuUkC1mKNy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHHrEa2LuohVBtd0d2c0FRcouWqrjl2DNEljIwXFeaUuX2C99yhvHHA/JMxbYqqPm OsJr0h9bsKOHlpOBDyGM8UlUpyAM1gNbKMnrAhHpIcKAFTyIRZeGdDUK8XTulBVvRy 32NuJS+rQx/+ipDk5QVlVhDyB7ZqHBWkl3qqZ/GQ= 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 136/330] dmaengine: stm32-mdma: use vchan_terminate_vdesc() in .terminate_all Date: Thu, 17 Sep 2020 21:57:56 -0400 Message-Id: <20200918020110.2063155-136-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 dfc708812a2acfc0ca56f56233b3c3e7b0d4ffe7 ] To avoid race with vchan_complete, use the race free way to terminate running transfer. Move vdesc->node list_del in stm32_mdma_start_transfer instead of in stm32_mdma_xfer_end to avoid another race in vchan_dma_desc_free_list. Signed-off-by: Amelie Delaunay Link: https://lore.kernel.org/r/20200127085334.13163-7-amelie.delaunay@st.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/stm32-mdma.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c index 5838311cf9900..ee1cbf3be75d5 100644 --- a/drivers/dma/stm32-mdma.c +++ b/drivers/dma/stm32-mdma.c @@ -1127,6 +1127,8 @@ static void stm32_mdma_start_transfer(struct stm32_mdma_chan *chan) return; } + list_del(&vdesc->node); + chan->desc = to_stm32_mdma_desc(vdesc); hwdesc = chan->desc->node[0].hwdesc; chan->curr_hwdesc = 0; @@ -1242,8 +1244,10 @@ static int stm32_mdma_terminate_all(struct dma_chan *c) LIST_HEAD(head); spin_lock_irqsave(&chan->vchan.lock, flags); - if (chan->busy) { - stm32_mdma_stop(chan); + if (chan->desc) { + vchan_terminate_vdesc(&chan->desc->vdesc); + if (chan->busy) + stm32_mdma_stop(chan); chan->desc = NULL; } vchan_get_all_descriptors(&chan->vchan, &head); @@ -1331,7 +1335,6 @@ static enum dma_status stm32_mdma_tx_status(struct dma_chan *c, static void stm32_mdma_xfer_end(struct stm32_mdma_chan *chan) { - list_del(&chan->desc->vdesc.node); vchan_cookie_complete(&chan->desc->vdesc); chan->desc = NULL; chan->busy = false; -- 2.25.1