Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3120984imu; Sun, 11 Nov 2018 08:04:13 -0800 (PST) X-Google-Smtp-Source: AJdET5fP7UZecK6hWd61iOe/ctKSVAkFmyQ+39jgpap77RoPsbZ/Dljuw/k9sgFSCV9d0++MTL+d X-Received: by 2002:a63:f515:: with SMTP id w21mr14272677pgh.220.1541952253349; Sun, 11 Nov 2018 08:04:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541952253; cv=none; d=google.com; s=arc-20160816; b=YovlrsFgXPDqXIwt6xdsUeCx2TkBdP8zu76OUGqfQDaELpUIbokDQEDoV9BgXBW5q5 b/AbnITC4JfSQYKCfzUUHrhkWuBIxVO72Pc3YrczW2qLYIu8NwlfPu7v2OY+4FbYJRl0 /+m5aTMj1uKiEugnQVHt0g72DDz9ytpAvEPYgDeXCA5pLvQHUbKIpaOWvln73TURYUJ8 qiKTHTqmU1Kx6GP1W1JBrvBlQF1js0A4R/jsfZZCieuTWNm2tOrct8lR8eHnvJBHfyaH fLljwDb99cWrxNSDCwJlG2HmOH1bB7z0I2OibkWtuQgwX3a/x2Ekm2ydqebAn1qDw1Hl hG0g== 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=nH666EOtvVmbpUNdK9NW2BzS/9U1YNF2UGGH7L+aPe0=; b=rG0uB6sCFusWmm2+qMesGc4/+HKQsKSjJiNRLVu5q04pjlDwmuTAvoU0OjlfgiGpA2 U5UEJDEGwjZKjLPaPPu0i0Fn8osou6VpdCHEqNb8QDze6nJXGkb2qHuVnfGmkMSmXop3 11RVk6XcWlMlnwR+z/OYYQyUJPrGe42guKAwraILdO+K73Nf82/1tw+rWnOXLWgsbX4q Dm+ha1+n9wlX4N7CWrnfRFN+se+tjvtTuOo3p8K91melUk82xx/SEiOemU6581g0aJpi OHqzU4jVqxLN56aqSO3qOM86jYKn+iNf20hhdZV+HPrNJOE2O1lH+s1RosGbfuMA3Md4 /7hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="jpjU/cf1"; 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 2si12786611pgy.35.2018.11.11.08.03.40; Sun, 11 Nov 2018 08:04:13 -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; dkim=pass header.i=@kernel.org header.s=default header.b="jpjU/cf1"; 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 S1728798AbeKLBwB (ORCPT + 99 others); Sun, 11 Nov 2018 20:52:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:32800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728712AbeKLBwB (ORCPT ); Sun, 11 Nov 2018 20:52:01 -0500 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (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 D180D2148E; Sun, 11 Nov 2018 16:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541952185; bh=VNeyg8NSZeRmrbVaYIFI39QVs1frkLEKCLsu2UGobsA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jpjU/cf1BPzfK2vTywWtne5dItEm2oaM/4UX+uaA6MwIyux2Mc0b6oBVjGxIkfhRf lQAJqYc9dcHezfNKzWCOdLdSAc1ynicmXCywY/piNU4jHqGGGNeA5+BAiA4eEj0OEQ 3vV9VHzfC5lqDTv2yk9lSFu/G7f57feN9YdXX1/k= Date: Sun, 11 Nov 2018 16:03:00 +0000 From: Jonathan Cameron To: Baolin Wang Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , freeman.liu@unisoc.com, Mark Brown , linux-iio@vger.kernel.org, LKML Subject: Re: [PATCH] iio: adc: sc27xx: Add ADC data conversion timeout Message-ID: <20181111160300.3193196c@archlinux> In-Reply-To: References: <208f9043fbd9b14b7a0c2743f68fa424388f5dcd.1541733478.git.baolin.wang@linaro.org> <20181111124044.52f61897@archlinux> X-Mailer: Claws Mail 3.17.1 (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 Sun, 11 Nov 2018 23:00:18 +0800 Baolin Wang wrote: > Hi Jonathan, > > On 11 November 2018 at 20:40, Jonathan Cameron wrote: > > On Fri, 9 Nov 2018 11:25:31 +0800 > > Baolin Wang wrote: > > > >> From: Freeman Liu > >> > >> Sometimes the ADC controller met some problems, and it will not complete > >> the data conversion, that will can not wake up the read process any more > >> to block users. So we should add one maximum conversion time to avoid > >> this issue. > >> > >> Signed-off-by: Freeman Liu > >> Signed-off-by: Baolin Wang > > Hi. > > > > Patch looks good, but sounds like this is a fix so could I have a fixes > > tag and a patch title that makes that clear? > > > > I think we will want this one back ported to stable by the sound of it. > > > > If it is just a theoretical issue then perhaps we don't need to bother. > > Thanks for your review. This patch is not one bug fix, just make the > code more robust in case of some bad cases. So I think we do not need > the stable tag. Thanks. Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Jonathan > > > > > Thanks, > > > > Jonathan > > > >> --- > >> drivers/iio/adc/sc27xx_adc.c | 12 +++++++++++- > >> 1 file changed, 11 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c > >> index 7940b23..f7f7a189 100644 > >> --- a/drivers/iio/adc/sc27xx_adc.c > >> +++ b/drivers/iio/adc/sc27xx_adc.c > >> @@ -52,6 +52,9 @@ > >> /* Timeout (ms) for the trylock of hardware spinlocks */ > >> #define SC27XX_ADC_HWLOCK_TIMEOUT 5000 > >> > >> +/* Timeout (ms) for ADC data conversion according to ADC datasheet */ > >> +#define SC27XX_ADC_RDY_TIMEOUT 100 > >> + > >> /* Maximum ADC channel number */ > >> #define SC27XX_ADC_CHANNEL_MAX 32 > >> > >> @@ -223,7 +226,14 @@ static int sc27xx_adc_read(struct sc27xx_adc_data *data, int channel, > >> if (ret) > >> goto disable_adc; > >> > >> - wait_for_completion(&data->completion); > >> + ret = wait_for_completion_timeout(&data->completion, > >> + msecs_to_jiffies(SC27XX_ADC_RDY_TIMEOUT)); > >> + if (!ret) { > >> + dev_err(data->dev, "read ADC data timeout\n"); > >> + ret = -ETIMEDOUT; > >> + } else { > >> + ret = 0; > >> + } > >> > >> disable_adc: > >> regmap_update_bits(data->regmap, data->base + SC27XX_ADC_CTL, > > > > >