Skip to contentSkip to conversation

thermal: add hwmon sys I/F for thermal device

PATCH In review Zhang, Rui 5 participants 16 messages Feb 25, 2008 – Mar 20, 2008 ACPI

lore
Share & tools
lore

Zhang, Rui

author
#0 lore raw

PATCH 1/2 thermal: add hwmon sys I/F for thermal device

Add hwmon sys I/F for the generic thermal device.

---
 Documentation/thermal/sysfs-api.txt |   22 +++++----
 drivers/thermal/Kconfig             |    1 
 drivers/thermal/thermal.c           |   86 ++++++++++++++++++++++++++++++++----
 include/linux/thermal.h             |    1 
 4 files changed, 92 insertions(+), 18 deletions(-)

Index: linux-2.6.25-rc2/Documentation/thermal/sysfs-api.txt
=================================--- linux-2.6.25-rc2.orig/Documentation/thermal/sysfs-api.txt 2008-02-25 22:43:29.000000000 -0500
+++ linux-2.6.25-rc2/Documentation/thermal/sysfs-api.txt 2008-02-25 22:43:38.000000000 -0500
@@ -141,12 +141,14 @@

type Strings which represent the thermal zone type.
This is given by thermal zone driver as part of registration.
+ In order to keep the compatibility with hwmon,
+ it should not contain any spaces or dashes.
Eg: "ACPI thermal zone" indicates it's a ACPI thermal device RO
- Optional
+ Required

temp Current temperature as reported by thermal zone (sensor)
- Unit: degree Celsius
+ Unit: millidegree Celsius
RO
Required

@@ -163,7 +165,7 @@
charge of the thermal management.

trip_point_[0-*]_temp The temperature above which trip point will be fired
- Unit: degree Celsius
+ Unit: millidegree Celsius
RO
Optional

@@ -219,16 +221,16 @@

|thermal_zone1:

 	|-----type:			ACPI thermal zone
-	|-----temp:			37
+	|-----temp:			37000
 	|-----mode:			kernel
-	|-----trip_point_0_temp:	100
+	|-----trip_point_0_temp:	100000
 	|-----trip_point_0_type:	critical
-	|-----trip_point_1_temp:	80
+	|-----trip_point_1_temp:	80000
 	|-----trip_point_1_type:	passive
-	|-----trip_point_2_temp:	70
-	|-----trip_point_2_type:	active[0]
-	|-----trip_point_3_temp:	60
-	|-----trip_point_3_type:	active[1]
+	|-----trip_point_2_temp:	70000
+	|-----trip_point_2_type:	active0
+	|-----trip_point_3_temp:	60000
+	|-----trip_point_3_type:	active1
 	|-----cdev0:			--->/sys/class/thermal/cooling_device0
 	|-----cdev0_trip_point:		1	/* cdev0 can be used for passive */
 	|-----cdev1:			--->/sys/class/thermal/cooling_device3

Index: linux-2.6.25-rc2/drivers/thermal/Kconfig
=================================--- linux-2.6.25-rc2.orig/drivers/thermal/Kconfig 2008-02-25 22:43:29.000000000 -0500
+++ linux-2.6.25-rc2/drivers/thermal/Kconfig 2008-02-25 22:43:38.000000000 -0500
@@ -4,6 +4,7 @@

menuconfig THERMAL
bool "Generic Thermal sysfs driver"
+ select HWMON
default y
help
Generic Thermal Sysfs driver offers a generic mechanism for
Index: linux-2.6.25-rc2/drivers/thermal/thermal.c
=================================--- linux-2.6.25-rc2.orig/drivers/thermal/thermal.c 2008-02-25 22:43:29.000000000 -0500
+++ linux-2.6.25-rc2/drivers/thermal/thermal.c 2008-02-26 00:37:57.000000000 -0500
@@ -30,8 +30,9 @@
#include <linux/idr.h>
#include <linux/thermal.h>
#include <linux/spinlock.h>
+#include <linux/hwmon.h>

-MODULE_AUTHOR("Zhang Rui")
+MODULE_AUTHOR("Zhang Rui");
MODULE_DESCRIPTION("Generic thermal management sysfs support"); MODULE_LICENSE("GPL");

@@ -171,6 +172,47 @@
return tz->ops->get_trip_temp(tz, trip, buf);
}

+static ssize_t
+hwmon_type_show(struct device *dev, struct device_attribute *attr, char *buf) +{
+ struct device *device = dev->parent;
+ return type_show(device, attr, buf);
+}
+
+static ssize_t
+hwmon_temp_show(struct device *dev, struct device_attribute *attr, char *buf) +{
+ struct device *device = dev->parent;
+ return temp_show(device, attr, buf);
+}
+
+static ssize_t
+crit_trip_temp_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct device *device = dev->parent;
+ struct thermal_zone_device *tz = to_thermal_zone(device);
+ int result;
+
+ if (!tz->ops->get_trip_temp )
+ return -EPERM;
+
+ /* assume trip 0 to be the critical trip point by default */
+ if (tz->ops->get_trip_type) {
+ result = tz->ops->get_trip_type(tz, 0, buf);
+ if (result < 0)
+ return result;
+ if (strcmp(buf, "critical\n"))
+ return -ENODEV;
+ }
+
+ return tz->ops->get_trip_temp(tz, 0, buf);
+}
+
+static DEVICE_ATTR(name, 0444, hwmon_type_show, NULL);
+static DEVICE_ATTR(temp1_input, 0444, hwmon_temp_show, NULL); +static DEVICE_ATTR(temp1_crit, 0444, crit_trip_temp_show, NULL); +
static DEVICE_ATTR(type, 0444, type_show, NULL);
static DEVICE_ATTR(temp, 0444, temp_show, NULL);
static DEVICE_ATTR(mode, 0644, mode_show, mode_store);
@@ -569,6 +611,9 @@
int result;
int count;

+ if (!type)
+ return ERR_PTR(-EINVAL);
+
if (strlen(type) >= THERMAL_NAME_LENGTH)
return NULL;

@@ -604,13 +649,33 @@
return NULL;
}

- /* sys I/F */
- if (type) {
- result = device_create_file(&tz->device, &dev_attr_type);
- if (result)
- goto unregister;
+ /* hwmon sys I/F */
+ tz->hwmon = hwmon_device_register(&tz->device);
+ if (IS_ERR(tz->hwmon)) {
+ result = PTR_ERR(tz->hwmon);
+ tz->hwmon = NULL;
+ printk(KERN_ERR PREFIX
+ "unable to register hwmon device\n");
+ goto unregister;
}

+ result = device_create_file(tz->hwmon, &dev_attr_name);
+ if (result)
+ goto unregister;
+
+ result = device_create_file(tz->hwmon, &dev_attr_temp1_input);
+ if (result)
+ goto unregister;
+
+ result = device_create_file(tz->hwmon, &dev_attr_temp1_crit);
+ if (result)
+ goto unregister;
+
+ /* sys I/F */
+ result = device_create_file(&tz->device, &dev_attr_type);
+ if (result)
+ goto unregister;
+
result = device_create_file(&tz->device, &dev_attr_temp); if (result)
goto unregister;
@@ -676,8 +741,13 @@
tz->ops->unbind(tz, cdev);
mutex_unlock(&thermal_list_lock);

- if (tz->type[0])
- device_remove_file(&tz->device, &dev_attr_type);
+ device_remove_file(&tz->device, &dev_attr_name);
+ device_remove_file(&tz->device, &dev_attr_temp1_input);
+ device_remove_file(&tz->device, &dev_attr_temp1_crit);
+ hwmon_device_unregister(tz->hwmon);
+ tz->hwmon = NULL;
+
+ device_remove_file(&tz->device, &dev_attr_type);
device_remove_file(&tz->device, &dev_attr_temp); if (tz->ops->get_mode)
device_remove_file(&tz->device, &dev_attr_mode);
Index: linux-2.6.25-rc2/include/linux/thermal.h
=================================--- linux-2.6.25-rc2.orig/include/linux/thermal.h 2008-02-25 22:43:29.000000000 -0500
+++ linux-2.6.25-rc2/include/linux/thermal.h 2008-02-25 22:43:38.000000000 -0500
@@ -69,6 +69,7 @@
int id;
char type[THERMAL_NAME_LENGTH];
struct device device;
+ struct device *hwmon;
void *devdata;
int trips;
struct thermal_zone_device_ops *ops;

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#1 lore raw
Quoted 2 lines · Rui

Add hwmon sys I/F for the generic thermal device.

Great!

But I have several remarks:
1) Looking at the new code, you only add temp1_input, so I'm guessing that you are registering a seperate hwmon class entry per zone? Please don't do that, please register one hwmon class entry, and add multiple temp#_input attr to it (and the same for crit).

2) I see that temp_crit may not be always available:

Quoted 12 lines
(quoted diff) +12 -0
+static ssize_t
+crit_trip_temp_show(struct device *dev, struct device_attribute *attr,
+			char *buf)
+{
+	struct device *device = dev->parent;
+	struct thermal_zone_device *tz = to_thermal_zone(device);
+	int result;
+
+	if (!tz->ops->get_trip_temp )
+		return -EPERM;
+
+	/* assume trip 0 to be the critical trip point by default */

Review

Quoted 10 lines
(quoted diff) +10 -0
+	if (tz->ops->get_trip_type) {
+		result = tz->ops->get_trip_type(tz, 0, buf);
+		if (result < 0)
+			return result;
+		if (strcmp(buf, "critical\n"))
+			return -ENODEV;
+	}
+
+	return tz->ops->get_trip_temp(tz, 0, buf);
+}

But you do always register a temp#_crit sysfs attr, it would be much much better to only add this if reading it actually has a chance of returning a value, so if tz->ops->get_trip_temp != NULL and tz->ops->get_trip_type(tz, 0, buf) returns "critical" in buf.

Thanks & Regards,

Hans

Quoted 206 lines
---
 Documentation/thermal/sysfs-api.txt |   22 +++++----
 drivers/thermal/Kconfig             |    1 
 drivers/thermal/thermal.c           |   86 ++++++++++++++++++++++++++++++++----
 include/linux/thermal.h             |    1 
 4 files changed, 92 insertions(+), 18 deletions(-)

Index: linux-2.6.25-rc2/Documentation/thermal/sysfs-api.txt
=================================> --- linux-2.6.25-rc2.orig/Documentation/thermal/sysfs-api.txt 2008-02-25 22:43:29.000000000 -0500
+++ linux-2.6.25-rc2/Documentation/thermal/sysfs-api.txt 2008-02-25 22:43:38.000000000 -0500

(quoted diff) +12 -10
@@ -141,12 +141,14 @@
 
 type				Strings which represent the thermal zone type.
 				This is given by thermal zone driver as part of registration.
+				In order to keep the compatibility with hwmon,
+				it should not contain any spaces or dashes.
 				Eg: "ACPI thermal zone" indicates it's a ACPI thermal device
 				RO
-				Optional
+				Required
 
 temp				Current temperature as reported by thermal zone (sensor)
-				Unit: degree Celsius
+				Unit: millidegree Celsius
 				RO
 				Required
 
@@ -163,7 +165,7 @@
 					  charge of the thermal management.
 
 trip_point_[0-*]_temp		The temperature above which trip point will be fired
-				Unit: degree Celsius
+				Unit: millidegree Celsius
 				RO
 				Optional
 
@@ -219,16 +221,16 @@
 
 |thermal_zone1:
 	|-----type:			ACPI thermal zone
-	|-----temp:			37
+	|-----temp:			37000
 	|-----mode:			kernel
-	|-----trip_point_0_temp:	100
+	|-----trip_point_0_temp:	100000
 	|-----trip_point_0_type:	critical
-	|-----trip_point_1_temp:	80
+	|-----trip_point_1_temp:	80000
 	|-----trip_point_1_type:	passive
-	|-----trip_point_2_temp:	70
-	|-----trip_point_2_type:	active[0]
-	|-----trip_point_3_temp:	60
-	|-----trip_point_3_type:	active[1]
+	|-----trip_point_2_temp:	70000
+	|-----trip_point_2_type:	active0
+	|-----trip_point_3_temp:	60000
+	|-----trip_point_3_type:	active1
 	|-----cdev0:			--->/sys/class/thermal/cooling_device0
 	|-----cdev0_trip_point:		1	/* cdev0 can be used for passive */
 	|-----cdev1:			--->/sys/class/thermal/cooling_device3

Index: linux-2.6.25-rc2/drivers/thermal/Kconfig
=================================> --- linux-2.6.25-rc2.orig/drivers/thermal/Kconfig 2008-02-25 22:43:29.000000000 -0500
+++ linux-2.6.25-rc2/drivers/thermal/Kconfig 2008-02-25 22:43:38.000000000 -0500

(quoted diff) +1 -0
@@ -4,6 +4,7 @@
 
 menuconfig THERMAL
 	bool "Generic Thermal sysfs driver"
+	select HWMON
 	default y
 	help
 	  Generic Thermal Sysfs driver offers a generic mechanism for

Index: linux-2.6.25-rc2/drivers/thermal/thermal.c
=================================> --- linux-2.6.25-rc2.orig/drivers/thermal/thermal.c 2008-02-25 22:43:29.000000000 -0500
+++ linux-2.6.25-rc2/drivers/thermal/thermal.c 2008-02-26 00:37:57.000000000 -0500

(quoted diff) +78 -8
@@ -30,8 +30,9 @@
 #include <linux/idr.h>
 #include <linux/thermal.h>
 #include <linux/spinlock.h>
+#include <linux/hwmon.h>
 
-MODULE_AUTHOR("Zhang Rui")
+MODULE_AUTHOR("Zhang Rui");
 MODULE_DESCRIPTION("Generic thermal management sysfs support");
 MODULE_LICENSE("GPL");
 
@@ -171,6 +172,47 @@
 	return tz->ops->get_trip_temp(tz, trip, buf);
 }
 
+static ssize_t
+hwmon_type_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct device *device = dev->parent;
+	return type_show(device, attr, buf);
+}
+
+static ssize_t
+hwmon_temp_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct device *device = dev->parent;
+	return temp_show(device, attr, buf);
+}
+
+static ssize_t
+crit_trip_temp_show(struct device *dev, struct device_attribute *attr,
+			char *buf)
+{
+	struct device *device = dev->parent;
+	struct thermal_zone_device *tz = to_thermal_zone(device);
+	int result;
+
+	if (!tz->ops->get_trip_temp )
+		return -EPERM;
+
+	/* assume trip 0 to be the critical trip point by default */
+	if (tz->ops->get_trip_type) {
+		result = tz->ops->get_trip_type(tz, 0, buf);
+		if (result < 0)
+			return result;
+		if (strcmp(buf, "critical\n"))
+			return -ENODEV;
+	}
+
+	return tz->ops->get_trip_temp(tz, 0, buf);
+}
+
+static DEVICE_ATTR(name, 0444, hwmon_type_show, NULL);
+static DEVICE_ATTR(temp1_input, 0444, hwmon_temp_show, NULL);
+static DEVICE_ATTR(temp1_crit, 0444, crit_trip_temp_show, NULL);
+
 static DEVICE_ATTR(type, 0444, type_show, NULL);
 static DEVICE_ATTR(temp, 0444, temp_show, NULL);
 static DEVICE_ATTR(mode, 0644, mode_show, mode_store);
@@ -569,6 +611,9 @@
 	int result;
 	int count;
 
+	if (!type)
+		return ERR_PTR(-EINVAL);
+
 	if (strlen(type) >= THERMAL_NAME_LENGTH)
 		return NULL;
 
@@ -604,13 +649,33 @@
 		return NULL;
 	}
 
-	/* sys I/F */
-	if (type) {
-		result = device_create_file(&tz->device, &dev_attr_type);
-		if (result)
-			goto unregister;
+	/* hwmon sys I/F */
+	tz->hwmon = hwmon_device_register(&tz->device);
+	if (IS_ERR(tz->hwmon)) {
+		result = PTR_ERR(tz->hwmon);
+		tz->hwmon = NULL;
+		printk(KERN_ERR PREFIX
+			"unable to register hwmon device\n");
+		goto unregister;
 	}
 
+	result = device_create_file(tz->hwmon, &dev_attr_name);
+	if (result)
+		goto unregister;
+
+	result = device_create_file(tz->hwmon, &dev_attr_temp1_input);
+	if (result)
+		goto unregister;
+
+	result = device_create_file(tz->hwmon, &dev_attr_temp1_crit);
+	if (result)
+		goto unregister;
+
+	/* sys I/F */
+	result = device_create_file(&tz->device, &dev_attr_type);
+	if (result)
+		goto unregister;
+
 	result = device_create_file(&tz->device, &dev_attr_temp);
 	if (result)
 		goto unregister;
@@ -676,8 +741,13 @@
 		    tz->ops->unbind(tz, cdev);
 	mutex_unlock(&thermal_list_lock);
 
-	if (tz->type[0])
-		device_remove_file(&tz->device, &dev_attr_type);
+	device_remove_file(&tz->device, &dev_attr_name);
+	device_remove_file(&tz->device, &dev_attr_temp1_input);
+	device_remove_file(&tz->device, &dev_attr_temp1_crit);
+	hwmon_device_unregister(tz->hwmon);
+	tz->hwmon = NULL;
+
+	device_remove_file(&tz->device, &dev_attr_type);
 	device_remove_file(&tz->device, &dev_attr_temp);
 	if (tz->ops->get_mode)
 		device_remove_file(&tz->device, &dev_attr_mode);

Index: linux-2.6.25-rc2/include/linux/thermal.h
=================================> --- linux-2.6.25-rc2.orig/include/linux/thermal.h 2008-02-25 22:43:29.000000000 -0500
+++ linux-2.6.25-rc2/include/linux/thermal.h 2008-02-25 22:43:38.000000000 -0500

Review line 75

Quoted 7 lines
(quoted diff) +1 -0
@@ -69,6 +69,7 @@
 	int id;
 	char type[THERMAL_NAME_LENGTH];
 	struct device device;
+	struct device *hwmon;
 	void *devdata;
 	int trips;
 	struct thermal_zone_device_ops *ops;

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

author
#2 lore raw
Quoted 40 lines · Hans de Goede
Quoted 2 lines · Rui

Add hwmon sys I/F for the generic thermal device.

Great!

But I have several remarks:
1) Looking at the new code, you only add temp1_input, so I'm guessing that you
are registering a seperate hwmon class entry per zone? Please don't do that,
please register one hwmon class entry, and add multiple temp#_input attr to it
(and the same for crit).

2) I see that temp_crit may not be always available:

Review

Quoted 2 lines
(quoted diff) +2 -0
+static ssize_t
+crit_trip_temp_show(struct device *dev, struct device_attribute

*attr,

Quoted 10 lines
(quoted diff) +10 -0
+                    char *buf)
+{
+    struct device *device = dev->parent;
+    struct thermal_zone_device *tz = to_thermal_zone(device);
+    int result;
+
+    if (!tz->ops->get_trip_temp )
+            return -EPERM;
+
+    /* assume trip 0 to be the critical trip point by default */

Review

Quoted 10 lines
(quoted diff) +10 -0
+    if (tz->ops->get_trip_type) {
+            result = tz->ops->get_trip_type(tz, 0, buf);
+            if (result < 0)
+                    return result;
+            if (strcmp(buf, "critical\n"))
+                    return -ENODEV;
+    }
+
+    return tz->ops->get_trip_temp(tz, 0, buf);
+}
Quoted 7 lines

But you do always register a temp#_crit sysfs attr, it would be much much
better to only add this if reading it actually has a chance of returning a
value, so if tz->ops->get_trip_temp != NULL and tz->ops->get_trip_type(tz, 0,
buf) returns "critical" in buf.

then how about this one? :)

Add hwmon sys I/F for the generic thermal device.

Cc Hans de Geode <[email protected]>
---
 Documentation/thermal/sysfs-api.txt |   22 ++--
 drivers/thermal/Kconfig             |    1 
 drivers/thermal/thermal.c           |  161 ++++++++++++++++++++++++++++++------
 3 files changed, 147 insertions(+), 37 deletions(-)

Index: linux-2.6/Documentation/thermal/sysfs-api.txt =================================--- linux-2.6.orig/Documentation/thermal/sysfs-api.txt +++ linux-2.6/Documentation/thermal/sysfs-api.txt
@@ -143,10 +143,10 @@ type Strings which represent the ther
This is given by thermal zone driver as part of registration.
Eg: "ACPI thermal zone" indicates it's a ACPI thermal device RO
- Optional
+ Required

temp Current temperature as reported by thermal zone (sensor)
- Unit: degree Celsius
+ Unit: millidegree Celsius
RO
Required

@@ -163,7 +163,7 @@ mode One of the predefined values in
charge of the thermal management.

trip_point_[0-*]_temp The temperature above which trip point will be fired
- Unit: degree Celsius
+ Unit: millidegree Celsius
RO
Optional

@@ -193,7 +193,7 @@ type String which represents the type
eg. For memory controller device on intel_menlow platform:
this should be "Memory controller"
RO
- Optional
+ Required

max_state The maximum permissible cooling state of this cooling device.
RO
@@ -219,16 +219,16 @@ the sys I/F structure will be built like

|thermal_zone1:

 	|-----type:			ACPI thermal zone
-	|-----temp:			37
+	|-----temp:			37000
 	|-----mode:			kernel
-	|-----trip_point_0_temp:	100
+	|-----trip_point_0_temp:	100000
 	|-----trip_point_0_type:	critical
-	|-----trip_point_1_temp:	80
+	|-----trip_point_1_temp:	80000
 	|-----trip_point_1_type:	passive
-	|-----trip_point_2_temp:	70
-	|-----trip_point_2_type:	active[0]
-	|-----trip_point_3_temp:	60
-	|-----trip_point_3_type:	active[1]
+	|-----trip_point_2_temp:	70000
+	|-----trip_point_2_type:	active0
+	|-----trip_point_3_temp:	60000
+	|-----trip_point_3_type:	active1
 	|-----cdev0:			--->/sys/class/thermal/cooling_device0
 	|-----cdev0_trip_point:		1	/* cdev0 can be used for passive */
 	|-----cdev1:			--->/sys/class/thermal/cooling_device3

Index: linux-2.6/drivers/thermal/Kconfig =================================--- linux-2.6.orig/drivers/thermal/Kconfig +++ linux-2.6/drivers/thermal/Kconfig
@@ -4,6 +4,7 @@

menuconfig THERMAL
bool "Generic Thermal sysfs driver"
+ select HWMON
default y
help
Generic Thermal Sysfs driver offers a generic mechanism for
Index: linux-2.6/drivers/thermal/thermal.c =================================--- linux-2.6.orig/drivers/thermal/thermal.c +++ linux-2.6/drivers/thermal/thermal.c
@@ -30,8 +30,10 @@
#include <linux/idr.h>
#include <linux/thermal.h>
#include <linux/spinlock.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>

-MODULE_AUTHOR("Zhang Rui")
+MODULE_AUTHOR("Zhang Rui");
MODULE_DESCRIPTION("Generic thermal management sysfs support"); MODULE_LICENSE("GPL");

@@ -56,6 +58,8 @@ static LIST_HEAD(thermal_tz_list);
static LIST_HEAD(thermal_cdev_list);
static DEFINE_MUTEX(thermal_list_lock);

+static struct device *thermal_hwmon;
+
static int get_idr(struct idr *idr, struct mutex *lock, int *id) {
int err;
@@ -87,7 +91,67 @@ static void release_idr(struct idr *idr,
mutex_unlock(lock);
}

-/* sys I/F for thermal zone */
+/* hwmon sys I/F*/
+static ssize_t
+name_show(struct device *dev, struct device_attribute *attr, char *buf) +{
+ return sprintf(buf, "thermal_sys_class\n");
+}
+
+static ssize_t
+temp_input_show(struct device *dev, struct device_attribute *attr, char *buf) +{
+ struct thermal_zone_device *tz;
+ struct sensor_device_attribute *sensor_attr
+ = to_sensor_dev_attr(attr);
+
+ list_for_each_entry(tz, &thermal_tz_list, node)
+ if (tz->id = sensor_attr->index)
+ return tz->ops->get_temp(tz, buf);
+
+ return -ENODEV;
+}
+
+static ssize_t
+temp_crit_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct thermal_zone_device *tz;
+ struct sensor_device_attribute *sensor_attr
+ = to_sensor_dev_attr(attr);
+
+ list_for_each_entry(tz, &thermal_tz_list, node)
+ if (tz->id = sensor_attr->index)
+ return tz->ops->get_trip_temp(tz, 0, buf);
+
+ return -ENODEV;
+}
+
+static DEVICE_ATTR(name, 0444, name_show, NULL);
+static struct sensor_device_attribute sensor_attrs[] = {
+ SENSOR_ATTR(temp1_input, 0444, temp_input_show, NULL, 0),
+ SENSOR_ATTR(temp1_crit, 0444, temp_crit_show, NULL, 0),
+ SENSOR_ATTR(temp2_input, 0444, temp_input_show, NULL, 1),
+ SENSOR_ATTR(temp2_crit, 0444, temp_crit_show, NULL, 1),
+ SENSOR_ATTR(temp3_input, 0444, temp_input_show, NULL, 2),
+ SENSOR_ATTR(temp3_crit, 0444, temp_crit_show, NULL, 2),
+ SENSOR_ATTR(temp4_input, 0444, temp_input_show, NULL, 3),
+ SENSOR_ATTR(temp4_crit, 0444, temp_crit_show, NULL, 3),
+ SENSOR_ATTR(temp5_input, 0444, temp_input_show, NULL, 4),
+ SENSOR_ATTR(temp5_crit, 0444, temp_crit_show, NULL, 4),
+ SENSOR_ATTR(temp6_input, 0444, temp_input_show, NULL, 5),
+ SENSOR_ATTR(temp6_crit, 0444, temp_crit_show, NULL, 5),
+ SENSOR_ATTR(temp7_input, 0444, temp_input_show, NULL, 6),
+ SENSOR_ATTR(temp7_crit, 0444, temp_crit_show, NULL, 6),
+ SENSOR_ATTR(temp8_input, 0444, temp_input_show, NULL, 7),
+ SENSOR_ATTR(temp8_crit, 0444, temp_crit_show, NULL, 7),
+ SENSOR_ATTR(temp9_input, 0444, temp_input_show, NULL, 8),
+ SENSOR_ATTR(temp9_crit, 0444, temp_crit_show, NULL, 8),
+ SENSOR_ATTR(temp10_input, 0444, temp_input_show, NULL, 9),
+ SENSOR_ATTR(temp10_crit, 0444, temp_crit_show, NULL, 9),
+};
+
+/* thermal zone sys I/F */

#define to_thermal_zone(_dev) \
container_of(_dev, struct thermal_zone_device, device)
@@ -214,7 +278,7 @@ do { \
device_remove_file(_dev, &trip_point_attrs[_index * 2 + 1]); \
} while (0)

-/* sys I/F for cooling device */
+/* cooling device sys I/F */
#define to_cooling_device(_dev) \
container_of(_dev, struct thermal_cooling_device, device)

@@ -447,6 +511,9 @@ struct thermal_cooling_device *thermal_c
struct thermal_zone_device *pos;
int result;

+ if (!type)
+ return ERR_PTR(-EINVAL);
+
if (strlen(type) >= THERMAL_NAME_LENGTH)
return ERR_PTR(-EINVAL);

@@ -477,11 +544,9 @@ struct thermal_cooling_device *thermal_c
}

/* sys I/F */
- if (type) {
- result = device_create_file(&cdev->device, &dev_attr_cdev_type);
- if (result)
- goto unregister;
- }
+ result = device_create_file(&cdev->device, &dev_attr_cdev_type);
+ if (result)
+ goto unregister;

result = device_create_file(&cdev->device, &dev_attr_max_state); if (result)
@@ -547,8 +612,8 @@ void thermal_cooling_device_unregister(s
tz->ops->unbind(tz, cdev);
}
mutex_unlock(&thermal_list_lock);
- if (cdev->type[0])
- device_remove_file(&cdev->device, &dev_attr_cdev_type);
+
+ device_remove_file(&cdev->device, &dev_attr_cdev_type);
device_remove_file(&cdev->device, &dev_attr_max_state); device_remove_file(&cdev->device, &dev_attr_cur_state);

@@ -580,6 +645,9 @@ struct thermal_zone_device *thermal_zone
int result;
int count;

+ if (!type)
+ return ERR_PTR(-EINVAL);
+
if (strlen(type) >= THERMAL_NAME_LENGTH)
return ERR_PTR(-EINVAL);

@@ -615,13 +683,28 @@ struct thermal_zone_device *thermal_zone
return ERR_PTR(result);
}

- /* sys I/F */
- if (type) {
- result = device_create_file(&tz->device, &dev_attr_type);
- if (result)
- goto unregister;
+ /* hwmon sys I/F */
+ result = device_create_file(thermal_hwmon,
+ &sensor_attrs[tz->id * 2].dev_attr);
+ if (result)
+ goto unregister;
+
+ if (trips > 0) {
+ char buf[40];
+ result = tz->ops->get_trip_type(tz, 0, buf);
+ if (result > 0 && !strcmp(buf, "critical\n")) {
+ result = device_create_file(thermal_hwmon,
+ &sensor_attrs[tz->id * 2 + 1].dev_attr);
+ if (result)
+ goto unregister;
+ }
}

+ /* sys I/F */
+ result = device_create_file(&tz->device, &dev_attr_type);
+ if (result)
+ goto unregister;
+
result = device_create_file(&tz->device, &dev_attr_temp); if (result)
goto unregister;
@@ -687,8 +770,17 @@ void thermal_zone_device_unregister(stru
tz->ops->unbind(tz, cdev);
mutex_unlock(&thermal_list_lock);

- if (tz->type[0])
- device_remove_file(&tz->device, &dev_attr_type);
+ device_remove_file(thermal_hwmon,
+ &sensor_attrs[tz->id * 2].dev_attr);
+ if (tz->trips > 0) {
+ char buf[40];
+ if (tz->ops->get_trip_type(tz, 0, buf) > 0)
+ if (!strcmp(buf, "critical\n"))
+ device_remove_file(thermal_hwmon,
+ &sensor_attrs[tz->id * 2 + 1].dev_attr);
+ }
+
+ device_remove_file(&tz->device, &dev_attr_type);
device_remove_file(&tz->device, &dev_attr_temp); if (tz->ops->get_mode)
device_remove_file(&tz->device, &dev_attr_mode);
@@ -705,6 +797,19 @@ void thermal_zone_device_unregister(stru

EXPORT_SYMBOL(thermal_zone_device_unregister);

+static void __exit thermal_exit(void)
+{
+ if (thermal_hwmon) {
+ device_remove_file(thermal_hwmon, &dev_attr_name);
+ hwmon_device_unregister(thermal_hwmon);
+ }
+ class_unregister(&thermal_class);
+ idr_destroy(&thermal_tz_idr);
+ idr_destroy(&thermal_cdev_idr);
+ mutex_destroy(&thermal_idr_lock);
+ mutex_destroy(&thermal_list_lock);
+}
+
static int __init thermal_init(void)
{
int result = 0;
@@ -716,16 +821,20 @@ static int __init thermal_init(void)
mutex_destroy(&thermal_idr_lock); mutex_destroy(&thermal_list_lock);
}
- return result;
-}

-static void __exit thermal_exit(void)
-{
- class_unregister(&thermal_class);
- idr_destroy(&thermal_tz_idr);
- idr_destroy(&thermal_cdev_idr);
- mutex_destroy(&thermal_idr_lock);
- mutex_destroy(&thermal_list_lock);
+ thermal_hwmon = hwmon_device_register(NULL);
+ if (IS_ERR(thermal_hwmon)) {
+ result = PTR_ERR(thermal_hwmon);
+ thermal_hwmon = NULL;
+ printk(KERN_ERR PREFIX
+ "unable to register hwmon device\n");
+ thermal_exit();
+ return result;
+ }
+
+ result = device_create_file(thermal_hwmon, &dev_attr_name);
+
+ return result;
}

subsys_initcall(thermal_init);

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#3 lore raw
Quoted 40 lines · Rui
Quoted 39 lines · Hans de Goede
Quoted 2 lines · Rui

Add hwmon sys I/F for the generic thermal device.

Great!

But I have several remarks:
1) Looking at the new code, you only add temp1_input, so I'm guessing that you
are registering a seperate hwmon class entry per zone? Please don't do that,
please register one hwmon class entry, and add multiple temp#_input attr to it
(and the same for crit).

2) I see that temp_crit may not be always available:

Review

Quoted 2 lines
(quoted diff) +2 -0
+static ssize_t
+crit_trip_temp_show(struct device *dev, struct device_attribute

*attr,

Quoted 20 lines
(quoted diff) +20 -0
+                    char *buf)
+{
+    struct device *device = dev->parent;
+    struct thermal_zone_device *tz = to_thermal_zone(device);
+    int result;
+
+    if (!tz->ops->get_trip_temp )
+            return -EPERM;
+
+    /* assume trip 0 to be the critical trip point by default */
+    if (tz->ops->get_trip_type) {
+            result = tz->ops->get_trip_type(tz, 0, buf);
+            if (result < 0)
+                    return result;
+            if (strcmp(buf, "critical\n"))
+                    return -ENODEV;
+    }
+
+    return tz->ops->get_trip_temp(tz, 0, buf);
+}
Quoted 9 lines
Quoted 7 lines

But you do always register a temp#_crit sysfs attr, it would be much much
better to only add this if reading it actually has a chance of returning a
value, so if tz->ops->get_trip_temp != NULL and tz->ops->get_trip_type(tz, 0,
buf) returns "critical" in buf.

then how about this one? :)

From a hwmon interface perspective its much better, thanks! As for doing a
full review, I'm afraid I'm not familiar enough with the code for that.

Regards,

Hans

Quoted 324 lines

Add hwmon sys I/F for the generic thermal device.

Cc Hans de Geode <[email protected]>
---
 Documentation/thermal/sysfs-api.txt |   22 ++--
 drivers/thermal/Kconfig             |    1 
 drivers/thermal/thermal.c           |  161 ++++++++++++++++++++++++++++++------
 3 files changed, 147 insertions(+), 37 deletions(-)

Index: linux-2.6/Documentation/thermal/sysfs-api.txt =================================> --- linux-2.6.orig/Documentation/thermal/sysfs-api.txt +++ linux-2.6/Documentation/thermal/sysfs-api.txt

(quoted diff) +11 -11
@@ -143,10 +143,10 @@ type				Strings which represent the ther
 				This is given by thermal zone driver as part of registration.
 				Eg: "ACPI thermal zone" indicates it's a ACPI thermal device
 				RO
-				Optional
+				Required
 
 temp				Current temperature as reported by thermal zone (sensor)
-				Unit: degree Celsius
+				Unit: millidegree Celsius
 				RO
 				Required
 
@@ -163,7 +163,7 @@ mode				One of the predefined values in 
 					  charge of the thermal management.
 
 trip_point_[0-*]_temp		The temperature above which trip point will be fired
-				Unit: degree Celsius
+				Unit: millidegree Celsius
 				RO
 				Optional
 
@@ -193,7 +193,7 @@ type				String which represents the type
 				eg. For memory controller device on intel_menlow platform:
 				this should be "Memory controller"
 				RO
-				Optional
+				Required
 
 max_state			The maximum permissible cooling state of this cooling device.
 				RO
@@ -219,16 +219,16 @@ the sys I/F structure will be built like
 
 |thermal_zone1:
 	|-----type:			ACPI thermal zone
-	|-----temp:			37
+	|-----temp:			37000
 	|-----mode:			kernel
-	|-----trip_point_0_temp:	100
+	|-----trip_point_0_temp:	100000
 	|-----trip_point_0_type:	critical
-	|-----trip_point_1_temp:	80
+	|-----trip_point_1_temp:	80000
 	|-----trip_point_1_type:	passive
-	|-----trip_point_2_temp:	70
-	|-----trip_point_2_type:	active[0]
-	|-----trip_point_3_temp:	60
-	|-----trip_point_3_type:	active[1]
+	|-----trip_point_2_temp:	70000
+	|-----trip_point_2_type:	active0
+	|-----trip_point_3_temp:	60000
+	|-----trip_point_3_type:	active1
 	|-----cdev0:			--->/sys/class/thermal/cooling_device0
 	|-----cdev0_trip_point:		1	/* cdev0 can be used for passive */
 	|-----cdev1:			--->/sys/class/thermal/cooling_device3

Index: linux-2.6/drivers/thermal/Kconfig =================================> --- linux-2.6.orig/drivers/thermal/Kconfig +++ linux-2.6/drivers/thermal/Kconfig

(quoted diff) +1 -0
@@ -4,6 +4,7 @@
 
 menuconfig THERMAL
 	bool "Generic Thermal sysfs driver"
+	select HWMON
 	default y
 	help
 	  Generic Thermal Sysfs driver offers a generic mechanism for

Index: linux-2.6/drivers/thermal/thermal.c =================================> --- linux-2.6.orig/drivers/thermal/thermal.c +++ linux-2.6/drivers/thermal/thermal.c

(quoted diff) +128 -26
@@ -30,8 +30,10 @@
 #include <linux/idr.h>
 #include <linux/thermal.h>
 #include <linux/spinlock.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
 
-MODULE_AUTHOR("Zhang Rui")
+MODULE_AUTHOR("Zhang Rui");
 MODULE_DESCRIPTION("Generic thermal management sysfs support");
 MODULE_LICENSE("GPL");
 
@@ -56,6 +58,8 @@ static LIST_HEAD(thermal_tz_list);
 static LIST_HEAD(thermal_cdev_list);
 static DEFINE_MUTEX(thermal_list_lock);
 
+static struct device *thermal_hwmon;
+
 static int get_idr(struct idr *idr, struct mutex *lock, int *id)
 {
 	int err;
@@ -87,7 +91,67 @@ static void release_idr(struct idr *idr,
 		mutex_unlock(lock);
 }
 
-/* sys I/F for thermal zone */
+/* hwmon sys I/F*/
+static ssize_t
+name_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "thermal_sys_class\n");
+}
+
+static ssize_t
+temp_input_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct thermal_zone_device *tz;
+	struct sensor_device_attribute *sensor_attr
+						= to_sensor_dev_attr(attr);
+
+	list_for_each_entry(tz, &thermal_tz_list, node)
+		if (tz->id = sensor_attr->index)
+			return tz->ops->get_temp(tz, buf);
+
+	return -ENODEV;
+}
+
+static ssize_t
+temp_crit_show(struct device *dev, struct device_attribute *attr,
+		char *buf)
+{
+	struct thermal_zone_device *tz;
+	struct sensor_device_attribute *sensor_attr
+						= to_sensor_dev_attr(attr);
+
+	list_for_each_entry(tz, &thermal_tz_list, node)
+		if (tz->id = sensor_attr->index)
+			return tz->ops->get_trip_temp(tz, 0, buf);
+
+	return -ENODEV;
+}
+
+static DEVICE_ATTR(name, 0444, name_show, NULL);
+static struct sensor_device_attribute sensor_attrs[] = {
+	SENSOR_ATTR(temp1_input, 0444, temp_input_show, NULL, 0),
+	SENSOR_ATTR(temp1_crit, 0444, temp_crit_show, NULL, 0),
+	SENSOR_ATTR(temp2_input, 0444, temp_input_show, NULL, 1),
+	SENSOR_ATTR(temp2_crit, 0444, temp_crit_show, NULL, 1),
+	SENSOR_ATTR(temp3_input, 0444, temp_input_show, NULL, 2),
+	SENSOR_ATTR(temp3_crit, 0444, temp_crit_show, NULL, 2),
+	SENSOR_ATTR(temp4_input, 0444, temp_input_show, NULL, 3),
+	SENSOR_ATTR(temp4_crit, 0444, temp_crit_show, NULL, 3),
+	SENSOR_ATTR(temp5_input, 0444, temp_input_show, NULL, 4),
+	SENSOR_ATTR(temp5_crit, 0444, temp_crit_show, NULL, 4),
+	SENSOR_ATTR(temp6_input, 0444, temp_input_show, NULL, 5),
+	SENSOR_ATTR(temp6_crit, 0444, temp_crit_show, NULL, 5),
+	SENSOR_ATTR(temp7_input, 0444, temp_input_show, NULL, 6),
+	SENSOR_ATTR(temp7_crit, 0444, temp_crit_show, NULL, 6),
+	SENSOR_ATTR(temp8_input, 0444, temp_input_show, NULL, 7),
+	SENSOR_ATTR(temp8_crit, 0444, temp_crit_show, NULL, 7),
+	SENSOR_ATTR(temp9_input, 0444, temp_input_show, NULL, 8),
+	SENSOR_ATTR(temp9_crit, 0444, temp_crit_show, NULL, 8),
+	SENSOR_ATTR(temp10_input, 0444, temp_input_show, NULL, 9),
+	SENSOR_ATTR(temp10_crit, 0444, temp_crit_show, NULL, 9),
+};
+
+/* thermal zone sys I/F */
 
 #define to_thermal_zone(_dev) \
 	container_of(_dev, struct thermal_zone_device, device)
@@ -214,7 +278,7 @@ do {	\
 	device_remove_file(_dev, &trip_point_attrs[_index * 2 + 1]);	\
 } while (0)
 
-/* sys I/F for cooling device */
+/* cooling device sys I/F */
 #define to_cooling_device(_dev)	\
 	container_of(_dev, struct thermal_cooling_device, device)
 
@@ -447,6 +511,9 @@ struct thermal_cooling_device *thermal_c
 	struct thermal_zone_device *pos;
 	int result;
 
+	if (!type)
+		return ERR_PTR(-EINVAL);
+
 	if (strlen(type) >= THERMAL_NAME_LENGTH)
 		return ERR_PTR(-EINVAL);
 
@@ -477,11 +544,9 @@ struct thermal_cooling_device *thermal_c
 	}
 
 	/* sys I/F */
-	if (type) {
-		result = device_create_file(&cdev->device, &dev_attr_cdev_type);
-		if (result)
-			goto unregister;
-	}
+	result = device_create_file(&cdev->device, &dev_attr_cdev_type);
+	if (result)
+		goto unregister;
 
 	result = device_create_file(&cdev->device, &dev_attr_max_state);
 	if (result)
@@ -547,8 +612,8 @@ void thermal_cooling_device_unregister(s
 		tz->ops->unbind(tz, cdev);
 	}
 	mutex_unlock(&thermal_list_lock);
-	if (cdev->type[0])
-		device_remove_file(&cdev->device, &dev_attr_cdev_type);
+
+	device_remove_file(&cdev->device, &dev_attr_cdev_type);
 	device_remove_file(&cdev->device, &dev_attr_max_state);
 	device_remove_file(&cdev->device, &dev_attr_cur_state);
 
@@ -580,6 +645,9 @@ struct thermal_zone_device *thermal_zone
 	int result;
 	int count;
 
+	if (!type)
+		return ERR_PTR(-EINVAL);
+
 	if (strlen(type) >= THERMAL_NAME_LENGTH)
 		return ERR_PTR(-EINVAL);
 
@@ -615,13 +683,28 @@ struct thermal_zone_device *thermal_zone
 		return ERR_PTR(result);
 	}
 
-	/* sys I/F */
-	if (type) {
-		result = device_create_file(&tz->device, &dev_attr_type);
-		if (result)
-			goto unregister;
+	/* hwmon sys I/F */
+	result = device_create_file(thermal_hwmon,
+					&sensor_attrs[tz->id * 2].dev_attr);
+	if (result)
+		goto unregister;
+
+	if (trips > 0) {
+		char buf[40];
+		result = tz->ops->get_trip_type(tz, 0, buf);
+		if (result > 0 && !strcmp(buf, "critical\n")) {
+			result = device_create_file(thermal_hwmon,
+					&sensor_attrs[tz->id * 2 + 1].dev_attr);
+			if (result)
+				goto unregister;
+		}
 	}
 
+	/* sys I/F */
+	result = device_create_file(&tz->device, &dev_attr_type);
+	if (result)
+		goto unregister;
+
 	result = device_create_file(&tz->device, &dev_attr_temp);
 	if (result)
 		goto unregister;
@@ -687,8 +770,17 @@ void thermal_zone_device_unregister(stru
 		    tz->ops->unbind(tz, cdev);
 	mutex_unlock(&thermal_list_lock);
 
-	if (tz->type[0])
-		device_remove_file(&tz->device, &dev_attr_type);
+	device_remove_file(thermal_hwmon,
+				&sensor_attrs[tz->id * 2].dev_attr);
+	if (tz->trips > 0) {
+		char buf[40];
+		if (tz->ops->get_trip_type(tz, 0, buf) > 0)
+			if (!strcmp(buf, "critical\n"))
+				device_remove_file(thermal_hwmon,
+				&sensor_attrs[tz->id * 2 + 1].dev_attr);
+	}
+
+	device_remove_file(&tz->device, &dev_attr_type);
 	device_remove_file(&tz->device, &dev_attr_temp);
 	if (tz->ops->get_mode)
 		device_remove_file(&tz->device, &dev_attr_mode);
@@ -705,6 +797,19 @@ void thermal_zone_device_unregister(stru
 
 EXPORT_SYMBOL(thermal_zone_device_unregister);
 
+static void __exit thermal_exit(void)
+{
+	if (thermal_hwmon) {
+		device_remove_file(thermal_hwmon, &dev_attr_name);
+		hwmon_device_unregister(thermal_hwmon);
+	}
+	class_unregister(&thermal_class);
+	idr_destroy(&thermal_tz_idr);
+	idr_destroy(&thermal_cdev_idr);
+	mutex_destroy(&thermal_idr_lock);
+	mutex_destroy(&thermal_list_lock);
+}
+
 static int __init thermal_init(void)
 {
 	int result = 0;
@@ -716,16 +821,20 @@ static int __init thermal_init(void)
 		mutex_destroy(&thermal_idr_lock);
 		mutex_destroy(&thermal_list_lock);
 	}
-	return result;
-}
 
-static void __exit thermal_exit(void)
-{
-	class_unregister(&thermal_class);
-	idr_destroy(&thermal_tz_idr);
-	idr_destroy(&thermal_cdev_idr);
-	mutex_destroy(&thermal_idr_lock);
-	mutex_destroy(&thermal_list_lock);
+	thermal_hwmon = hwmon_device_register(NULL);
+	if (IS_ERR(thermal_hwmon)) {
+		result = PTR_ERR(thermal_hwmon);
+		thermal_hwmon = NULL;
+		printk(KERN_ERR PREFIX
+			"unable to register hwmon device\n");

Review static int __init thermal_init(void) · line 840

Quoted 10 lines
(quoted diff) +7 -0
+		thermal_exit();
+		return result;
+	}
+
+	result = device_create_file(thermal_hwmon, &dev_attr_name);
+
+	return result;
 }
 
 subsys_initcall(thermal_init);

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#4 lore raw
In reply to Hans de Goede

Hi Hans,

Quoted 11 lines · Hans de Goede
Quoted 2 lines · Rui

Add hwmon sys I/F for the generic thermal device.

Great!

But I have several remarks:
1) Looking at the new code, you only add temp1_input, so I'm guessing that you are registering a seperate hwmon class entry per zone? Please don't do that, please register one hwmon class entry, and add multiple temp#_input attr to it (and the same for crit).

I am sorry that I did not notice when you suggested this. I disagree, but now Rui's code is upstream so I guess it's too late to complain. Still here are my reasons:

One of the great things about libsensors is that it gives unique names to hardware monitoring devices, and for each device, each feature has a unique name as well. This makes it possible to ignore or label a specific feature in /etc/sensors.conf in a way that is stable over reboot and addition of new hardware.

By going with a single virtual device for all thermal zones, you break this model. Depending on which thermal zone drivers are loaded and in which order they are loaded, there will be more or less temp* files in the hwmon directory and you also can't predict their order. The labelling issue could be solved by adding temp*_label files, but this still prevents the user from overriding a label. And there's no way to reliably ignore a specific thermal zone or to ask for information about a specific thermal zone with the current model.

For this reason, I think it would be much better to have one hwmon class device for each _type_ of thermal zone. For example, all ACPI thermal zones would be listed as one hwmon class device. If we later add support for another type of thermal zones, all thermal zones of this type would be listed as one (different) hwmon class device. This makes each specific thermal zone driver responsible for the stability of the numbering of the various thermal zones of a given type. This would also let us give names to the different thermal zone types (e.g. "acpitz" for ACPI thermal zones) so that the users and supporters have an idea who is providing these temperature values and limits.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#5 lore raw
Quoted 33 lines · Jean Delvare

Hi Hans,

Quoted 10 lines · Hans de Goede
Quoted 2 lines · Rui

Add hwmon sys I/F for the generic thermal device.

Great!

But I have several remarks:
1) Looking at the new code, you only add temp1_input, so I'm guessing that you are registering a seperate hwmon class entry per zone? Please don't do that, please register one hwmon class entry, and add multiple temp#_input attr to it (and the same for crit).

I am sorry that I did not notice when you suggested this. I disagree, but now Rui's code is upstream so I guess it's too late to complain. Still here are my reasons:

One of the great things about libsensors is that it gives unique names to hardware monitoring devices, and for each device, each feature has a unique name as well. This makes it possible to ignore or label a specific feature in /etc/sensors.conf in a way that is stable over reboot and addition of new hardware.

By going with a single virtual device for all thermal zones, you break this model. Depending on which thermal zone drivers are loaded and in which order they are loaded, there will be more or less temp* files in the hwmon directory and you also can't predict their order. The labelling issue could be solved by adding temp*_label files, but this still prevents the user from overriding a label. And there's no way to reliably ignore a specific thermal zone or to ask for information about a specific thermal zone with the current model.

Quoted 11 lines

For this reason, I think it would be much better to have one hwmon class device for each _type_ of thermal zone. For example, all ACPI thermal zones would be listed as one hwmon class device. If we later add support for another type of thermal zones, all thermal zones of this type would be listed as one (different) hwmon class device. This makes each specific thermal zone driver responsible for the stability of the numbering of the various thermal zones of a given type. This would also let us give names to the different thermal zone types (e.g. "acpitz" for ACPI thermal zones) so that the users and supporters have an idea who is providing these temperature values and limits.

I fully agree, I didn't know there was a generic thermal zone model, and that there could be multiple drivers implementing it (let alone multiple thermal zone drivers active for one system ??) I thought this was all ACPI only,

If this (multiple thermal zone drivers active for one system) can really happen then we really should fix it so that there is one hwmon class entry per thermal zone driver. This can be done without changing the ABI, as things would still follow the standard hwmon ABI.

Regards,

Hans

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#6 lore raw
Quoted 46 lines · Hans de Goede
Quoted 33 lines · Jean Delvare

Hi Hans,

Quoted 10 lines · Hans de Goede
Quoted 2 lines · Rui

Add hwmon sys I/F for the generic thermal device.

Great!

But I have several remarks:
1) Looking at the new code, you only add temp1_input, so I'm guessing that you are registering a seperate hwmon class entry per zone? Please don't do that, please register one hwmon class entry, and add multiple temp#_input attr to it (and the same for crit).

I am sorry that I did not notice when you suggested this. I disagree, but now Rui's code is upstream so I guess it's too late to complain. Still here are my reasons:

One of the great things about libsensors is that it gives unique names to hardware monitoring devices, and for each device, each feature has a unique name as well. This makes it possible to ignore or label a specific feature in /etc/sensors.conf in a way that is stable over reboot and addition of new hardware.

By going with a single virtual device for all thermal zones, you break this model. Depending on which thermal zone drivers are loaded and in which order they are loaded, there will be more or less temp* files in the hwmon directory and you also can't predict their order. The labelling issue could be solved by adding temp*_label files, but this still prevents the user from overriding a label. And there's no way to reliably ignore a specific thermal zone or to ask for information about a specific thermal zone with the current model.

Quoted 11 lines

For this reason, I think it would be much better to have one hwmon class device for each _type_ of thermal zone. For example, all ACPI thermal zones would be listed as one hwmon class device. If we later add support for another type of thermal zones, all thermal zones of this type would be listed as one (different) hwmon class device. This makes each specific thermal zone driver responsible for the stability of the numbering of the various thermal zones of a given type. This would also let us give names to the different thermal zone types (e.g. "acpitz" for ACPI thermal zones) so that the users and supporters have an idea who is providing these temperature values and limits.

Quoted 3 lines

I fully agree, I didn't know there was a generic thermal zone model, and that there could be multiple drivers implementing it (let alone multiple thermal zone drivers active for one system ??) I thought this was all ACPI only,

My understanding is that the new thermal zone code is meant to be generic and ACPI is only one possible underlying implementations, which sounds very good to me. ACPI just happens to be the only implementation at the time being.

Quoted 4 lines

If this (multiple thermal zone drivers active for one system) can really happen then we really should fix it so that there is one hwmon class entry per thermal zone driver. This can be done without changing the ABI, as things would still follow the standard hwmon ABI.

I have to admit that I'm not sure what sense that would make (and how safe it would be) to have more than one type of thermal zones active at the same time. If the idea if that only one type of thermal zones can exist for a given system (i.e. the selection happens at build time), then my objection can safely be ignored, except for the fact that I still would like the "name" attribute to reflect the type of the thermal zones.

Rui, Len, how did you originally envision the coexistence (or not) of different types of thermal zones?

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
author
#13 lore raw
In reply to Jean Delvare
Quoted 22 lines · Jean Delvare

Hi Hans,

Quoted 8 lines · Hans de Goede
Quoted 2 lines · Rui

Add hwmon sys I/F for the generic thermal device.

Great!

But I have several remarks:
1) Looking at the new code, you only add temp1_input, so I'm

guessing that you

Quoted 1 line

are registering a seperate hwmon class entry per zone? Please don't

do that,

Quoted 1 line

please register one hwmon class entry, and add multiple temp#_input

attr to it

Quoted 1 line

(and the same for crit).

I am sorry that I did not notice when you suggested this. I disagree, but now Rui's code is upstream so I guess it's too late to complain. Still here are my reasons:

Quoted 6 lines

One of the great things about libsensors is that it gives unique names to hardware monitoring devices, and for each device, each feature has a
unique name as well. This makes it possible to ignore or label a specific feature in /etc/sensors.conf in a way that is stable over reboot and addition of new hardware.

Interesting.

Quoted 4 lines

By going with a single virtual device for all thermal zones, you break this model. Depending on which thermal zone drivers are loaded and in which order they are loaded, there will be more or less temp* files in the hwmon directory and you also can't predict their order.

Yes, you're right.

Quoted 3 lines

The
labelling issue could be solved by adding temp*_label files, but this still prevents the user from overriding a label.

why user needs to override the label?

Quoted 6 lines

And there's no way to
reliably ignore a specific thermal zone or to ask for information about a specific thermal zone with the current model.

For this reason, I think it would be much better to have one hwmon class device for each _type_ of thermal zone.

Well. I disagree.
First, the generic thermal driver only checks the callbacks and builds the sys I/F for each thermal zone registered. So there is no difference between different thermal zones. Checking the type of different thermal zone and register a hwmon device for each _type of thermal zones doesn't make sense to me. :(
Second, take ACPI thermal zone for example, the number/order of the ACPI thermal zones can not be predicted either. All of this information is gotten during system boot time.

Quoted 9 lines

For example, all ACPI
thermal zones would be listed as one hwmon class device. If we later add support for another type of thermal zones, all thermal zones of this type would be listed as one (different) hwmon class device. This makes each specific thermal zone driver responsible for the stability of the numbering of the various thermal zones of a given type. This would also let us give names to the different thermal zone types (e.g. "acpitz" for ACPI thermal zones) so that the users and supporters have an idea who is providing these temperature values and limits.

If we really need to do this, I suggest we do this in the native driver. Say acpi thermal driver is responsible for registering a hwmon device for ACPI thermal zones, just like the other hwmon native sensor drivers. what do you think?

thanks,
rui

Quoted 10 lines

--
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

author
#12 lore raw
In reply to Hans de Goede
Quoted 62 lines · Hans de Goede
Quoted 10 lines · Jean Delvare

Hi Hans,

Quoted 7 lines · Hans de Goede
Quoted 2 lines · Rui

Add hwmon sys I/F for the generic thermal device.

Great!

But I have several remarks:
1) Looking at the new code, you only add temp1_input, so I'm

guessing that you

Quoted 1 line
Quoted 1 line

are registering a seperate hwmon class entry per zone? Please don't

do that,

Quoted 1 line
Quoted 1 line

please register one hwmon class entry, and add multiple temp#_input

attr to it

Quoted 3 lines
Quoted 1 line

(and the same for crit).

I am sorry that I did not notice when you suggested this. I

disagree,

Quoted 4 lines

but now Rui's code is upstream so I guess it's too late to complain. Still here are my reasons:

One of the great things about libsensors is that it gives unique

names

Quoted 1 line

to hardware monitoring devices, and for each device, each feature

has a

Quoted 5 lines

unique name as well. This makes it possible to ignore or label a specific feature in /etc/sensors.conf in a way that is stable over reboot and addition of new hardware.

By going with a single virtual device for all thermal zones, you

break

Quoted 1 line

this model. Depending on which thermal zone drivers are loaded and

in

Quoted 1 line

which order they are loaded, there will be more or less temp* files

in

Quoted 2 lines

the hwmon directory and you also can't predict their order. The labelling issue could be solved by adding temp*_label files, but

this

Quoted 1 line

still prevents the user from overriding a label. And there's no way

to

Quoted 1 line

reliably ignore a specific thermal zone or to ask for information

about

Quoted 7 lines

a specific thermal zone with the current model.

For this reason, I think it would be much better to have one hwmon class device for each _type_ of thermal zone. For example, all ACPI thermal zones would be listed as one hwmon class device. If we later add support for another type of thermal zones, all thermal zones of this type would be listed as one (different) hwmon class device.

This

Quoted 1 line

makes each specific thermal zone driver responsible for the

stability

Quoted 2 lines

of the numbering of the various thermal zones of a given type. This would also let us give names to the different thermal zone types

(e.g.

Quoted 1 line

"acpitz" for ACPI thermal zones) so that the users and supporters

have

Quoted 2 lines

an idea who is providing these temperature values and limits.

Quoted 6 lines

I fully agree, I didn't know there was a generic thermal zone model, and that
there could be multiple drivers implementing it (let alone multiple thermal
zone drivers active for one system ??) I thought this was all ACPI only,

The purpose of the thermal zone driver is to build a generic sys I/F for thermal management in user space. Different type of thermal zones can make use of it doesn't mean they are active for one system. :)

thanks,
rui

Quoted 8 lines

If this (multiple thermal zone drivers active for one system) can really happen
then we really should fix it so that there is one hwmon class entry per thermal
zone driver.

This can be done without changing the ABI, as things would still
follow the standard hwmon ABI.

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

author
#7 lore raw
In reply to Jean Delvare
Quoted 95 lines · Jean Delvare
Quoted 11 lines · Hans de Goede
Quoted 10 lines · Jean Delvare

Hi Hans,

Quoted 7 lines · Hans de Goede
Quoted 2 lines · Rui

Add hwmon sys I/F for the generic thermal device.

Great!

But I have several remarks:
1) Looking at the new code, you only add temp1_input, so I'm

guessing that you

Quoted 1 line
Quoted 1 line
Quoted 1 line

are registering a seperate hwmon class entry per zone? Please

don't do that,

Quoted 1 line
Quoted 1 line
Quoted 1 line

please register one hwmon class entry, and add multiple

temp#_input attr to it

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

(and the same for crit).

I am sorry that I did not notice when you suggested this. I

disagree,

Quoted 1 line
Quoted 1 line

but now Rui's code is upstream so I guess it's too late to

complain.

Quoted 3 lines
Quoted 3 lines

Still here are my reasons:

One of the great things about libsensors is that it gives unique

names

Quoted 1 line
Quoted 1 line

to hardware monitoring devices, and for each device, each feature

has a

Quoted 5 lines
Quoted 5 lines

unique name as well. This makes it possible to ignore or label a specific feature in /etc/sensors.conf in a way that is stable over reboot and addition of new hardware.

By going with a single virtual device for all thermal zones, you

break

Quoted 1 line
Quoted 1 line

this model. Depending on which thermal zone drivers are loaded and

in

Quoted 1 line
Quoted 1 line

which order they are loaded, there will be more or less temp*

files in

Quoted 2 lines
Quoted 2 lines

the hwmon directory and you also can't predict their order. The labelling issue could be solved by adding temp*_label files, but

this

Quoted 1 line
Quoted 1 line

still prevents the user from overriding a label. And there's no

way to

Quoted 1 line
Quoted 1 line

reliably ignore a specific thermal zone or to ask for information

about

Quoted 4 lines
Quoted 4 lines

a specific thermal zone with the current model.

For this reason, I think it would be much better to have one hwmon class device for each _type_ of thermal zone. For example, all

ACPI

Quoted 1 line
Quoted 1 line

thermal zones would be listed as one hwmon class device. If we

later

Quoted 1 line
Quoted 1 line

add support for another type of thermal zones, all thermal zones

of

Quoted 1 line
Quoted 1 line

this type would be listed as one (different) hwmon class device.

This

Quoted 1 line
Quoted 1 line

makes each specific thermal zone driver responsible for the

stability

Quoted 1 line
Quoted 1 line

of the numbering of the various thermal zones of a given type.

This

Quoted 1 line
Quoted 1 line

would also let us give names to the different thermal zone types

(e.g.

Quoted 1 line
Quoted 1 line

"acpitz" for ACPI thermal zones) so that the users and supporters

have

Quoted 4 lines
Quoted 2 lines

an idea who is providing these temperature values and limits.

I fully agree, I didn't know there was a generic thermal zone model,

and that

Quoted 1 line

there could be multiple drivers implementing it (let alone multiple

thermal

Quoted 1 line

zone drivers active for one system ??) I thought this was all ACPI

only,

My understanding is that the new thermal zone code is meant to be generic and ACPI is only one possible underlying implementations, which
sounds very good to me. ACPI just happens to be the only implementation
at the time being.

Quoted 1 line

If this (multiple thermal zone drivers active for one system) can

really happen

Quoted 1 line

then we really should fix it so that there is one hwmon class entry

per thermal

Quoted 1 line

zone driver. This can be done without changing the ABI, as things

would still

Quoted 1 line

follow the standard hwmon ABI.

I have to admit that I'm not sure what sense that would make (and how safe it would be) to have more than one type of thermal zones active at
the same time.

Quoted 8 lines

If the idea if that only one type of thermal zones can
exist for a given system (i.e. the selection happens at build time), then my objection can safely be ignored, except for the fact that I still would like the "name" attribute to reflect the type of the thermal zones.

Rui, Len, how did you originally envision the coexistence (or not) of
different types of thermal zones?

driver/thermal/thermal.c won't change any behavior of the current system. It just creates a generic sys I/F, that's why we call it the Generic Thermal Sysfs driver. :)

We want to introduce a generic solution for thermal management, which usually contains a user application for policy control, a generic thermal sysfs driver which provides a set of platform-independent interfaces, native sensor drivers and device drivers for thermal monitoring and device throttling.
Note that the target is the handheld devices which is not covered by hwmon.
The idea comes from Len's ols paper, please refer to
http://www.kernel.org/pub/linux/kernel/people/lenb/acpi/doc/OLS2007-cool-web/

I don't think the generic thermal sysfs driver need to handle the coexistence of different types of thermal zones, because:
If there are any, they always exist without the generic thermal driver. If they break something, it's broken before the generic thermal driver is implemented, and the generic thermal driver give it a chance to handle this in user space.
Please correct me if I misunderstand your question. :)

thanks,
rui

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

reviewer
#10 lore raw
In reply to Jean Delvare
Quoted 47 lines · Jean Delvare
Quoted 46 lines · Hans de Goede
Quoted 44 lines · Jean Delvare

Hi Hans,

Quoted 10 lines · Hans de Goede
Quoted 2 lines · Rui

Add hwmon sys I/F for the generic thermal device.

Great!

But I have several remarks:
1) Looking at the new code, you only add temp1_input, so I'm guessing that you are registering a seperate hwmon class entry per zone? Please don't do that, please register one hwmon class entry, and add multiple temp#_input attr to it (and the same for crit).

I am sorry that I did not notice when you suggested this. I disagree, but now Rui's code is upstream so I guess it's too late to complain. Still here are my reasons:

One of the great things about libsensors is that it gives unique names to hardware monitoring devices, and for each device, each feature has a unique name as well. This makes it possible to ignore or label a specific feature in /etc/sensors.conf in a way that is stable over reboot and addition of new hardware.

By going with a single virtual device for all thermal zones, you break this model. Depending on which thermal zone drivers are loaded and in which order they are loaded, there will be more or less temp* files in the hwmon directory and you also can't predict their order. The labelling issue could be solved by adding temp*_label files, but this still prevents the user from overriding a label. And there's no way to reliably ignore a specific thermal zone or to ask for information about a specific thermal zone with the current model.

For this reason, I think it would be much better to have one hwmon class device for each _type_ of thermal zone. For example, all ACPI thermal zones would be listed as one hwmon class device. If we later add support for another type of thermal zones, all thermal zones of this type would be listed as one (different) hwmon class device. This makes each specific thermal zone driver responsible for the stability of the numbering of the various thermal zones of a given type. This would also let us give names to the different thermal zone types (e.g. "acpitz" for ACPI thermal zones) so that the users and supporters have an idea who is providing these temperature values and limits.

Quoted 8 lines
Quoted 3 lines

I fully agree, I didn't know there was a generic thermal zone model, and that there could be multiple drivers implementing it (let alone multiple thermal zone drivers active for one system ??) I thought this was all ACPI only,

My understanding is that the new thermal zone code is meant to be generic and ACPI is only one possible underlying implementations, which sounds very good to me. ACPI just happens to be the only implementation at the time being.

Your understanding is correct.
While ACPI is currently the only customer of the generic thermal I/F, there is a future platform in the pipeline that has no ACPI and it too will use the generic thermal I/F.

Quoted 13 lines
Quoted 4 lines

If this (multiple thermal zone drivers active for one system) can really happen then we really should fix it so that there is one hwmon class entry per thermal zone driver. This can be done without changing the ABI, as things would still follow the standard hwmon ABI.

I have to admit that I'm not sure what sense that would make (and how safe it would be) to have more than one type of thermal zones active at the same time. If the idea if that only one type of thermal zones can exist for a given system (i.e. the selection happens at build time), then my objection can safely be ignored, except for the fact that I still would like the "name" attribute to reflect the type of the thermal zones.

Quoted 2 lines

Rui, Len, how did you originally envision the coexistence (or not) of different types of thermal zones?

Right now we seem to be ACPI and then non-ACPI on different systems. However, I don't see any reason that both can't be on the same system.

-Len

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#14 lore raw
In reply to Zhang, Rui
Quoted 6 lines · Rui
Quoted 3 lines · Jean Delvare

The
labelling issue could be solved by adding temp*_label files, but this still prevents the user from overriding a label.

why user needs to override the label?

Well allowing the user to specify user visible names is always good. But that can still be done with temp*_label files. Last time I checked (when I wrote the _label sysfs atrr support code) it would only check for and use a foo#_label file if no label was specified in sensors.conf.

This would of course require the temp# numbering to be consistent over reboots and kernel versions.

Regards,

Hans

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#15 lore raw
In reply to Zhang, Rui

Hi Rui,

Quoted 17 lines · Rui
Quoted 10 lines · Jean Delvare

I am sorry that I did not notice when you suggested this. I disagree, but now Rui's code is upstream so I guess it's too late to complain. Still here are my reasons:

One of the great things about libsensors is that it gives unique names to hardware monitoring devices, and for each device, each feature has a
unique name as well. This makes it possible to ignore or label a specific feature in /etc/sensors.conf in a way that is stable over reboot and addition of new hardware.

Interesting.

Quoted 4 lines

By going with a single virtual device for all thermal zones, you break this model. Depending on which thermal zone drivers are loaded and in which order they are loaded, there will be more or less temp* files in the hwmon directory and you also can't predict their order.

Quoted 6 lines

Yes, you're right.

Quoted 3 lines

The
labelling issue could be solved by adding temp*_label files, but this still prevents the user from overriding a label.

why user needs to override the label?

Originally, the kernel drivers don't provide any labels (because they don't know which temperature sensor corresponds to what) so the default labels are temp1, temp2, temp3 etc. The users instead what to see "CPU Temp", "M/B Temp" etc. which is why libsensors makes it possible to associate a label to each input. If a given kernel driver knows what temperature sensors correspond to, then this driver could propose a label. However there are many reasons why the user may want to override the proposed label:
* The BIOS is broken and mislabeled the zone.
* The default label is too long and doesn't fit it some graphical interface.
* The user wants to translate the text to his/her native language.
* Different thermal zones end up with the same label and the user wants to differentiate them.

Quoted 4 lines
Quoted 4 lines

And there's no way to
reliably ignore a specific thermal zone or to ask for information about a specific thermal zone with the current model.

Quoted 8 lines
Quoted 2 lines

For this reason, I think it would be much better to have one hwmon class device for each _type_ of thermal zone.

Well. I disagree.
First, the generic thermal driver only checks the callbacks and builds the sys I/F for each thermal zone registered. So there is no difference between different thermal zones. Checking the type of different thermal zone and register a hwmon device for each _type of thermal zones doesn't make sense to me. :(

The type of the thermal zone is known to the generic thermal driver somehow, as it exposes the information through the "type" sysfs file. I understand that it doesn't make any difference between different types other than that, but as long as it can differentiate between them, it could create different hwmon devices. Whether we want to do it or not, can be discussed of course.

Quoted 3 lines

Second, take ACPI thermal zone for example, the number/order of the ACPI thermal zones can not be predicted either. All of this information is gotten during system boot time.

The number/order of the ACPI thermal zones is stable accross reboots, isn't it? That's all we really care about.

Quoted 10 lines
Quoted 10 lines

For example, all ACPI
thermal zones would be listed as one hwmon class device. If we later add support for another type of thermal zones, all thermal zones of this type would be listed as one (different) hwmon class device. This makes each specific thermal zone driver responsible for the stability of the numbering of the various thermal zones of a given type. This would also let us give names to the different thermal zone types (e.g. "acpitz" for ACPI thermal zones) so that the users and supporters have an idea who is providing these temperature values and limits.

Quoted 4 lines

If we really need to do this, I suggest we do this in the native driver. Say acpi thermal driver is responsible for registering a hwmon device for ACPI thermal zones, just like the other hwmon native sensor drivers. what do you think?

That's what I wanted to do originally, before you showed up with this generic thermal driver. Of course each native thermal zone driver could register its own hwmon interface. This will however cause code duplication. I don't really care (I doubt there will be that many different native thermal zone drivers anyway), it's really up to you how you want to implement it, as long as it integrates properly with libsensors.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#11 lore raw
In reply to Len Brown
Quoted 3 lines · Len Brown

While ACPI is currently the only customer of the generic thermal I/F, there is a future platform in the pipeline that has no ACPI and it too will use the generic thermal I/F.

A future platform that has no ACPI? Yeeehoooo! :)

(Sorry couldn't resist.)

Quoted 6 lines
Quoted 3 lines

(...)
Rui, Len, how did you originally envision the coexistence (or not) of different types of thermal zones?

Right now we seem to be ACPI and then non-ACPI on different systems. However, I don't see any reason that both can't be on the same system.

OK, in this case this confirms that the current model (all thermal zones in one hwmon device) is not correct.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#8 lore raw
In reply to Zhang, Rui
Quoted 18 lines · Rui
Quoted 2 lines · Jean Delvare

Rui, Len, how did you originally envision the coexistence (or not) of
different types of thermal zones?

driver/thermal/thermal.c won't change any behavior of the current system. It just creates a generic sys I/F, that's why we call it the Generic Thermal Sysfs driver. :)

We want to introduce a generic solution for thermal management, which usually contains a user application for policy control, a generic thermal sysfs driver which provides a set of platform-independent interfaces, native sensor drivers and device drivers for thermal monitoring and device throttling.
Note that the target is the handheld devices which is not covered by hwmon.
The idea comes from Len's ols paper, please refer to
http://www.kernel.org/pub/linux/kernel/people/lenb/acpi/doc/OLS2007-cool-web/

Quoted 7 lines

I don't think the generic thermal sysfs driver need to handle the coexistence of different types of thermal zones, because:
If there are any, they always exist without the generic thermal driver. If they break something, it's broken before the generic thermal driver is implemented, and the generic thermal driver give it a chance to handle this in user space.
Please correct me if I misunderstand your question. :)

Maybe I have not been clear, but my question was not about the generic thermal driver itself. I understand that it's only adding an interface to other drivers and not creating anything new. My question was about thermal zones in general, i.e.: Do we expect systems to have more than one thermal zone type at a given time, or not? Len seems to think we do.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#9 lore raw
Quoted 5 lines · Jean Delvare

Maybe I have not been clear, but my question was not about the generic thermal driver itself. I understand that it's only adding an interface to other drivers and not creating anything new. My question was about thermal zones in general, i.e.: Do we expect systems to have more than one thermal zone type at a given time, or not? Len seems to think we do.

We do, unless we decide to emulate ACPI-style zones to hide that.

Thinkpads have at least two types *always*, for example. EC ones, and the ACPI ones... and there is some variable overlap between them. And there are at least four devices related to the thermal control (CPU, GPU, gig-E, fan), of which one (fan) is systemic and works for all zones.

Signature · 9 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors