Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1632897ybc; Wed, 13 Nov 2019 01:47:45 -0800 (PST) X-Google-Smtp-Source: APXvYqwX0/2dAEF003ciFrio6T6btMshqmuLI8zt3nXDu7yCCMGbWApXhgmLBk5RxeC1r7nn18os X-Received: by 2002:a17:906:f209:: with SMTP id gt9mr1770889ejb.241.1573638465285; Wed, 13 Nov 2019 01:47:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573638465; cv=none; d=google.com; s=arc-20160816; b=CtxtmtClpzZzVmqQfui96tyL/+sla+CdpbL6qDD5Rucp9at+YqPjire0faSQbTKGSX cE1IWd5byD2v7j355kuCT+cf/CdjQkdOCcqpX8ejh/PB8FVEtjpyd/QtZNOR4Ffzo1+1 /QF6g0/CXe/NjU0VpNlgl2r8fSgtE4cbALhxQCY/fjUOuE6Q+VyjAUwvDC5RbtC1h8pX EXRv0KZRIHzkw8uAdl6GGWIKeFJtiQKUsOuAQdPtdnKSIskL0B4TP+DGD+o+/rTlCNNi lo8tEDD/G9ZDNPJIWQmuxsYO+4A+GJVjO0oWL1Qbs/53YymmJB9CG14MlP7+6F8Wl31i wxJg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=9cutEXzxNI39seiaN7htlcPsRlhmFU3WW/Zlkuh1rAI=; b=FqYqmtLEp6Y20eaHJiTC8f73I+eIZ3Fmk65M3ljsiXBjNPxqvg/Byv2a9ltXSeVyvy CyplABssiwSA/IT4fJGE3AVEmoTamFyBxlUGLC5IW+l1u1dSWuSL39Oe4WS1ki/jNhpO OfqQYufO2c2viSoK2XjWEvQrXiILCjXF2jCLZAyIZflXM3CKJ3NkZdtVhpx9KALGq32s 55Fl2vf826D9BnpOuSWlJk5yfj6DWRZrPuXtXAW2WQ7EA1zr2720+3nRR3k2pYPJ4Qj0 6C/9qKECOYI2T6cGVuN3rKkvsVg2DeAwj0k1oAyKJOLSlFUR74uvkMsyTQP2lgknZEXz tJWw== 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 p30si925557eda.205.2019.11.13.01.47.20; Wed, 13 Nov 2019 01:47:45 -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 S1727321AbfKMJqe convert rfc822-to-8bit (ORCPT + 99 others); Wed, 13 Nov 2019 04:46:34 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:37799 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbfKMJqd (ORCPT ); Wed, 13 Nov 2019 04:46:33 -0500 Received: by mail-oi1-f193.google.com with SMTP id y194so1218427oie.4; Wed, 13 Nov 2019 01:46:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=grATdiINrLQEcjShNKetMHR+1iFUrTj1Oa6wxu6nBC8=; b=eydRv2+RcZ1p3E04nROAsIM4JJmmCQ9CXgB9ztszZ70YtViFy9cHtParOFLhV0wlrO ba/CVyibzzKKn645L0PqCU7e1n9ZFUcv3jXFLivq4UnVZ/clf5ofMKWt60OikSUrjzuG 8+kRTpQlAlnvNKpIwNqji/crBB4bZtD0s/J13aBJg4tqY55MI6laN1I8Jqyu/CvfBWkE VWT3l8VJ4rl3Uglwc9bf2phs+oR/hUmhMPED/a4lipEhm/W8Ggr5nUC+3T9VTJngeKeM en5kQ0ZlrOlzmjvf/NK/yi+0C97rvvmrBy38TuHnBrLjMF/s70FCq96T4svMyCrIH7Fp Pphw== X-Gm-Message-State: APjAAAUngXhpigi/usK03BVN1WwUdq5ayGwbM2L5cF6HthcIaUbUOQXI JRTBrCQc1mqBHqyWxth+S2HH2iTGIqj+pzZvpsU= X-Received: by 2002:aca:3a86:: with SMTP id h128mr2099125oia.131.1573638392868; Wed, 13 Nov 2019 01:46:32 -0800 (PST) MIME-Version: 1.0 References: <20191113092133.23723-1-geert+renesas@glider.be> <20191113093828.vk5qqtlr7bs5z5fb@uno.localdomain> In-Reply-To: <20191113093828.vk5qqtlr7bs5z5fb@uno.localdomain> From: Geert Uytterhoeven Date: Wed, 13 Nov 2019 10:46:21 +0100 Message-ID: Subject: Re: [PATCH] iio: adc: max9611: Fix too short conversion time delay To: Jacopo Mondi Cc: Geert Uytterhoeven , Jacopo Mondi , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Wolfram Sang , linux-iio@vger.kernel.org, Linux-Renesas , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacopo, On Wed, Nov 13, 2019 at 10:36 AM Jacopo Mondi wrote: > On Wed, Nov 13, 2019 at 10:21:33AM +0100, Geert Uytterhoeven wrote: > > As of commit b9ddd5091160793e ("iio: adc: max9611: Fix temperature > > reading in probe"), max9611 initialization sometimes fails on the > > Salvator-X(S) development board with: > > > > max9611 4-007f: Invalid value received from ADC 0x8000: aborting > > max9611: probe of 4-007f failed with error -5 > > > > The max9611 driver tests communications with the chip by reading the die > > temperature during the probe function, which returns an invalid value. > > > > According to the datasheet, the typical ADC conversion time is 2 ms, but > > no minimum or maximum values are provided. However, the driver assumes > > a 1 ms conversion time. Usually the usleep_range() call returns after > > more than 1.8 ms, hence it succeeds. When it returns earlier, the data > > register may be read too early, and the previous measurement value will > > be returned. After boot, this is the temperature POR (power-on reset) > > value, causing the failure above. > > > > Fix this by increasing the delay from 1000-2000 µs to 2000-2200 µs. > > > > Note that this issue has always been present, but it was exposed by the > > aformentioned commit. > > > > Fixes: 69780a3bbc0b1e7e ("iio: adc: Add Maxim max9611 ADC driver") > > Signed-off-by: Geert Uytterhoeven > > --- > > This problem was exposed in v5.3. > > > > After this patch, probing of the two max9611 sensors succeeded during > > ca. 3000 boot cycles on Salvator-X(S) boards, equipped with various > > R-Car H3/M3-W/M3-N SoCs. > > --- > > drivers/iio/adc/max9611.c | 11 ++++++++--- > > 1 file changed, 8 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c > > index da073d72f649f829..b0755f25356d700d 100644 > > --- a/drivers/iio/adc/max9611.c > > +++ b/drivers/iio/adc/max9611.c > > @@ -89,6 +89,11 @@ > > #define MAX9611_TEMP_SCALE_NUM 1000000 > > #define MAX9611_TEMP_SCALE_DIV 2083 > > > > +/* > > + * Conversion time is 2 ms (typically) > > + */ > > +#define MAX9611_CONV_TIME_US_RANGE 2000, 2200 > > + > > Is a 20% sleep range enough or should it be slightly lengthen ? 10%? This only impacts the variation, so what really happens depends on the rate of the hrtimer (if present). On R-Car Gen3, I think that uses the ARM Architectured Timer (cp15), which has a period of 120 ns. > Apart from this, thanks a lot for finding the issue root cause! > > Reviewed-by: Jacopo Mondi Thanks! Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds