Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1592727imn; Sun, 31 Jul 2022 13:25:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1su90NalVdU1LQLaFQJP/ufZxjHhh0rpcbj/J9d3zLTyONMDGDeYbHeZ/Kqu3ynkrP80jUa X-Received: by 2002:a17:907:7294:b0:72b:1ae:9c47 with SMTP id dt20-20020a170907729400b0072b01ae9c47mr10145498ejc.253.1659299104872; Sun, 31 Jul 2022 13:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659299104; cv=none; d=google.com; s=arc-20160816; b=nRkTrWlRshxRqSZXb2ptViXd/tanqiGiG/wRwI5ekE09wic/ush3tcKmv6ugmQ2bVY MPAxkbg6r62b82PT0v7VQSYVVtxg+3BlVi9/LEw+UYJtxb5q3TvKZiNEH//6mQ/VodGT HCffpeAn5azUkKupTpNdenKT3wr/mRHTK07Yoaoqzxps6Il3ICOeiKU2NhYzvOHipqqW i5bM06wqxMj5SQQU8sDMdPmvgTA9J06yQ0RqlWoW6D77Lb0aHETaVqa9ZoiaTU1/Ix6t Vzv+UDEfvhgb5zIsNP2fw/+nVXRbEX8jqg02YOXqJPNJX2bVrcYbpu+TVU5L9fk9KnG3 t7zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=V+Ismb5ySNdM2m0h4dTiDa515hA62V5f3ujwXDgw9us=; b=e2RGQ3D723K5z47s357UMtTwddnYrSJAjxIEfWQOggVXBrhmMOrMKjFlzjTrtElDpe 9fNuEjI0dhMRKE96H0AK2zvRvefuQGwCmsReiX0+iYTrr9pCIb/AUwuuR4f6BcQ96Iwr z4c396bDPfA66GAhDY+Hagk3X0mAIE8BZt+fMc2rOd/uy9arMO/+5K0l2i3/UsGpxGNv gEX/k3fFDoAh+ODXyuKzWNt0t8/djmMipvD6w245ETo7YnEhvVaG7rrnMhcAtNunT+2L NHCbntClCytmWcC+434RnN6I+lo4hS31aoPmK7loX1NvbqZIx0BYu/XMGojGZvV+l6h5 SJjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Q/4PXuK6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f13-20020a0564021e8d00b0043d7f3e0aa7si3011406edf.26.2022.07.31.13.24.40; Sun, 31 Jul 2022 13:25:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Q/4PXuK6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S237772AbiGaUHg (ORCPT + 99 others); Sun, 31 Jul 2022 16:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230351AbiGaUHe (ORCPT ); Sun, 31 Jul 2022 16:07:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B01C65DC; Sun, 31 Jul 2022 13:07:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C7D966108F; Sun, 31 Jul 2022 20:07:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98E2AC433D6; Sun, 31 Jul 2022 20:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659298052; bh=+qfOhp/3423pXOH1mc2GCsLtY504nNGk6+866UHD/8U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Q/4PXuK6Rm1ZDU5zh+PHtVqkHDkeja0FxrqhVm6uZudzjJy+dN7y49IqpX3GLjOcV 8s7rEFRNCfdirL0JMqdTxaeQ/cBotEp7msPl0PDKI+3ainWh1VGy/sclLGnELfCHao 4BAI44Mu6iO+dCJhGBUYxIV3iE3Txleh1W0emyYFc/RnfD+UbUJiOQ5NB0IUZgyMgo +wr+R4/MF+IBurVsqO3af7YGDruWmDvQtm34ibhZcfJlvR522/Glh324xNkWvXeDxk aNWVpQAprEg99s2R+E9KYrrg/jzPg/BcP9FYCqsFVU4xeykTgs+ZWR2dHwW9XqWpIC eDMN43OtAHrLA== Date: Sun, 31 Jul 2022 21:17:43 +0100 From: Jonathan Cameron To: Matti =?UTF-8?B?TGVodGltw6RraQ==?= Cc: linux-iio@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Lars-Peter Clausen , Miquel Raynal , Linus Walleij , Alexandru Ardelean , Cai Huoqing , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] iio: st_sensors: Retry ID verification on failure Message-ID: <20220731211743.6ab9264f@jic23-huawei> In-Reply-To: <6c839ba3-b671-76fb-95e1-94bf2f2da303@gmail.com> References: <20220724164316.68393-1-matti.lehtimaki@gmail.com> <20220731170057.2b8ac00e@jic23-huawei> <6c839ba3-b671-76fb-95e1-94bf2f2da303@gmail.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 31 Jul 2022 21:51:55 +0300 Matti Lehtim=C3=A4ki wrote: > On 31.7.2022 19.00, Jonathan Cameron wrote: > > On Sun, 24 Jul 2022 19:43:15 +0300 > > Matti Lehtim=C3=A4ki wrote: > > =20 > >> Some sensors do not always start fast enough to read a valid ID from > >> registers at first attempt. Let's retry at most 3 times with short sle= ep > >> in between to fix random timing issues. > >> > >> Signed-off-by: Matti Lehtim=C3=A4ki =20 > > Hi Matti, > >=20 > > My gut feeling is this isn't in a fast path, so why not just wait > > for whatever the documented power up time of the sensor is? > >=20 > > I'd expect to see a sleep in st_sensors_power_enable() if one is > > required. =20 >=20 > In the specification for the sensor (lis2hh12) I have on my device I > found that the maximum boot time of the sensor (starting from Vdd power > on) is defined as 20 ms. Not sure if the other sensors supported by the > driver have different values but based on checking a couple of > specifications I didn't find any bigger values so far. >=20 > >> + msleep(20); =20 > > How do we know 60msecs is long enough for all sensors? =20 >=20 > Based on the specification for the sensor I have and also driver used in > Android kernel for my device (it uses a 3 x 20 ms loop) I think 20 ms is > a good value but to be sure a slightly longer might make sense. As > suggested in the other review comment by changing the regmap_read to > regmap_read_poll_timeout the function doesn't always need to wait at > least 20 ms in case first read doesn't provide the correct value, if a > suitable shorter poll interval is used (something like 1-10 ms). >=20 > However testing on my device has shown that I still need to have a loop > or at least a retry possibility because I have noticed a rare random > read error (-6, happens after some time not at first read) when reading > the id from the hardware. This could be due to for example internal > init failure of the sensor chip causing an internal reset. Because of > this read error regmap_read_poll_timeout returns with an error and > without retrying to read the id the sensor probe fails. Nasty. If you can get a confirmation that it's a possible failure on startup from the manufacturer then I'd be happier with that justification to retry rather than just sleep for say 30msec after power on. Jonathan >=20 > -Matti