Skip to content

Commit 077df62

Browse files
committed
tools/thermal: Add thermal daemon skeleton
This change provides a simple daemon skeleton. It is an example of how to use the thermal library which wraps all the complex code related to the netlink and transforms it into a callback oriented code. The goal of this skeleton is to give a base brick for anyone interested in writing its own thermal engine or as an example to rely on to write its own thermal monitoring implementation. In the future, it will evolve with more features and hopefully more logic. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://lore.kernel.org/r/20220420160933.347088-5-daniel.lezcano@linaro.org
1 parent 110acbc commit 077df62

4 files changed

Lines changed: 383 additions & 3 deletions

File tree

tools/Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ help:
3232
@echo ' spi - spi tools'
3333
@echo ' tmon - thermal monitoring and tuning tool'
3434
@echo ' thermometer - temperature capture tool'
35+
@echo ' thermal-engine - thermal monitoring tool'
3536
@echo ' thermal - thermal library'
3637
@echo ' tracing - misc tracing tools'
3738
@echo ' turbostat - Intel CPU idle stats and freq reporting tool'
@@ -99,6 +100,9 @@ tmon: FORCE
99100
thermometer: FORCE
100101
$(call descend,thermal/$@)
101102

103+
thermal-engine: FORCE thermal
104+
$(call descend,thermal/$@)
105+
102106
freefall: FORCE
103107
$(call descend,laptop/$@)
104108

@@ -109,7 +113,7 @@ all: acpi cgroup counter cpupower gpio hv firewire \
109113
perf selftests bootconfig spi turbostat usb \
110114
virtio vm bpf x86_energy_perf_policy \
111115
tmon freefall iio objtool kvm_stat wmi \
112-
pci debugging tracing thermal thermometer
116+
pci debugging tracing thermal thermometer thermal-engine
113117

114118
acpi_install:
115119
$(call descend,power/$(@:_install=),install)
@@ -135,6 +139,9 @@ tmon_install:
135139
thermometer_install:
136140
$(call descend,thermal/$(@:_install=),install)
137141

142+
thermal-engine_install:
143+
$(call descend,thermal/$(@:_install=),install)
144+
138145
freefall_install:
139146
$(call descend,laptop/$(@:_install=),install)
140147

@@ -147,7 +154,7 @@ install: acpi_install cgroup_install counter_install cpupower_install gpio_insta
147154
virtio_install vm_install bpf_install x86_energy_perf_policy_install \
148155
tmon_install freefall_install objtool_install kvm_stat_install \
149156
wmi_install pci_install debugging_install intel-speed-select_install \
150-
tracing_install thermometer_install
157+
tracing_install thermometer_install thermal-engine_install
151158

152159
acpi_clean:
153160
$(call descend,power/acpi,clean)
@@ -183,6 +190,9 @@ turbostat_clean x86_energy_perf_policy_clean intel-speed-select_clean:
183190
thermometer_clean:
184191
$(call descend,thermal/thermometer,clean)
185192

193+
thermal-engine_clean:
194+
$(call descend,thermal/thermal-engine,clean)
195+
186196
tmon_clean:
187197
$(call descend,thermal/tmon,clean)
188198

@@ -197,6 +207,6 @@ clean: acpi_clean cgroup_clean counter_clean cpupower_clean hv_clean firewire_cl
197207
vm_clean bpf_clean iio_clean x86_energy_perf_policy_clean tmon_clean \
198208
freefall_clean build_clean libbpf_clean libsubcmd_clean \
199209
gpio_clean objtool_clean leds_clean wmi_clean pci_clean firmware_clean debugging_clean \
200-
intel-speed-select_clean tracing_clean thermal_clean thermometer_clean
210+
intel-speed-select_clean tracing_clean thermal_clean thermometer_clean thermal-engine_clean
201211

202212
.PHONY: FORCE

tools/thermal/thermal-engine/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
thermal-engine-y += thermal-engine.o
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
# Makefile for thermal tools
3+
4+
ifeq ($(srctree),)
5+
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
6+
srctree := $(patsubst %/,%,$(dir $(srctree)))
7+
srctree := $(patsubst %/,%,$(dir $(srctree)))
8+
# $(info Determined 'srctree' to be $(srctree))
9+
endif
10+
11+
CFLAGS = -Wall -Wextra
12+
CFLAGS += -I$(srctree)/tools/thermal/lib
13+
CFLAGS += -I$(srctree)/tools/lib/thermal/include
14+
15+
LDFLAGS = -L$(srctree)/tools/thermal/lib
16+
LDFLAGS += -L$(srctree)/tools/lib/thermal
17+
LDFLAGS += -lthermal_tools
18+
LDFLAGS += -lthermal
19+
LDFLAGS += -lconfig
20+
LDFLAGS += -lnl-genl-3 -lnl-3
21+
22+
VERSION = 0.0.1
23+
24+
all: thermal-engine
25+
%: %.c
26+
$(CC) $(CFLAGS) -D VERSION=\"$(VERSION)\" -o $@ $^ $(LDFLAGS)
27+
clean:
28+
$(RM) thermal-engine

0 commit comments

Comments
 (0)