Skip to contentSkip to conversation

cpupower update for Linux 5.12-rc1

GIT PULL Shuah Khan 2 participants 2 messages Feb 8, 2021 CPU power monitoring

lore
Share & tools
lore

Shuah Khan

author maintainer
#0 lore raw

Hi Rafael,

Please pull the following cpupower update for Linux 5.12-rc1

This cpupower update for Linux 5.12-rc1 consists of:

- Updates to the cpupower command to add support for AMD family 0x19 and cleanup the code to remove many of the family checks to make future family updates easier.

- Adding Makefile dependencies for install targets to allow building cpupower in parallel rather than serially.

diff is attached.

thanks,
-- Shuah

----------------------------------------------------------------
The following changes since commit e71ba9452f0b5b2e8dc8aa5445198cd9214a6a62:

Linux 5.11-rc2 (2021-01-03 15:55:30 -0800)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux
tags/linux-cpupower-5.12-rc1

for you to fetch changes up to 3a3ecfdb605cc8d98988012a4f88c34b4d220c21:

cpupower: Add cpuid cap flag for MSR_AMD_HWCR support (2021-01-26
09:40:45 -0700)

----------------------------------------------------------------
linux-cpupower-5.12-rc1

This cpupower update for Linux 5.12-rc1 consists of:

- Updates to the cpupower command to add support for AMD family 0x19 and cleanup the code to remove many of the family checks to make future family updates easier.

- Adding Makefile dependencies for install targets to allow building cpupower in parallel rather than serially.

----------------------------------------------------------------
Ivan Babrou (1):
cpupower: add Makefile dependencies for install targets

Nathan Fontenot (7):
cpupower: Update msr_pstate union struct naming
cpupower: Add CPUPOWER_CAP_AMD_HW_PSTATE cpuid caps flag
cpupower: Remove unused pscur variable.
cpupower: Update family checks when decoding HW pstates
cpupower: Condense pstate enabled bit checks in decode_pstates()
cpupower: Remove family arg to decode_pstates()
cpupower: Add cpuid cap flag for MSR_AMD_HWCR support

Robert Richter (1):
cpupower: Correct macro name for CPB caps flag

 tools/power/cpupower/Makefile                |  8 ++--
 tools/power/cpupower/bench/Makefile          |  2 +-
 tools/power/cpupower/utils/cpufreq-info.c    |  3 +-
 tools/power/cpupower/utils/helpers/amd.c     | 65 
+++++++++++++---------------
 tools/power/cpupower/utils/helpers/cpuid.c   | 20 +++++++--
 tools/power/cpupower/utils/helpers/helpers.h | 14 +++---
 tools/power/cpupower/utils/helpers/misc.c    |  9 +---
 7 files changed, 62 insertions(+), 59 deletions(-)

----------------------------------------------------------------

tools/power/cpupower/Makefile +4 -4
index c7bcddbd486d..3b1594447f29 100644
@@ -270,14 +270,14 @@ clean:
 	$(MAKE) -C bench O=$(OUTPUT) clean
 
 
-install-lib:
+install-lib: libcpupower
 	$(INSTALL) -d $(DESTDIR)${libdir}
 	$(CP) $(OUTPUT)libcpupower.so* $(DESTDIR)${libdir}/
 	$(INSTALL) -d $(DESTDIR)${includedir}
 	$(INSTALL_DATA) lib/cpufreq.h $(DESTDIR)${includedir}/cpufreq.h
 	$(INSTALL_DATA) lib/cpuidle.h $(DESTDIR)${includedir}/cpuidle.h
 
-install-tools:
+install-tools: $(OUTPUT)cpupower
 	$(INSTALL) -d $(DESTDIR)${bindir}
 	$(INSTALL_PROGRAM) $(OUTPUT)cpupower $(DESTDIR)${bindir}
 	$(INSTALL) -d $(DESTDIR)${bash_completion_dir}
@@ -293,14 +293,14 @@ install-man:
 	$(INSTALL_DATA) -D man/cpupower-info.1 $(DESTDIR)${mandir}/man1/cpupower-info.1
 	$(INSTALL_DATA) -D man/cpupower-monitor.1 $(DESTDIR)${mandir}/man1/cpupower-monitor.1
 
-install-gmo:
+install-gmo: create-gmo
 	$(INSTALL) -d $(DESTDIR)${localedir}
 	for HLANG in $(LANGUAGES); do \
 		echo '$(INSTALL_DATA) -D $(OUTPUT)po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo'; \
 		$(INSTALL_DATA) -D $(OUTPUT)po/$$HLANG.gmo $(DESTDIR)${localedir}/$$HLANG/LC_MESSAGES/cpupower.mo; \
 	done;
 
-install-bench:
+install-bench: compile-bench
 	@#DESTDIR must be set from outside to survive
 	@sbindir=$(sbindir) bindir=$(bindir) docdir=$(docdir) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT) install
 
tools/power/cpupower/bench/Makefile +1 -1
index f68b4bc55273..d9d9923af85c 100644
@@ -27,7 +27,7 @@ $(OUTPUT)cpufreq-bench: $(OBJS)
 
 all: $(OUTPUT)cpufreq-bench
 
-install:
+install: $(OUTPUT)cpufreq-bench
 	mkdir -p $(DESTDIR)/$(sbindir)
 	mkdir -p $(DESTDIR)/$(bindir)
 	mkdir -p $(DESTDIR)/$(docdir)
tools/power/cpupower/utils/cpufreq-info.c +1 -2
index 6efc0f6b1b11..f9895e31ff5a 100644
@@ -186,8 +186,7 @@ static int get_boost_mode_x86(unsigned int cpu)
 	if ((cpupower_cpu_info.vendor == X86_VENDOR_AMD &&
 	     cpupower_cpu_info.family >= 0x10) ||
 	     cpupower_cpu_info.vendor == X86_VENDOR_HYGON) {
-		ret = decode_pstates(cpu, cpupower_cpu_info.family, b_states,
-				     pstates, &pstate_no);
+		ret = decode_pstates(cpu, b_states, pstates, &pstate_no);
 		if (ret)
 			return ret;
 
tools/power/cpupower/utils/helpers/amd.c +29 -36

131 lines not on this page · raw message

tools/power/cpupower/utils/helpers/cpuid.c +17 -3
index 73bfafc60e9b..72eb43593180 100644
@@ -128,9 +128,23 @@ int get_cpu_info(struct cpupower_cpu_info *cpu_info)
 	/* AMD or Hygon Boost state enable/disable register */
 	if (cpu_info->vendor == X86_VENDOR_AMD ||
 	    cpu_info->vendor == X86_VENDOR_HYGON) {
-		if (ext_cpuid_level >= 0x80000007 &&
-		    (cpuid_edx(0x80000007) & (1 << 9)))
-			cpu_info->caps |= CPUPOWER_CAP_AMD_CBP;
+		if (ext_cpuid_level >= 0x80000007) {
+			if (cpuid_edx(0x80000007) & (1 << 9)) {
+				cpu_info->caps |= CPUPOWER_CAP_AMD_CPB;
+
+				if (cpu_info->family >= 0x17)
+					cpu_info->caps |= CPUPOWER_CAP_AMD_CPB_MSR;
+			}
+
+			if ((cpuid_edx(0x80000007) & (1 << 7)) &&
+			    cpu_info->family != 0x14) {
+				/* HW pstate was not implemented in family 0x14 */
+				cpu_info->caps |= CPUPOWER_CAP_AMD_HW_PSTATE;
+
+				if (cpu_info->family >= 0x17)
+					cpu_info->caps |= CPUPOWER_CAP_AMD_PSTATEDEF;
+			}
+		}
 
 		if (ext_cpuid_level >= 0x80000008 &&
 		    cpuid_ebx(0x80000008) & (1 << 4))
tools/power/cpupower/utils/helpers/helpers.h +8 -6
index 0642e60a6ce1..33ffacee7fcb 100644
@@ -64,12 +64,15 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL,
 
 #define CPUPOWER_CAP_INV_TSC		0x00000001
 #define CPUPOWER_CAP_APERF		0x00000002
-#define CPUPOWER_CAP_AMD_CBP		0x00000004
+#define CPUPOWER_CAP_AMD_CPB		0x00000004
 #define CPUPOWER_CAP_PERF_BIAS		0x00000008
 #define CPUPOWER_CAP_HAS_TURBO_RATIO	0x00000010
 #define CPUPOWER_CAP_IS_SNB		0x00000020
 #define CPUPOWER_CAP_INTEL_IDA		0x00000040
 #define CPUPOWER_CAP_AMD_RDPRU		0x00000080
+#define CPUPOWER_CAP_AMD_HW_PSTATE	0x00000100
+#define CPUPOWER_CAP_AMD_PSTATEDEF	0x00000200
+#define CPUPOWER_CAP_AMD_CPB_MSR	0x00000400
 
 #define CPUPOWER_AMD_CPBDIS		0x02000000
 
@@ -125,8 +128,8 @@ extern struct pci_dev *pci_slot_func_init(struct pci_access **pacc,
 
 /* AMD HW pstate decoding **************************/
 
-extern int decode_pstates(unsigned int cpu, unsigned int cpu_family,
-			  int boost_states, unsigned long *pstates, int *no);
+extern int decode_pstates(unsigned int cpu, int boost_states,
+			  unsigned long *pstates, int *no);
 
 /* AMD HW pstate decoding **************************/
 
@@ -143,9 +146,8 @@ unsigned int cpuid_edx(unsigned int op);
 /* cpuid and cpuinfo helpers  **************************/
 /* X86 ONLY ********************************************/
 #else
-static inline int decode_pstates(unsigned int cpu, unsigned int cpu_family,
-				 int boost_states, unsigned long *pstates,
-				 int *no)
+static inline int decode_pstates(unsigned int cpu, int boost_states,
+				 unsigned long *pstates, int *no)
 { return -1; };
 
 static inline int read_msr(int cpu, unsigned int idx, unsigned long long *val)
tools/power/cpupower/utils/helpers/misc.c +2 -7
index 650b9a9a6584..fc6e34511721 100644
@@ -16,17 +16,12 @@
 int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active,
 			int *states)
 {
-	struct cpupower_cpu_info cpu_info;
 	int ret;
 	unsigned long long val;
 
 	*support = *active = *states = 0;
 
-	ret = get_cpu_info(&cpu_info);
-	if (ret)
-		return ret;
-
-	if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CBP) {
+	if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CPB) {
 		*support = 1;
 
 		/* AMD Family 0x17 does not utilize PCI D18F4 like prior
@@ -34,7 +29,7 @@ int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active,
 		 * has Hardware determined variable increments instead.
 		 */
 
-		if (cpu_info.family == 0x17 || cpu_info.family == 0x18) {
+		if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CPB_MSR) {
 			if (!read_msr(cpu, MSR_AMD_HWCR, &val)) {
 				if (!(val & CPUPOWER_AMD_CPBDIS))
 					*active = 1;
#1 lore raw
Quoted 7 lines · Shuah Khan

Hi Rafael,

Please pull the following cpupower update for Linux 5.12-rc1

This cpupower update for Linux 5.12-rc1 consists of:

Quoted 8 lines

- Updates to the cpupower command to add support for AMD family 0x19 and cleanup the code to remove many of the family checks to make future family updates easier.

- Adding Makefile dependencies for install targets to allow building cpupower in parallel rather than serially.

diff is attached.

Pulled, thanks!