Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp649591ybm; Tue, 21 May 2019 00:50:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqxL1qFSK4W7BzQOdHbAol7zxTKgaTdsXw9bxY2n3L13y7v4UCm+FC23uxha+xR8Nb6A2ZDC X-Received: by 2002:a17:902:f096:: with SMTP id go22mr82187915plb.49.1558425036128; Tue, 21 May 2019 00:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558425036; cv=none; d=google.com; s=arc-20160816; b=c19HPJCL3cdF9I0Oc9HTS0Y/gHQRY0YMfTRtP/X0PyPTRqNQ4CTV7KUGZBsM3DdnKW SotHD/DW4Sk8pOTnVz/tGvObsi+EK2J+RPW7LIjHRadeChBzk7mFj4H9kQZZgnQlmKMp mHjYZ2lRbdTAqupswOKPR79X66nCAYNMulk21xwQ3PVDJcumSXPp+nGO6yKG7c/OmykD IhO7mfNZbK0Y7W3azvmfRNGlmKaPxA9AkI6Y3ZcDlQ8x6T+tm/98qjKlp1YyLL2OiAjS DcoY0DWIuWrNLu5I7Gb4kK2B2E8l8PMNKU2+cauYJgoim8KApkOBHIhuaPF3k2dqPI8v MSlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8zgHCNNAaRKUDXaCTBWO/1Hax8YqnjHR7J0OLHMlo8w=; b=R/udt8RWhY2xsoI5qapRHvE6Ve2ZCc+PjGNoW35w10uN4MYa7igCbVK6RYcZfg/P34 8xWkBAK1W4l42bfV1zuUFhBoEzMNZN1oGvHpD/bXHEDUkeUQkn8Wp3LWsVrdc891enfg VlBz3Gs6VLIU5mA6faz5Th9eSkLNMctF564enAX2hmAhHdi9wZ6YskZpwOtZzvhmFKFX IsdlMtTJJIYJMjKn+2tTZDifERwbNQh+kXnam7LZ8bPIOGCC26ReDsJhRDsvD48q/EoL tFnEHelE9y2qgl6sgWAfWzOpWyctIZHuanRx2ohwTFuNGOHBkomGn5ixBAittSEbxfFn E8xg== 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 d16si20662161pfr.229.2019.05.21.00.50.20; Tue, 21 May 2019 00:50:36 -0700 (PDT) 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 S1726994AbfEUHro (ORCPT + 99 others); Tue, 21 May 2019 03:47:44 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:43597 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725790AbfEUHrn (ORCPT ); Tue, 21 May 2019 03:47:43 -0400 X-Originating-IP: 90.88.22.185 Received: from localhost (aaubervilliers-681-1-80-185.w90-88.abo.wanadoo.fr [90.88.22.185]) (Authenticated sender: maxime.ripard@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 2CB2F240004; Tue, 21 May 2019 07:47:24 +0000 (UTC) Date: Tue, 21 May 2019 09:47:23 +0200 From: Maxime Ripard To: Vasily Khoruzhick Cc: Yangtao Li , Mark Rutland , daniel.lezcano@linaro.org, Catalin Marinas , Will Deacon , bjorn.andersson@linaro.org, mchehab+samsung@kernel.org, paulmck@linux.ibm.com, Stefan Wahren , linux-pm@vger.kernel.org, Chen-Yu Tsai , Jagan Teki , andy.gross@linaro.org, rui.zhang@intel.com, devicetree , marc.w.gonzalez@free.fr, edubezval@gmail.com, enric.balletbo@collabora.com, Rob Herring , Jonathan.Cameron@huawei.com, arm-linux , Greg Kroah-Hartman , linux-kernel , Olof Johansson , "David S. Miller" Subject: Re: [PATCH 2/3] thermal: sun50i: add thermal driver for h6 Message-ID: <20190521074723.s3hcrnpc5pkdreqe@flea> References: <20190512082614.9045-1-tiny.windzz@gmail.com> <20190512082614.9045-3-tiny.windzz@gmail.com> <20190512133930.t5txssl7mou2gljt@flea> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uzo2p4ihnuoqkun5" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --uzo2p4ihnuoqkun5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, May 17, 2019 at 12:21:57PM -0700, Vasily Khoruzhick wrote: > On Sun, May 12, 2019 at 6:39 AM Maxime Ripard wrote: > > > +static int tsens_get_temp(void *data, int *temp) > > > +{ > > > + struct tsensor *s = data; > > > + struct tsens_device *tmdev = s->tmdev; > > > + int val; > > > + > > > + regmap_read(tmdev->regmap, tmdev->chip->temp_data_base + > > > + 0x4 * s->id, &val); > > > + > > > + if (unlikely(val == 0)) > > > + return -EBUSY; > > > > I'm not sure why a val equals to 0 would be associated with EBUSY? > > First few reads of temp data return 0, and in case of H6 (and A64) it > means max temperature, so kernel does emergency shutdown. I used > -ETIMEDOUT as a workaround in my tree, but it's not appropriate here > either. Any suggestions are welcome. If we can use the interrupts and wait for a value to be converted before we read, then we should do that. > > Also, it's not in a fast path, so you can drop the unlikely. Chances > > are it's not that unlikely anyway. > > As I said earlier, it's just few samples after start up. That's not really my point though. unlikely is tricky to get right, because the compiler has his own meaning of what exactly unlikely means statistically to be able to do the right branching optimisations. However, this particular real case scenario might not have the same probability, which might result in a poor optimisation choice due to the unlikely being there. Moreover, this probability can evolve in the future. For example, let's assume that we enable dynamic PM in the driver. Starting from there, most of the reads become "first" reads, and your unlikely case becomes the likely one. My point was that, because of this, and because of the fact that it's really not a hot path, we should just drop it. Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com --uzo2p4ihnuoqkun5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXOOtCwAKCRDj7w1vZxhR xagHAQDdykPbWKdDic/RhsfGFYna5RZkWIPRvdVdikshfRJofQEAoFj6rDEFv4qd usQ5po0YFvhjL3xoWPQb0PQV4k9yLwI= =oWJX -----END PGP SIGNATURE----- --uzo2p4ihnuoqkun5--