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

Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/cpupowerutils

Pull cpupower updates from Dominik Brodowski.

* git://git.kernel.org/pub/scm/linux/kernel/git/brodo/cpupowerutils:
cpupower tools: add install target to the debug tools' makefiles
cpupower tools: allow to build debug tools in a separate directory too
cpupower: Fix broken mask values
cpupower tool: allow to build in a separate directory
cpupower tool: makefile: simplify the recipe used to generate cpupower.pot target
cpupower tool: remove use of undefined variables from the clean target of the top makefile
cpupower: Fix linking with --as-needed
cpupower: Remove unneeded code and by that fix a memleak
cpupower: Fix number of idle states
cpupower: Unify cpupower-frequency-* manpages
cpupower: Add cpupower-idle-info manpage
cpupower: AMD fam14h/Ontario monitor can also be used by fam12h cpus
cpupower: Better interface for accessing AMD pci registers

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