Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1630902ybc; Wed, 13 Nov 2019 01:45:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzEBHUL7oNyHFnUx10s6GmIOUfqs/MxWnlhC4/0kWNumZ2ft0E1rh5tTA9QCiRQGJ3/HrTi X-Received: by 2002:a05:6402:138c:: with SMTP id b12mr2524949edv.28.1573638313840; Wed, 13 Nov 2019 01:45:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573638313; cv=none; d=google.com; s=arc-20160816; b=wAEoMdpAf6GhhcrUuMHnFhEHPIc45rLYvrcPTbaabB1BoriTBXwqh+MWwtTIuoHNRi brq8G71L1izqAPBM0zD4S6PjizafKXPZG4ers0belDvLFxQg7h2pJo1Lq4gbV4FcSEEm bPEPvEvEX/tkWBVxhVRWHmZLnG3nrMTPqCv49eGW8PXwqaVmmJklS9xp7I1UYLFO+RNj Sy05UO4Moyzc9KOcrX9jka9Ogc+thS1OEM9QxLxUee8DyaPN9xNnYK9AN05KZ1mrNJeD ta/zrfGi6IAfC2Lr/PyqPjYGrnpEYxRcclHOad6Rsz13kLYDYK2CktnWv5Rwo/N1Mjqi fafg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=WpBUEUBVKUMrmcqnABn9MPFYPLG9SgUt3u7vOCoq0EM=; b=iV3//TEj9EHFhXptXlRQzIzc7gA44EtOoDsUdTqRtUAwlO7y9pGmWbSjcs6isAZm3g 5L14j3aV8UghoveHg44zrC/1eeluPaJ60876A5k+Wv/WA5NOBFp4fv8wQPZxd6rGb8VS H2SwDaijlSTDLU0ZIghRTOXIT1kBbv8S3yRcKAhUXlTywaOZ//kiHNNwBmQikL/iODMJ f6naPKKCt5OrrLUP0ujSOdB+zKEdI9bRAUjJ3i3Et0IsELTu2SLdf+c9oTNtrWQiNJr0 xiu3lf92KdGA/uATWG19pGVWajvIKiM5ZJ9EZRldjwPf8PhrA8BEZ+5bJ7vOGeRTWCvS lhQQ== 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 k51si968602edb.411.2019.11.13.01.44.49; Wed, 13 Nov 2019 01:45: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; 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 S1727394AbfKMJlg (ORCPT + 99 others); Wed, 13 Nov 2019 04:41:36 -0500 Received: from mail-oi1-f195.google.com ([209.85.167.195]:45099 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbfKMJlf (ORCPT ); Wed, 13 Nov 2019 04:41:35 -0500 Received: by mail-oi1-f195.google.com with SMTP id 14so1164752oir.12; Wed, 13 Nov 2019 01:41:35 -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; bh=WpBUEUBVKUMrmcqnABn9MPFYPLG9SgUt3u7vOCoq0EM=; b=bJn8niws5L+KieiYZLeYzh/6fCSy3qY/oHIU/knjUNgBWMAHDR+uSf7GHGAb3PCYvT ipKSc5fx5OKUMHbUP9AW0kiKCAWL68kQaKNlAWI+ZCSGzGbYacPyjEfbfhhA2vXVw7TY 3bsoMPQ/lBiNiGx4pW+zrlOsK4EO8ZeJzA9EnNdAUCj5BTtXBSNI8KOz7qwqUevEa3kt cVVEkiTgsd5xWnKYdsJWEdZX+nDzav7592vkc5U5Ai97F/MGQArmLlK3yVzAwwJjNvYn HkhWkypXBHek3CpO1PkiQaEpHNmReRUV7k/ZON+oGPeE/DWDKK5sSZ+7nfSXmQAWtdNa LW0g== X-Gm-Message-State: APjAAAXpkd37aesU08U6+WG5pbPb12noyLRDHyXYIRH2JmeACDwQfRj6 g5woPupmuIknYwCTI9620D1YoC8EqfamBY48lUWQSEth X-Received: by 2002:aca:3a86:: with SMTP id h128mr2082054oia.131.1573638094532; Wed, 13 Nov 2019 01:41:34 -0800 (PST) MIME-Version: 1.0 References: <20191016102520.124370-1-jacopo+renesas@jmondi.org> In-Reply-To: From: Geert Uytterhoeven Date: Wed, 13 Nov 2019 10:41:23 +0100 Message-ID: Subject: Re: [PATCH] iio: adc: max9611: Defer probe on POR read To: Jacopo Mondi Cc: linux-iio@vger.kernel.org, Linux-Renesas , Linux Kernel Mailing List , Wolfram Sang , Linux I2C 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 On Sun, Nov 10, 2019 at 7:45 PM Geert Uytterhoeven wrote: > On Thu, Oct 17, 2019 at 2:55 PM Geert Uytterhoeven wrote: > > On Wed, Oct 16, 2019 at 12:23 PM Jacopo Mondi wrote: > > > The max9611 driver tests communications with the chip by reading the die > > > temperature during the probe function. If the temperature register > > > POR (power-on reset) value is returned from the test read, defer probe to > > > give the chip a bit more time to properly exit from reset. > > > > > > Reported-by: Geert Uytterhoeven > > > Signed-off-by: Jacopo Mondi > > > > > I've not been able to reproduce the issue on my boards (M3-N > > > Salvator-XS and M3-W Salvator-X). As you reported the issue you might be > > > able to reproduce it, could you please test this? > > > > I can reproduce it on Salvator-XS with R-Car H3 ES2.0. > > According to my logs, I've seen the issue on all Salvator-X(S) boards, > > but not with the same frequency. Probability is highest on H3 ES2.0 > > (ca. 5% of the boots since I first saw the issue), followed by H3 ES1.0, > > M3-W, and M3-N. > > > > After more investigation, my findings are: > > 1. I cannot reproduce the issue if the max9611 driver is modular. > > Is it related to using max9611 "too soon" after i2c bus init? > > How can "i2c bus init" impact a slave device? > > Perhaps due to pin configuration, e.g. changing from another pin > > function or GPIO to function i2c4? Not true: I managed to reproduce it with a modular driver. > > 2. Adding a delay at the top of max9611_init() fixes the issue. > > This would explain why the issue is less likely to happy on slower > > SoCs like M3-N. > > 3. Disabling all other i2c slaves on i2c4 in DTS fixes the issue. > > Before, max9611 was initialized last, so this moves init earlier, > > contradicting theory #1. > > 4. Just disabling the adv7482 (which registers 11 dummies i2c slaves) > > in DTS does not fix the issue. > > > > Unfortunately i2c4 is exposed on a 60-pin Samtec QSH connector only, > > for which I have no breakout adapter. > > Some soldering fixed that. Still investigating. > Here's a status update: > > A. I can reproduce the issue at 100 kHz instead of 400 kHz. > B. 3 above doesn't seem to be true: I can reproduce it with all other > slaves disabled. > C. The code says: > > /* > * need a delay here to make register configuration > * stabilize. 1 msec at least, from empirical testing. > */ > usleep_range(1000, 2000); > > However, the datasheet says: > > Parameter MIN TYP MAX > Conversion Time - 2 ms - > > So 1 ms is definitely too short. > Unfortunately the datasheet has no maximum value. usleep_range(1000, 2000) usually results in a sleep time of 2.0 ms: OK It may take longer: I saw 4.8 -- 7.7 ms (nothing in between 2.0 -- 4.8!): OK It may take shorter: - 1.2 -- 1.7 ms: FAIL - 1.8 ms - 2 ms: OK So a minimum delay of 2 ms seems like a good value. > D. For 2: msleep(1) is sufficient, usleep_range(200, 500) is not. > And this is still not explained by C. Without adding an msleep() call to max9611_init(), the usleep_range() call in max9611_read_single() happens at an arbitrary moment. After adding an msleep() call to max9611_init(), the code becomes synchronized to the jiffies clock, and the usleep_range() call in max9611_read_single() never completes in less than 2 ms, thus avoiding the issue. > I also don't know yet who's resetting the chip on reboot, as it > does not have a reset line, but all registers are zeroed (except > for the POR temperature value). Looks like the PMIC powers down the +3.3V rail for ca. 25 ms when PSCI initiates a system reboot. Patch sent: "[PATCH] iio: adc: max9611: Fix too short conversion time delay" (https://lore.kernel.org/lkml/20191113092133.23723-1-geert+renesas@glider.be/). 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