Received: by 10.223.176.5 with SMTP id f5csp995113wra; Fri, 2 Feb 2018 09:24:55 -0800 (PST) X-Google-Smtp-Source: AH8x224V06It3RUHCLKOSdMrrIKfetmKR8hmHdiS+mos6gC6HNEw7IgcJU9jEkl1NynK8B5oOepJ X-Received: by 10.99.127.90 with SMTP id p26mr1853944pgn.252.1517592295091; Fri, 02 Feb 2018 09:24:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517592295; cv=none; d=google.com; s=arc-20160816; b=tgDcXKbRNRvNlJGIw4LIWkvqHbtPvEzQuRFGl7GaPdxKpjLvGJSRhkyjEeMjlabW6r uWZCbh5I3ZMy+2/BJqADS2uVyN3hKfa9CVzr4SVPNFSC9QR6ryvUX8JIsC9bIh+4KnSY ckTO3ESP86gJqy8hHDkPjO812YtoIoVJpm7bxx4lt87y6nvCdOlhf10EKqdgBHWH3KKJ 5PglY2LZq3/mNF5FjLlt1UcJdgVKY48NdoiaNRM9GLLtKP5l8ACq3musQNM3CrDi+EBq 7famZPrVkC2NSOslOwHXD7AMoY6NCNpDpkDW74DmQvb0iPkLIUegEy7GJ7OePq9BltTy fPXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iFN0n0HwSdAF4Fn/4QGgYy3O+NUw7ITnZUjbRB5lfXI=; b=hGYPj7296OTUcmFAvhysN9UKri6VCy7AdjA54/C4H/MiHILj7CZwmeIOZFe+g4EkhM ii98N1yiLgNMbNlZK6dbL1sGXhBAZMr8YCqmAyCPQ3hzDsQKw/4efEEymlfKDgC5WQiO l5Z9LTEqvvhxQvG8g+kjlUllDbUYJJeo84FBKUtX2Kcc7RnEBBwR34vMkd2FMZoIHVDo ZH/s5+hbE6MS9j+2F5yH3zeF9BMwxYYmn0Ln095sORvMIrGHJ6h1oXs6N/LEEFSSDbhj MgN7gDNBOipk5umAh8Ws07T//B7VQvsNxzuAMsNicvF9TS7126wHCDW+4EPM1PV0uoFq DSRw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13si2116236pfm.305.2018.02.02.09.24.40; Fri, 02 Feb 2018 09:24:55 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753813AbeBBRX1 (ORCPT + 99 others); Fri, 2 Feb 2018 12:23:27 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40404 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753583AbeBBRON (ORCPT ); Fri, 2 Feb 2018 12:14:13 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 72197DA8; Fri, 2 Feb 2018 17:14:04 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabrice Gasnier , Jonathan Cameron Subject: [PATCH 4.14 151/156] iio: adc: stm32: fix scan of multiple channels with DMA Date: Fri, 2 Feb 2018 17:58:52 +0100 Message-Id: <20180202140847.189804360@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fabrice Gasnier commit 04e491ca9df60ffe8637d00d68e5ab8bc73b30d5 upstream. By default, watermark is set to '1'. Watermark is used to fine tune cyclic dma buffer period. In case watermark is left untouched (e.g. 1) and several channels are being scanned, buffer period is wrongly set (e.g. to 1 sample). As a consequence, data is never pushed to upper layer. Fix buffer period size, by taking scan channels number into account. Fixes: 2763ea0585c9 ("iio: adc: stm32: add optional dma support") Signed-off-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/stm32-adc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -1314,6 +1314,7 @@ static int stm32_adc_set_watermark(struc { struct stm32_adc *adc = iio_priv(indio_dev); unsigned int watermark = STM32_DMA_BUFFER_SIZE / 2; + unsigned int rx_buf_sz = STM32_DMA_BUFFER_SIZE; /* * dma cyclic transfers are used, buffer is split into two periods. @@ -1322,7 +1323,7 @@ static int stm32_adc_set_watermark(struc * - one buffer (period) driver can push with iio_trigger_poll(). */ watermark = min(watermark, val * (unsigned)(sizeof(u16))); - adc->rx_buf_sz = watermark * 2; + adc->rx_buf_sz = min(rx_buf_sz, watermark * 2 * adc->num_conv); return 0; }