All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Valentin <edubezval@gmail.com>
To: Brian Norris <briannorris@chromium.org>
Cc: Caesar Wang <wxt@rock-chips.com>,
	rui.zhang@intel.com, heiko@sntech.de, smbarber@chromium.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-rockchip@lists.infradead.org
Subject: Re: [PATCH v3 3/5] thermal: rockchip: fixes invalid temperature case
Date: Tue, 29 Nov 2016 22:26:59 -0800	[thread overview]
Message-ID: <20161130062658.GA28498@localhost.localdomain> (raw)
In-Reply-To: <20161130055927.GA125421@google.com>

Hello,

On Tue, Nov 29, 2016 at 09:59:28PM -0800, Brian Norris wrote:
> On Tue, Nov 29, 2016 at 09:02:42PM -0800, Eduardo Valentin wrote:
> > On Tue, Nov 29, 2016 at 01:57:45PM -0800, Brian Norris wrote:
> > > I was thinking while reviewing that the binary search serves more to
> > > complicate things than to help -- it's much harder to read (and validate
> > > that the loop termination logic is correct). And searching through a few
> > > dozen table entries doesn't really get much benefit from a O(n) ->
> > > O(log(n)) speed improvement.
> > 
> > true. but if in your code path you do several walks in the table just to
> > check if parameters are valid, given that you could simply decide if
> > they are valid or not with simpler if condition, then, still worth, no?
> > :-)
> 
> Yes, your suggestions seems like they would have made the code both (a
> little) more straightforward and efficient. But...
> 
> > > Anyway, I'm not sure if you were thinking along the same lines as me.
> > > 
> > 
> > Something like that, except I though of something even simpler:
> > +	if ((temp % table->step) != 0)
> > +		return -ERANGE;
> > 
> > If temp passes that check, then you go to the temp -> code conversion.
> 
> ...that check isn't valid as of patch 4, where Caesar adds handling for
> intermediate steps. We really never should have been strictly snapping
> to the 5C steps in the first place; intermediate values are OK.
> 
> So, we still need some kind of search to find the right step -- or
> closest bracketing range, to compute the interpolated value. We should
> only reject temperatures that are too high or too low for the ADC to
> represent.

Ok. got it. check small comment on patch 4 then.

> 
> 
> --- Side track ---
> 
> BTW, when we're considering rejecting temperatures here: shouldn't this
> be fed back to the upper layers more nicely? We're improving the error
> handling for this driver in this series, but it still leaves things
> behaving a little odd. When I tested, I can do:
> 
> ## set something obviously way too high
> echo 700000 > trip_point_X_temp
> 
> and get a 0 (success) return code from the sysfs write() syscall, even
> though the rockchip driver rejected it with -ERANGE. Is there really no
> way to feed back thermal range limits of a sensor to the of-thermal
> framework?
> 

well, that is a bit strange to me. Are you sure you are returning the
-ERANGE? Because, my assumption is that the following of-thermal code
path would return the error code back to core:
 328         if (data->ops->set_trip_temp) {
 329                 int ret;
 330 
 331                 ret = data->ops->set_trip_temp(data->sensor_data, trip, temp);
 332                 if (ret)
 333                         return ret;
 334         }

And this part of thermal core would return it back to sysfs layer:
 757         ret = tz->ops->set_trip_temp(tz, trip, temperature);
 758         if (ret)
 759                 return ret;

or am I missing something?

> Brian

  reply	other threads:[~2016-11-30  6:27 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 11:11 [PATCH v3 0/5] thermal: fixes the rockchip thermal Caesar Wang
2016-11-28 11:12 ` [PATCH v3 3/5] thermal: rockchip: fixes invalid temperature case Caesar Wang
2016-11-28 18:47   ` Brian Norris
2016-11-29  1:45   ` Eduardo Valentin
     [not found]     ` <20161129014553.GA3097-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2016-11-29 21:57       ` Brian Norris
2016-11-29 21:57         ` Brian Norris
2016-11-30  5:02         ` Eduardo Valentin
2016-11-30  5:59           ` Brian Norris
2016-11-30  6:26             ` Eduardo Valentin [this message]
2016-12-12 10:46               ` Caesar Wang
     [not found] ` <1480331524-18741-1-git-send-email-wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-11-28 11:12   ` [PATCH v3 1/5] thermal: rockchip: improve conversion error messages Caesar Wang
2016-11-28 11:12     ` Caesar Wang
2016-11-29  1:51     ` Eduardo Valentin
2016-11-29  5:47       ` Brian Norris
2016-11-30  5:04         ` Eduardo Valentin
2016-12-12 10:47           ` Caesar Wang
2016-11-28 11:12   ` [PATCH v3 2/5] thermal: rockchip: don't pass table structs by value Caesar Wang
2016-11-28 11:12     ` Caesar Wang
2016-11-28 11:12   ` [PATCH v3 4/5] thermal: rockchip: optimize the conversion table Caesar Wang
2016-11-28 11:12     ` Caesar Wang
2016-11-29  1:48     ` Eduardo Valentin
2016-11-30  6:29     ` Eduardo Valentin
2016-12-12 10:48       ` Caesar Wang
2016-11-28 11:12   ` [PATCH v3 5/5] thermal: rockchip: handle set_trips without the trip points Caesar Wang
2016-11-28 11:12     ` Caesar Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161130062658.GA28498@localhost.localdomain \
    --to=edubezval@gmail.com \
    --cc=briannorris@chromium.org \
    --cc=heiko@sntech.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=rui.zhang@intel.com \
    --cc=smbarber@chromium.org \
    --cc=wxt@rock-chips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.