From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxime Ripard Subject: Re: [PATCH 2/3] thermal: sun50i: add thermal driver for h6 Date: Tue, 21 May 2019 09:41:22 +0200 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" Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org 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.n List-Id: devicetree@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--