[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190521074723.s3hcrnpc5pkdreqe@flea>
Date: Tue, 21 May 2019 09:47:23 +0200
From: Maxime Ripard <maxime.ripard@...tlin.com>
To: Vasily Khoruzhick <anarsoul@...il.com>
Cc: Yangtao Li <tiny.windzz@...il.com>,
Mark Rutland <mark.rutland@....com>, daniel.lezcano@...aro.org,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will.deacon@....com>, bjorn.andersson@...aro.org,
mchehab+samsung@...nel.org, paulmck@...ux.ibm.com,
Stefan Wahren <stefan.wahren@...e.com>,
linux-pm@...r.kernel.org, Chen-Yu Tsai <wens@...e.org>,
Jagan Teki <jagan@...rulasolutions.com>, andy.gross@...aro.org,
rui.zhang@...el.com, devicetree <devicetree@...r.kernel.org>,
marc.w.gonzalez@...e.fr, edubezval@...il.com,
enric.balletbo@...labora.com, Rob Herring <robh+dt@...nel.org>,
Jonathan.Cameron@...wei.com,
arm-linux <linux-arm-kernel@...ts.infradead.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
Olof Johansson <olof@...om.net>,
"David S. Miller" <davem@...emloft.net>
Subject: Re: [PATCH 2/3] thermal: sun50i: add thermal driver for h6
On Fri, May 17, 2019 at 12:21:57PM -0700, Vasily Khoruzhick wrote:
> On Sun, May 12, 2019 at 6:39 AM Maxime Ripard <maxime.ripard@...tlin.com> 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
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists