[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190516173649.5s2s32ol43kbbhzg@core.my.home>
Date: Thu, 16 May 2019 19:36:49 +0200
From: Ondřej Jirman <megous@...ous.com>
To: Maxime Ripard <maxime.ripard@...tlin.com>
Cc: Yangtao Li <tiny.windzz@...il.com>, mark.rutland@....com,
daniel.lezcano@...aro.org, catalin.marinas@....com,
will.deacon@....com, bjorn.andersson@...aro.org,
mchehab+samsung@...nel.org, paulmck@...ux.ibm.com,
stefan.wahren@...e.com, linux-pm@...r.kernel.org, wens@...e.org,
jagan@...rulasolutions.com, andy.gross@...aro.org,
rui.zhang@...el.com, devicetree@...r.kernel.org,
marc.w.gonzalez@...e.fr, edubezval@...il.com,
enric.balletbo@...labora.com, robh+dt@...nel.org,
Jonathan.Cameron@...wei.com, linux-arm-kernel@...ts.infradead.org,
gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
olof@...om.net, davem@...emloft.net
Subject: Re: [PATCH 2/3] thermal: sun50i: add thermal driver for h6
Hello Maxime,
On Thu, May 16, 2019 at 05:02:52PM +0200, Maxime Ripard wrote:
> Hi,
>
> On Sun, May 12, 2019 at 11:41:28PM +0200, Ondřej Jirman 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?
> >
> > 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 = (-2794) * -67 = 187198
> >
> > 187°C 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'm not entirely sure, because I might have inadverently used a combination of
interrupt and polling when testing this. It may be that if we set polling-delay
to 0 in dts, that tz core will not try to call get_temp prematurely at all, and
will simply wait for temperature update from the interrupt.
I guess this needs to be tested/checked in tz code.
regards,
o.
> Maxime
>
> --
> Maxime Ripard, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@...ts.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Powered by blists - more mailing lists