diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-07-07 16:23:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-07-07 16:23:13 -0400 |
commit | 448bfad8a185876ce8de484a921d49769972cad7 (patch) | |
tree | 2dd2648f31b2bf7c127734baae70df82ae5b1d0d | |
parent | 4c2f503aade27ebf12f5733a583d711f99dc5ec1 (diff) | |
parent | 4adccf9fc84aaf5e4d18442e163d549e0b603075 (diff) |
Merge branch 'for-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
Pull thermal fixes from Zhang Rui:
"Specifics:
- update Email address of Thermal subsystem maintainer Eduardo
Valentin.
- fix a problem that unloading thermal module results in kernel crash
because a non-exist device file is removed on thermal unload.
- fix a problem that critical trip point is set wrongly on latest
i.MX6 SOC and results in system critical shutdown.
- a couple of fixes to Tmon tool, of-thermal code and ti thermal
driver"
* 'for-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
tmon: set umask to a reasonable value
tmon: Check log file for common secuirty issues
tools/thermal: tmon: fix compilation errors when building statically
thermal: ti-soc-thermal: ti-bandgap.c: Cleaning up wrong address is checked
Thermal: imx: correct critical trip temperature setting
thermal: Bind cooling devices with the correct arguments
thermal: Add braces around suspect code
thermal: hwmon: Make the check for critical temp valid consistent
MAINTAINERS: Update Eduardo Valentin's email address
-rw-r--r-- | MAINTAINERS | 4 | ||||
-rw-r--r-- | drivers/thermal/imx_thermal.c | 18 | ||||
-rw-r--r-- | drivers/thermal/of-thermal.c | 7 | ||||
-rw-r--r-- | drivers/thermal/thermal_hwmon.c | 33 | ||||
-rw-r--r-- | drivers/thermal/ti-soc-thermal/ti-bandgap.c | 2 | ||||
-rw-r--r-- | tools/thermal/tmon/Makefile | 2 | ||||
-rw-r--r-- | tools/thermal/tmon/tmon.c | 26 |
7 files changed, 58 insertions, 34 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 6813d0aa5ecf..5eb2398a7fab 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -8984,7 +8984,7 @@ F: drivers/media/radio/radio-raremono.c | |||
8984 | 8984 | ||
8985 | THERMAL | 8985 | THERMAL |
8986 | M: Zhang Rui <rui.zhang@intel.com> | 8986 | M: Zhang Rui <rui.zhang@intel.com> |
8987 | M: Eduardo Valentin <eduardo.valentin@ti.com> | 8987 | M: Eduardo Valentin <edubezval@gmail.com> |
8988 | L: linux-pm@vger.kernel.org | 8988 | L: linux-pm@vger.kernel.org |
8989 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git | 8989 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git |
8990 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git | 8990 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git |
@@ -9011,7 +9011,7 @@ S: Maintained | |||
9011 | F: drivers/platform/x86/thinkpad_acpi.c | 9011 | F: drivers/platform/x86/thinkpad_acpi.c |
9012 | 9012 | ||
9013 | TI BANDGAP AND THERMAL DRIVER | 9013 | TI BANDGAP AND THERMAL DRIVER |
9014 | M: Eduardo Valentin <eduardo.valentin@ti.com> | 9014 | M: Eduardo Valentin <edubezval@gmail.com> |
9015 | L: linux-pm@vger.kernel.org | 9015 | L: linux-pm@vger.kernel.org |
9016 | S: Supported | 9016 | S: Supported |
9017 | F: drivers/thermal/ti-soc-thermal/ | 9017 | F: drivers/thermal/ti-soc-thermal/ |
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index a99c63152b8d..2c516f2eebed 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c | |||
@@ -306,7 +306,7 @@ static int imx_get_sensor_data(struct platform_device *pdev) | |||
306 | { | 306 | { |
307 | struct imx_thermal_data *data = platform_get_drvdata(pdev); | 307 | struct imx_thermal_data *data = platform_get_drvdata(pdev); |
308 | struct regmap *map; | 308 | struct regmap *map; |
309 | int t1, t2, n1, n2; | 309 | int t1, n1; |
310 | int ret; | 310 | int ret; |
311 | u32 val; | 311 | u32 val; |
312 | u64 temp64; | 312 | u64 temp64; |
@@ -333,14 +333,10 @@ static int imx_get_sensor_data(struct platform_device *pdev) | |||
333 | /* | 333 | /* |
334 | * Sensor data layout: | 334 | * Sensor data layout: |
335 | * [31:20] - sensor value @ 25C | 335 | * [31:20] - sensor value @ 25C |
336 | * [19:8] - sensor value of hot | ||
337 | * [7:0] - hot temperature value | ||
338 | * Use universal formula now and only need sensor value @ 25C | 336 | * Use universal formula now and only need sensor value @ 25C |
339 | * slope = 0.4297157 - (0.0015976 * 25C fuse) | 337 | * slope = 0.4297157 - (0.0015976 * 25C fuse) |
340 | */ | 338 | */ |
341 | n1 = val >> 20; | 339 | n1 = val >> 20; |
342 | n2 = (val & 0xfff00) >> 8; | ||
343 | t2 = val & 0xff; | ||
344 | t1 = 25; /* t1 always 25C */ | 340 | t1 = 25; /* t1 always 25C */ |
345 | 341 | ||
346 | /* | 342 | /* |
@@ -366,16 +362,16 @@ static int imx_get_sensor_data(struct platform_device *pdev) | |||
366 | data->c2 = n1 * data->c1 + 1000 * t1; | 362 | data->c2 = n1 * data->c1 + 1000 * t1; |
367 | 363 | ||
368 | /* | 364 | /* |
369 | * Set the default passive cooling trip point to 20 °C below the | 365 | * Set the default passive cooling trip point, |
370 | * maximum die temperature. Can be changed from userspace. | 366 | * can be changed from userspace. |
371 | */ | 367 | */ |
372 | data->temp_passive = 1000 * (t2 - 20); | 368 | data->temp_passive = IMX_TEMP_PASSIVE; |
373 | 369 | ||
374 | /* | 370 | /* |
375 | * The maximum die temperature is t2, let's give 5 °C cushion | 371 | * The maximum die temperature set to 20 C higher than |
376 | * for noise and possible temperature rise between measurements. | 372 | * IMX_TEMP_PASSIVE. |
377 | */ | 373 | */ |
378 | data->temp_critical = 1000 * (t2 - 5); | 374 | data->temp_critical = 1000 * 20 + data->temp_passive; |
379 | 375 | ||
380 | return 0; | 376 | return 0; |
381 | } | 377 | } |
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 04b1be7fa018..4b2b999b7611 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c | |||
@@ -156,8 +156,8 @@ static int of_thermal_bind(struct thermal_zone_device *thermal, | |||
156 | 156 | ||
157 | ret = thermal_zone_bind_cooling_device(thermal, | 157 | ret = thermal_zone_bind_cooling_device(thermal, |
158 | tbp->trip_id, cdev, | 158 | tbp->trip_id, cdev, |
159 | tbp->min, | 159 | tbp->max, |
160 | tbp->max); | 160 | tbp->min); |
161 | if (ret) | 161 | if (ret) |
162 | return ret; | 162 | return ret; |
163 | } | 163 | } |
@@ -712,11 +712,12 @@ thermal_of_build_thermal_zone(struct device_node *np) | |||
712 | } | 712 | } |
713 | 713 | ||
714 | i = 0; | 714 | i = 0; |
715 | for_each_child_of_node(child, gchild) | 715 | for_each_child_of_node(child, gchild) { |
716 | ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++], | 716 | ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++], |
717 | tz->trips, tz->ntrips); | 717 | tz->trips, tz->ntrips); |
718 | if (ret) | 718 | if (ret) |
719 | goto free_tbps; | 719 | goto free_tbps; |
720 | } | ||
720 | 721 | ||
721 | finish: | 722 | finish: |
722 | of_node_put(child); | 723 | of_node_put(child); |
diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c index fdb07199d9c2..1967bee4f076 100644 --- a/drivers/thermal/thermal_hwmon.c +++ b/drivers/thermal/thermal_hwmon.c | |||
@@ -140,6 +140,12 @@ thermal_hwmon_lookup_temp(const struct thermal_hwmon_device *hwmon, | |||
140 | return NULL; | 140 | return NULL; |
141 | } | 141 | } |
142 | 142 | ||
143 | static bool thermal_zone_crit_temp_valid(struct thermal_zone_device *tz) | ||
144 | { | ||
145 | unsigned long temp; | ||
146 | return tz->ops->get_crit_temp && !tz->ops->get_crit_temp(tz, &temp); | ||
147 | } | ||
148 | |||
143 | int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) | 149 | int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) |
144 | { | 150 | { |
145 | struct thermal_hwmon_device *hwmon; | 151 | struct thermal_hwmon_device *hwmon; |
@@ -189,21 +195,18 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) | |||
189 | if (result) | 195 | if (result) |
190 | goto free_temp_mem; | 196 | goto free_temp_mem; |
191 | 197 | ||
192 | if (tz->ops->get_crit_temp) { | 198 | if (thermal_zone_crit_temp_valid(tz)) { |
193 | unsigned long temperature; | 199 | snprintf(temp->temp_crit.name, |
194 | if (!tz->ops->get_crit_temp(tz, &temperature)) { | 200 | sizeof(temp->temp_crit.name), |
195 | snprintf(temp->temp_crit.name, | ||
196 | sizeof(temp->temp_crit.name), | ||
197 | "temp%d_crit", hwmon->count); | 201 | "temp%d_crit", hwmon->count); |
198 | temp->temp_crit.attr.attr.name = temp->temp_crit.name; | 202 | temp->temp_crit.attr.attr.name = temp->temp_crit.name; |
199 | temp->temp_crit.attr.attr.mode = 0444; | 203 | temp->temp_crit.attr.attr.mode = 0444; |
200 | temp->temp_crit.attr.show = temp_crit_show; | 204 | temp->temp_crit.attr.show = temp_crit_show; |
201 | sysfs_attr_init(&temp->temp_crit.attr.attr); | 205 | sysfs_attr_init(&temp->temp_crit.attr.attr); |
202 | result = device_create_file(hwmon->device, | 206 | result = device_create_file(hwmon->device, |
203 | &temp->temp_crit.attr); | 207 | &temp->temp_crit.attr); |
204 | if (result) | 208 | if (result) |
205 | goto unregister_input; | 209 | goto unregister_input; |
206 | } | ||
207 | } | 210 | } |
208 | 211 | ||
209 | mutex_lock(&thermal_hwmon_list_lock); | 212 | mutex_lock(&thermal_hwmon_list_lock); |
@@ -250,7 +253,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) | |||
250 | } | 253 | } |
251 | 254 | ||
252 | device_remove_file(hwmon->device, &temp->temp_input.attr); | 255 | device_remove_file(hwmon->device, &temp->temp_input.attr); |
253 | if (tz->ops->get_crit_temp) | 256 | if (thermal_zone_crit_temp_valid(tz)) |
254 | device_remove_file(hwmon->device, &temp->temp_crit.attr); | 257 | device_remove_file(hwmon->device, &temp->temp_crit.attr); |
255 | 258 | ||
256 | mutex_lock(&thermal_hwmon_list_lock); | 259 | mutex_lock(&thermal_hwmon_list_lock); |
diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c index a1271b55103a..634b6ce0e63a 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c | |||
@@ -1155,7 +1155,7 @@ static struct ti_bandgap *ti_bandgap_build(struct platform_device *pdev) | |||
1155 | /* register shadow for context save and restore */ | 1155 | /* register shadow for context save and restore */ |
1156 | bgp->regval = devm_kzalloc(&pdev->dev, sizeof(*bgp->regval) * | 1156 | bgp->regval = devm_kzalloc(&pdev->dev, sizeof(*bgp->regval) * |
1157 | bgp->conf->sensor_count, GFP_KERNEL); | 1157 | bgp->conf->sensor_count, GFP_KERNEL); |
1158 | if (!bgp) { | 1158 | if (!bgp->regval) { |
1159 | dev_err(&pdev->dev, "Unable to allocate mem for driver ref\n"); | 1159 | dev_err(&pdev->dev, "Unable to allocate mem for driver ref\n"); |
1160 | return ERR_PTR(-ENOMEM); | 1160 | return ERR_PTR(-ENOMEM); |
1161 | } | 1161 | } |
diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile index 447321104ec0..e775adcbd29f 100644 --- a/tools/thermal/tmon/Makefile +++ b/tools/thermal/tmon/Makefile | |||
@@ -21,7 +21,7 @@ OBJS = tmon.o tui.o sysfs.o pid.o | |||
21 | OBJS += | 21 | OBJS += |
22 | 22 | ||
23 | tmon: $(OBJS) Makefile tmon.h | 23 | tmon: $(OBJS) Makefile tmon.h |
24 | $(CC) ${CFLAGS} $(LDFLAGS) $(OBJS) -o $(TARGET) -lm -lpanel -lncursesw -lpthread | 24 | $(CC) ${CFLAGS} $(LDFLAGS) $(OBJS) -o $(TARGET) -lm -lpanel -lncursesw -ltinfo -lpthread |
25 | 25 | ||
26 | valgrind: tmon | 26 | valgrind: tmon |
27 | sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null | 27 | sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null |
diff --git a/tools/thermal/tmon/tmon.c b/tools/thermal/tmon/tmon.c index b30f531173e4..09b7c3218334 100644 --- a/tools/thermal/tmon/tmon.c +++ b/tools/thermal/tmon/tmon.c | |||
@@ -142,6 +142,7 @@ static void start_syslog(void) | |||
142 | static void prepare_logging(void) | 142 | static void prepare_logging(void) |
143 | { | 143 | { |
144 | int i; | 144 | int i; |
145 | struct stat logstat; | ||
145 | 146 | ||
146 | if (!logging) | 147 | if (!logging) |
147 | return; | 148 | return; |
@@ -152,6 +153,29 @@ static void prepare_logging(void) | |||
152 | return; | 153 | return; |
153 | } | 154 | } |
154 | 155 | ||
156 | if (lstat(TMON_LOG_FILE, &logstat) < 0) { | ||
157 | syslog(LOG_ERR, "Unable to stat log file %s\n", TMON_LOG_FILE); | ||
158 | fclose(tmon_log); | ||
159 | tmon_log = NULL; | ||
160 | return; | ||
161 | } | ||
162 | |||
163 | /* The log file must be a regular file owned by us */ | ||
164 | if (S_ISLNK(logstat.st_mode)) { | ||
165 | syslog(LOG_ERR, "Log file is a symlink. Will not log\n"); | ||
166 | fclose(tmon_log); | ||
167 | tmon_log = NULL; | ||
168 | return; | ||
169 | } | ||
170 | |||
171 | if (logstat.st_uid != getuid()) { | ||
172 | syslog(LOG_ERR, "We don't own the log file. Not logging\n"); | ||
173 | fclose(tmon_log); | ||
174 | tmon_log = NULL; | ||
175 | return; | ||
176 | } | ||
177 | |||
178 | |||
155 | fprintf(tmon_log, "#----------- THERMAL SYSTEM CONFIG -------------\n"); | 179 | fprintf(tmon_log, "#----------- THERMAL SYSTEM CONFIG -------------\n"); |
156 | for (i = 0; i < ptdata.nr_tz_sensor; i++) { | 180 | for (i = 0; i < ptdata.nr_tz_sensor; i++) { |
157 | char binding_str[33]; /* size of long + 1 */ | 181 | char binding_str[33]; /* size of long + 1 */ |
@@ -331,7 +355,7 @@ static void start_daemon_mode() | |||
331 | disable_tui(); | 355 | disable_tui(); |
332 | 356 | ||
333 | /* change the file mode mask */ | 357 | /* change the file mode mask */ |
334 | umask(0); | 358 | umask(S_IWGRP | S_IWOTH); |
335 | 359 | ||
336 | /* new SID for the daemon process */ | 360 | /* new SID for the daemon process */ |
337 | sid = setsid(); | 361 | sid = setsid(); |