Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2055618ybg; Sun, 27 Oct 2019 10:08:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUoAoMo5LC0wZHXmJvZ4gAK9ZdzTFYvjc+dbfK1Rbh4HGqUNXWNuvWIAgnPvB2ecTUjX4D X-Received: by 2002:aa7:dcd7:: with SMTP id w23mr15412668edu.34.1572196111935; Sun, 27 Oct 2019 10:08:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572196111; cv=none; d=google.com; s=arc-20160816; b=eQunp4xl8E5Jy1TNUvAtfVb2CAJrTqdfzA8WMQzquw8P96/RaYFS+XwSGMb/sLJ9ic yF1eraQZ6ch6agQPS/sJ85goWHSo+s+w05njVwAD2NiZmibNtXTc4iC/jzzqMPP8ugxz t3nrhcoKYMDbAwA88276ZTkSg6H6zt4AjTBGvPw5gqr8tAnbemv+OpQ/WCu080PEeMGq hcbUb62rnPpuNntryEN6ZQTvAMc69AMvAADAtVbFZ8JO0KnCePmVq3FDgf7J9pWHwQLb Lht/Et2YswbBEmKtXD+gUPvFGtSqO4818RFgdz2QxwuH6WCrl2uuPrhLw80XHsP/wt8S UJLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=eCZnGishukyTMqjQd5JsCjydrzaG2FQ9LGe8C0VypAM=; b=rBPzWVdDe88l/83a4yHMS2T15ld+hpwhwdt848DmJd/WICB4COwjez/HJuDzXo4lTh Y0lO/VCcBYlkyFtrqmW84BnaE95fK5d7AgQB65sWIl9jJqWc+YBRCDv1hCITEh3tcv0k fzZLHxxbttbelZi4r2H5pRGqMKNsAHUHA48xqcJgdgWo7BcW5M2a2l7UR75MAVHFtrwF hB7LyofPu4LlbcJfxUpqP35EW8E8gWZkM+qYWah+psOynMgXt9cUnvifnV/R3OnMEXDI JD9ihYvgVp3cU2GGT+B++LlDKk9KC2/HdeKsVVoTfNnB5snbfrqCMBudJbgUV5So+j/U odCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wf+tMYqV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id k15si4789386eja.412.2019.10.27.10.08.07; Sun, 27 Oct 2019 10:08:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wf+tMYqV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727646AbfJ0P6m (ORCPT + 99 others); Sun, 27 Oct 2019 11:58:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:44502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbfJ0P6m (ORCPT ); Sun, 27 Oct 2019 11:58:42 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 3FDA620873; Sun, 27 Oct 2019 15:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572191921; bh=66tHgdFuZFgwvfMgb7+hbPciCMsrO5SrqRnt9hjmZ1k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=wf+tMYqVxXsb/cfDFmgvgPoKwpWL1D6/od446FGICrGRm0LTENlOwSfb+bZP39CaC L+YBLArt/NSlK1PMzP08+dVPdbKM/wQGsNZDiPtLZdzh9ekovGl9V7uOS2AHNiLiTw ngMYY9lTMV0XSL+UNnmJgDb9uQH75z1845RCRLyA= Date: Sun, 27 Oct 2019 15:58:36 +0000 From: Jonathan Cameron To: Fabrice Gasnier Cc: , , , , , , , , Subject: Re: [PATCH] iio: adc: stm32-adc: fix stopping dma Message-ID: <20191027155836.2e3d8ebf@archlinux> In-Reply-To: <1572015860-8931-1-git-send-email-fabrice.gasnier@st.com> References: <1572015860-8931-1-git-send-email-fabrice.gasnier@st.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 25 Oct 2019 17:04:20 +0200 Fabrice Gasnier wrote: > There maybe a race when using dmaengine_terminate_all(). The predisable > routine may call iio_triggered_buffer_predisable() prior to a pending DMA > callback. > Adopt dmaengine_terminate_sync() to ensure there's no pending DMA request > before calling iio_triggered_buffer_predisable(). > > Fixes: 2763ea0585c9 ("iio: adc: stm32: add optional dma support") > > Signed-off-by: Fabrice Gasnier Applied to the fixes-togreg branch of iio.git and marked for stable. I'm guessing this is not something that has been observed in practice, but seems like a safe fix anyway to backport. Thanks, Jonathan > --- > drivers/iio/adc/stm32-adc.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c > index 663f8a5..73aee59 100644 > --- a/drivers/iio/adc/stm32-adc.c > +++ b/drivers/iio/adc/stm32-adc.c > @@ -1399,7 +1399,7 @@ static int stm32_adc_dma_start(struct iio_dev *indio_dev) > cookie = dmaengine_submit(desc); > ret = dma_submit_error(cookie); > if (ret) { > - dmaengine_terminate_all(adc->dma_chan); > + dmaengine_terminate_sync(adc->dma_chan); > return ret; > } > > @@ -1477,7 +1477,7 @@ static void __stm32_adc_buffer_predisable(struct iio_dev *indio_dev) > stm32_adc_conv_irq_disable(adc); > > if (adc->dma_chan) > - dmaengine_terminate_all(adc->dma_chan); > + dmaengine_terminate_sync(adc->dma_chan); > > if (stm32_adc_set_trig(indio_dev, NULL)) > dev_err(&indio_dev->dev, "Can't clear trigger\n");