* Re: [PATCH 2/3] lm90: initialize parameters from devicetree [not found] ` <20160122223238.GB21534@Stephans-iMac.lan> @ 2016-01-23 2:53 ` Guenter Roeck [not found] ` <56A2EB3E.4080002-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Guenter Roeck @ 2016-01-23 2:53 UTC (permalink / raw) To: Stéphan Kochen Cc: Jean Delvare, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, lm-sensors, devicetree, linux-pm@vger.kernel.org, Zhang Rui, Eduardo Valentin On 01/22/2016 02:32 PM, Stéphan Kochen wrote: > On Fri, Jan 22, 2016 at 06:53:44AM -0800, Guenter Roeck wrote: >> On 01/21/2016 11:34 AM, Stéphan Kochen wrote: >>> Allow a device tree to set initial temperature sensor parameters. >> >> This very much smells like configuration, not hardware description. >> >> Having said that, the thermal subsystem does something similar. This raises even more >> questions, though. Since patch 3 of the series introduces registration with the thermal >> subsystem, it seems to me that the thermal subsystem should provide any limits used >> to program the chips, and that there should be a mechanism for the thermal subsystem >> to interact with the driver to both set the limits and to be informed if a limit >> is exceeded. >> >> Also, _if_ such a set of properties is introduced and accepted by the devicetree >> reviewers, it should probably be a set of properties which applies to _all_ hardware >> monitoring drivers, not just to one. Even if support is not implemented immediately >> in the hwmon core, the properties should be usable in a generic way, and not >> reflect sysfs attribute names used by the hwmon subsystem. > > The original kernel for Ouya is a 3.1 kernel from nVidia's old > Linux4Tegra branches. This kernel had its own Tegra-specific thermal > zone support which seems to do more or less that: the thermal zone > system actually uses the sensor alert interrupts to detect when it needs > to act, and reconfigures alert bounds as the temperature slides to > another range it wants to monitor. > > Thermal zones in current master only have the ability to check sensor > values at an interval. > > I'd agree that update-interval and the low/high bounds could be > controlled by the thermal zone system. I'm less certain what to do with > the critical/emergency bounds, and the remote-offset. > > Thing about Ouya is that, even with the thermal zone currently working, > the alert bounds set when the system comes up seem to be crippling the > system with interrupts shortly after the sensor is activated. So they > have to be set to something sane. Hence why I added both. > > I'm not sure if you're expecting me to do the work of extending thermal > zones. I guess I'd need to figure out how a sensor would notify a > thermal zone of an alert, and implement that functionality while staying > backwards compatible. > 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. Copying the the linux-pm mailing list and thermal maintainers for additional advise. Thanks, Guenter ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <56A2EB3E.4080002-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>]
* Interrupt driven thermal OF sensors (was: [PATCH 2/3] lm90: initialize parameters from devicetree) [not found] ` <56A2EB3E.4080002-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org> @ 2016-01-27 21:18 ` Stéphan Kochen 2016-01-28 5:05 ` Interrupt driven thermal OF sensors Guenter Roeck 0 siblings, 1 reply; 4+ messages in thread From: Stéphan Kochen @ 2016-01-27 21:18 UTC (permalink / raw) To: Guenter Roeck Cc: Jean Delvare, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, lm-sensors-GZX6beZjE8VD60Wz+7aTrA, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Zhang Rui, Eduardo Valentin 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Interrupt driven thermal OF sensors 2016-01-27 21:18 ` Interrupt driven thermal OF sensors (was: [PATCH 2/3] lm90: initialize parameters from devicetree) Stéphan Kochen @ 2016-01-28 5:05 ` Guenter Roeck 2016-01-29 0:16 ` Stéphan Kochen 0 siblings, 1 reply; 4+ messages in thread From: Guenter Roeck @ 2016-01-28 5:05 UTC (permalink / raw) To: Stéphan Kochen Cc: Jean Delvare, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, lm-sensors, devicetree, linux-pm@vger.kernel.org, Zhang Rui, Eduardo Valentin On 01/27/2016 01:18 PM, Stéphan Kochen wrote: > 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. > ... and thus disable any external chip signals associated with those limits. > - 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.) > The idea with most if not all temperature sensors is that multiple trip points would be configured as multiple limits in the chip. Often those limits, when reached, are tied to pins to cause a specific action (eg to cause an interrupt, turn on a fan, or shut down the hardware). In effect, you suggest to re-define this mechanism and, for all practical purposes, use just one of the limits provided by the chip(s). Personally I don't think that would be a good idea, because it would have impact on hardware design. It would effectively limit the use of the thermal subsystem with temperature sensor chips to hardware designs which take the thermal subsystem's expectations and assumptions into account. At the same time, it would for all practical purposes mandate the use of the thermal subsystem on such systems, because the hardware would depend on the thermal subsystem's implementation to control the temperature in the system. While it may be feasible in some situations to have the thermal subsystem dynamically set free-moving limits, there are many other situations where those limits are tied to hardware responses, and the limits need to be static. Maybe this is just a different world view. The thermal subsystem may see the world assuming that it always has an unlimited number of trip points available, and the chip it supports only support lower and upper boundaries (or trip points), which can be set and changed as needed. This is somewhat different to the traditional world view, implemented not only in many temperature sensors, but also in fan controller or Super-IO chips, where a set of temperatures is programmed into the chip only once. I hope that it is possible to support both mechanisms. Thanks, Guenter > 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! > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Interrupt driven thermal OF sensors 2016-01-28 5:05 ` Interrupt driven thermal OF sensors Guenter Roeck @ 2016-01-29 0:16 ` Stéphan Kochen 0 siblings, 0 replies; 4+ messages in thread From: Stéphan Kochen @ 2016-01-29 0:16 UTC (permalink / raw) To: Guenter Roeck Cc: Jean Delvare, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, lm-sensors, devicetree, linux-pm@vger.kernel.org, Zhang Rui, Eduardo Valentin On Wed, Jan 27, 2016 at 09:05:08PM -0800, Guenter Roeck wrote: > ... and thus disable any external chip signals associated with those limits. > > The idea with most if not all temperature sensors is that multiple trip points > would be configured as multiple limits in the chip. Often those limits, > when reached, are tied to pins to cause a specific action (eg to cause > an interrupt, turn on a fan, or shut down the hardware). In effect, you > suggest to re-define this mechanism and, for all practical purposes, > use just one of the limits provided by the chip(s). > > Personally I don't think that would be a good idea, because it would have > impact on hardware design. It would effectively limit the use of the thermal > subsystem with temperature sensor chips to hardware designs which take > the thermal subsystem's expectations and assumptions into account. > At the same time, it would for all practical purposes mandate the use > of the thermal subsystem on such systems, because the hardware would depend > on the thermal subsystem's implementation to control the temperature > in the system. Ah, whoops. That makes a lot of sense. And I think I even saw the poweroff in action once, when I misconfigured the temperature offset register. > While it may be feasible in some situations to have the thermal subsystem > dynamically set free-moving limits, there are many other situations where > those limits are tied to hardware responses, and the limits need to be static. > > Maybe this is just a different world view. The thermal subsystem may see the > world assuming that it always has an unlimited number of trip points available, > and the chip it supports only support lower and upper boundaries (or trip points), > which can be set and changed as needed. This is somewhat different to the > traditional world view, implemented not only in many temperature sensors, > but also in fan controller or Super-IO chips, where a set of temperatures > is programmed into the chip only once. I hope that it is possible to support > both mechanisms. That would be nice. For starters, I think it should be possible for a driver to enable thermal subsystem stuff only if an of_node is present. (Though I haven't checked what that's set to with `status = "disabled"` in the device tree. Hopefully NULL.) So, one option is to, instead of thermal OF telling the driver what the limits are, we simply have thermal OF only notify the driver of trip changes, and the driver does all the work of inspecting defined trips. In the LM90 case, it can set low/high and critical alerts nicely based on trip types (critical or not). But, for example, MAX6696 has an additional 'emergency' alert. Should that just be left untouched? Either way, this means hardcoding thermal trip to sensor alert mapping in the driver. A more elaborate solution would be to define that mapping in the device tree, and have thermal OF handle it, instructing the driver to set specific alerts. (And then the device tree author may choose to leave certain sensor alerts alone.) -- Stéphan Kochen ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-01-29 0:16 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <1453404877-17897-1-git-send-email-stephan@kochen.nl> [not found] ` <1453404877-17897-3-git-send-email-stephan@kochen.nl> [not found] ` <56A24278.8050909@roeck-us.net> [not found] ` <20160122223238.GB21534@Stephans-iMac.lan> 2016-01-23 2:53 ` [PATCH 2/3] lm90: initialize parameters from devicetree Guenter Roeck [not found] ` <56A2EB3E.4080002-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org> 2016-01-27 21:18 ` Interrupt driven thermal OF sensors (was: [PATCH 2/3] lm90: initialize parameters from devicetree) Stéphan Kochen 2016-01-28 5:05 ` Interrupt driven thermal OF sensors Guenter Roeck 2016-01-29 0:16 ` Stéphan Kochen
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).