Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'fixes-for-4.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal

Pull thermal management fixes from Eduardo Valentin:
"Specifics:

- Several fixes in tmon tool.

- Fixes in intel int340x for _ART and _TRT tables.

- Add id for Avoton SoC into powerclamp driver.

- Fixes in RCAR thermal driver to remove race conditions and fix fail
path

- Fixes in TI thermal driver: removal of unnecessary code and build
fix if !CONFIG_PM_SLEEP

- Cleanups in exynos thermal driver

- Add stubs for include/linux/thermal.h. Now drivers using thermal
calls but that also work without CONFIG_THERMAL will be able to
compile for systems that don't care about thermal.

Note: I am sending this pull on Rui's behalf while he fixes issues in
his Linux box"

* 'fixes-for-4.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal:
thermal: int340x_thermal: Ignore missing _ART, _TRT tables
thermal/intel_powerclamp: add id for Avoton SoC
tools/thermal: tmon: silence 'set but not used' warnings
tools/thermal: tmon: use pkg-config to determine library dependencies
tools/thermal: tmon: support cross-compiling
tools/thermal: tmon: add .gitignore
tools/thermal: tmon: fixup tui windowing calculations
tools/thermal: tmon: tui: don't hard-code dialog window size assumptions
tools/thermal: tmon: add min/max macros
tools/thermal: tmon: add --target-temp parameter
thermal: exynos: Clean-up code to use oneline entry for exynos compatible table
thermal: rcar: Make error and remove paths symmetrical with init
thermal: rcar: Fix race condition between init and interrupt
thermal: Introduce dummy functions when thermal is not defined
ti-soc-thermal: Delete an unnecessary check before the function call "cpufreq_cooling_unregister"
thermal: ti-soc-thermal: bandgap: Fix build warning if !CONFIG_PM_SLEEP

+144 -66
+4 -6
drivers/thermal/int340x_thermal/int3400_thermal.c
··· 262 262 result = acpi_parse_art(priv->adev->handle, &priv->art_count, 263 263 &priv->arts, true); 264 264 if (result) 265 - goto free_priv; 266 - 265 + dev_dbg(&pdev->dev, "_ART table parsing error\n"); 267 266 268 267 result = acpi_parse_trt(priv->adev->handle, &priv->trt_count, 269 268 &priv->trts, true); 270 269 if (result) 271 - goto free_art; 270 + dev_dbg(&pdev->dev, "_TRT table parsing error\n"); 272 271 273 272 platform_set_drvdata(pdev, priv); 274 273 ··· 280 281 &int3400_thermal_params, 0, 0); 281 282 if (IS_ERR(priv->thermal)) { 282 283 result = PTR_ERR(priv->thermal); 283 - goto free_trt; 284 + goto free_art_trt; 284 285 } 285 286 286 287 priv->rel_misc_dev_res = acpi_thermal_rel_misc_device_add( ··· 294 295 295 296 free_zone: 296 297 thermal_zone_device_unregister(priv->thermal); 297 - free_trt: 298 + free_art_trt: 298 299 kfree(priv->trts); 299 - free_art: 300 300 kfree(priv->arts); 301 301 free_priv: 302 302 kfree(priv);
+1
drivers/thermal/intel_powerclamp.c
··· 688 688 { X86_VENDOR_INTEL, 6, 0x45}, 689 689 { X86_VENDOR_INTEL, 6, 0x46}, 690 690 { X86_VENDOR_INTEL, 6, 0x4c}, 691 + { X86_VENDOR_INTEL, 6, 0x4d}, 691 692 { X86_VENDOR_INTEL, 6, 0x56}, 692 693 {} 693 694 };
+11 -15
drivers/thermal/rcar_thermal.c
··· 387 387 388 388 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 389 389 if (irq) { 390 - int ret; 391 - 392 390 /* 393 391 * platform has IRQ support. 394 392 * Then, driver uses common registers 395 - */ 396 - 397 - ret = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0, 398 - dev_name(dev), common); 399 - if (ret) { 400 - dev_err(dev, "irq request failed\n "); 401 - return ret; 402 - } 403 - 404 - /* 405 393 * rcar_has_irq_support() will be enabled 406 394 */ 407 395 res = platform_get_resource(pdev, IORESOURCE_MEM, mres++); ··· 444 456 } 445 457 446 458 /* enable temperature comparation */ 447 - if (irq) 459 + if (irq) { 460 + ret = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0, 461 + dev_name(dev), common); 462 + if (ret) { 463 + dev_err(dev, "irq request failed\n "); 464 + goto error_unregister; 465 + } 466 + 448 467 rcar_thermal_common_write(common, ENR, enr_bits); 468 + } 449 469 450 470 platform_set_drvdata(pdev, common); 451 471 ··· 463 467 464 468 error_unregister: 465 469 rcar_thermal_for_each_priv(priv, common) { 466 - thermal_zone_device_unregister(priv->zone); 467 470 if (rcar_has_irq_support(priv)) 468 471 rcar_thermal_irq_disable(priv); 472 + thermal_zone_device_unregister(priv->zone); 469 473 } 470 474 471 475 pm_runtime_put(dev); ··· 481 485 struct rcar_thermal_priv *priv; 482 486 483 487 rcar_thermal_for_each_priv(priv, common) { 484 - thermal_zone_device_unregister(priv->zone); 485 488 if (rcar_has_irq_support(priv)) 486 489 rcar_thermal_irq_disable(priv); 490 + thermal_zone_device_unregister(priv->zone); 487 491 } 488 492 489 493 pm_runtime_put(dev);
+10 -28
drivers/thermal/samsung/exynos_tmu.c
··· 918 918 } 919 919 920 920 static const struct of_device_id exynos_tmu_match[] = { 921 - { 922 - .compatible = "samsung,exynos3250-tmu", 923 - }, 924 - { 925 - .compatible = "samsung,exynos4210-tmu", 926 - }, 927 - { 928 - .compatible = "samsung,exynos4412-tmu", 929 - }, 930 - { 931 - .compatible = "samsung,exynos5250-tmu", 932 - }, 933 - { 934 - .compatible = "samsung,exynos5260-tmu", 935 - }, 936 - { 937 - .compatible = "samsung,exynos5420-tmu", 938 - }, 939 - { 940 - .compatible = "samsung,exynos5420-tmu-ext-triminfo", 941 - }, 942 - { 943 - .compatible = "samsung,exynos5440-tmu", 944 - }, 945 - { 946 - .compatible = "samsung,exynos7-tmu", 947 - }, 948 - {}, 921 + { .compatible = "samsung,exynos3250-tmu", }, 922 + { .compatible = "samsung,exynos4210-tmu", }, 923 + { .compatible = "samsung,exynos4412-tmu", }, 924 + { .compatible = "samsung,exynos5250-tmu", }, 925 + { .compatible = "samsung,exynos5260-tmu", }, 926 + { .compatible = "samsung,exynos5420-tmu", }, 927 + { .compatible = "samsung,exynos5420-tmu-ext-triminfo", }, 928 + { .compatible = "samsung,exynos5440-tmu", }, 929 + { .compatible = "samsung,exynos7-tmu", }, 930 + { /* sentinel */ }, 949 931 }; 950 932 MODULE_DEVICE_TABLE(of, exynos_tmu_match); 951 933
+1 -1
drivers/thermal/ti-soc-thermal/ti-bandgap.c
··· 1402 1402 return 0; 1403 1403 } 1404 1404 1405 - #ifdef CONFIG_PM 1405 + #ifdef CONFIG_PM_SLEEP 1406 1406 static int ti_bandgap_save_ctxt(struct ti_bandgap *bgp) 1407 1407 { 1408 1408 int i;
+1 -1
drivers/thermal/ti-soc-thermal/ti-thermal-common.c
··· 429 429 430 430 data = ti_bandgap_get_sensor_data(bgp, id); 431 431 432 - if (data && data->cool_dev) 432 + if (data) 433 433 cpufreq_cooling_unregister(data->cool_dev); 434 434 435 435 return 0;
+53 -1
include/linux/thermal.h
··· 314 314 } 315 315 316 316 #endif 317 + 318 + #if IS_ENABLED(CONFIG_THERMAL) 317 319 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int, 318 320 void *, struct thermal_zone_device_ops *, 319 321 const struct thermal_zone_params *, int, int); ··· 342 340 struct thermal_cooling_device *, int); 343 341 void thermal_cdev_update(struct thermal_cooling_device *); 344 342 void thermal_notify_framework(struct thermal_zone_device *, int); 343 + #else 344 + static inline struct thermal_zone_device *thermal_zone_device_register( 345 + const char *type, int trips, int mask, void *devdata, 346 + struct thermal_zone_device_ops *ops, 347 + const struct thermal_zone_params *tzp, 348 + int passive_delay, int polling_delay) 349 + { return ERR_PTR(-ENODEV); } 350 + static inline void thermal_zone_device_unregister( 351 + struct thermal_zone_device *tz) 352 + { } 353 + static inline int thermal_zone_bind_cooling_device( 354 + struct thermal_zone_device *tz, int trip, 355 + struct thermal_cooling_device *cdev, 356 + unsigned long upper, unsigned long lower) 357 + { return -ENODEV; } 358 + static inline int thermal_zone_unbind_cooling_device( 359 + struct thermal_zone_device *tz, int trip, 360 + struct thermal_cooling_device *cdev) 361 + { return -ENODEV; } 362 + static inline void thermal_zone_device_update(struct thermal_zone_device *tz) 363 + { } 364 + static inline struct thermal_cooling_device * 365 + thermal_cooling_device_register(char *type, void *devdata, 366 + const struct thermal_cooling_device_ops *ops) 367 + { return ERR_PTR(-ENODEV); } 368 + static inline struct thermal_cooling_device * 369 + thermal_of_cooling_device_register(struct device_node *np, 370 + char *type, void *devdata, const struct thermal_cooling_device_ops *ops) 371 + { return ERR_PTR(-ENODEV); } 372 + static inline void thermal_cooling_device_unregister( 373 + struct thermal_cooling_device *cdev) 374 + { } 375 + static inline struct thermal_zone_device *thermal_zone_get_zone_by_name( 376 + const char *name) 377 + { return ERR_PTR(-ENODEV); } 378 + static inline int thermal_zone_get_temp( 379 + struct thermal_zone_device *tz, unsigned long *temp) 380 + { return -ENODEV; } 381 + static inline int get_tz_trend(struct thermal_zone_device *tz, int trip) 382 + { return -ENODEV; } 383 + static inline struct thermal_instance * 384 + get_thermal_instance(struct thermal_zone_device *tz, 385 + struct thermal_cooling_device *cdev, int trip) 386 + { return ERR_PTR(-ENODEV); } 387 + static inline void thermal_cdev_update(struct thermal_cooling_device *cdev) 388 + { } 389 + static inline void thermal_notify_framework(struct thermal_zone_device *tz, 390 + int trip) 391 + { } 392 + #endif /* CONFIG_THERMAL */ 345 393 346 - #ifdef CONFIG_NET 394 + #if defined(CONFIG_NET) && IS_ENABLED(CONFIG_THERMAL) 347 395 extern int thermal_generate_netlink_event(struct thermal_zone_device *tz, 348 396 enum events event); 349 397 #else
+1
tools/thermal/tmon/.gitignore
··· 1 + /tmon
+12 -3
tools/thermal/tmon/Makefile
··· 2 2 3 3 BINDIR=usr/bin 4 4 WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int 5 - CFLAGS= -O1 ${WARNFLAGS} -fstack-protector 6 - CC=gcc 5 + CFLAGS+= -O1 ${WARNFLAGS} -fstack-protector 6 + CC=$(CROSS_COMPILE)gcc 7 7 8 8 CFLAGS+=-D VERSION=\"$(VERSION)\" 9 9 LDFLAGS+= ··· 16 16 CONFIG_FILE= 17 17 CONFIG_PATH= 18 18 19 + # Static builds might require -ltinfo, for instance 20 + ifneq ($(findstring -static, $(LDFLAGS)),) 21 + STATIC := --static 22 + endif 23 + 24 + TMON_LIBS=-lm -lpthread 25 + TMON_LIBS += $(shell pkg-config --libs $(STATIC) panelw ncursesw 2> /dev/null || \ 26 + pkg-config --libs $(STATIC) panel ncurses 2> /dev/null || \ 27 + echo -lpanel -lncurses) 19 28 20 29 OBJS = tmon.o tui.o sysfs.o pid.o 21 30 OBJS += 22 31 23 32 tmon: $(OBJS) Makefile tmon.h 24 - $(CC) ${CFLAGS} $(LDFLAGS) $(OBJS) -o $(TARGET) -lm -lpanel -lncursesw -ltinfo -lpthread 33 + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET) $(TMON_LIBS) 25 34 26 35 valgrind: tmon 27 36 sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null
+2
tools/thermal/tmon/tmon.8
··· 55 55 .PP 56 56 The \fB-t --time-interval\fP option sets the polling interval in seconds 57 57 .PP 58 + The \fB-T --target-temp\fP option sets the initial target temperature 59 + .PP 58 60 The \fB-v --version\fP option shows the version of \fBtmon \fP 59 61 .PP 60 62 The \fB-z --zone\fP option sets the target therma zone instance to be controlled
+12 -2
tools/thermal/tmon/tmon.c
··· 64 64 printf(" -h, --help show this help message\n"); 65 65 printf(" -l, --log log data to /var/tmp/tmon.log\n"); 66 66 printf(" -t, --time-interval sampling time interval, > 1 sec.\n"); 67 + printf(" -T, --target-temp initial target temperature\n"); 67 68 printf(" -v, --version show version\n"); 68 69 printf(" -z, --zone target thermal zone id\n"); 69 70 ··· 220 219 { "control", 1, NULL, 'c' }, 221 220 { "daemon", 0, NULL, 'd' }, 222 221 { "time-interval", 1, NULL, 't' }, 222 + { "target-temp", 1, NULL, 'T' }, 223 223 { "log", 0, NULL, 'l' }, 224 224 { "help", 0, NULL, 'h' }, 225 225 { "version", 0, NULL, 'v' }, ··· 233 231 { 234 232 int err = 0; 235 233 int id2 = 0, c; 236 - double yk = 0.0; /* controller output */ 234 + double yk = 0.0, temp; /* controller output */ 237 235 int target_tz_index; 238 236 239 237 if (geteuid() != 0) { ··· 241 239 exit(EXIT_FAILURE); 242 240 } 243 241 244 - while ((c = getopt_long(argc, argv, "c:dlht:vgz:", opts, &id2)) != -1) { 242 + while ((c = getopt_long(argc, argv, "c:dlht:T:vgz:", opts, &id2)) != -1) { 245 243 switch (c) { 246 244 case 'c': 247 245 no_control = 0; ··· 255 253 ticktime = strtod(optarg, NULL); 256 254 if (ticktime < 1) 257 255 ticktime = 1; 256 + break; 257 + case 'T': 258 + temp = strtod(optarg, NULL); 259 + if (temp < 0) { 260 + fprintf(stderr, "error: temperature must be positive\n"); 261 + return 1; 262 + } 263 + target_temp_user = temp; 258 264 break; 259 265 case 'l': 260 266 printf("Logging data to /var/tmp/tmon.log\n");
+36 -9
tools/thermal/tmon/tui.c
··· 30 30 31 31 #include "tmon.h" 32 32 33 + #define min(x, y) ({ \ 34 + typeof(x) _min1 = (x); \ 35 + typeof(y) _min2 = (y); \ 36 + (void) (&_min1 == &_min2); \ 37 + _min1 < _min2 ? _min1 : _min2; }) 38 + 39 + #define max(x, y) ({ \ 40 + typeof(x) _max1 = (x); \ 41 + typeof(y) _max2 = (y); \ 42 + (void) (&_max1 == &_max2); \ 43 + _max1 > _max2 ? _max1 : _max2; }) 44 + 33 45 static PANEL *data_panel; 34 46 static PANEL *dialogue_panel; 35 47 static PANEL *top; ··· 110 98 wrefresh(status_bar_window); 111 99 } 112 100 101 + /* wrap at 5 */ 102 + #define DIAG_DEV_ROWS 5 103 + /* 104 + * list cooling devices + "set temp" entry; wraps after 5 rows, if they fit 105 + */ 106 + static int diag_dev_rows(void) 107 + { 108 + int entries = ptdata.nr_cooling_dev + 1; 109 + int rows = max(DIAG_DEV_ROWS, (entries + 1) / 2); 110 + return min(rows, entries); 111 + } 112 + 113 113 void setup_windows(void) 114 114 { 115 115 int y_begin = 1; ··· 146 122 * dialogue window is a pop-up, when needed it lays on top of cdev win 147 123 */ 148 124 149 - dialogue_window = subwin(stdscr, ptdata.nr_cooling_dev+5, maxx-50, 125 + dialogue_window = subwin(stdscr, diag_dev_rows() + 5, maxx-50, 150 126 DIAG_Y, DIAG_X); 151 127 152 128 thermal_data_window = subwin(stdscr, ptdata.nr_tz_sensor * ··· 282 258 } 283 259 284 260 const char DIAG_TITLE[] = "[ TUNABLES ]"; 285 - #define DIAG_DEV_ROWS 5 286 261 void show_dialogue(void) 287 262 { 288 263 int j, x = 0, y = 0; 264 + int rows, cols; 289 265 WINDOW *w = dialogue_window; 290 266 291 267 if (tui_disabled || !w) 292 268 return; 269 + 270 + getmaxyx(w, rows, cols); 271 + 272 + /* Silence compiler 'unused' warnings */ 273 + (void)cols; 293 274 294 275 werase(w); 295 276 box(w, 0, 0); 296 277 mvwprintw(w, 0, maxx/4, DIAG_TITLE); 297 278 /* list all the available tunables */ 298 279 for (j = 0; j <= ptdata.nr_cooling_dev; j++) { 299 - y = j % DIAG_DEV_ROWS; 280 + y = j % diag_dev_rows(); 300 281 if (y == 0 && j != 0) 301 282 x += 20; 302 283 if (j == ptdata.nr_cooling_dev) ··· 312 283 ptdata.cdi[j].type, ptdata.cdi[j].instance); 313 284 } 314 285 wattron(w, A_BOLD); 315 - mvwprintw(w, DIAG_DEV_ROWS+1, 1, "Enter Choice [A-Z]?"); 286 + mvwprintw(w, diag_dev_rows()+1, 1, "Enter Choice [A-Z]?"); 316 287 wattroff(w, A_BOLD); 317 - /* y size of dialogue win is nr cdev + 5, so print legend 318 - * at the bottom line 319 - */ 320 - mvwprintw(w, ptdata.nr_cooling_dev+3, 1, 288 + /* print legend at the bottom line */ 289 + mvwprintw(w, rows - 2, 1, 321 290 "Legend: A=Active, P=Passive, C=Critical"); 322 291 323 292 wrefresh(dialogue_window); ··· 464 437 snprintf(buf, sizeof(buf), "New Value for %.10s-%2d: ", 465 438 ptdata.cdi[cdev_id].type, 466 439 ptdata.cdi[cdev_id].instance); 467 - write_dialogue_win(buf, DIAG_DEV_ROWS+2, 2); 440 + write_dialogue_win(buf, diag_dev_rows() + 2, 2); 468 441 handle_input_val(cdev_id); 469 442 } else { 470 443 snprintf(buf, sizeof(buf), "Invalid selection %d", ch);