Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp5231059ybx; Sun, 10 Nov 2019 09:16:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzLnfgDmqNj0W+s8TRKQRq4QOV8w3GXtTiHcskVYpZp+81BPHU9kHLZObGvTGVEXAVG2WID X-Received: by 2002:a50:950a:: with SMTP id u10mr22271125eda.68.1573406186469; Sun, 10 Nov 2019 09:16:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573406186; cv=none; d=google.com; s=arc-20160816; b=jHUFwpmcE9eWKHl7IwLbDhzA557rTTUaSQd8MxahI0ttU97p2fZKhdQAVYgqzbMmG0 FaV4LDXq/aL3XVQTxzqmayILeotwcqOj6TC2t69TrRg7Z7RFiZFtMd8ZqCQ0gC3O9E+v +MTsaLemKAkpZXd4+dF+V3TdwiwZGUTmzEmdN5V20fFuI7Op4b4uESHRMSRQsjAnZ0JI UNOFPqPlSBAlEbJtjmQbS0BMSaFKUfw9ai0lF63cJROrIuypNaUZXHDOtbI54Ade8eLr /9UYdBvrf+AjVkPcjSj+SM6JUCJSlLvsmZ2+6u0JbOZ4OTmo34B+XqMcR3jmzxxivdT5 9gDg== 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=Vb9cynGQtd7H/nVfi0zV4NdlhOZcP/EkE9KCcmAVRXQ=; b=ogevqmLQOu8JfMJchGsBLlijtb6dihiyhVeKM+dM87mEAltNtzQ7btDZDWX23Fc0Vk YDqcZEFhXHO6m3n+xItWMprGvhvGIspzrSvm41t6isoksrRQDsb2Z1dhLtwzyMB3P1Yq TrmrQepis0T0ZNi760JzNmnlJHYHvZuNCgS0mjaH8ssMvBhwFMUweY//uvG/TjHHUzOM +olGZtTs6+sJJHvNLZgSCvs0+l6SPgJQP+DFgka2cp/OoQYXFu4CTHKIV5vcZB0cXacr SERDsDOyp5wEjpG49ZtmG94sfQY1yY1DZB2tSxfTCO/Zbgrdwr9fvaKBjFACzMSQEeZf 3C9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hedpLf19; 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 r2si7684266ejz.12.2019.11.10.09.16.02; Sun, 10 Nov 2019 09:16:26 -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=hedpLf19; 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 S1727024AbfKJRPc (ORCPT + 99 others); Sun, 10 Nov 2019 12:15:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:55232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726710AbfKJRPb (ORCPT ); Sun, 10 Nov 2019 12:15:31 -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 78C4D20842; Sun, 10 Nov 2019 17:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573406130; bh=Tn8BA0CZ7EQ17xxib+PdktIxuLXO4OYAEyNK0hVfKPA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hedpLf19JpwsCNS73WaQvVNdYcic7yOAlC1PdsKhunR6S77z0+1mzh7L6EeUQ6d1X e8mOYwe362H+jzPRAgsYDyTRiMuKxGszoVxazF37P4JIvbHlulieIAqa3idKp5b/02 iC8Rk0PXHpL2gAJHCuLEnmHbZSQqm68EKdAVVOVk= Date: Sun, 10 Nov 2019 17:15:26 +0000 From: Jonathan Cameron To: Geert Uytterhoeven Cc: Jacopo Mondi , linux-iio@vger.kernel.org, Linux-Renesas , Linux Kernel Mailing List , Wolfram Sang , Linux I2C Subject: Re: [PATCH] iio: adc: max9611: Defer probe on POR read Message-ID: <20191110171526.2bd269a9@archlinux> In-Reply-To: References: <20191016102520.124370-1-jacopo+renesas@jmondi.org> X-Mailer: Claws Mail 3.17.4 (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 Thu, 17 Oct 2019 14:55:58 +0200 Geert Uytterhoeven wrote: > Hi Jacopo, > > CC i2c Ping. Wolfram, a query in here for you. Thanks, Jonathan > > 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 > > Thanks for your patch! > > > Geert, > > 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? > 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. > > Wolfram: do you have any clues? > > > Also, I opted for deferring probe instead of arbitrary repeat the > > temperature read. What's your opinion? > > While this is probably OK if the max9611 driver is built-in, I'm afraid > this may lead to unbounded delays for a reprobe in case the driver > is modular. > > > --- a/drivers/iio/adc/max9611.c > > +++ b/drivers/iio/adc/max9611.c > > @@ -80,6 +80,7 @@ > > * The complete formula to calculate temperature is: > > * ((adc_read >> 7) * 1000) / (1 / 480 * 1000) > > */ > > +#define MAX9611_TEMP_POR 0x8000 > > #define MAX9611_TEMP_MAX_POS 0x7f80 > > #define MAX9611_TEMP_MAX_NEG 0xff80 > > #define MAX9611_TEMP_MIN_NEG 0xd980 > > @@ -480,8 +481,10 @@ static int max9611_init(struct max9611_dev *max9611) > > if (ret) > > return ret; > > > > - regval &= MAX9611_TEMP_MASK; > > + if (regval == MAX9611_TEMP_POR) > > + return -EPROBE_DEFER; > > > > + regval &= MAX9611_TEMP_MASK; > > if ((regval > MAX9611_TEMP_MAX_POS && > > regval < MAX9611_TEMP_MIN_NEG) || > > regval > MAX9611_TEMP_MAX_NEG) { > > Gr{oetje,eeting}s, > > Geert >