Skip to content

Commit

Permalink
Merge branch 'fixes-for-4.0-rc2' of git://git.kernel.org/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x/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
  • Loading branch information
Linus Torvalds committed Mar 2, 2015
2 parents 1a6f77a + 5912e26 commit 10d6dfc
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 67 deletions.
10 changes: 4 additions & 6 deletions drivers/thermal/int340x_thermal/int3400_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,12 @@ static int int3400_thermal_probe(struct platform_device *pdev)
result = acpi_parse_art(priv->adev->handle, &priv->art_count,
&priv->arts, true);
if (result)
goto free_priv;

dev_dbg(&pdev->dev, "_ART table parsing error\n");

result = acpi_parse_trt(priv->adev->handle, &priv->trt_count,
&priv->trts, true);
if (result)
goto free_art;
dev_dbg(&pdev->dev, "_TRT table parsing error\n");

platform_set_drvdata(pdev, priv);

Expand All @@ -281,7 +280,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)
&int3400_thermal_params, 0, 0);
if (IS_ERR(priv->thermal)) {
result = PTR_ERR(priv->thermal);
goto free_trt;
goto free_art_trt;
}

priv->rel_misc_dev_res = acpi_thermal_rel_misc_device_add(
Expand All @@ -295,9 +294,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)

free_zone:
thermal_zone_device_unregister(priv->thermal);
free_trt:
free_art_trt:
kfree(priv->trts);
free_art:
kfree(priv->arts);
free_priv:
kfree(priv);
Expand Down
1 change: 1 addition & 0 deletions drivers/thermal/intel_powerclamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ static const struct x86_cpu_id intel_powerclamp_ids[] = {
{ X86_VENDOR_INTEL, 6, 0x45},
{ X86_VENDOR_INTEL, 6, 0x46},
{ X86_VENDOR_INTEL, 6, 0x4c},
{ X86_VENDOR_INTEL, 6, 0x4d},
{ X86_VENDOR_INTEL, 6, 0x56},
{}
};
Expand Down
26 changes: 11 additions & 15 deletions drivers/thermal/rcar_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,21 +387,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)

irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (irq) {
int ret;

/*
* platform has IRQ support.
* Then, driver uses common registers
*/

ret = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0,
dev_name(dev), common);
if (ret) {
dev_err(dev, "irq request failed\n ");
return ret;
}

/*
* rcar_has_irq_support() will be enabled
*/
res = platform_get_resource(pdev, IORESOURCE_MEM, mres++);
Expand Down Expand Up @@ -456,8 +444,16 @@ static int rcar_thermal_probe(struct platform_device *pdev)
}

/* enable temperature comparation */
if (irq)
if (irq) {
ret = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0,
dev_name(dev), common);
if (ret) {
dev_err(dev, "irq request failed\n ");
goto error_unregister;
}

rcar_thermal_common_write(common, ENR, enr_bits);
}

platform_set_drvdata(pdev, common);

Expand All @@ -467,9 +463,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)

error_unregister:
rcar_thermal_for_each_priv(priv, common) {
thermal_zone_device_unregister(priv->zone);
if (rcar_has_irq_support(priv))
rcar_thermal_irq_disable(priv);
thermal_zone_device_unregister(priv->zone);
}

pm_runtime_put(dev);
Expand All @@ -485,9 +481,9 @@ static int rcar_thermal_remove(struct platform_device *pdev)
struct rcar_thermal_priv *priv;

rcar_thermal_for_each_priv(priv, common) {
thermal_zone_device_unregister(priv->zone);
if (rcar_has_irq_support(priv))
rcar_thermal_irq_disable(priv);
thermal_zone_device_unregister(priv->zone);
}

pm_runtime_put(dev);
Expand Down
38 changes: 10 additions & 28 deletions drivers/thermal/samsung/exynos_tmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,34 +918,16 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
}

static const struct of_device_id exynos_tmu_match[] = {
{
.compatible = "samsung,exynos3250-tmu",
},
{
.compatible = "samsung,exynos4210-tmu",
},
{
.compatible = "samsung,exynos4412-tmu",
},
{
.compatible = "samsung,exynos5250-tmu",
},
{
.compatible = "samsung,exynos5260-tmu",
},
{
.compatible = "samsung,exynos5420-tmu",
},
{
.compatible = "samsung,exynos5420-tmu-ext-triminfo",
},
{
.compatible = "samsung,exynos5440-tmu",
},
{
.compatible = "samsung,exynos7-tmu",
},
{},
{ .compatible = "samsung,exynos3250-tmu", },
{ .compatible = "samsung,exynos4210-tmu", },
{ .compatible = "samsung,exynos4412-tmu", },
{ .compatible = "samsung,exynos5250-tmu", },
{ .compatible = "samsung,exynos5260-tmu", },
{ .compatible = "samsung,exynos5420-tmu", },
{ .compatible = "samsung,exynos5420-tmu-ext-triminfo", },
{ .compatible = "samsung,exynos5440-tmu", },
{ .compatible = "samsung,exynos7-tmu", },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, exynos_tmu_match);

Expand Down
2 changes: 1 addition & 1 deletion drivers/thermal/ti-soc-thermal/ti-bandgap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ int ti_bandgap_remove(struct platform_device *pdev)
return 0;
}

#ifdef CONFIG_PM
#ifdef CONFIG_PM_SLEEP
static int ti_bandgap_save_ctxt(struct ti_bandgap *bgp)
{
int i;
Expand Down
2 changes: 1 addition & 1 deletion drivers/thermal/ti-soc-thermal/ti-thermal-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ int ti_thermal_unregister_cpu_cooling(struct ti_bandgap *bgp, int id)

data = ti_bandgap_get_sensor_data(bgp, id);

if (data && data->cool_dev)
if (data)
cpufreq_cooling_unregister(data->cool_dev);

return 0;
Expand Down
56 changes: 54 additions & 2 deletions include/linux/thermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
}

#endif

#if IS_ENABLED(CONFIG_THERMAL)
struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
void *, struct thermal_zone_device_ops *,
const struct thermal_zone_params *, int, int);
Expand All @@ -340,8 +342,58 @@ struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
struct thermal_cooling_device *, int);
void thermal_cdev_update(struct thermal_cooling_device *);
void thermal_notify_framework(struct thermal_zone_device *, int);

#ifdef CONFIG_NET
#else
static inline struct thermal_zone_device *thermal_zone_device_register(
const char *type, int trips, int mask, void *devdata,
struct thermal_zone_device_ops *ops,
const struct thermal_zone_params *tzp,
int passive_delay, int polling_delay)
{ return ERR_PTR(-ENODEV); }
static inline void thermal_zone_device_unregister(
struct thermal_zone_device *tz)
{ }
static inline int thermal_zone_bind_cooling_device(
struct thermal_zone_device *tz, int trip,
struct thermal_cooling_device *cdev,
unsigned long upper, unsigned long lower)
{ return -ENODEV; }
static inline int thermal_zone_unbind_cooling_device(
struct thermal_zone_device *tz, int trip,
struct thermal_cooling_device *cdev)
{ return -ENODEV; }
static inline void thermal_zone_device_update(struct thermal_zone_device *tz)
{ }
static inline struct thermal_cooling_device *
thermal_cooling_device_register(char *type, void *devdata,
const struct thermal_cooling_device_ops *ops)
{ return ERR_PTR(-ENODEV); }
static inline struct thermal_cooling_device *
thermal_of_cooling_device_register(struct device_node *np,
char *type, void *devdata, const struct thermal_cooling_device_ops *ops)
{ return ERR_PTR(-ENODEV); }
static inline void thermal_cooling_device_unregister(
struct thermal_cooling_device *cdev)
{ }
static inline struct thermal_zone_device *thermal_zone_get_zone_by_name(
const char *name)
{ return ERR_PTR(-ENODEV); }
static inline int thermal_zone_get_temp(
struct thermal_zone_device *tz, unsigned long *temp)
{ return -ENODEV; }
static inline int get_tz_trend(struct thermal_zone_device *tz, int trip)
{ return -ENODEV; }
static inline struct thermal_instance *
get_thermal_instance(struct thermal_zone_device *tz,
struct thermal_cooling_device *cdev, int trip)
{ return ERR_PTR(-ENODEV); }
static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
{ }
static inline void thermal_notify_framework(struct thermal_zone_device *tz,
int trip)
{ }
#endif /* CONFIG_THERMAL */

#if defined(CONFIG_NET) && IS_ENABLED(CONFIG_THERMAL)
extern int thermal_generate_netlink_event(struct thermal_zone_device *tz,
enum events event);
#else
Expand Down
1 change: 1 addition & 0 deletions tools/thermal/tmon/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/tmon
15 changes: 12 additions & 3 deletions tools/thermal/tmon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ VERSION = 1.0

BINDIR=usr/bin
WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int
CFLAGS= -O1 ${WARNFLAGS} -fstack-protector
CC=gcc
CFLAGS+= -O1 ${WARNFLAGS} -fstack-protector
CC=$(CROSS_COMPILE)gcc

CFLAGS+=-D VERSION=\"$(VERSION)\"
LDFLAGS+=
Expand All @@ -16,12 +16,21 @@ INSTALL_CONFIGFILE=install -m 644 -p
CONFIG_FILE=
CONFIG_PATH=

# Static builds might require -ltinfo, for instance
ifneq ($(findstring -static, $(LDFLAGS)),)
STATIC := --static
endif

TMON_LIBS=-lm -lpthread
TMON_LIBS += $(shell pkg-config --libs $(STATIC) panelw ncursesw 2> /dev/null || \
pkg-config --libs $(STATIC) panel ncurses 2> /dev/null || \
echo -lpanel -lncurses)

OBJS = tmon.o tui.o sysfs.o pid.o
OBJS +=

tmon: $(OBJS) Makefile tmon.h
$(CC) ${CFLAGS} $(LDFLAGS) $(OBJS) -o $(TARGET) -lm -lpanel -lncursesw -ltinfo -lpthread
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET) $(TMON_LIBS)

valgrind: tmon
sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null
Expand Down
2 changes: 2 additions & 0 deletions tools/thermal/tmon/tmon.8
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ The \fB-l --log\fP option write data to /var/tmp/tmon.log
.PP
The \fB-t --time-interval\fP option sets the polling interval in seconds
.PP
The \fB-T --target-temp\fP option sets the initial target temperature
.PP
The \fB-v --version\fP option shows the version of \fBtmon \fP
.PP
The \fB-z --zone\fP option sets the target therma zone instance to be controlled
Expand Down
14 changes: 12 additions & 2 deletions tools/thermal/tmon/tmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void usage()
printf(" -h, --help show this help message\n");
printf(" -l, --log log data to /var/tmp/tmon.log\n");
printf(" -t, --time-interval sampling time interval, > 1 sec.\n");
printf(" -T, --target-temp initial target temperature\n");
printf(" -v, --version show version\n");
printf(" -z, --zone target thermal zone id\n");

Expand Down Expand Up @@ -219,6 +220,7 @@ static struct option opts[] = {
{ "control", 1, NULL, 'c' },
{ "daemon", 0, NULL, 'd' },
{ "time-interval", 1, NULL, 't' },
{ "target-temp", 1, NULL, 'T' },
{ "log", 0, NULL, 'l' },
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'v' },
Expand All @@ -231,15 +233,15 @@ int main(int argc, char **argv)
{
int err = 0;
int id2 = 0, c;
double yk = 0.0; /* controller output */
double yk = 0.0, temp; /* controller output */
int target_tz_index;

if (geteuid() != 0) {
printf("TMON needs to be run as root\n");
exit(EXIT_FAILURE);
}

while ((c = getopt_long(argc, argv, "c:dlht:vgz:", opts, &id2)) != -1) {
while ((c = getopt_long(argc, argv, "c:dlht:T:vgz:", opts, &id2)) != -1) {
switch (c) {
case 'c':
no_control = 0;
Expand All @@ -254,6 +256,14 @@ int main(int argc, char **argv)
if (ticktime < 1)
ticktime = 1;
break;
case 'T':
temp = strtod(optarg, NULL);
if (temp < 0) {
fprintf(stderr, "error: temperature must be positive\n");
return 1;
}
target_temp_user = temp;
break;
case 'l':
printf("Logging data to /var/tmp/tmon.log\n");
logging = 1;
Expand Down
Loading

0 comments on commit 10d6dfc

Please sign in to comment.