All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mason <slash.tmp@free.fr>
To: Eduardo Valentin <edubezval@gmail.com>
Cc: linux-pm <linux-pm@vger.kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Javi Merino <javi.merino@arm.com>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Arnd Bergmann <arnd@arndb.de>, Mans Rullgard <mans@mansr.com>,
	Rob Herring <robh@kernel.org>
Subject: Re: [PATCH v5] thermal: add temperature sensor support for tango SoC
Date: Tue, 29 Mar 2016 20:48:43 +0200	[thread overview]
Message-ID: <56FACE0B.9060606@free.fr> (raw)
In-Reply-To: <20160329020050.GA15721@localhost.localdomain>

On 29/03/2016 04:00, Eduardo Valentin wrote:

> Again, only minor comments, as follows.

I do hope we can get this driver sorted out in time for the 4.7
merge window.

>> +The SMP8758 SoC includes 3 instances of this temperature sensor
>> +(in the CPU, video decoder, and PCIe controller).
> 
> Would you be able to add a link to sensor documentation?

I couldn't find any documentation online, even on Chinese sites.

>> +	cpu_temp: thermal@920100 {
>> +		compatible = "sigma,smp8758-thermal";
>> +		#thermal-sensor-cells = <0>;
>> +		reg = <0x920100 12>;
> 
> I believe you have to put #thermal-sensor-cells as last entry.

I've been using the node as-is in my DT, which works as expected.
What kinds of failure did you have in mind?

>> +	  Enable the Tango temperature sensor driver, which provides support
>> +	  for the sensors used since the SMP8758.
> 
> Please add a better description, e.g. which sensors are supported,
> locations, accuracy, and more meaningful info an engineer could read out
> of the help section.

I will try to give a few more details, but AFAICS the majority
of entries for other SoCs are as short as mine...

What do you mean by "which sensors"?

Locations isn't really relevant here because different SoCs
will have them in different places.

> No license/author/contact section here?

License is given by MODULE_LICENSE("GPL");
author and contact are given by git log or git blame.

>> +	writel(thresh_idx << 8 | CMD_READ, base + TEMPSI_CMD);
>> +	usleep_range(100, 200);
>
> nip: blank line here.

Did you mean "nit"? :-)

>> +	return readl(base + TEMPSI_RES);

Hmm, I don't see this rule in the CodingStyle document.

There are even examples to the contrary:

		kfree(foo->bar);
		kfree(foo);
		return ret;

>> +	if (temp_above_thresh(base, idx)) {
>> +		/* Upward linear search, increment thresh */
>> +		while (idx < IDX_MAX && temp_above_thresh(base, ++idx))
>> +			cpu_relax();
>> +		idx = idx - 1; /* always return lower bound */
>> +	} else {
>> +		/* Downward linear search, decrement thresh */
>> +		while (idx > IDX_MIN && !temp_above_thresh(base, --idx))
>> +			cpu_relax();
>> +	}
> 
> Did I understand this right? We can only read if the temperature is
> above an index or not, right?

Right, the hardware's output is a single bit:
"Is the temperature above the programmed threshold?" yes/no.

> and we spin for 100-200us after every 
> attempt to check if temperature is above and index.

Nit: we don't spin, we sleep.

100-200 µs is a bit conservative, the hardware doesn't need
that much. But I wanted to give Linux the opportunity to
group multiple checks together, and even switch to a different
task if necessary. I assumed that it doesn't make sense to
context switch for only tens of microseconds?

> So, worst case,
> if we start from IDX_MIN, and temp is at IDX_MAX, we spin for
> 40 * (100 .. 200) us (with cpu_relax in between).

On my system, cpu_relax is just a compiler barrier, so barely
a blip. And the worst case doesn't occur. But I will change
IDX_MIN to 10, because I don't care about sub-zero temperatures.

> Does the chip support different temperature read strategy?

I'm not sure what you mean.

> How does this perform in average case?

Typical idle temps are index 18-20 (43-52 °C)
When I load the CPU with cpuburn, the temp climbs to
index 22-24 (61-70 °C).
But obviously, these numbers depend on the thermal solution.

> How about a local search within +-2 indexes of thresh_idx?

What problem would that solve?

>> +	priv->zone = thermal_zone_of_sensor_register(dev, 0, priv, &ops);
> 
> Would it make sense to use the devm_thermal_zone_of_sensor_register
> version instead?

Does that automatically call thermal_zone_of_sensor_unregister
in the remove() method?

I prefer having the symmetry of register/unregister, but
I guess it's your call as maintainer.

Regards.


  reply	other threads:[~2016-03-29 18:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-01 16:49 [RFC] Temperature sensor driver (tango) Mason
2016-03-04 15:52 ` [PATCH v2] thermal: add temperature sensor support for tango SoC Mason
2016-03-08 21:48   ` Eduardo Valentin
2016-03-21 10:31     ` Mason
2016-03-24 12:18     ` [PATCH v3] " Mason
2016-03-24 17:56       ` Mason
2016-03-27 20:35     ` [PATCH v4] " Mason
2016-03-28 11:49       ` [PATCH v5] " Mason
2016-03-29  2:00         ` Eduardo Valentin
2016-03-29 18:48           ` Mason [this message]
2016-03-30  0:05             ` Eduardo Valentin
2016-03-30 15:18               ` Mason
2016-03-31 20:16                 ` [PATCH v6] " Mason
2016-04-01  1:52                   ` Eduardo Valentin
2016-04-04 11:48                     ` Mason
2016-04-04 11:49                     ` [PATCH v7] " Mason
2016-04-05  2:05                       ` Eduardo Valentin
2016-04-05 14:58                       ` Mason
2016-04-06 15:48                         ` Eduardo Valentin
2016-04-06 15:51                       ` Eduardo Valentin
2016-04-13 20:28                         ` Mason
2016-04-19 14:21                         ` [PATCH v8 1/2] " Mason
2016-04-19 14:49                           ` Mason
2016-04-19 14:32                         ` [PATCH v8 2/2] ARM: dts: tango4: Initial thermal support Mason
2016-04-20 22:45                           ` Eduardo Valentin
2016-04-01  1:48                 ` [PATCH v5] thermal: add temperature sensor support for tango SoC Eduardo Valentin

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=56FACE0B.9060606@free.fr \
    --to=slash.tmp@free.fr \
    --cc=arnd@arndb.de \
    --cc=edubezval@gmail.com \
    --cc=javi.merino@arm.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=mans@mansr.com \
    --cc=robh@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=viresh.kumar@linaro.org \
    /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.