Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit a02bed4

Browse files
committed
Merge branches 'pm-opp' and 'pm-tools'
Merge OPP (operating performance points) and tooling updates for 6.11-rc1: - Fix missing cleanup on error in _opp_attach_genpd() (Viresh Kumar). - Introduce an OF helper function to inform if required-opps is used and drop a redundant in-parameter to _set_opp_level() (Ulf Hansson). - Update pm-graph to v5.12 which includes fixes and major code revamp for python3.12 (Todd Brandt). - Address several assorted issues in the cpupower utility (Roman Storozhenko). * pm-opp: OPP: Introduce an OF helper function to inform if required-opps is used OPP: Drop a redundant in-parameter to _set_opp_level() OPP: Fix missing cleanup on error in _opp_attach_genpd() * pm-tools: cpupower: fix lib default installation path cpupower: Disable direct build of the 'bench' subproject cpupower: Change the var type of the 'monitor' subcommand display mode cpupower: Remove absent 'v' parameter from monitor man page cpupower: Improve cpupower build process description cpupower: Add 'help' target to the main Makefile cpupower: Replace a dead reference link with working ones pm-graph: v5.12, code revamp for python3.12 pm-graph: v5.12, fixes
3 parents 7fae6f8 + 161bd53 + b48b342 commit a02bed4

File tree

10 files changed

+815
-579
lines changed

10 files changed

+815
-579
lines changed

drivers/opp/core.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,7 @@ static int _set_required_opps(struct device *dev, struct opp_table *opp_table,
11021102
return 0;
11031103
}
11041104

1105-
static int _set_opp_level(struct device *dev, struct opp_table *opp_table,
1106-
struct dev_pm_opp *opp)
1105+
static int _set_opp_level(struct device *dev, struct dev_pm_opp *opp)
11071106
{
11081107
unsigned int level = 0;
11091108
int ret = 0;
@@ -1171,7 +1170,7 @@ static int _disable_opp_table(struct device *dev, struct opp_table *opp_table)
11711170
if (opp_table->regulators)
11721171
regulator_disable(opp_table->regulators[0]);
11731172

1174-
ret = _set_opp_level(dev, opp_table, NULL);
1173+
ret = _set_opp_level(dev, NULL);
11751174
if (ret)
11761175
goto out;
11771176

@@ -1220,7 +1219,7 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table,
12201219
return ret;
12211220
}
12221221

1223-
ret = _set_opp_level(dev, opp_table, opp);
1222+
ret = _set_opp_level(dev, opp);
12241223
if (ret)
12251224
return ret;
12261225

@@ -1267,7 +1266,7 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table,
12671266
return ret;
12681267
}
12691268

1270-
ret = _set_opp_level(dev, opp_table, opp);
1269+
ret = _set_opp_level(dev, opp);
12711270
if (ret)
12721271
return ret;
12731272

@@ -2443,8 +2442,10 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev,
24432442
* Cross check it again and fix if required.
24442443
*/
24452444
gdev = dev_to_genpd_dev(virt_dev);
2446-
if (IS_ERR(gdev))
2447-
return PTR_ERR(gdev);
2445+
if (IS_ERR(gdev)) {
2446+
ret = PTR_ERR(gdev);
2447+
goto err;
2448+
}
24482449

24492450
genpd_table = _find_opp_table(gdev);
24502451
if (!IS_ERR(genpd_table)) {

drivers/opp/of.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,38 @@ int of_get_required_opp_performance_state(struct device_node *np, int index)
14431443
}
14441444
EXPORT_SYMBOL_GPL(of_get_required_opp_performance_state);
14451445

1446+
/**
1447+
* dev_pm_opp_of_has_required_opp - Find out if a required-opps exists.
1448+
* @dev: The device to investigate.
1449+
*
1450+
* Returns true if the device's node has a "operating-points-v2" property and if
1451+
* the corresponding node for the opp-table describes opp nodes that uses the
1452+
* "required-opps" property.
1453+
*
1454+
* Return: True if a required-opps is present, else false.
1455+
*/
1456+
bool dev_pm_opp_of_has_required_opp(struct device *dev)
1457+
{
1458+
struct device_node *opp_np, *np;
1459+
int count;
1460+
1461+
opp_np = _opp_of_get_opp_desc_node(dev->of_node, 0);
1462+
if (!opp_np)
1463+
return false;
1464+
1465+
np = of_get_next_available_child(opp_np, NULL);
1466+
of_node_put(opp_np);
1467+
if (!np) {
1468+
dev_warn(dev, "Empty OPP table\n");
1469+
return false;
1470+
}
1471+
1472+
count = of_count_phandle_with_args(np, "required-opps", NULL);
1473+
of_node_put(np);
1474+
1475+
return count > 0;
1476+
}
1477+
14461478
/**
14471479
* dev_pm_opp_get_of_node() - Gets the DT node corresponding to an opp
14481480
* @opp: opp for which DT node has to be returned for

include/linux/pm_opp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpuma
474474
struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev);
475475
struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp);
476476
int of_get_required_opp_performance_state(struct device_node *np, int index);
477+
bool dev_pm_opp_of_has_required_opp(struct device *dev);
477478
int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table);
478479
int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus);
479480
int dev_pm_opp_calc_power(struct device *dev, unsigned long *uW,
@@ -552,6 +553,11 @@ static inline int of_get_required_opp_performance_state(struct device_node *np,
552553
return -EOPNOTSUPP;
553554
}
554555

556+
static inline bool dev_pm_opp_of_has_required_opp(struct device *dev)
557+
{
558+
return false;
559+
}
560+
555561
static inline int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table)
556562
{
557563
return -EOPNOTSUPP;

tools/power/cpupower/Makefile

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ LANGUAGES = de fr it cs pt ka
6767
bindir ?= /usr/bin
6868
sbindir ?= /usr/sbin
6969
mandir ?= /usr/man
70+
libdir ?= /usr/lib
7071
includedir ?= /usr/include
7172
localedir ?= /usr/share/locale
7273
docdir ?= /usr/share/doc/packages/cpupower
@@ -94,15 +95,6 @@ RANLIB = $(CROSS)ranlib
9495
HOSTCC = gcc
9596
MKDIR = mkdir
9697

97-
# 64bit library detection
98-
include ../../scripts/Makefile.arch
99-
100-
ifeq ($(IS_64_BIT), 1)
101-
libdir ?= /usr/lib64
102-
else
103-
libdir ?= /usr/lib
104-
endif
105-
10698
# Now we set up the build system
10799
#
108100

@@ -332,4 +324,39 @@ uninstall:
332324
rm -f $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \
333325
done;
334326

335-
.PHONY: all utils libcpupower update-po create-gmo install-lib install-tools install-man install-gmo install uninstall clean
327+
help:
328+
@echo 'Building targets:'
329+
@echo ' all - Default target. Could be omitted. Put build artifacts'
330+
@echo ' to "O" cmdline option dir (default: current dir)'
331+
@echo ' install - Install previously built project files from the output'
332+
@echo ' dir defined by "O" cmdline option (default: current dir)'
333+
@echo ' to the install dir defined by "DESTDIR" cmdline or'
334+
@echo ' Makefile config block option (default: "")'
335+
@echo ' install-lib - Install previously built library binary from the output'
336+
@echo ' dir defined by "O" cmdline option (default: current dir)'
337+
@echo ' and library headers from "lib/" for userspace to the install'
338+
@echo ' dir defined by "DESTDIR" cmdline (default: "")'
339+
@echo ' install-tools - Install previously built "cpupower" util from the output'
340+
@echo ' dir defined by "O" cmdline option (default: current dir) and'
341+
@echo ' "cpupower-completion.sh" script from the src dir to the'
342+
@echo ' install dir defined by "DESTDIR" cmdline or Makefile'
343+
@echo ' config block option (default: "")'
344+
@echo ' install-man - Install man pages from the "man" src subdir to the'
345+
@echo ' install dir defined by "DESTDIR" cmdline or Makefile'
346+
@echo ' config block option (default: "")'
347+
@echo ' install-gmo - Install previously built language files from the output'
348+
@echo ' dir defined by "O" cmdline option (default: current dir)'
349+
@echo ' to the install dir defined by "DESTDIR" cmdline or Makefile'
350+
@echo ' config block option (default: "")'
351+
@echo ' install-bench - Install previously built "cpufreq-bench" util files from the'
352+
@echo ' output dir defined by "O" cmdline option (default: current dir)'
353+
@echo ' to the install dir defined by "DESTDIR" cmdline or Makefile'
354+
@echo ' config block option (default: "")'
355+
@echo ''
356+
@echo 'Cleaning targets:'
357+
@echo ' clean - Clean build artifacts from the dir defined by "O" cmdline'
358+
@echo ' option (default: current dir)'
359+
@echo ' uninstall - Remove previously installed files from the dir defined by "DESTDIR"'
360+
@echo ' cmdline or Makefile config block option (default: "")'
361+
362+
.PHONY: all utils libcpupower update-po create-gmo install-lib install-tools install-man install-gmo install uninstall clean help

tools/power/cpupower/README

Lines changed: 150 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,156 @@ interfaces [depending on configuration, see below].
2222
compilation and installation
2323
----------------------------
2424

25-
make
26-
su
27-
make install
28-
29-
should suffice on most systems. It builds libcpupower to put in
30-
/usr/lib; cpupower, cpufreq-bench_plot.sh to put in /usr/bin; and
31-
cpufreq-bench to put in /usr/sbin. If you want to set up the paths
32-
differently and/or want to configure the package to your specific
33-
needs, you need to open "Makefile" with an editor of your choice and
34-
edit the block marked CONFIGURATION.
25+
There are 2 output directories - one for the build output and another for
26+
the installation of the build results, that is the utility, library,
27+
man pages, etc...
28+
29+
default directory
30+
-----------------
31+
32+
In the case of default directory, build and install process requires no
33+
additional parameters:
34+
35+
build
36+
-----
37+
38+
$ make
39+
40+
The output directory for the 'make' command is the current directory and
41+
its subdirs in the kernel tree:
42+
tools/power/cpupower
43+
44+
install
45+
-------
46+
47+
$ sudo make install
48+
49+
'make install' command puts targets to default system dirs:
50+
51+
-----------------------------------------------------------------------
52+
| Installing file | System dir |
53+
-----------------------------------------------------------------------
54+
| libcpupower | /usr/lib |
55+
-----------------------------------------------------------------------
56+
| cpupower | /usr/bin |
57+
-----------------------------------------------------------------------
58+
| cpufreq-bench_plot.sh | /usr/bin |
59+
-----------------------------------------------------------------------
60+
| man pages | /usr/man |
61+
-----------------------------------------------------------------------
62+
63+
To put it in other words it makes build results available system-wide,
64+
enabling any user to simply start using it without any additional steps
65+
66+
custom directory
67+
----------------
68+
69+
There are 2 make's command-line variables 'O' and 'DESTDIR' that setup
70+
appropriate dirs:
71+
'O' - build directory
72+
'DESTDIR' - installation directory. This variable could also be setup in
73+
the 'CONFIGURATION' block of the "Makefile"
74+
75+
build
76+
-----
77+
78+
$ make O=<your_custom_build_catalog>
79+
80+
Example:
81+
$ make O=/home/hedin/prj/cpupower/build
82+
83+
install
84+
-------
85+
86+
$ make O=<your_custom_build_catalog> DESTDIR=<your_custom_install_catalog>
87+
88+
Example:
89+
$ make O=/home/hedin/prj/cpupower/build DESTDIR=/home/hedin/prj/cpupower \
90+
> install
91+
92+
Notice that both variables 'O' and 'DESTDIR' have been provided. The reason
93+
is that the build results are saved in the custom output dir defined by 'O'
94+
variable. So, this dir is the source for the installation step. If only
95+
'DESTDIR' were provided then the 'install' target would assume that the
96+
build directory is the current one, build everything there and install
97+
from the current dir.
98+
99+
The files will be installed to the following dirs:
100+
101+
-----------------------------------------------------------------------
102+
| Installing file | System dir |
103+
-----------------------------------------------------------------------
104+
| libcpupower | ${DESTDIR}/usr/lib |
105+
-----------------------------------------------------------------------
106+
| cpupower | ${DESTDIR}/usr/bin |
107+
-----------------------------------------------------------------------
108+
| cpufreq-bench_plot.sh | ${DESTDIR}/usr/bin |
109+
-----------------------------------------------------------------------
110+
| man pages | ${DESTDIR}/usr/man |
111+
-----------------------------------------------------------------------
112+
113+
If you look at the table for the default 'make' output dirs you will
114+
notice that the only difference with the non-default case is the
115+
${DESTDIR} prefix. So, the structure of the output dirs remains the same
116+
regardles of the root output directory.
117+
118+
119+
clean and uninstall
120+
-------------------
121+
122+
'clean' target is intended for cleanup the build catalog from build results
123+
'uninstall' target is intended for removing installed files from the
124+
installation directory
125+
126+
default directory
127+
-----------------
128+
129+
This case is a straightforward one:
130+
$ make clean
131+
$ make uninstall
132+
133+
custom directory
134+
----------------
135+
136+
Use 'O' command line variable to remove previously built files from the
137+
build dir:
138+
$ make O=<your_custom_build_catalog> clean
139+
140+
Example:
141+
$ make O=/home/hedin/prj/cpupower/build clean
142+
143+
Use 'DESTDIR' command line variable to uninstall previously installed files
144+
from the given dir:
145+
$ make DESTDIR=<your_custom_install_catalog>
146+
147+
Example:
148+
make DESTDIR=/home/hedin/prj/cpupower uninstall
149+
150+
151+
running the tool
152+
----------------
153+
154+
default directory
155+
-----------------
156+
157+
$ sudo cpupower
158+
159+
custom directory
160+
----------------
161+
162+
When it comes to run the utility from the custom build catalog things
163+
become a little bit complicated as 'just run' approach doesn't work.
164+
Assuming that the current dir is '<your_custom_install_catalog>/usr',
165+
issuing the following command:
166+
167+
$ sudo ./bin/cpupower
168+
will produce the following error output:
169+
./bin/cpupower: error while loading shared libraries: libcpupower.so.1:
170+
cannot open shared object file: No such file or directory
171+
172+
The issue is that binary cannot find the 'libcpupower' library. So, we
173+
shall point to the lib dir:
174+
sudo LD_LIBRARY_PATH=lib64/ ./bin/cpupower
35175

36176

37177
THANKS

tools/power/cpupower/bench/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# SPDX-License-Identifier: GPL-2.0
2+
ifeq ($(MAKELEVEL),0)
3+
$(error This Makefile is not intended to be run standalone, but only as a part \
4+
of the main one in the parent dir)
5+
endif
6+
27
OUTPUT := ./
38
ifeq ("$(origin O)", "command line")
49
ifneq ($(O),)

tools/power/cpupower/man/cpupower-monitor.1

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ Measure idle and frequency characteristics of an arbitrary command/workload.
8181
The executable \fBcommand\fP is forked and upon its exit, statistics gathered since it was
8282
forked are displayed.
8383
.RE
84-
.PP
85-
\-v
86-
.RS 4
87-
Increase verbosity if the binary was compiled with the DEBUG option set.
88-
.RE
8984

9085
.SH MONITOR DESCRIPTIONS
9186
.SS "Idle_Stats"
@@ -172,9 +167,11 @@ displayed.
172167
"BIOS and Kernel Developer’s Guide (BKDG) for AMD Family 14h Processors"
173168
https://support.amd.com/us/Processor_TechDocs/43170.pdf
174169

175-
"Intel® Turbo Boost Technology
176-
in Intel® Core™ Microarchitecture (Nehalem) Based Processors"
177-
http://download.intel.com/design/processor/applnots/320354.pdf
170+
"What Is Intel® Turbo Boost Technology?"
171+
https://www.intel.com/content/www/us/en/gaming/resources/turbo-boost.html
172+
173+
"Power Management - Technology Overview"
174+
https://cdrdv2.intel.com/v1/dl/getContent/637748
178175

179176
"Intel® 64 and IA-32 Architectures Software Developer's Manual
180177
Volume 3B: System Programming Guide"

tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static unsigned int avail_monitors;
3535
static char *progname;
3636

3737
enum operation_mode_e { list = 1, show, show_all };
38-
static int mode;
38+
static enum operation_mode_e mode;
3939
static int interval = 1;
4040
static char *show_monitors_param;
4141
static struct cpupower_topology cpu_top;

0 commit comments

Comments
 (0)