aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/power/cpupower/Makefile93
-rw-r--r--tools/power/cpupower/bench/Makefile23
-rw-r--r--tools/power/cpupower/debug/i386/Makefile40
-rw-r--r--tools/power/cpupower/debug/x86_64/Makefile26
-rw-r--r--tools/power/cpupower/man/cpupower-frequency-info.14
-rw-r--r--tools/power/cpupower/man/cpupower-frequency-set.14
-rw-r--r--tools/power/cpupower/man/cpupower-idle-info.190
-rw-r--r--tools/power/cpupower/man/cpupower-monitor.12
-rw-r--r--tools/power/cpupower/utils/cpuidle-info.c12
-rw-r--r--tools/power/cpupower/utils/helpers/amd.c4
-rw-r--r--tools/power/cpupower/utils/helpers/helpers.h11
-rw-r--r--tools/power/cpupower/utils/helpers/pci.c35
-rw-r--r--tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c25
13 files changed, 259 insertions, 110 deletions
diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
index e8a03aceceb1..a93e06cfcc2a 100644
--- a/tools/power/cpupower/Makefile
+++ b/tools/power/cpupower/Makefile
@@ -19,6 +19,16 @@
19# along with this program; if not, write to the Free Software 19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21# 21#
22OUTPUT=./
23ifeq ("$(origin O)", "command line")
24 OUTPUT := $(O)/
25endif
26
27ifneq ($(OUTPUT),)
28# check that the output directory actually exists
29OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd)
30$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
31endif
22 32
23# --- CONFIGURATION BEGIN --- 33# --- CONFIGURATION BEGIN ---
24 34
@@ -87,6 +97,7 @@ AR = $(CROSS)ar
87STRIP = $(CROSS)strip 97STRIP = $(CROSS)strip
88RANLIB = $(CROSS)ranlib 98RANLIB = $(CROSS)ranlib
89HOSTCC = gcc 99HOSTCC = gcc
100MKDIR = mkdir
90 101
91 102
92# Now we set up the build system 103# Now we set up the build system
@@ -95,7 +106,7 @@ HOSTCC = gcc
95# set up PWD so that older versions of make will work with our build. 106# set up PWD so that older versions of make will work with our build.
96PWD = $(shell pwd) 107PWD = $(shell pwd)
97 108
98GMO_FILES = ${shell for HLANG in ${LANGUAGES}; do echo po/$$HLANG.gmo; done;} 109GMO_FILES = ${shell for HLANG in ${LANGUAGES}; do echo $(OUTPUT)po/$$HLANG.gmo; done;}
99 110
100export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS 111export CROSS CC AR STRIP RANLIB CFLAGS LDFLAGS LIB_OBJS
101 112
@@ -122,15 +133,18 @@ UTIL_OBJS = utils/helpers/amd.o utils/helpers/topology.o utils/helpers/msr.o \
122 utils/cpupower.o utils/cpufreq-info.o utils/cpufreq-set.o \ 133 utils/cpupower.o utils/cpufreq-info.o utils/cpufreq-set.o \
123 utils/cpupower-set.o utils/cpupower-info.o utils/cpuidle-info.o 134 utils/cpupower-set.o utils/cpupower-info.o utils/cpuidle-info.o
124 135
136UTIL_SRC := $(UTIL_OBJS:.o=.c)
137
138UTIL_OBJS := $(addprefix $(OUTPUT),$(UTIL_OBJS))
139
125UTIL_HEADERS = utils/helpers/helpers.h utils/idle_monitor/cpupower-monitor.h \ 140UTIL_HEADERS = utils/helpers/helpers.h utils/idle_monitor/cpupower-monitor.h \
126 utils/helpers/bitmask.h \ 141 utils/helpers/bitmask.h \
127 utils/idle_monitor/idle_monitors.h utils/idle_monitor/idle_monitors.def 142 utils/idle_monitor/idle_monitors.h utils/idle_monitor/idle_monitors.def
128 143
129UTIL_SRC := $(UTIL_OBJS:.o=.c)
130
131LIB_HEADERS = lib/cpufreq.h lib/sysfs.h 144LIB_HEADERS = lib/cpufreq.h lib/sysfs.h
132LIB_SRC = lib/cpufreq.c lib/sysfs.c 145LIB_SRC = lib/cpufreq.c lib/sysfs.c
133LIB_OBJS = lib/cpufreq.o lib/sysfs.o 146LIB_OBJS = lib/cpufreq.o lib/sysfs.o
147LIB_OBJS := $(addprefix $(OUTPUT),$(LIB_OBJS))
134 148
135CFLAGS += -pipe 149CFLAGS += -pipe
136 150
@@ -168,83 +182,90 @@ endif
168 182
169# the actual make rules 183# the actual make rules
170 184
171all: libcpupower cpupower $(COMPILE_NLS) $(COMPILE_BENCH) 185all: libcpupower $(OUTPUT)cpupower $(COMPILE_NLS) $(COMPILE_BENCH)
172 186
173lib/%.o: $(LIB_SRC) $(LIB_HEADERS) 187$(OUTPUT)lib/%.o: $(LIB_SRC) $(LIB_HEADERS)
174 $(ECHO) " CC " $@ 188 $(ECHO) " CC " $@
175 $(QUIET) $(CC) $(CFLAGS) -fPIC -o $@ -c lib/$*.c 189 $(QUIET) $(CC) $(CFLAGS) -fPIC -o $@ -c lib/$*.c
176 190
177libcpupower.so.$(LIB_MAJ): $(LIB_OBJS) 191$(OUTPUT)libcpupower.so.$(LIB_MAJ): $(LIB_OBJS)
178 $(ECHO) " LD " $@ 192 $(ECHO) " LD " $@
179 $(QUIET) $(CC) -shared $(CFLAGS) $(LDFLAGS) -o $@ \ 193 $(QUIET) $(CC) -shared $(CFLAGS) $(LDFLAGS) -o $@ \
180 -Wl,-soname,libcpupower.so.$(LIB_MIN) $(LIB_OBJS) 194 -Wl,-soname,libcpupower.so.$(LIB_MIN) $(LIB_OBJS)
181 @ln -sf $@ libcpupower.so 195 @ln -sf $(@F) $(OUTPUT)libcpupower.so
182 @ln -sf $@ libcpupower.so.$(LIB_MIN) 196 @ln -sf $(@F) $(OUTPUT)libcpupower.so.$(LIB_MIN)
183 197
184libcpupower: libcpupower.so.$(LIB_MAJ) 198libcpupower: $(OUTPUT)libcpupower.so.$(LIB_MAJ)
185 199
186# Let all .o files depend on its .c file and all headers 200# Let all .o files depend on its .c file and all headers
187# Might be worth to put this into utils/Makefile at some point of time 201# Might be worth to put this into utils/Makefile at some point of time
188$(UTIL_OBJS): $(UTIL_HEADERS) 202$(UTIL_OBJS): $(UTIL_HEADERS)
189 203
190.c.o: 204$(OUTPUT)%.o: %.c
191 $(ECHO) " CC " $@ 205 $(ECHO) " CC " $@
192 $(QUIET) $(CC) $(CFLAGS) -I./lib -I ./utils -o $@ -c $*.c 206 $(QUIET) $(CC) $(CFLAGS) -I./lib -I ./utils -o $@ -c $*.c
193 207
194cpupower: $(UTIL_OBJS) libcpupower.so.$(LIB_MAJ) 208$(OUTPUT)cpupower: $(UTIL_OBJS) $(OUTPUT)libcpupower.so.$(LIB_MAJ)
195 $(ECHO) " CC " $@ 209 $(ECHO) " CC " $@
196 $(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) -lcpupower -lrt -lpci -L. -o $@ $(UTIL_OBJS) 210 $(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lcpupower -lrt -lpci -L$(OUTPUT) -o $@
197 $(QUIET) $(STRIPCMD) $@ 211 $(QUIET) $(STRIPCMD) $@
198 212
199po/$(PACKAGE).pot: $(UTIL_SRC) 213$(OUTPUT)po/$(PACKAGE).pot: $(UTIL_SRC)
200 $(ECHO) " GETTEXT " $@ 214 $(ECHO) " GETTEXT " $@
201 $(QUIET) xgettext --default-domain=$(PACKAGE) --add-comments \ 215 $(QUIET) xgettext --default-domain=$(PACKAGE) --add-comments \
202 --keyword=_ --keyword=N_ $(UTIL_SRC) && \ 216 --keyword=_ --keyword=N_ $(UTIL_SRC) -p $(@D) -o $(@F)
203 test -f $(PACKAGE).po && \
204 mv -f $(PACKAGE).po po/$(PACKAGE).pot
205 217
206po/%.gmo: po/%.po 218$(OUTPUT)po/%.gmo: po/%.po
207 $(ECHO) " MSGFMT " $@ 219 $(ECHO) " MSGFMT " $@
208 $(QUIET) msgfmt -o $@ po/$*.po 220 $(QUIET) msgfmt -o $@ po/$*.po
209 221
210create-gmo: ${GMO_FILES} 222create-gmo: ${GMO_FILES}
211 223
212update-po: po/$(PACKAGE).pot 224update-po: $(OUTPUT)po/$(PACKAGE).pot
213 $(ECHO) " MSGMRG " $@ 225 $(ECHO) " MSGMRG " $@
214 $(QUIET) @for HLANG in $(LANGUAGES); do \ 226 $(QUIET) @for HLANG in $(LANGUAGES); do \
215 echo -n "Updating $$HLANG "; \ 227 echo -n "Updating $$HLANG "; \
216 if msgmerge po/$$HLANG.po po/$(PACKAGE).pot -o \ 228 if msgmerge po/$$HLANG.po $< -o \
217 po/$$HLANG.new.po; then \ 229 $(OUTPUT)po/$$HLANG.new.po; then \
218 mv -f po/$$HLANG.new.po po/$$HLANG.po; \ 230 mv -f $(OUTPUT)po/$$HLANG.new.po $(OUTPUT)po/$$HLANG.po; \
219 else \ 231 else \
220 echo "msgmerge for $$HLANG failed!"; \ 232 echo "msgmerge for $$HLANG failed!"; \
221 rm -f po/$$HLANG.new.po; \ 233 rm -f $(OUTPUT)po/$$HLANG.new.po; \
222 fi; \ 234 fi; \
223 done; 235 done;
224 236
225compile-bench: libcpupower.so.$(LIB_MAJ) 237compile-bench: $(OUTPUT)libcpupower.so.$(LIB_MAJ)
226 @V=$(V) confdir=$(confdir) $(MAKE) -C bench 238 @V=$(V) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT)
239
240# we compile into subdirectories. if the target directory is not the
241# source directory, they might not exists. So we depend the various
242# files onto their directories.
243DIRECTORY_DEPS = $(LIB_OBJS) $(UTIL_OBJS) $(GMO_FILES)
244$(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS)))
245
246# In the second step, we make a rule to actually create these directories
247$(sort $(dir $(DIRECTORY_DEPS))):
248 $(ECHO) " MKDIR " $@
249 $(QUIET) $(MKDIR) -p $@ 2>/dev/null
227 250
228clean: 251clean:
229 -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \ 252 -find $(OUTPUT) \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \
230 | xargs rm -f 253 | xargs rm -f
231 -rm -f $(UTIL_BINS) 254 -rm -f $(OUTPUT)cpupower
232 -rm -f $(IDLE_OBJS) 255 -rm -f $(OUTPUT)libcpupower.so*
233 -rm -f cpupower 256 -rm -rf $(OUTPUT)po/*.{gmo,pot}
234 -rm -f libcpupower.so* 257 $(MAKE) -C bench O=$(OUTPUT) clean
235 -rm -rf po/*.gmo po/*.pot
236 $(MAKE) -C bench clean
237 258
238 259
239install-lib: 260install-lib:
240 $(INSTALL) -d $(DESTDIR)${libdir} 261 $(INSTALL) -d $(DESTDIR)${libdir}
241 $(CP) libcpupower.so* $(DESTDIR)${libdir}/ 262 $(CP) $(OUTPUT)libcpupower.so* $(DESTDIR)${libdir}/
242 $(INSTALL) -d $(DESTDIR)${includedir} 263 $(INSTALL) -d $(DESTDIR)${includedir}
243 $(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h 264 $(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h
244 265
245install-tools: 266install-tools:
246 $(INSTALL) -d $(DESTDIR)${bindir} 267 $(INSTALL) -d $(DESTDIR)${bindir}
247 $(INSTALL_PROGRAM) cpupower $(DESTDIR)${bindir} 268 $(INSTALL_PROGRAM) $(OUTPUT)cpupower $(DESTDIR)${bindir}
248 269
249install-man: 270install-man:
250 $(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1 271 $(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1
@@ -257,13 +278,13 @@ install-man:
257install-gmo: 278install-gmo:
258 $(INSTALL) -d $(DESTDIR)${localedir} 279 $(INSTALL) -d $(DESTDIR)${localedir}
259 for HLANG in $(LANGUAGES); do \ 280 for HLANG in $(LANGUAGES); do \
260 echo '$(INSTALL_DATA) -D po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo'; \ 281 echo '$(INSTALL_DATA) -D $(OUTPUT)po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo'; \
261 $(INSTALL_DATA) -D po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \ 282 $(INSTALL_DATA) -D $(OUTPUT)po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \
262 done; 283 done;
263 284
264install-bench: 285install-bench:
265 @#DESTDIR must be set from outside to survive 286 @#DESTDIR must be set from outside to survive
266 @sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench install 287 @sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT) install
267 288
268install: all install-lib install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH) 289install: all install-lib install-tools install-man $(INSTALL_NLS) $(INSTALL_BENCH)
269 290
diff --git a/tools/power/cpupower/bench/Makefile b/tools/power/cpupower/bench/Makefile
index 2b67606fc3e3..7ec7021a29cd 100644
--- a/tools/power/cpupower/bench/Makefile
+++ b/tools/power/cpupower/bench/Makefile
@@ -1,29 +1,36 @@
1LIBS = -L../ -lm -lcpupower 1OUTPUT := ./
2ifeq ("$(origin O)", "command line")
3ifneq ($(O),)
4 OUTPUT := $(O)/
5endif
6endif
2 7
3OBJS = main.o parse.o system.o benchmark.o 8LIBS = -L../ -L$(OUTPUT) -lm -lcpupower
9
10OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o
4CFLAGS += -D_GNU_SOURCE -I../lib -DDEFAULT_CONFIG_FILE=\"$(confdir)/cpufreq-bench.conf\" 11CFLAGS += -D_GNU_SOURCE -I../lib -DDEFAULT_CONFIG_FILE=\"$(confdir)/cpufreq-bench.conf\"
5 12
6%.o : %.c 13$(OUTPUT)%.o : %.c
7 $(ECHO) " CC " $@ 14 $(ECHO) " CC " $@
8 $(QUIET) $(CC) -c $(CFLAGS) $< -o $@ 15 $(QUIET) $(CC) -c $(CFLAGS) $< -o $@
9 16
10cpufreq-bench: $(OBJS) 17$(OUTPUT)cpufreq-bench: $(OBJS)
11 $(ECHO) " CC " $@ 18 $(ECHO) " CC " $@
12 $(QUIET) $(CC) -o $@ $(CFLAGS) $(OBJS) $(LIBS) 19 $(QUIET) $(CC) -o $@ $(CFLAGS) $(OBJS) $(LIBS)
13 20
14all: cpufreq-bench 21all: $(OUTPUT)cpufreq-bench
15 22
16install: 23install:
17 mkdir -p $(DESTDIR)/$(sbindir) 24 mkdir -p $(DESTDIR)/$(sbindir)
18 mkdir -p $(DESTDIR)/$(bindir) 25 mkdir -p $(DESTDIR)/$(bindir)
19 mkdir -p $(DESTDIR)/$(docdir) 26 mkdir -p $(DESTDIR)/$(docdir)
20 mkdir -p $(DESTDIR)/$(confdir) 27 mkdir -p $(DESTDIR)/$(confdir)
21 install -m 755 cpufreq-bench $(DESTDIR)/$(sbindir)/cpufreq-bench 28 install -m 755 $(OUTPUT)cpufreq-bench $(DESTDIR)/$(sbindir)/cpufreq-bench
22 install -m 755 cpufreq-bench_plot.sh $(DESTDIR)/$(bindir)/cpufreq-bench_plot.sh 29 install -m 755 cpufreq-bench_plot.sh $(DESTDIR)/$(bindir)/cpufreq-bench_plot.sh
23 install -m 644 README-BENCH $(DESTDIR)/$(docdir)/README-BENCH 30 install -m 644 README-BENCH $(DESTDIR)/$(docdir)/README-BENCH
24 install -m 755 cpufreq-bench_script.sh $(DESTDIR)/$(docdir)/cpufreq-bench_script.sh 31 install -m 755 cpufreq-bench_script.sh $(DESTDIR)/$(docdir)/cpufreq-bench_script.sh
25 install -m 644 example.cfg $(DESTDIR)/$(confdir)/cpufreq-bench.conf 32 install -m 644 example.cfg $(DESTDIR)/$(confdir)/cpufreq-bench.conf
26 33
27clean: 34clean:
28 rm -f *.o 35 rm -f $(OUTPUT)*.o
29 rm -f cpufreq-bench 36 rm -f $(OUTPUT)cpufreq-bench
diff --git a/tools/power/cpupower/debug/i386/Makefile b/tools/power/cpupower/debug/i386/Makefile
index d08cc1ead9bc..3ba158f0e287 100644
--- a/tools/power/cpupower/debug/i386/Makefile
+++ b/tools/power/cpupower/debug/i386/Makefile
@@ -1,20 +1,38 @@
1OUTPUT=./
2ifeq ("$(origin O)", "command line")
3 OUTPUT := $(O)/
4endif
5
6DESTDIR =
7bindir = /usr/bin
8
9INSTALL = /usr/bin/install
10
11
1default: all 12default: all
2 13
3centrino-decode: centrino-decode.c 14$(OUTPUT)centrino-decode: centrino-decode.c
4 $(CC) $(CFLAGS) -o centrino-decode centrino-decode.c 15 $(CC) $(CFLAGS) -o $@ centrino-decode.c
5 16
6dump_psb: dump_psb.c 17$(OUTPUT)dump_psb: dump_psb.c
7 $(CC) $(CFLAGS) -o dump_psb dump_psb.c 18 $(CC) $(CFLAGS) -o $@ dump_psb.c
8 19
9intel_gsic: intel_gsic.c 20$(OUTPUT)intel_gsic: intel_gsic.c
10 $(CC) $(CFLAGS) -o intel_gsic -llrmi intel_gsic.c 21 $(CC) $(CFLAGS) -o $@ -llrmi intel_gsic.c
11 22
12powernow-k8-decode: powernow-k8-decode.c 23$(OUTPUT)powernow-k8-decode: powernow-k8-decode.c
13 $(CC) $(CFLAGS) -o powernow-k8-decode powernow-k8-decode.c 24 $(CC) $(CFLAGS) -o $@ powernow-k8-decode.c
14 25
15all: centrino-decode dump_psb intel_gsic powernow-k8-decode 26all: $(OUTPUT)centrino-decode $(OUTPUT)dump_psb $(OUTPUT)intel_gsic $(OUTPUT)powernow-k8-decode
16 27
17clean: 28clean:
18 rm -rf centrino-decode dump_psb intel_gsic powernow-k8-decode 29 rm -rf $(OUTPUT){centrino-decode,dump_psb,intel_gsic,powernow-k8-decode}
30
31install:
32 $(INSTALL) -d $(DESTDIR)${bindir}
33 $(INSTALL) $(OUTPUT)centrino-decode $(DESTDIR)${bindir}
34 $(INSTALL) $(OUTPUT)powernow-k8-decode $(DESTDIR)${bindir}
35 $(INSTALL) $(OUTPUT)dump_psb $(DESTDIR)${bindir}
36 $(INSTALL) $(OUTPUT)intel_gsic $(DESTDIR)${bindir}
19 37
20.PHONY: all default clean 38.PHONY: all default clean install
diff --git a/tools/power/cpupower/debug/x86_64/Makefile b/tools/power/cpupower/debug/x86_64/Makefile
index 3326217dd311..1c5214526716 100644
--- a/tools/power/cpupower/debug/x86_64/Makefile
+++ b/tools/power/cpupower/debug/x86_64/Makefile
@@ -1,14 +1,30 @@
1OUTPUT=./
2ifeq ("$(origin O)", "command line")
3 OUTPUT := $(O)/
4endif
5
6DESTDIR =
7bindir = /usr/bin
8
9INSTALL = /usr/bin/install
10
11
1default: all 12default: all
2 13
3centrino-decode: ../i386/centrino-decode.c 14$(OUTPUT)centrino-decode: ../i386/centrino-decode.c
4 $(CC) $(CFLAGS) -o $@ $< 15 $(CC) $(CFLAGS) -o $@ $<
5 16
6powernow-k8-decode: ../i386/powernow-k8-decode.c 17$(OUTPUT)powernow-k8-decode: ../i386/powernow-k8-decode.c
7 $(CC) $(CFLAGS) -o $@ $< 18 $(CC) $(CFLAGS) -o $@ $<
8 19
9all: centrino-decode powernow-k8-decode 20all: $(OUTPUT)centrino-decode $(OUTPUT)powernow-k8-decode
10 21
11clean: 22clean:
12 rm -rf centrino-decode powernow-k8-decode 23 rm -rf $(OUTPUT)centrino-decode $(OUTPUT)powernow-k8-decode
24
25install:
26 $(INSTALL) -d $(DESTDIR)${bindir}
27 $(INSTALL) $(OUTPUT)centrino-decode $(DESTDIR)${bindir}
28 $(INSTALL) $(OUTPUT)powernow-k8-decode $(DESTDIR)${bindir}
13 29
14.PHONY: all default clean 30.PHONY: all default clean install
diff --git a/tools/power/cpupower/man/cpupower-frequency-info.1 b/tools/power/cpupower/man/cpupower-frequency-info.1
index bb60a8d1e45a..4a1918ea8f9c 100644
--- a/tools/power/cpupower/man/cpupower-frequency-info.1
+++ b/tools/power/cpupower/man/cpupower-frequency-info.1
@@ -1,4 +1,4 @@
1.TH "cpupower-frequency-info" "1" "0.1" "Mattia Dongili" "" 1.TH "CPUPOWER\-FREQUENCY\-INFO" "1" "0.1" "" "cpupower Manual"
2.SH "NAME" 2.SH "NAME"
3.LP 3.LP
4cpupower frequency\-info \- Utility to retrieve cpufreq kernel information 4cpupower frequency\-info \- Utility to retrieve cpufreq kernel information
@@ -50,8 +50,6 @@ Prints out information like provided by the /proc/cpufreq interface in 2.4. and
50\fB\-m\fR \fB\-\-human\fR 50\fB\-m\fR \fB\-\-human\fR
51human\-readable output for the \-f, \-w, \-s and \-y parameters. 51human\-readable output for the \-f, \-w, \-s and \-y parameters.
52.TP 52.TP
53\fB\-h\fR \fB\-\-help\fR
54Prints out the help screen.
55.SH "REMARKS" 53.SH "REMARKS"
56.LP 54.LP
57By default only values of core zero are displayed. How to display settings of 55By default only values of core zero are displayed. How to display settings of
diff --git a/tools/power/cpupower/man/cpupower-frequency-set.1 b/tools/power/cpupower/man/cpupower-frequency-set.1
index 685f469093ad..3eacc8d03d1a 100644
--- a/tools/power/cpupower/man/cpupower-frequency-set.1
+++ b/tools/power/cpupower/man/cpupower-frequency-set.1
@@ -1,4 +1,4 @@
1.TH "cpupower-freqency-set" "1" "0.1" "Mattia Dongili" "" 1.TH "CPUPOWER\-FREQUENCY\-SET" "1" "0.1" "" "cpupower Manual"
2.SH "NAME" 2.SH "NAME"
3.LP 3.LP
4cpupower frequency\-set \- A small tool which allows to modify cpufreq settings. 4cpupower frequency\-set \- A small tool which allows to modify cpufreq settings.
@@ -26,8 +26,6 @@ specific frequency to be set. Requires userspace governor to be available and lo
26\fB\-r\fR \fB\-\-related\fR 26\fB\-r\fR \fB\-\-related\fR
27modify all hardware-related CPUs at the same time 27modify all hardware-related CPUs at the same time
28.TP 28.TP
29\fB\-h\fR \fB\-\-help\fR
30Prints out the help screen.
31.SH "REMARKS" 29.SH "REMARKS"
32.LP 30.LP
33By default values are applied on all cores. How to modify single core 31By default values are applied on all cores. How to modify single core
diff --git a/tools/power/cpupower/man/cpupower-idle-info.1 b/tools/power/cpupower/man/cpupower-idle-info.1
new file mode 100644
index 000000000000..4178effd9e99
--- /dev/null
+++ b/tools/power/cpupower/man/cpupower-idle-info.1
@@ -0,0 +1,90 @@
1.TH "CPUPOWER-IDLE-INFO" "1" "0.1" "" "cpupower Manual"
2.SH "NAME"
3.LP
4cpupower idle\-info \- Utility to retrieve cpu idle kernel information
5.SH "SYNTAX"
6.LP
7cpupower [ \-c cpulist ] idle\-info [\fIoptions\fP]
8.SH "DESCRIPTION"
9.LP
10A tool which prints out per cpu idle information helpful to developers and interested users.
11.SH "OPTIONS"
12.LP
13.TP
14\fB\-f\fR \fB\-\-silent\fR
15Only print a summary of all available C-states in the system.
16.TP
17\fB\-e\fR \fB\-\-proc\fR
18deprecated.
19Prints out idle information in old /proc/acpi/processor/*/power format. This
20interface has been removed from the kernel for quite some time, do not let
21further code depend on this option, best do not use it.
22
23.SH IDLE\-INFO DESCRIPTIONS
24CPU sleep state statistics and descriptions are retrieved from sysfs files,
25exported by the cpuidle kernel subsystem. The kernel only updates these
26statistics when it enters or leaves an idle state, therefore on a very idle or
27a very busy system, these statistics may not be accurate. They still provide a
28good overview about the usage and availability of processor sleep states on
29the platform.
30
31Be aware that the sleep states as exported by the hardware or BIOS and used by
32the Linux kernel may not exactly reflect the capabilities of the
33processor. This often is the case on the X86 architecture when the acpi_idle
34driver is used. It is also possible that the hardware overrules the kernel
35requests, due to internal activity monitors or other reasons.
36On recent X86 platforms it is often possible to read out hardware registers
37which monitor the duration of sleep states the processor resided in. The
38cpupower monitor tool (cpupower\-monitor(1)) can be used to show real sleep
39state residencies. Please refer to the architecture specific description
40section below.
41
42.SH IDLE\-INFO ARCHITECTURE SPECIFIC DESCRIPTIONS
43.SS "X86"
44POLL idle state
45
46If cpuidle is active, X86 platforms have one special idle state.
47The POLL idle state is not a real idle state, it does not save any
48power. Instead, a busy\-loop is executed doing nothing for a short period of
49time. This state is used if the kernel knows that work has to be processed
50very soon and entering any real hardware idle state may result in a slight
51performance penalty.
52
53There exist two different cpuidle drivers on the X86 architecture platform:
54
55"acpi_idle" cpuidle driver
56
57The acpi_idle cpuidle driver retrieves available sleep states (C\-states) from
58the ACPI BIOS tables (from the _CST ACPI function on recent platforms or from
59the FADT BIOS table on older ones).
60The C1 state is not retrieved from ACPI tables. If the C1 state is entered,
61the kernel will call the hlt instruction (or mwait on Intel).
62
63"intel_idle" cpuidle driver
64
65In kernel 2.6.36 the intel_idle driver was introduced.
66It only serves recent Intel CPUs (Nehalem, Westmere, Sandybridge, Atoms or
67newer). On older Intel CPUs the acpi_idle driver is still used (if the BIOS
68provides C\-state ACPI tables).
69The intel_idle driver knows the sleep state capabilities of the processor and
70ignores ACPI BIOS exported processor sleep states tables.
71
72.SH "REMARKS"
73.LP
74By default only values of core zero are displayed. How to display settings of
75other cores is described in the cpupower(1) manpage in the \-\-cpu option
76section.
77.SH REFERENCES
78http://www.acpi.info/spec.htm
79.SH "FILES"
80.nf
81\fI/sys/devices/system/cpu/cpu*/cpuidle/state*\fP
82\fI/sys/devices/system/cpu/cpuidle/*\fP
83.fi
84.SH "AUTHORS"
85.nf
86Thomas Renninger <trenn@suse.de>
87.fi
88.SH "SEE ALSO"
89.LP
90cpupower(1), cpupower\-monitor(1), cpupower\-info(1), cpupower\-set(1)
diff --git a/tools/power/cpupower/man/cpupower-monitor.1 b/tools/power/cpupower/man/cpupower-monitor.1
index d5cfa265c3d3..1141c2073719 100644
--- a/tools/power/cpupower/man/cpupower-monitor.1
+++ b/tools/power/cpupower/man/cpupower-monitor.1
@@ -107,7 +107,7 @@ Deepest package sleep states may in reality show up as machine/platform wide
107sleep states and can only be entered if all cores are idle. Look up Intel 107sleep states and can only be entered if all cores are idle. Look up Intel
108manuals (some are provided in the References section) for further details. 108manuals (some are provided in the References section) for further details.
109 109
110.SS "Ontario" "Liano" 110.SS "Fam_12h" "Fam_14h"
111AMD laptop and desktop processor (family 12h and 14h) sleep state counters. 111AMD laptop and desktop processor (family 12h and 14h) sleep state counters.
112The registers are accessed via PCI and therefore can still be read out while 112The registers are accessed via PCI and therefore can still be read out while
113cores have been offlined. 113cores have been offlined.
diff --git a/tools/power/cpupower/utils/cpuidle-info.c b/tools/power/cpupower/utils/cpuidle-info.c
index b028267c1376..8145af5f93a6 100644
--- a/tools/power/cpupower/utils/cpuidle-info.c
+++ b/tools/power/cpupower/utils/cpuidle-info.c
@@ -35,17 +35,9 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose)
35 printf(_("CPU %u: Can't read idle state info\n"), cpu); 35 printf(_("CPU %u: Can't read idle state info\n"), cpu);
36 return; 36 return;
37 } 37 }
38 tmp = sysfs_get_idlestate_name(cpu, idlestates - 1);
39 if (!tmp) {
40 printf(_("Could not determine max idle state %u\n"),
41 idlestates - 1);
42 return;
43 }
44
45 printf(_("Number of idle states: %d\n"), idlestates); 38 printf(_("Number of idle states: %d\n"), idlestates);
46
47 printf(_("Available idle states:")); 39 printf(_("Available idle states:"));
48 for (idlestate = 1; idlestate < idlestates; idlestate++) { 40 for (idlestate = 0; idlestate < idlestates; idlestate++) {
49 tmp = sysfs_get_idlestate_name(cpu, idlestate); 41 tmp = sysfs_get_idlestate_name(cpu, idlestate);
50 if (!tmp) 42 if (!tmp)
51 continue; 43 continue;
@@ -57,7 +49,7 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose)
57 if (!verbose) 49 if (!verbose)
58 return; 50 return;
59 51
60 for (idlestate = 1; idlestate < idlestates; idlestate++) { 52 for (idlestate = 0; idlestate < idlestates; idlestate++) {
61 tmp = sysfs_get_idlestate_name(cpu, idlestate); 53 tmp = sysfs_get_idlestate_name(cpu, idlestate);
62 if (!tmp) 54 if (!tmp)
63 continue; 55 continue;
diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c
index 87d5605bdda8..6437ef39aeea 100644
--- a/tools/power/cpupower/utils/helpers/amd.c
+++ b/tools/power/cpupower/utils/helpers/amd.c
@@ -112,14 +112,12 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family,
112int amd_pci_get_num_boost_states(int *active, int *states) 112int amd_pci_get_num_boost_states(int *active, int *states)
113{ 113{
114 struct pci_access *pci_acc; 114 struct pci_access *pci_acc;
115 int vendor_id = 0x1022;
116 int boost_dev_ids[4] = {0x1204, 0x1604, 0x1704, 0};
117 struct pci_dev *device; 115 struct pci_dev *device;
118 uint8_t val = 0; 116 uint8_t val = 0;
119 117
120 *active = *states = 0; 118 *active = *states = 0;
121 119
122 device = pci_acc_init(&pci_acc, vendor_id, boost_dev_ids); 120 device = pci_slot_func_init(&pci_acc, 0x18, 4);
123 121
124 if (device == NULL) 122 if (device == NULL)
125 return -ENODEV; 123 return -ENODEV;
diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h
index 2747e738efb0..2eb584cf2f55 100644
--- a/tools/power/cpupower/utils/helpers/helpers.h
+++ b/tools/power/cpupower/utils/helpers/helpers.h
@@ -66,8 +66,8 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL,
66#define CPUPOWER_CAP_AMD_CBP 0x00000004 66#define CPUPOWER_CAP_AMD_CBP 0x00000004
67#define CPUPOWER_CAP_PERF_BIAS 0x00000008 67#define CPUPOWER_CAP_PERF_BIAS 0x00000008
68#define CPUPOWER_CAP_HAS_TURBO_RATIO 0x00000010 68#define CPUPOWER_CAP_HAS_TURBO_RATIO 0x00000010
69#define CPUPOWER_CAP_IS_SNB 0x00000011 69#define CPUPOWER_CAP_IS_SNB 0x00000020
70#define CPUPOWER_CAP_INTEL_IDA 0x00000012 70#define CPUPOWER_CAP_INTEL_IDA 0x00000040
71 71
72#define MAX_HW_PSTATES 10 72#define MAX_HW_PSTATES 10
73 73
@@ -132,8 +132,11 @@ extern unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu);
132 132
133/* PCI stuff ****************************/ 133/* PCI stuff ****************************/
134extern int amd_pci_get_num_boost_states(int *active, int *states); 134extern int amd_pci_get_num_boost_states(int *active, int *states);
135extern struct pci_dev *pci_acc_init(struct pci_access **pacc, int vendor_id, 135extern struct pci_dev *pci_acc_init(struct pci_access **pacc, int domain,
136 int *dev_ids); 136 int bus, int slot, int func, int vendor,
137 int dev);
138extern struct pci_dev *pci_slot_func_init(struct pci_access **pacc,
139 int slot, int func);
137 140
138/* PCI stuff ****************************/ 141/* PCI stuff ****************************/
139 142
diff --git a/tools/power/cpupower/utils/helpers/pci.c b/tools/power/cpupower/utils/helpers/pci.c
index cd2eb6fe41c4..9690798e6446 100644
--- a/tools/power/cpupower/utils/helpers/pci.c
+++ b/tools/power/cpupower/utils/helpers/pci.c
@@ -10,19 +10,24 @@
10 * **pacc : if a valid pci_dev is returned 10 * **pacc : if a valid pci_dev is returned
11 * *pacc must be passed to pci_acc_cleanup to free it 11 * *pacc must be passed to pci_acc_cleanup to free it
12 * 12 *
13 * vendor_id : the pci vendor id matching the pci device to access 13 * domain: domain
14 * dev_ids : device ids matching the pci device to access 14 * bus: bus
15 * slot: slot
16 * func: func
17 * vendor: vendor
18 * device: device
19 * Pass -1 for one of the six above to match any
15 * 20 *
16 * Returns : 21 * Returns :
17 * struct pci_dev which can be used with pci_{read,write}_* functions 22 * struct pci_dev which can be used with pci_{read,write}_* functions
18 * to access the PCI config space of matching pci devices 23 * to access the PCI config space of matching pci devices
19 */ 24 */
20struct pci_dev *pci_acc_init(struct pci_access **pacc, int vendor_id, 25struct pci_dev *pci_acc_init(struct pci_access **pacc, int domain, int bus,
21 int *dev_ids) 26 int slot, int func, int vendor, int dev)
22{ 27{
23 struct pci_filter filter_nb_link = { -1, -1, -1, -1, vendor_id, 0}; 28 struct pci_filter filter_nb_link = { domain, bus, slot, func,
29 vendor, dev };
24 struct pci_dev *device; 30 struct pci_dev *device;
25 unsigned int i;
26 31
27 *pacc = pci_alloc(); 32 *pacc = pci_alloc();
28 if (*pacc == NULL) 33 if (*pacc == NULL)
@@ -31,14 +36,20 @@ struct pci_dev *pci_acc_init(struct pci_access **pacc, int vendor_id,
31 pci_init(*pacc); 36 pci_init(*pacc);
32 pci_scan_bus(*pacc); 37 pci_scan_bus(*pacc);
33 38
34 for (i = 0; dev_ids[i] != 0; i++) { 39 for (device = (*pacc)->devices; device; device = device->next) {
35 filter_nb_link.device = dev_ids[i]; 40 if (pci_filter_match(&filter_nb_link, device))
36 for (device = (*pacc)->devices; device; device = device->next) { 41 return device;
37 if (pci_filter_match(&filter_nb_link, device))
38 return device;
39 }
40 } 42 }
41 pci_cleanup(*pacc); 43 pci_cleanup(*pacc);
42 return NULL; 44 return NULL;
43} 45}
46
47/* Typically one wants to get a specific slot(device)/func of the root domain
48 and bus */
49struct pci_dev *pci_slot_func_init(struct pci_access **pacc, int slot,
50 int func)
51{
52 return pci_acc_init(pacc, 0, 0, slot, func, -1, -1);
53}
54
44#endif /* defined(__i386__) || defined(__x86_64__) */ 55#endif /* defined(__i386__) || defined(__x86_64__) */
diff --git a/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
index 202e555988be..2116df9ad832 100644
--- a/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
+++ b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
@@ -20,8 +20,6 @@
20#include "idle_monitor/cpupower-monitor.h" 20#include "idle_monitor/cpupower-monitor.h"
21#include "helpers/helpers.h" 21#include "helpers/helpers.h"
22 22
23/******** PCI parts could go into own file and get shared ***************/
24
25#define PCI_NON_PC0_OFFSET 0xb0 23#define PCI_NON_PC0_OFFSET 0xb0
26#define PCI_PC1_OFFSET 0xb4 24#define PCI_PC1_OFFSET 0xb4
27#define PCI_PC6_OFFSET 0xb8 25#define PCI_PC6_OFFSET 0xb8
@@ -82,10 +80,7 @@ static cstate_t amd_fam14h_cstates[AMD_FAM14H_STATE_NUM] = {
82}; 80};
83 81
84static struct pci_access *pci_acc; 82static struct pci_access *pci_acc;
85static int pci_vendor_id = 0x1022;
86static int pci_dev_ids[2] = {0x1716, 0};
87static struct pci_dev *amd_fam14h_pci_dev; 83static struct pci_dev *amd_fam14h_pci_dev;
88
89static int nbp1_entered; 84static int nbp1_entered;
90 85
91struct timespec start_time; 86struct timespec start_time;
@@ -286,13 +281,13 @@ struct cpuidle_monitor *amd_fam14h_register(void)
286 if (cpupower_cpu_info.vendor != X86_VENDOR_AMD) 281 if (cpupower_cpu_info.vendor != X86_VENDOR_AMD)
287 return NULL; 282 return NULL;
288 283
289 if (cpupower_cpu_info.family == 0x14) { 284 if (cpupower_cpu_info.family == 0x14)
290 if (cpu_count <= 0 || cpu_count > 2) { 285 strncpy(amd_fam14h_monitor.name, "Fam_14h",
291 fprintf(stderr, "AMD fam14h: Invalid cpu count: %d\n", 286 MONITOR_NAME_LEN - 1);
292 cpu_count); 287 else if (cpupower_cpu_info.family == 0x12)
293 return NULL; 288 strncpy(amd_fam14h_monitor.name, "Fam_12h",
294 } 289 MONITOR_NAME_LEN - 1);
295 } else 290 else
296 return NULL; 291 return NULL;
297 292
298 /* We do not alloc for nbp1 machine wide counter */ 293 /* We do not alloc for nbp1 machine wide counter */
@@ -303,7 +298,9 @@ struct cpuidle_monitor *amd_fam14h_register(void)
303 sizeof(unsigned long long)); 298 sizeof(unsigned long long));
304 } 299 }
305 300
306 amd_fam14h_pci_dev = pci_acc_init(&pci_acc, pci_vendor_id, pci_dev_ids); 301 /* We need PCI device: Slot 18, Func 6, compare with BKDG
302 for fam 12h/14h */
303 amd_fam14h_pci_dev = pci_slot_func_init(&pci_acc, 0x18, 6);
307 if (amd_fam14h_pci_dev == NULL || pci_acc == NULL) 304 if (amd_fam14h_pci_dev == NULL || pci_acc == NULL)
308 return NULL; 305 return NULL;
309 306
@@ -325,7 +322,7 @@ static void amd_fam14h_unregister(void)
325} 322}
326 323
327struct cpuidle_monitor amd_fam14h_monitor = { 324struct cpuidle_monitor amd_fam14h_monitor = {
328 .name = "Ontario", 325 .name = "",
329 .hw_states = amd_fam14h_cstates, 326 .hw_states = amd_fam14h_cstates,
330 .hw_states_num = AMD_FAM14H_STATE_NUM, 327 .hw_states_num = AMD_FAM14H_STATE_NUM,
331 .start = amd_fam14h_start, 328 .start = amd_fam14h_start,