Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp644733ybm; Tue, 21 May 2019 00:43:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQpKYoTWdctuOqE7CQUhGrhys+u5qm24cvjxzSG3EG+PFYZa5wU1kSVAEFETKEAzfJ2gRE X-Received: by 2002:a63:2bd1:: with SMTP id r200mr18004170pgr.202.1558424637814; Tue, 21 May 2019 00:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558424637; cv=none; d=google.com; s=arc-20160816; b=XMLE0gnjpEC228Thc2GAoBKG8WKCkhqoG+Xn9NaLs1IcW6qd4Yudd7K+dJ1TTUUFxP XtVLtTvYkKOydS3J/HjwCsO+7qpqHifMPTaypMlfhWtGAM4ma3pY+IyhYLRy4++ULiuT 4JtLXVWVX4t0FvVyRBp1SZ8x+MPWqnIsYxCB/meg9sd5hF8xPKGE+b6RYnNoPq8JoGLB JPDr6FPqDc+jzUGjAgVpfyEkn9wLz7pkwAX1ab6GvZpbKdpGeU2bhEOnqYsQNhK18rju JLFZAWzvZq3o5mwIOFku/b2w5OXN/RgxMbf1ZDLH6FFL+LstDOy0FyPmAsY3zGxpHOkP WqAA== 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=nJEiuKaQRyNZeDiRC1VRZmDAk2VW02vuVvY/BM/FdqY=; b=ruJ291FN/gWOowKKJY66QDgETAtYkpZW6Jp7c1MVvPzkFXPlxckcxvEKIZMMH5WFtC w5ml5PPQbppL+OElO2asmxuHErWtqYv4QhoUwaayDO6whBX57rNjyoPXuUNRoMu2fUUc F7h5W3k15p9TUgbAwWtrTHPd/1DlZtSUey0xlzGIH9EOTVgnxEXjexn2+bE+i9YIGpEQ qZimEPmawjUKpaeB5bMWCGgb7YIydPQZ7gzRN5sJ+sHdnTeFW67Mw6LzY9vEcV+JnIIS n6wIFHtAqfc1pLGU8LSG4vqgAgsYqJxnIuo00s99J1ELIMbNzyg+QhYTPrbkFZQumQHn 2IOA== 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 j4si22824028pfr.59.2019.05.21.00.43.42; Tue, 21 May 2019 00:43:57 -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 S1726724AbfEUHlh (ORCPT + 99 others); Tue, 21 May 2019 03:41:37 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:46563 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbfEUHlg (ORCPT ); Tue, 21 May 2019 03:41:36 -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 329F5240014; Tue, 21 May 2019 07:41:22 +0000 (UTC) Date: Tue, 21 May 2019 09:41:22 +0200 From: Maxime Ripard To: Frank Lee Cc: Mark Rutland , Daniel Lezcano , catalin.marinas@arm.com, will.deacon@arm.com, bjorn.andersson@linaro.org, Mauro Carvalho Chehab , paulmck@linux.ibm.com, stefan.wahren@i2se.com, Linux PM , Chen-Yu Tsai , Jagan Teki , Andy Gross , rui.zhang@intel.com, devicetree@vger.kernel.org, marc.w.gonzalez@free.fr, Eduardo Valentin , enric.balletbo@collabora.com, robh+dt@kernel.org, Jonathan.Cameron@huawei.com, Linux ARM , Greg Kroah-Hartman , Linux Kernel Mailing List , olof@lixom.net, David Miller Subject: Re: [PATCH 2/3] thermal: sun50i: add thermal driver for h6 Message-ID: <20190521074122.syyctwvfsorl45dv@flea> References: <20190512082614.9045-1-tiny.windzz@gmail.com> <20190512082614.9045-3-tiny.windzz@gmail.com> <20190512133930.t5txssl7mou2gljt@flea> <20190512214128.qjyys3vfpwdiacib@core.my.home> <20190516150252.hf4u3bloo37chy6q@flea> <20190517073151.mz6hcmzubk7iqfre@flea> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oyv7cdm2vd7as2px" 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 --oyv7cdm2vd7as2px Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Sat, May 18, 2019 at 01:19:54AM +0800, Frank Lee wrote: > On Fri, May 17, 2019 at 3:32 PM Maxime Ripard = wrote: > > > > On Fri, May 17, 2019 at 02:10:47AM +0800, Frank Lee wrote: > > > > On Sun, May 12, 2019 at 11:41:28PM +0200, Ond=C5=99ej Jirman wrote: > > > > > > > +static int tsens_get_temp(void *data, int *temp) > > > > > > > +{ > > > > > > > + struct tsensor *s =3D data; > > > > > > > + struct tsens_device *tmdev =3D s->tmdev; > > > > > > > + int val; > > > > > > > + > > > > > > > + regmap_read(tmdev->regmap, tmdev->chip->temp_data_base + > > > > > > > + 0x4 * s->id, &val); > > > > > > > + > > > > > > > + if (unlikely(val =3D=3D 0)) > > > > > > > + return -EBUSY; > > > > > > > > > > > > I'm not sure why a val equals to 0 would be associated with EBU= SY? > > > > > > > > > > Thermal zone driver can (will) call get_temp before we got the > > > > > first interrupt and the thermal data. In that case val will be 0. > > > > > > > > > > Resulting in: > > > > > > > > > > (val + offset) * scale =3D (-2794) * -67 =3D 187198 > > > > > > > > > > 187=C2=B0C and immediate shutdown during boot - based on cirtical > > > > > temperature being reached. > > > > > > > > > > Busy here means, get_temp does not yet have data. Thermal zone > > > > > driver just reports any error to dmesg output. > > > > > > > > Ah, that makes sense. > > > > > > > > I guess if we're switching to an interrupt-based driver, then we can > > > > just use a waitqueue, or is get_temp supposed to be atomic? > > > > > > I think get_temp should not be bloacked. > > > > Why not? > > Maybe, I am wrong. I also want to know if we should do this. I guess it really all depends on whether you can sleep or not in get_temps. If you can, then you should wait for the value to be converted and the THS raising an interrupt. If you can't, then we should ask what the thermal frameworks expects in such a case. Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com --oyv7cdm2vd7as2px Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXOOrogAKCRDj7w1vZxhR xULTAQC1mWNEVwrK+oid9JOzl0rrU7ybLUMo5gBPlvdd1iIu+QEAzEe9pVgCRCN6 Z8AqbAjBGsyR2h/P/5jg1jYC4d/GBQg= =MglJ -----END PGP SIGNATURE----- --oyv7cdm2vd7as2px--