devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Stéphan Kochen" <stephan-j6uo2F6POYhmR6Xm/wNWPw@public.gmane.org>
To: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Cc: Jean Delvare <jdelvare-IBi9RG/b67k@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Ian Campbell
	<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
	Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Zhang Rui <rui.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Eduardo Valentin
	<edubezval-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Interrupt driven thermal OF sensors (was: [PATCH 2/3] lm90: initialize parameters from devicetree)
Date: Wed, 27 Jan 2016 22:18:53 +0100	[thread overview]
Message-ID: <20160127211853.GA28555@Stephans-iMac.lan> (raw)
In-Reply-To: <56A2EB3E.4080002-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>

On Fri, Jan 22, 2016 at 06:53:50PM -0800, Guenter Roeck wrote:
> The thermal subsystem supports setting trip points, which I would think
> is what you are looking for here. Question is if an how you can use the
> information from the thermal subsystem (and thus the thermal zone configuration)
> to set the various limits in the lm90 driver. This should hopefully be sufficient
> to fix your immediate problem. For handling alerts, I guess we'll have to wait for
> thermal subsystem improvements (unless of course you volunteer to do that work.

I may take a shot at this. So in short, the goal is to have a device
tree thermal zone communicate trip points to the sensor driver, and use
interrupts to act on trips.

(This indirectly solves my problem of my sensor having weird initial
values. Perhaps we also want a solution for this case if the thermal
subsystem is disabled, but for me there'd be no need.)

Here's what I see:

 - The thermal core layer already supports interrupt driven systems.
   Support is missing from thermal OF, the layer between thermal core
   and the sensor driver implementing device tree support.

 - Thermal OF registers a device in thermal core for each zone defined
   in the device tree.

 - In theory, a thermal zone in the device tree can have multiple
   sensors, and multiple zones can refer to the same sensor, but the
   current implementation only supports 1-on-1 relations.

 - There are already exports thermal_zone_device_update and
   thermal_notify_framework in thermal core, which allow external code
   to trigger an update.

 - Updates happen by explicit calls to such exports, or by an optional
   and configurable interval in thermal core.

What I think we want:

 - Any additions should be optional extensions implemented by sensor
   drivers. Polling should keep on working for all sensor drivers
   already supporting thermal OF, with no interface changes.

 - For interrupt-capable sensor drivers, the thermal OF device should
   keep the sensor driver updated with the current nearest trip
   temperature and hysteresis. (Don't burden drivers with a full list of
   trip points.)

 - In the case of LM90, this would set the low and high alert
   temperatures. LM90 can have additional alerts (critical, emergency),
   but a sensor driver registered with thermal OF should disable any
   additional alerts.

 - Similarly, a sensor driver should disable alerts when there is no
   current trip temperature or hysteresis. (E.g., we're below the lowest
   trip point.)

Implementation-wise:

 - The struct thermal_zone_of_device_ops needs an additional function to
   set the current sensor trip temperature and hysteresis. Presence of
   this function indicates the sensor driver has interrupt support.

 - The thermal OF device will call this function every time the
   temperature slides across trip points. (Or when trip points are
   altered.)

 - The thermal OF device should ignore the polling delay (set it to 0)
   if its sensor has interrupt support. (In this case, we can also make
   polling-delay optional. It's currently required in the device tree.)

 - On interrupt, the sensor driver should call
   thermal_zone_device_update with its thermal_zone_device, as returned
   by thermal_zone_of_sensor_register.

My only concern is that I don't understand kernel contexts and interrupt
handling well enough. It looks like at least its up to the sensor driver
to ensure calls into the thermal subsystem have long left the hardware
interrupt context, which I think should be sufficient.

Hoping all of this sounds about right!

-- 
Stéphan Kochen
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-01-27 21:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21 19:34 [PATCH 0/3] lm90: device tree and thermal zone support Stéphan Kochen
     [not found] ` <1453404877-17897-1-git-send-email-stephan-j6uo2F6POYhmR6Xm/wNWPw@public.gmane.org>
2016-01-21 19:34   ` [PATCH 1/3] lm90: separate register accessors from sysfs Stéphan Kochen
     [not found]     ` <1453404877-17897-2-git-send-email-stephan-j6uo2F6POYhmR6Xm/wNWPw@public.gmane.org>
2016-01-22 14:42       ` Guenter Roeck
     [not found]         ` <56A23FD2.9040009-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2016-01-22 22:00           ` Stéphan Kochen
     [not found]             ` <20160122220056.GA21534-3Ql6wuUqVi7fKcxHm0zdRv8+0UxHXcjY@public.gmane.org>
2016-01-25  9:41               ` [lm-sensors] " Jean Delvare
2016-01-21 19:34   ` [PATCH 2/3] lm90: initialize parameters from devicetree Stéphan Kochen
     [not found]     ` <1453404877-17897-3-git-send-email-stephan-j6uo2F6POYhmR6Xm/wNWPw@public.gmane.org>
2016-01-22 14:53       ` Guenter Roeck
     [not found]         ` <56A24278.8050909-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2016-01-22 22:32           ` Stéphan Kochen
2016-01-23  2:53             ` Guenter Roeck
     [not found]               ` <56A2EB3E.4080002-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2016-01-27 21:18                 ` Stéphan Kochen [this message]
2016-01-28  5:05                   ` Interrupt driven thermal OF sensors Guenter Roeck
2016-01-29  0:16                     ` Stéphan Kochen
2016-01-21 19:34   ` [PATCH 3/3] lm90: register with thermal zones Stéphan Kochen
     [not found]     ` <1453404877-17897-4-git-send-email-stephan-j6uo2F6POYhmR6Xm/wNWPw@public.gmane.org>
2016-01-22 22:45       ` Rob Herring
2016-01-22 23:02         ` Stéphan Kochen
     [not found]           ` <20160122230239.GA22301-3Ql6wuUqVi7fKcxHm0zdRv8+0UxHXcjY@public.gmane.org>
2016-01-22 23:11             ` Rob Herring

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=20160127211853.GA28555@Stephans-iMac.lan \
    --to=stephan-j6uo2f6poyhmr6xm/wnwpw@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=edubezval-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
    --cc=jdelvare-IBi9RG/b67k@public.gmane.org \
    --cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
    --cc=linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=rui.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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 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).