Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2631513pxb; Sun, 8 Nov 2020 07:34:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkmyD/4Ymwf4eaP5n1JMJQjJ3+t8DmmU8QcDXBk5ea2sLE8zLWo5yoksYabdJl2b3tH3JS X-Received: by 2002:a17:906:2e8e:: with SMTP id o14mr11533251eji.324.1604849661824; Sun, 08 Nov 2020 07:34:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604849661; cv=none; d=google.com; s=arc-20160816; b=hyZkErw/Na26G/DSKF8yVxpWfSMVf6MaduHODfESNvc1n8aoft8zNKnYfHD+iKXRoc k0tWcXSNwp2awDiGaNUkTBKyU4xjP/798bW5el87a/vXkRB7a9Yus7aNDPsBYDzuPpGl rEQojdr05vRpQO7W3J8TJWrnoEpALKf5W7ZSLZKekpreuAMxdvHbf2KT+pU+vuqCdqe5 tKhviVkJ6W9qbD6kUHCkBz1Z1jMmVErnOtB6TgTjVi8JcgrHL9OKqB8BU/chPn6u9Qd2 aJRhzssjsbI5dDFNvIUWs9bZUaZu4LLSlNNha3gQIG6FxBDLzSedtlcxpxilfWQ+UFkG Iy1Q== 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:subject:cc:to:from:date :dkim-signature; bh=mqJla4Q+KkIrBU4qkiwhOV5DmloFX3lBQU8krE6qD/8=; b=Mn55hQaeaxTBOWbUFLKICRZpjtXKQfIuZGJKDpZ06xyKHLburDI7FAPWE9BfD2r8vK fZkW49QaP4GEGMVQNeMTC9zYyOPBUFS4ZdQh3RlkRzIZ1yQFlTyGBrxze2XQl+ME0u45 OwRtorQxNtSMne1hvLWPrdtqR0qoTnYohrVxIt6A/0qQmtLh436Jo6cze9jzl6qC8hES wNu1NwEJxBCxQFReMYSI2mWZXyBcG5lfyE3K8bRT9IW/x3YcmMGUYM7R1zUOBQrwuCBl K6HQQMZsmHXc0GV+uULQHpuCN/K9tvAcmVAk+OZ+jCVNsdukGsgSKzKilFsfezY+pXWq p4ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jHVr2WEC; 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 gl10si5249197ejb.138.2020.11.08.07.33.58; Sun, 08 Nov 2020 07:34:21 -0800 (PST) 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=jHVr2WEC; 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 S1728513AbgKHPcM (ORCPT + 99 others); Sun, 8 Nov 2020 10:32:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:50082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbgKHPcL (ORCPT ); Sun, 8 Nov 2020 10:32:11 -0500 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 4B492206E0; Sun, 8 Nov 2020 15:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604849530; bh=hzzEOE8KcptRT00HXVKeMWjrWy6JY/zrHz1aMOEGi3E=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jHVr2WECv/0IdgCFKzHdh5muE4w7tm8d8q1IPaWS+X4OAPlhyEAGFJkde8FiIeMw7 PpLE+x4nTEoWiBHYrMyZbYkyj+892C4WspqY480pRssqTNn6VxETb3aNBjmBqb9JCm CyifnZdf8bO4i/KdGGqVDbXVEQYXf0HwiODXa1SQ= Date: Sun, 8 Nov 2020 15:32:05 +0000 From: Jonathan Cameron To: Fabrice Gasnier Cc: Olivier Moysan , , , , , , , , Subject: Re: [PATCH] iio: adc: stm32-adc: dma transfers cleanup Message-ID: <20201108153205.7aa4fa28@archlinux> In-Reply-To: <8ed73130-57e7-4073-cdf2-5f31596e728c@st.com> References: <20201105142941.27301-1-olivier.moysan@st.com> <8ed73130-57e7-4073-cdf2-5f31596e728c@st.com> X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Nov 2020 18:38:27 +0100 Fabrice Gasnier wrote: > On 11/5/20 3:29 PM, Olivier Moysan wrote: > > - Remove processing related to DMA in irq handler as this > > data transfer is managed directly in DMA callback. > > - Update comment in stm32_adc_set_watermark() function. > > > > Signed-off-by: Olivier Moysan > > Hi Olivier, > > Reviewed-by: Fabrice Gasnier Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to poke at it. Thanks, Jonathan > > Thanks, > Fabrice > > --- > > drivers/iio/adc/stm32-adc.c | 29 ++++++----------------------- > > 1 file changed, 6 insertions(+), 23 deletions(-) > > > > diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c > > index b3f31f147347..08be826f1462 100644 > > --- a/drivers/iio/adc/stm32-adc.c > > +++ b/drivers/iio/adc/stm32-adc.c > > @@ -1310,7 +1310,7 @@ static int stm32_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val) > > * dma cyclic transfers are used, buffer is split into two periods. > > * There should be : > > * - always one buffer (period) dma is working on > > - * - one buffer (period) driver can push with iio_trigger_poll(). > > + * - one buffer (period) driver can push data. > > */ > > watermark = min(watermark, val * (unsigned)(sizeof(u16))); > > adc->rx_buf_sz = min(rx_buf_sz, watermark * 2 * adc->num_conv); > > @@ -1573,31 +1573,14 @@ static irqreturn_t stm32_adc_trigger_handler(int irq, void *p) > > > > dev_dbg(&indio_dev->dev, "%s bufi=%d\n", __func__, adc->bufi); > > > > - if (!adc->dma_chan) { > > - /* reset buffer index */ > > - adc->bufi = 0; > > - iio_push_to_buffers_with_timestamp(indio_dev, adc->buffer, > > - pf->timestamp); > > - } else { > > - int residue = stm32_adc_dma_residue(adc); > > - > > - while (residue >= indio_dev->scan_bytes) { > > - u16 *buffer = (u16 *)&adc->rx_buf[adc->bufi]; > > - > > - iio_push_to_buffers_with_timestamp(indio_dev, buffer, > > - pf->timestamp); > > - residue -= indio_dev->scan_bytes; > > - adc->bufi += indio_dev->scan_bytes; > > - if (adc->bufi >= adc->rx_buf_sz) > > - adc->bufi = 0; > > - } > > - } > > - > > + /* reset buffer index */ > > + adc->bufi = 0; > > + iio_push_to_buffers_with_timestamp(indio_dev, adc->buffer, > > + pf->timestamp); > > iio_trigger_notify_done(indio_dev->trig); > > > > /* re-enable eoc irq */ > > - if (!adc->dma_chan) > > - stm32_adc_conv_irq_enable(adc); > > + stm32_adc_conv_irq_enable(adc); > > > > return IRQ_HANDLED; > > } > >