From: Mason <slash.tmp@free.fr>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: cpufreq <cpufreq@vger.kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Eduardo Valentin <edubezval@gmail.com>,
Amit Daniel <amit.kachhap@linaro.org>,
Andrew Lunn <andrew@lunn.ch>,
Radhesh Fadnis <radhesh.fadnis@ti.com>
Subject: Re: Using a temperature sensor with 1-bit output for CPU throttling
Date: Wed, 29 Apr 2015 15:47:13 +0200 [thread overview]
Message-ID: <5540E0E1.6080504@free.fr> (raw)
In-Reply-To: <553F6E85.5090402@free.fr>
On 28/04/2015 13:27, Mason wrote:
> The SoC I'm working on provides a temperature sensor (NXP) in the CPU block.
> The sensor seems to be very primitive, so I wanted to ask experienced people
> what would be the best way to use it from Linux.
>
> General Description
> "The sensor generates an output signal that indicates if the die temperature
> exceeds a programmable threshold. This makes it particularly suitable for
> detecting overheating."
>
> So it seems that the original purpose of this sensor was to periodically
> check that the temperature has not exceeded a given threshold.
>
> - Is the CPU temp higher than 100°C ?
> - No.
> - OK. Business as usual.
>
> (1 second later)
> - Is the CPU temp higher than 100°C ?
> - Yes.
> - Uh-oh! I need to do something about it.
>
>
> Basic Functions
> "The temp sensor uses a bandgap type of circuit to compare a voltage which
> has a negative temperature coefficient with a voltage that is proportional
> to absolute temperature. A resistor bank allows 40 different temperature
> thresholds to be selected and the logic output 'out_temperature' will then
> indicate whether the actual die temperature lies above or below the selected
> threshold."
>
> The available thresholds seem to be chosen somewhat arbitrarily:
>
> -45.1, -39.7, -33.7, -29.4, -24.4, -20.4, -15.4, -10.1,
> -6.4, -1.4, 3.6, 7.6, 12.9, 16.6, 20.6, 25.6, 30.9,
> 34.9, 38.6, 43.9, 48.9, 52.9, 57.9, 61.9, 66.9, 70.9,
> 76.3, 81.3, 85.3, 90.3, 95.3, 98.9, 102.9, 108.3, 111.9,
> 117.3, 122.3, 126.3, 131.3, 135.3, 139.3
>
> The spacing between values seems arbitrary also.
> (Is there an underlying physical explanation?)
>
> I'm not sure that there is much point in testing for temperatures lower
> than 50°C ? (I'm told that the SoC can reliably function up to 125°C.)
>
> Do higher temperatures shorten the lifespan of a component?
> In other words, would a CPU running 24/7 at 100°C "break" sooner
> than one running 24/7 at 50°C ?
>
>
> Characteristics
>
> Symbol Parameter Min Typ Max Unit
>
> (Operating conditions)
> Tjunc Junction temperature -40 25 125 °C
> Vdd Supply voltage 1.0 1.1 1.26 V
>
> (Normal operating mode)
> Idd Supply current 50 60 μA
> Vbandgapref Ref output voltage 0.72 0.8 0.88 V
> ∆outtemp Absolute Temp ±2 ±10 °C
> threshold error
> T_res Temp resolution 3 4.5 7 °C
>
>
> Given the semantics of the temperature sensor hardware block, I was
> tempted to implement something along these lines:
>
> Create a kernel thread that runs periodically (e.g. every second)
> to check if the temperature is above 100°C.
> - If not, do nothing
> - If yes, somehow prevent the CPU from using the highest frequencies
> defined in cpufreq's freq table
> (They are 1000, 500, 333, 200, 100 MHz)
>
> Is that a sensible approach?
> Is there a way to implement this using the thermal framework?
>
> Or am I looking at this wrong, and things should be done a
> different way? (I'm using 3.14 by the way.)
>
> I suppose I could perform some kind of binary search to zoom in
> on the current threshold (although it might change during the
> measurements, so I'd rather not go there.)
I'm aware that I posted many questions. I'd be grateful if someone
would answer even a tiny subset. That would get the ball rolling.
If I understand correctly, if I want to use the CPU throttling
framework, I need to define a "thermal zone device" and a
"cooling device". AFAIU, the cooling device is taken care of
by cpu_cooling.c
cpufreq_cooling_register(cpu_present_mask);
My temperature sensor would be the thermal zone device?
How do I tie the two devices together?
Is that where a thermal governor comes in play?
I took a look at the dove_thermal driver, because it seems simple
enough to understand (by me).
Looking at ti-soc-thermal/omap?-thermal-data.c
the lookup table looks familiar. Are they using the same kind
of technology as my primitive sensor? (bandgap)
I do note that the precision is much higher though.
Regards.
next prev parent reply other threads:[~2015-04-29 13:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-28 11:27 Using a temperature sensor with 1-bit output for CPU throttling Mason
2015-04-29 13:47 ` Mason [this message]
2015-04-29 16:36 ` Javi Merino
2015-07-21 9:10 ` Mason
2015-07-21 11:49 ` Mason
2015-07-23 9:19 ` Mason
2015-07-23 12:51 ` Mason
2015-05-13 8:02 ` Mason
2015-05-14 9:25 ` Punit Agrawal
2015-05-14 9:46 ` Mason
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=5540E0E1.6080504@free.fr \
--to=slash.tmp@free.fr \
--cc=amit.kachhap@linaro.org \
--cc=andrew@lunn.ch \
--cc=cpufreq@vger.kernel.org \
--cc=edubezval@gmail.com \
--cc=linux-pm@vger.kernel.org \
--cc=radhesh.fadnis@ti.com \
--cc=rui.zhang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).