Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
On 18 December 2012 17:29, Durgadoss R wrote: > This patch adds a thermal_trip directory under > /sys/class/thermal/zoneX. This directory contains > the trip point values for sensors bound to this > zone. > > Signed-off-by: Durgadoss R > --- > drivers/thermal/thermal_sys.c | 237 > - > include/linux/thermal.h | 37 +++ > 2 files changed, 272 insertions(+), 2 deletions(-) > > diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c > index b39bf97..29ec073 100644 > --- a/drivers/thermal/thermal_sys.c > +++ b/drivers/thermal/thermal_sys.c > @@ -448,6 +448,22 @@ static void thermal_zone_device_check(struct work_struct > *work) > thermal_zone_device_update(tz); > } > > +static int get_sensor_indx_by_kobj(struct thermal_zone *tz, const char *name) > +{ > + int i, indx = -EINVAL; > + > + mutex_lock(_list_lock); > + for (i = 0; i < tz->sensor_indx; i++) { > + if (!strnicmp(name, kobject_name(tz->kobj_trip[i]), > + THERMAL_NAME_LENGTH)) { > + indx = i; > + break; > + } > + } > + mutex_unlock(_list_lock); > + return indx; > +} > + > static void remove_sensor_from_zone(struct thermal_zone *tz, > struct thermal_sensor *ts) > { > @@ -459,9 +475,15 @@ static void remove_sensor_from_zone(struct thermal_zone > *tz, > > sysfs_remove_link(>device.kobj, kobject_name(>device.kobj)); > > + /* Delete this sensor's trip Kobject */ > + kobject_del(tz->kobj_trip[indx]); > + > /* Shift the entries in the tz->sensors array */ > - for (j = indx; j < MAX_SENSORS_PER_ZONE - 1; j++) > + for (j = indx; j < MAX_SENSORS_PER_ZONE - 1; j++) { > tz->sensors[j] = tz->sensors[j + 1]; > + tz->sensor_trip[j] = tz->sensor_trip[j + 1]; > + tz->kobj_trip[j] = tz->kobj_trip[j + 1]; > + } > > tz->sensor_indx--; > } > @@ -875,6 +897,120 @@ policy_show(struct device *dev, struct device_attribute > *devattr, char *buf) > return sprintf(buf, "%s\n", tz->governor->name); > } > > +static ssize_t > +active_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) > +{ > + int i, indx, ret = 0; > + struct thermal_zone *tz; > + struct device *dev; > + > + /* In this function, for > +* /sys/class/thermal/zoneX/thermal_trip/sensorY: > +* attr points to sysfs node 'active' > +* kobj points to sensorY > +* kobj->parent points to thermal_trip > +* kobj->parent->parent points to zoneX > +*/ > + > + /* Get the zone pointer */ > + dev = container_of(kobj->parent->parent, struct device, kobj); > + tz = to_zone(dev); > + if (!tz) > + return -EINVAL; > + > + /* > +* We need this because in the sysfs tree, 'sensorY' is > +* not really the sensor pointer. It just has the name > +* 'sensorY'; whereas 'zoneX' is actually the zone pointer. > +* This means container_of(kobj, struct device, kobj) will not > +* provide the actual sensor pointer. > +*/ > + indx = get_sensor_indx_by_kobj(tz, kobject_name(kobj)); > + if (indx < 0) > + return indx; > + > + if (tz->sensor_trip[indx]->num_active_trips <= 0) > + return sprintf(buf, "\n"); > + > + ret += sprintf(buf, "0x%x", tz->sensor_trip[indx]->active_trip_mask); > + for (i = 0; i < tz->sensor_trip[indx]->num_active_trips; i++) { > + ret += sprintf(buf + ret, " %d", > + tz->sensor_trip[indx]->active_trips[i]); > + } > + > + ret += sprintf(buf + ret, "\n"); > + return ret; > +} > + > +static ssize_t > +ptrip_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) > +{ > + int i, indx, ret = 0; > + struct thermal_zone *tz; > + struct device *dev; > + > + /* Get the zone pointer */ > + dev = container_of(kobj->parent->parent, struct device, kobj); > + tz = to_zone(dev); > + if (!tz) > + return -EINVAL; > + > + indx = get_sensor_indx_by_kobj(tz, kobject_name(kobj)); > + if (indx < 0) > + return indx; > + > + if (tz->sensor_trip[indx]->num_passive_trips <= 0) > + return sprintf(buf, "\n"); > + > + for (i = 0; i < tz->sensor_trip[indx]->num_passive_trips; i++) { > + ret += sprintf(buf + ret, "%d ", > + tz->sensor_trip[indx]->passive_trips[i]); > + } > + > + ret += sprintf(buf + ret, "\n"); > + return ret; > +} > + > +static ssize_t > +hot_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) > +{ > + int indx; > + struct thermal_zone *tz; > + struct device *dev; > +
Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
On 18 December 2012 17:29, Durgadoss R durgados...@intel.com wrote: This patch adds a thermal_trip directory under /sys/class/thermal/zoneX. This directory contains the trip point values for sensors bound to this zone. Signed-off-by: Durgadoss R durgados...@intel.com --- drivers/thermal/thermal_sys.c | 237 - include/linux/thermal.h | 37 +++ 2 files changed, 272 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index b39bf97..29ec073 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -448,6 +448,22 @@ static void thermal_zone_device_check(struct work_struct *work) thermal_zone_device_update(tz); } +static int get_sensor_indx_by_kobj(struct thermal_zone *tz, const char *name) +{ + int i, indx = -EINVAL; + + mutex_lock(sensor_list_lock); + for (i = 0; i tz-sensor_indx; i++) { + if (!strnicmp(name, kobject_name(tz-kobj_trip[i]), + THERMAL_NAME_LENGTH)) { + indx = i; + break; + } + } + mutex_unlock(sensor_list_lock); + return indx; +} + static void remove_sensor_from_zone(struct thermal_zone *tz, struct thermal_sensor *ts) { @@ -459,9 +475,15 @@ static void remove_sensor_from_zone(struct thermal_zone *tz, sysfs_remove_link(tz-device.kobj, kobject_name(ts-device.kobj)); + /* Delete this sensor's trip Kobject */ + kobject_del(tz-kobj_trip[indx]); + /* Shift the entries in the tz-sensors array */ - for (j = indx; j MAX_SENSORS_PER_ZONE - 1; j++) + for (j = indx; j MAX_SENSORS_PER_ZONE - 1; j++) { tz-sensors[j] = tz-sensors[j + 1]; + tz-sensor_trip[j] = tz-sensor_trip[j + 1]; + tz-kobj_trip[j] = tz-kobj_trip[j + 1]; + } tz-sensor_indx--; } @@ -875,6 +897,120 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf) return sprintf(buf, %s\n, tz-governor-name); } +static ssize_t +active_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + int i, indx, ret = 0; + struct thermal_zone *tz; + struct device *dev; + + /* In this function, for +* /sys/class/thermal/zoneX/thermal_trip/sensorY: +* attr points to sysfs node 'active' +* kobj points to sensorY +* kobj-parent points to thermal_trip +* kobj-parent-parent points to zoneX +*/ + + /* Get the zone pointer */ + dev = container_of(kobj-parent-parent, struct device, kobj); + tz = to_zone(dev); + if (!tz) + return -EINVAL; + + /* +* We need this because in the sysfs tree, 'sensorY' is +* not really the sensor pointer. It just has the name +* 'sensorY'; whereas 'zoneX' is actually the zone pointer. +* This means container_of(kobj, struct device, kobj) will not +* provide the actual sensor pointer. +*/ + indx = get_sensor_indx_by_kobj(tz, kobject_name(kobj)); + if (indx 0) + return indx; + + if (tz-sensor_trip[indx]-num_active_trips = 0) + return sprintf(buf, Not available\n); + + ret += sprintf(buf, 0x%x, tz-sensor_trip[indx]-active_trip_mask); + for (i = 0; i tz-sensor_trip[indx]-num_active_trips; i++) { + ret += sprintf(buf + ret, %d, + tz-sensor_trip[indx]-active_trips[i]); + } + + ret += sprintf(buf + ret, \n); + return ret; +} + +static ssize_t +ptrip_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + int i, indx, ret = 0; + struct thermal_zone *tz; + struct device *dev; + + /* Get the zone pointer */ + dev = container_of(kobj-parent-parent, struct device, kobj); + tz = to_zone(dev); + if (!tz) + return -EINVAL; + + indx = get_sensor_indx_by_kobj(tz, kobject_name(kobj)); + if (indx 0) + return indx; + + if (tz-sensor_trip[indx]-num_passive_trips = 0) + return sprintf(buf, Not available\n); + + for (i = 0; i tz-sensor_trip[indx]-num_passive_trips; i++) { + ret += sprintf(buf + ret, %d , + tz-sensor_trip[indx]-passive_trips[i]); + } + + ret += sprintf(buf + ret, \n); + return ret; +} + +static ssize_t +hot_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + int indx; + struct thermal_zone *tz; + struct device *dev; + + /* Get the zone pointer */ + dev = container_of(kobj-parent-parent, struct device, kobj); + tz =
RE: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
> -Original Message- > From: Greg KH [mailto:gre...@linuxfoundation.org] > Sent: Thursday, December 20, 2012 11:21 PM > To: R, Durgadoss > Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; > hongbo.zh...@linaro.org; w...@nvidia.com > Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node > > On Thu, Dec 20, 2012 at 04:58:32PM +, R, Durgadoss wrote: > > > -Original Message- > > > From: Greg KH [mailto:gre...@linuxfoundation.org] > > > Sent: Thursday, December 20, 2012 10:09 PM > > > To: R, Durgadoss > > > Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; > > > hongbo.zh...@linaro.org; w...@nvidia.com > > > Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node > > > > > > On Thu, Dec 20, 2012 at 04:25:32PM +, R, Durgadoss wrote: > > > > > > > > > -Original Message- > > > > > From: Greg KH [mailto:gre...@linuxfoundation.org] > > > > > Sent: Thursday, December 20, 2012 9:42 PM > > > > > To: R, Durgadoss > > > > > Cc: Zhang, Rui; linux...@vger.kernel.org; linux- > ker...@vger.kernel.org; > > > > > hongbo.zh...@linaro.org; w...@nvidia.com > > > > > Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node > > > > > > > > > > On Thu, Dec 20, 2012 at 07:52:03AM +, R, Durgadoss wrote: > > > > > > > On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: > > > > > > > > This patch adds a thermal_trip directory under > > > > > > > > /sys/class/thermal/zoneX. This directory contains > > > > > > > > the trip point values for sensors bound to this > > > > > > > > zone. > > > > > > > > > > > > > > Eeek, you just broke userspace tools that now can no longer see > > > these > > > > > > > entries :( > > > > > > > > > > > > > > Why do you need to create a subdirectory? As you found out, > doing > > > so > > > > > > > isn't the easiest, right? That is on purpose. > > > > > > > > > > > > Yes, I observed the complexity. > > > > > > > > > > > > > > > > > > > > I really wouldn't recommend doing this at all, please stick within > the > > > > > > > 'struct device' framework here, don't create new kobjects and > hang > > > sysfs > > > > > > > files off of them. > > > > > > > > > > > > But, we cannot put all _trip directly under ZoneX directory. > > > > > > > > > > Why not? What is preventing this? > > > > > > > > > > > We can remove the thermal_trip directory, and put sensorY_trip > under > > > > > > /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a > > > > > > directory which has four sysfs nodes named, active, passive, crit, > > > > > > hot. > > > > > > > > > > > > Rui, What do you think about this ? > > > > > > > > > > > > The only other way I see, is directly put > > > > > sensorY_trip_[active/passive/hot/crit] > > > > > > which will create way too many nodes, under > > > /sys/class/thermal/zoneX/. > > > > > > > > > > What is "too many"? 2? 5? How many are we talking about > > > here? > > > > > > > > Not in 1000's though.. > > > > > > > > > What is the limiting factor that is preventing this from all going > > > > > into > > > > > one directory? > > > > > > > > We support a MAX of 12 sensors per zone today, which will lead to > > > > 12 * 4, 48 nodes under this directory named > > > > sensorY_trip_[active/passive/hot/crit], besides the other nodes. > > > > > > That's fine, we can easily support that many files, have you tried this > > > already? > > > > Yes, in fact, this is sort of what was the old implementation.. > > although with different sysfs nodes. > > What "old" implementation, one that is in-kernel? Are you changing the > user interface here? Sorry, I should have used better wordings ;( [s/old/existing] There are other sysfs nodes following the correct convention under /sys/class/thermal/, which is what I was mentioning. No, we are not changing the user interface, in these patches. Thanks, Durga -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
On Thu, Dec 20, 2012 at 04:58:32PM +, R, Durgadoss wrote: > > -Original Message- > > From: Greg KH [mailto:gre...@linuxfoundation.org] > > Sent: Thursday, December 20, 2012 10:09 PM > > To: R, Durgadoss > > Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; > > hongbo.zh...@linaro.org; w...@nvidia.com > > Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node > > > > On Thu, Dec 20, 2012 at 04:25:32PM +, R, Durgadoss wrote: > > > > > > > -Original Message- > > > > From: Greg KH [mailto:gre...@linuxfoundation.org] > > > > Sent: Thursday, December 20, 2012 9:42 PM > > > > To: R, Durgadoss > > > > Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; > > > > hongbo.zh...@linaro.org; w...@nvidia.com > > > > Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node > > > > > > > > On Thu, Dec 20, 2012 at 07:52:03AM +, R, Durgadoss wrote: > > > > > > On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: > > > > > > > This patch adds a thermal_trip directory under > > > > > > > /sys/class/thermal/zoneX. This directory contains > > > > > > > the trip point values for sensors bound to this > > > > > > > zone. > > > > > > > > > > > > Eeek, you just broke userspace tools that now can no longer see > > these > > > > > > entries :( > > > > > > > > > > > > Why do you need to create a subdirectory? As you found out, doing > > so > > > > > > isn't the easiest, right? That is on purpose. > > > > > > > > > > Yes, I observed the complexity. > > > > > > > > > > > > > > > > > I really wouldn't recommend doing this at all, please stick within > > > > > > the > > > > > > 'struct device' framework here, don't create new kobjects and hang > > sysfs > > > > > > files off of them. > > > > > > > > > > But, we cannot put all _trip directly under ZoneX directory. > > > > > > > > Why not? What is preventing this? > > > > > > > > > We can remove the thermal_trip directory, and put sensorY_trip under > > > > > /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a > > > > > directory which has four sysfs nodes named, active, passive, crit, > > > > > hot. > > > > > > > > > > Rui, What do you think about this ? > > > > > > > > > > The only other way I see, is directly put > > > > sensorY_trip_[active/passive/hot/crit] > > > > > which will create way too many nodes, under > > /sys/class/thermal/zoneX/. > > > > > > > > What is "too many"? 2? 5? How many are we talking about > > here? > > > > > > Not in 1000's though.. > > > > > > > What is the limiting factor that is preventing this from all going into > > > > one directory? > > > > > > We support a MAX of 12 sensors per zone today, which will lead to > > > 12 * 4, 48 nodes under this directory named > > > sensorY_trip_[active/passive/hot/crit], besides the other nodes. > > > > That's fine, we can easily support that many files, have you tried this > > already? > > Yes, in fact, this is sort of what was the old implementation.. > although with different sysfs nodes. What "old" implementation, one that is in-kernel? Are you changing the user interface here? thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
> -Original Message- > From: Greg KH [mailto:gre...@linuxfoundation.org] > Sent: Thursday, December 20, 2012 10:09 PM > To: R, Durgadoss > Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; > hongbo.zh...@linaro.org; w...@nvidia.com > Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node > > On Thu, Dec 20, 2012 at 04:25:32PM +, R, Durgadoss wrote: > > > > > -Original Message- > > > From: Greg KH [mailto:gre...@linuxfoundation.org] > > > Sent: Thursday, December 20, 2012 9:42 PM > > > To: R, Durgadoss > > > Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; > > > hongbo.zh...@linaro.org; w...@nvidia.com > > > Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node > > > > > > On Thu, Dec 20, 2012 at 07:52:03AM +, R, Durgadoss wrote: > > > > > On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: > > > > > > This patch adds a thermal_trip directory under > > > > > > /sys/class/thermal/zoneX. This directory contains > > > > > > the trip point values for sensors bound to this > > > > > > zone. > > > > > > > > > > Eeek, you just broke userspace tools that now can no longer see > these > > > > > entries :( > > > > > > > > > > Why do you need to create a subdirectory? As you found out, doing > so > > > > > isn't the easiest, right? That is on purpose. > > > > > > > > Yes, I observed the complexity. > > > > > > > > > > > > > > I really wouldn't recommend doing this at all, please stick within the > > > > > 'struct device' framework here, don't create new kobjects and hang > sysfs > > > > > files off of them. > > > > > > > > But, we cannot put all _trip directly under ZoneX directory. > > > > > > Why not? What is preventing this? > > > > > > > We can remove the thermal_trip directory, and put sensorY_trip under > > > > /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a > > > > directory which has four sysfs nodes named, active, passive, crit, > > > > hot. > > > > > > > > Rui, What do you think about this ? > > > > > > > > The only other way I see, is directly put > > > sensorY_trip_[active/passive/hot/crit] > > > > which will create way too many nodes, under > /sys/class/thermal/zoneX/. > > > > > > What is "too many"? 2? 5? How many are we talking about > here? > > > > Not in 1000's though.. > > > > > What is the limiting factor that is preventing this from all going into > > > one directory? > > > > We support a MAX of 12 sensors per zone today, which will lead to > > 12 * 4, 48 nodes under this directory named > > sensorY_trip_[active/passive/hot/crit], besides the other nodes. > > That's fine, we can easily support that many files, have you tried this > already? Yes, in fact, this is sort of what was the old implementation.. although with different sysfs nodes. > > The main point is, if you use a kobject like you are, userspace tools > can't "see" these directories and files easily, if at all. Try it out > with libudev yourself to verify it, the attributes will not show up as > owned to that device like you need them to be. I haven't used libudev exactly, but I realized this sort of thing, when I was trying to catch UEvents on this device path. I will give libudev a try.. > > So put them all in one directory, we can handle 10's of thousands of > files quite easily, so 48 is trivial :) Okay, Will make it this way :-) Now I can see the implementation getting much simpler !! Thank you Greg, Durga P.S: I should thank you for this file(samples/kobject/kobject-example.c) also, from where I got how to get this implementation done :-) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
On Thu, Dec 20, 2012 at 04:25:32PM +, R, Durgadoss wrote: > > > -Original Message- > > From: Greg KH [mailto:gre...@linuxfoundation.org] > > Sent: Thursday, December 20, 2012 9:42 PM > > To: R, Durgadoss > > Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; > > hongbo.zh...@linaro.org; w...@nvidia.com > > Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node > > > > On Thu, Dec 20, 2012 at 07:52:03AM +, R, Durgadoss wrote: > > > > On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: > > > > > This patch adds a thermal_trip directory under > > > > > /sys/class/thermal/zoneX. This directory contains > > > > > the trip point values for sensors bound to this > > > > > zone. > > > > > > > > Eeek, you just broke userspace tools that now can no longer see these > > > > entries :( > > > > > > > > Why do you need to create a subdirectory? As you found out, doing so > > > > isn't the easiest, right? That is on purpose. > > > > > > Yes, I observed the complexity. > > > > > > > > > > > I really wouldn't recommend doing this at all, please stick within the > > > > 'struct device' framework here, don't create new kobjects and hang sysfs > > > > files off of them. > > > > > > But, we cannot put all _trip directly under ZoneX directory. > > > > Why not? What is preventing this? > > > > > We can remove the thermal_trip directory, and put sensorY_trip under > > > /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a > > > directory which has four sysfs nodes named, active, passive, crit, > > > hot. > > > > > > Rui, What do you think about this ? > > > > > > The only other way I see, is directly put > > sensorY_trip_[active/passive/hot/crit] > > > which will create way too many nodes, under /sys/class/thermal/zoneX/. > > > > What is "too many"? 2? 5? How many are we talking about here? > > Not in 1000's though.. > > > What is the limiting factor that is preventing this from all going into > > one directory? > > We support a MAX of 12 sensors per zone today, which will lead to > 12 * 4, 48 nodes under this directory named > sensorY_trip_[active/passive/hot/crit], besides the other nodes. That's fine, we can easily support that many files, have you tried this already? The main point is, if you use a kobject like you are, userspace tools can't "see" these directories and files easily, if at all. Try it out with libudev yourself to verify it, the attributes will not show up as owned to that device like you need them to be. So put them all in one directory, we can handle 10's of thousands of files quite easily, so 48 is trivial :) thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
> -Original Message- > From: Greg KH [mailto:gre...@linuxfoundation.org] > Sent: Thursday, December 20, 2012 9:42 PM > To: R, Durgadoss > Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; > hongbo.zh...@linaro.org; w...@nvidia.com > Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node > > On Thu, Dec 20, 2012 at 07:52:03AM +, R, Durgadoss wrote: > > > On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: > > > > This patch adds a thermal_trip directory under > > > > /sys/class/thermal/zoneX. This directory contains > > > > the trip point values for sensors bound to this > > > > zone. > > > > > > Eeek, you just broke userspace tools that now can no longer see these > > > entries :( > > > > > > Why do you need to create a subdirectory? As you found out, doing so > > > isn't the easiest, right? That is on purpose. > > > > Yes, I observed the complexity. > > > > > > > > I really wouldn't recommend doing this at all, please stick within the > > > 'struct device' framework here, don't create new kobjects and hang sysfs > > > files off of them. > > > > But, we cannot put all _trip directly under ZoneX directory. > > Why not? What is preventing this? > > > We can remove the thermal_trip directory, and put sensorY_trip under > > /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a > > directory which has four sysfs nodes named, active, passive, crit, > > hot. > > > > Rui, What do you think about this ? > > > > The only other way I see, is directly put > sensorY_trip_[active/passive/hot/crit] > > which will create way too many nodes, under /sys/class/thermal/zoneX/. > > What is "too many"? 2? 5? How many are we talking about here? Not in 1000's though.. > What is the limiting factor that is preventing this from all going into > one directory? We support a MAX of 12 sensors per zone today, which will lead to 12 * 4, 48 nodes under this directory named sensorY_trip_[active/passive/hot/crit], besides the other nodes. Thanks, Durga -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
On Thu, Dec 20, 2012 at 07:52:03AM +, R, Durgadoss wrote: > > On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: > > > This patch adds a thermal_trip directory under > > > /sys/class/thermal/zoneX. This directory contains > > > the trip point values for sensors bound to this > > > zone. > > > > Eeek, you just broke userspace tools that now can no longer see these > > entries :( > > > > Why do you need to create a subdirectory? As you found out, doing so > > isn't the easiest, right? That is on purpose. > > Yes, I observed the complexity. > > > > > I really wouldn't recommend doing this at all, please stick within the > > 'struct device' framework here, don't create new kobjects and hang sysfs > > files off of them. > > But, we cannot put all _trip directly under ZoneX directory. Why not? What is preventing this? > We can remove the thermal_trip directory, and put sensorY_trip under > /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a > directory which has four sysfs nodes named, active, passive, crit, > hot. > > Rui, What do you think about this ? > > The only other way I see, is directly put > sensorY_trip_[active/passive/hot/crit] > which will create way too many nodes, under /sys/class/thermal/zoneX/. What is "too many"? 2? 5? How many are we talking about here? What is the limiting factor that is preventing this from all going into one directory? thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
On Thu, Dec 20, 2012 at 07:52:03AM +, R, Durgadoss wrote: On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: This patch adds a thermal_trip directory under /sys/class/thermal/zoneX. This directory contains the trip point values for sensors bound to this zone. Eeek, you just broke userspace tools that now can no longer see these entries :( Why do you need to create a subdirectory? As you found out, doing so isn't the easiest, right? That is on purpose. Yes, I observed the complexity. I really wouldn't recommend doing this at all, please stick within the 'struct device' framework here, don't create new kobjects and hang sysfs files off of them. But, we cannot put all _trip directly under ZoneX directory. Why not? What is preventing this? We can remove the thermal_trip directory, and put sensorY_trip under /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a directory which has four sysfs nodes named, active, passive, crit, hot. Rui, What do you think about this ? The only other way I see, is directly put sensorY_trip_[active/passive/hot/crit] which will create way too many nodes, under /sys/class/thermal/zoneX/. What is too many? 2? 5? How many are we talking about here? What is the limiting factor that is preventing this from all going into one directory? thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
-Original Message- From: Greg KH [mailto:gre...@linuxfoundation.org] Sent: Thursday, December 20, 2012 9:42 PM To: R, Durgadoss Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; hongbo.zh...@linaro.org; w...@nvidia.com Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node On Thu, Dec 20, 2012 at 07:52:03AM +, R, Durgadoss wrote: On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: This patch adds a thermal_trip directory under /sys/class/thermal/zoneX. This directory contains the trip point values for sensors bound to this zone. Eeek, you just broke userspace tools that now can no longer see these entries :( Why do you need to create a subdirectory? As you found out, doing so isn't the easiest, right? That is on purpose. Yes, I observed the complexity. I really wouldn't recommend doing this at all, please stick within the 'struct device' framework here, don't create new kobjects and hang sysfs files off of them. But, we cannot put all _trip directly under ZoneX directory. Why not? What is preventing this? We can remove the thermal_trip directory, and put sensorY_trip under /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a directory which has four sysfs nodes named, active, passive, crit, hot. Rui, What do you think about this ? The only other way I see, is directly put sensorY_trip_[active/passive/hot/crit] which will create way too many nodes, under /sys/class/thermal/zoneX/. What is too many? 2? 5? How many are we talking about here? Not in 1000's though.. What is the limiting factor that is preventing this from all going into one directory? We support a MAX of 12 sensors per zone today, which will lead to 12 * 4, 48 nodes under this directory named sensorY_trip_[active/passive/hot/crit], besides the other nodes. Thanks, Durga -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
On Thu, Dec 20, 2012 at 04:25:32PM +, R, Durgadoss wrote: -Original Message- From: Greg KH [mailto:gre...@linuxfoundation.org] Sent: Thursday, December 20, 2012 9:42 PM To: R, Durgadoss Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; hongbo.zh...@linaro.org; w...@nvidia.com Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node On Thu, Dec 20, 2012 at 07:52:03AM +, R, Durgadoss wrote: On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: This patch adds a thermal_trip directory under /sys/class/thermal/zoneX. This directory contains the trip point values for sensors bound to this zone. Eeek, you just broke userspace tools that now can no longer see these entries :( Why do you need to create a subdirectory? As you found out, doing so isn't the easiest, right? That is on purpose. Yes, I observed the complexity. I really wouldn't recommend doing this at all, please stick within the 'struct device' framework here, don't create new kobjects and hang sysfs files off of them. But, we cannot put all _trip directly under ZoneX directory. Why not? What is preventing this? We can remove the thermal_trip directory, and put sensorY_trip under /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a directory which has four sysfs nodes named, active, passive, crit, hot. Rui, What do you think about this ? The only other way I see, is directly put sensorY_trip_[active/passive/hot/crit] which will create way too many nodes, under /sys/class/thermal/zoneX/. What is too many? 2? 5? How many are we talking about here? Not in 1000's though.. What is the limiting factor that is preventing this from all going into one directory? We support a MAX of 12 sensors per zone today, which will lead to 12 * 4, 48 nodes under this directory named sensorY_trip_[active/passive/hot/crit], besides the other nodes. That's fine, we can easily support that many files, have you tried this already? The main point is, if you use a kobject like you are, userspace tools can't see these directories and files easily, if at all. Try it out with libudev yourself to verify it, the attributes will not show up as owned to that device like you need them to be. So put them all in one directory, we can handle 10's of thousands of files quite easily, so 48 is trivial :) thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
-Original Message- From: Greg KH [mailto:gre...@linuxfoundation.org] Sent: Thursday, December 20, 2012 10:09 PM To: R, Durgadoss Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; hongbo.zh...@linaro.org; w...@nvidia.com Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node On Thu, Dec 20, 2012 at 04:25:32PM +, R, Durgadoss wrote: -Original Message- From: Greg KH [mailto:gre...@linuxfoundation.org] Sent: Thursday, December 20, 2012 9:42 PM To: R, Durgadoss Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; hongbo.zh...@linaro.org; w...@nvidia.com Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node On Thu, Dec 20, 2012 at 07:52:03AM +, R, Durgadoss wrote: On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: This patch adds a thermal_trip directory under /sys/class/thermal/zoneX. This directory contains the trip point values for sensors bound to this zone. Eeek, you just broke userspace tools that now can no longer see these entries :( Why do you need to create a subdirectory? As you found out, doing so isn't the easiest, right? That is on purpose. Yes, I observed the complexity. I really wouldn't recommend doing this at all, please stick within the 'struct device' framework here, don't create new kobjects and hang sysfs files off of them. But, we cannot put all _trip directly under ZoneX directory. Why not? What is preventing this? We can remove the thermal_trip directory, and put sensorY_trip under /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a directory which has four sysfs nodes named, active, passive, crit, hot. Rui, What do you think about this ? The only other way I see, is directly put sensorY_trip_[active/passive/hot/crit] which will create way too many nodes, under /sys/class/thermal/zoneX/. What is too many? 2? 5? How many are we talking about here? Not in 1000's though.. What is the limiting factor that is preventing this from all going into one directory? We support a MAX of 12 sensors per zone today, which will lead to 12 * 4, 48 nodes under this directory named sensorY_trip_[active/passive/hot/crit], besides the other nodes. That's fine, we can easily support that many files, have you tried this already? Yes, in fact, this is sort of what was the old implementation.. although with different sysfs nodes. The main point is, if you use a kobject like you are, userspace tools can't see these directories and files easily, if at all. Try it out with libudev yourself to verify it, the attributes will not show up as owned to that device like you need them to be. I haven't used libudev exactly, but I realized this sort of thing, when I was trying to catch UEvents on this device path. I will give libudev a try.. So put them all in one directory, we can handle 10's of thousands of files quite easily, so 48 is trivial :) Okay, Will make it this way :-) Now I can see the implementation getting much simpler !! Thank you Greg, Durga P.S: I should thank you for this file(samples/kobject/kobject-example.c) also, from where I got how to get this implementation done :-) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
On Thu, Dec 20, 2012 at 04:58:32PM +, R, Durgadoss wrote: -Original Message- From: Greg KH [mailto:gre...@linuxfoundation.org] Sent: Thursday, December 20, 2012 10:09 PM To: R, Durgadoss Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; hongbo.zh...@linaro.org; w...@nvidia.com Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node On Thu, Dec 20, 2012 at 04:25:32PM +, R, Durgadoss wrote: -Original Message- From: Greg KH [mailto:gre...@linuxfoundation.org] Sent: Thursday, December 20, 2012 9:42 PM To: R, Durgadoss Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; hongbo.zh...@linaro.org; w...@nvidia.com Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node On Thu, Dec 20, 2012 at 07:52:03AM +, R, Durgadoss wrote: On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: This patch adds a thermal_trip directory under /sys/class/thermal/zoneX. This directory contains the trip point values for sensors bound to this zone. Eeek, you just broke userspace tools that now can no longer see these entries :( Why do you need to create a subdirectory? As you found out, doing so isn't the easiest, right? That is on purpose. Yes, I observed the complexity. I really wouldn't recommend doing this at all, please stick within the 'struct device' framework here, don't create new kobjects and hang sysfs files off of them. But, we cannot put all _trip directly under ZoneX directory. Why not? What is preventing this? We can remove the thermal_trip directory, and put sensorY_trip under /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a directory which has four sysfs nodes named, active, passive, crit, hot. Rui, What do you think about this ? The only other way I see, is directly put sensorY_trip_[active/passive/hot/crit] which will create way too many nodes, under /sys/class/thermal/zoneX/. What is too many? 2? 5? How many are we talking about here? Not in 1000's though.. What is the limiting factor that is preventing this from all going into one directory? We support a MAX of 12 sensors per zone today, which will lead to 12 * 4, 48 nodes under this directory named sensorY_trip_[active/passive/hot/crit], besides the other nodes. That's fine, we can easily support that many files, have you tried this already? Yes, in fact, this is sort of what was the old implementation.. although with different sysfs nodes. What old implementation, one that is in-kernel? Are you changing the user interface here? thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
-Original Message- From: Greg KH [mailto:gre...@linuxfoundation.org] Sent: Thursday, December 20, 2012 11:21 PM To: R, Durgadoss Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; hongbo.zh...@linaro.org; w...@nvidia.com Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node On Thu, Dec 20, 2012 at 04:58:32PM +, R, Durgadoss wrote: -Original Message- From: Greg KH [mailto:gre...@linuxfoundation.org] Sent: Thursday, December 20, 2012 10:09 PM To: R, Durgadoss Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; hongbo.zh...@linaro.org; w...@nvidia.com Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node On Thu, Dec 20, 2012 at 04:25:32PM +, R, Durgadoss wrote: -Original Message- From: Greg KH [mailto:gre...@linuxfoundation.org] Sent: Thursday, December 20, 2012 9:42 PM To: R, Durgadoss Cc: Zhang, Rui; linux...@vger.kernel.org; linux- ker...@vger.kernel.org; hongbo.zh...@linaro.org; w...@nvidia.com Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node On Thu, Dec 20, 2012 at 07:52:03AM +, R, Durgadoss wrote: On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: This patch adds a thermal_trip directory under /sys/class/thermal/zoneX. This directory contains the trip point values for sensors bound to this zone. Eeek, you just broke userspace tools that now can no longer see these entries :( Why do you need to create a subdirectory? As you found out, doing so isn't the easiest, right? That is on purpose. Yes, I observed the complexity. I really wouldn't recommend doing this at all, please stick within the 'struct device' framework here, don't create new kobjects and hang sysfs files off of them. But, we cannot put all _trip directly under ZoneX directory. Why not? What is preventing this? We can remove the thermal_trip directory, and put sensorY_trip under /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a directory which has four sysfs nodes named, active, passive, crit, hot. Rui, What do you think about this ? The only other way I see, is directly put sensorY_trip_[active/passive/hot/crit] which will create way too many nodes, under /sys/class/thermal/zoneX/. What is too many? 2? 5? How many are we talking about here? Not in 1000's though.. What is the limiting factor that is preventing this from all going into one directory? We support a MAX of 12 sensors per zone today, which will lead to 12 * 4, 48 nodes under this directory named sensorY_trip_[active/passive/hot/crit], besides the other nodes. That's fine, we can easily support that many files, have you tried this already? Yes, in fact, this is sort of what was the old implementation.. although with different sysfs nodes. What old implementation, one that is in-kernel? Are you changing the user interface here? Sorry, I should have used better wordings ;( [s/old/existing] There are other sysfs nodes following the correct convention under /sys/class/thermal/, which is what I was mentioning. No, we are not changing the user interface, in these patches. Thanks, Durga -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
Hi Greg, Thank you for looking at this. > -Original Message- > From: Greg KH [mailto:gre...@linuxfoundation.org] > Sent: Thursday, December 20, 2012 11:12 AM > To: R, Durgadoss > Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; > hongbo.zh...@linaro.org; w...@nvidia.com > Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node > > On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: > > This patch adds a thermal_trip directory under > > /sys/class/thermal/zoneX. This directory contains > > the trip point values for sensors bound to this > > zone. > > Eeek, you just broke userspace tools that now can no longer see these > entries :( > > Why do you need to create a subdirectory? As you found out, doing so > isn't the easiest, right? That is on purpose. Yes, I observed the complexity. > > I really wouldn't recommend doing this at all, please stick within the > 'struct device' framework here, don't create new kobjects and hang sysfs > files off of them. But, we cannot put all _trip directly under ZoneX directory. We can remove the thermal_trip directory, and put sensorY_trip under /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a directory which has four sysfs nodes named, active, passive, crit, hot. Rui, What do you think about this ? The only other way I see, is directly put sensorY_trip_[active/passive/hot/crit] which will create way too many nodes, under /sys/class/thermal/zoneX/. Thanks, Durga > > thanks, > > greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: > This patch adds a thermal_trip directory under > /sys/class/thermal/zoneX. This directory contains > the trip point values for sensors bound to this > zone. Eeek, you just broke userspace tools that now can no longer see these entries :( Why do you need to create a subdirectory? As you found out, doing so isn't the easiest, right? That is on purpose. I really wouldn't recommend doing this at all, please stick within the 'struct device' framework here, don't create new kobjects and hang sysfs files off of them. thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: This patch adds a thermal_trip directory under /sys/class/thermal/zoneX. This directory contains the trip point values for sensors bound to this zone. Eeek, you just broke userspace tools that now can no longer see these entries :( Why do you need to create a subdirectory? As you found out, doing so isn't the easiest, right? That is on purpose. I really wouldn't recommend doing this at all, please stick within the 'struct device' framework here, don't create new kobjects and hang sysfs files off of them. thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node
Hi Greg, Thank you for looking at this. -Original Message- From: Greg KH [mailto:gre...@linuxfoundation.org] Sent: Thursday, December 20, 2012 11:12 AM To: R, Durgadoss Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org; hongbo.zh...@linaro.org; w...@nvidia.com Subject: Re: [PATCH 4/8] Thermal: Add Thermal_trip sysfs node On Tue, Dec 18, 2012 at 02:59:33PM +0530, Durgadoss R wrote: This patch adds a thermal_trip directory under /sys/class/thermal/zoneX. This directory contains the trip point values for sensors bound to this zone. Eeek, you just broke userspace tools that now can no longer see these entries :( Why do you need to create a subdirectory? As you found out, doing so isn't the easiest, right? That is on purpose. Yes, I observed the complexity. I really wouldn't recommend doing this at all, please stick within the 'struct device' framework here, don't create new kobjects and hang sysfs files off of them. But, we cannot put all _trip directly under ZoneX directory. We can remove the thermal_trip directory, and put sensorY_trip under /sys/class/thermal/zoneX/. But this sensorY_trip needs to be a directory which has four sysfs nodes named, active, passive, crit, hot. Rui, What do you think about this ? The only other way I see, is directly put sensorY_trip_[active/passive/hot/crit] which will create way too many nodes, under /sys/class/thermal/zoneX/. Thanks, Durga thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/8] Thermal: Add Thermal_trip sysfs node
This patch adds a thermal_trip directory under /sys/class/thermal/zoneX. This directory contains the trip point values for sensors bound to this zone. Signed-off-by: Durgadoss R --- drivers/thermal/thermal_sys.c | 237 - include/linux/thermal.h | 37 +++ 2 files changed, 272 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index b39bf97..29ec073 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -448,6 +448,22 @@ static void thermal_zone_device_check(struct work_struct *work) thermal_zone_device_update(tz); } +static int get_sensor_indx_by_kobj(struct thermal_zone *tz, const char *name) +{ + int i, indx = -EINVAL; + + mutex_lock(_list_lock); + for (i = 0; i < tz->sensor_indx; i++) { + if (!strnicmp(name, kobject_name(tz->kobj_trip[i]), + THERMAL_NAME_LENGTH)) { + indx = i; + break; + } + } + mutex_unlock(_list_lock); + return indx; +} + static void remove_sensor_from_zone(struct thermal_zone *tz, struct thermal_sensor *ts) { @@ -459,9 +475,15 @@ static void remove_sensor_from_zone(struct thermal_zone *tz, sysfs_remove_link(>device.kobj, kobject_name(>device.kobj)); + /* Delete this sensor's trip Kobject */ + kobject_del(tz->kobj_trip[indx]); + /* Shift the entries in the tz->sensors array */ - for (j = indx; j < MAX_SENSORS_PER_ZONE - 1; j++) + for (j = indx; j < MAX_SENSORS_PER_ZONE - 1; j++) { tz->sensors[j] = tz->sensors[j + 1]; + tz->sensor_trip[j] = tz->sensor_trip[j + 1]; + tz->kobj_trip[j] = tz->kobj_trip[j + 1]; + } tz->sensor_indx--; } @@ -875,6 +897,120 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf) return sprintf(buf, "%s\n", tz->governor->name); } +static ssize_t +active_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + int i, indx, ret = 0; + struct thermal_zone *tz; + struct device *dev; + + /* In this function, for +* /sys/class/thermal/zoneX/thermal_trip/sensorY: +* attr points to sysfs node 'active' +* kobj points to sensorY +* kobj->parent points to thermal_trip +* kobj->parent->parent points to zoneX +*/ + + /* Get the zone pointer */ + dev = container_of(kobj->parent->parent, struct device, kobj); + tz = to_zone(dev); + if (!tz) + return -EINVAL; + + /* +* We need this because in the sysfs tree, 'sensorY' is +* not really the sensor pointer. It just has the name +* 'sensorY'; whereas 'zoneX' is actually the zone pointer. +* This means container_of(kobj, struct device, kobj) will not +* provide the actual sensor pointer. +*/ + indx = get_sensor_indx_by_kobj(tz, kobject_name(kobj)); + if (indx < 0) + return indx; + + if (tz->sensor_trip[indx]->num_active_trips <= 0) + return sprintf(buf, "\n"); + + ret += sprintf(buf, "0x%x", tz->sensor_trip[indx]->active_trip_mask); + for (i = 0; i < tz->sensor_trip[indx]->num_active_trips; i++) { + ret += sprintf(buf + ret, " %d", + tz->sensor_trip[indx]->active_trips[i]); + } + + ret += sprintf(buf + ret, "\n"); + return ret; +} + +static ssize_t +ptrip_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + int i, indx, ret = 0; + struct thermal_zone *tz; + struct device *dev; + + /* Get the zone pointer */ + dev = container_of(kobj->parent->parent, struct device, kobj); + tz = to_zone(dev); + if (!tz) + return -EINVAL; + + indx = get_sensor_indx_by_kobj(tz, kobject_name(kobj)); + if (indx < 0) + return indx; + + if (tz->sensor_trip[indx]->num_passive_trips <= 0) + return sprintf(buf, "\n"); + + for (i = 0; i < tz->sensor_trip[indx]->num_passive_trips; i++) { + ret += sprintf(buf + ret, "%d ", + tz->sensor_trip[indx]->passive_trips[i]); + } + + ret += sprintf(buf + ret, "\n"); + return ret; +} + +static ssize_t +hot_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + int indx; + struct thermal_zone *tz; + struct device *dev; + + /* Get the zone pointer */ + dev = container_of(kobj->parent->parent, struct device, kobj); + tz = to_zone(dev); + if (!tz) + return -EINVAL; + + indx = get_sensor_indx_by_kobj(tz, kobject_name(kobj)); + if (indx < 0) + return indx; + + return
[PATCH 4/8] Thermal: Add Thermal_trip sysfs node
This patch adds a thermal_trip directory under /sys/class/thermal/zoneX. This directory contains the trip point values for sensors bound to this zone. Signed-off-by: Durgadoss R durgados...@intel.com --- drivers/thermal/thermal_sys.c | 237 - include/linux/thermal.h | 37 +++ 2 files changed, 272 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index b39bf97..29ec073 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -448,6 +448,22 @@ static void thermal_zone_device_check(struct work_struct *work) thermal_zone_device_update(tz); } +static int get_sensor_indx_by_kobj(struct thermal_zone *tz, const char *name) +{ + int i, indx = -EINVAL; + + mutex_lock(sensor_list_lock); + for (i = 0; i tz-sensor_indx; i++) { + if (!strnicmp(name, kobject_name(tz-kobj_trip[i]), + THERMAL_NAME_LENGTH)) { + indx = i; + break; + } + } + mutex_unlock(sensor_list_lock); + return indx; +} + static void remove_sensor_from_zone(struct thermal_zone *tz, struct thermal_sensor *ts) { @@ -459,9 +475,15 @@ static void remove_sensor_from_zone(struct thermal_zone *tz, sysfs_remove_link(tz-device.kobj, kobject_name(ts-device.kobj)); + /* Delete this sensor's trip Kobject */ + kobject_del(tz-kobj_trip[indx]); + /* Shift the entries in the tz-sensors array */ - for (j = indx; j MAX_SENSORS_PER_ZONE - 1; j++) + for (j = indx; j MAX_SENSORS_PER_ZONE - 1; j++) { tz-sensors[j] = tz-sensors[j + 1]; + tz-sensor_trip[j] = tz-sensor_trip[j + 1]; + tz-kobj_trip[j] = tz-kobj_trip[j + 1]; + } tz-sensor_indx--; } @@ -875,6 +897,120 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf) return sprintf(buf, %s\n, tz-governor-name); } +static ssize_t +active_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + int i, indx, ret = 0; + struct thermal_zone *tz; + struct device *dev; + + /* In this function, for +* /sys/class/thermal/zoneX/thermal_trip/sensorY: +* attr points to sysfs node 'active' +* kobj points to sensorY +* kobj-parent points to thermal_trip +* kobj-parent-parent points to zoneX +*/ + + /* Get the zone pointer */ + dev = container_of(kobj-parent-parent, struct device, kobj); + tz = to_zone(dev); + if (!tz) + return -EINVAL; + + /* +* We need this because in the sysfs tree, 'sensorY' is +* not really the sensor pointer. It just has the name +* 'sensorY'; whereas 'zoneX' is actually the zone pointer. +* This means container_of(kobj, struct device, kobj) will not +* provide the actual sensor pointer. +*/ + indx = get_sensor_indx_by_kobj(tz, kobject_name(kobj)); + if (indx 0) + return indx; + + if (tz-sensor_trip[indx]-num_active_trips = 0) + return sprintf(buf, Not available\n); + + ret += sprintf(buf, 0x%x, tz-sensor_trip[indx]-active_trip_mask); + for (i = 0; i tz-sensor_trip[indx]-num_active_trips; i++) { + ret += sprintf(buf + ret, %d, + tz-sensor_trip[indx]-active_trips[i]); + } + + ret += sprintf(buf + ret, \n); + return ret; +} + +static ssize_t +ptrip_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + int i, indx, ret = 0; + struct thermal_zone *tz; + struct device *dev; + + /* Get the zone pointer */ + dev = container_of(kobj-parent-parent, struct device, kobj); + tz = to_zone(dev); + if (!tz) + return -EINVAL; + + indx = get_sensor_indx_by_kobj(tz, kobject_name(kobj)); + if (indx 0) + return indx; + + if (tz-sensor_trip[indx]-num_passive_trips = 0) + return sprintf(buf, Not available\n); + + for (i = 0; i tz-sensor_trip[indx]-num_passive_trips; i++) { + ret += sprintf(buf + ret, %d , + tz-sensor_trip[indx]-passive_trips[i]); + } + + ret += sprintf(buf + ret, \n); + return ret; +} + +static ssize_t +hot_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + int indx; + struct thermal_zone *tz; + struct device *dev; + + /* Get the zone pointer */ + dev = container_of(kobj-parent-parent, struct device, kobj); + tz = to_zone(dev); + if (!tz) + return -EINVAL; + + indx = get_sensor_indx_by_kobj(tz, kobject_name(kobj)); + if (indx 0) + return indx; + + return