[GIT PULL] cpupower fixes update for Linux 7.3-rc1

Shuah Khan <[email protected]>
Newsgroups org.kernel.vger.linux-pm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Hi Rafael,

Please pull the cpupower update for Linux 7.3-rc1.

Adds support for generic CPPC display that depends only on standardized
fields, improving AMD specific implementation for the same.

Removes conditional return with no effect as part of tree-wide code clean
up effort.

diff is attached.

thanks,
-- Shuah

----------------------------------------------------------------
The following changes since commit dc59e4fea9d83f03bad6bddf3fa2e52491777482:

   Linux 7.2-rc1 (2026-06-28 12:01:31 -0700)

are available in the Git repository at:

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

for you to fetch changes up to adfe0057326ffbc2cd5ff69a57ec0e50b5e74095:

   cpupower: remove conditional return with no effect (2026-08-04 13:12:06 -0600)

----------------------------------------------------------------
linux-cpupower-7.3-rc1

Adds support for generic CPPC display that depends only on standardized
fields, improving AMD specific implementation for the same.

Removes conditional return with no effect as part of tree-wide code clean
up effort.

----------------------------------------------------------------
Jeremy Linton (4):
       cpupower: Add generic CPPC performance display
       cpupower: Build and call CPPC information on non-AMD processors
       cpupower: Print kernel and hardware frequency information
       cpupower: Add libm to cpupower for generic CPPC view

Sang-Heon Jeon (1):
       cpupower: remove conditional return with no effect

  tools/power/cpupower/Makefile                |  6 +--
  tools/power/cpupower/utils/cpufreq-info.c    | 11 +++---
  tools/power/cpupower/utils/helpers/cppc.c    | 56 ++++++++++++++++++++++++++++
  tools/power/cpupower/utils/helpers/helpers.h |  2 +
  tools/power/cpupower/utils/powercap-info.c   |  2 -
  5 files changed, 67 insertions(+), 10 deletions(-)
  create mode 100644 tools/power/cpupower/utils/helpers/cppc.c
----------------------------------------------------------------
linux-cpupower-7.3-rc1.diff (text/x-patch, 5.4 KB)
diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
index 969716dfe8de..ab428e336d87 100644
--- a/tools/power/cpupower/Makefile
+++ b/tools/power/cpupower/Makefile
@@ -131,7 +131,7 @@ override CFLAGS += -DVERSION=\"$(VERSION)\" -DPACKAGE=\"$(PACKAGE)\" \
 
 UTIL_OBJS =  utils/helpers/amd.o utils/helpers/msr.o \
 	utils/helpers/sysfs.o utils/helpers/misc.o utils/helpers/cpuid.o \
-	utils/helpers/pci.o utils/helpers/bitmask.o \
+	utils/helpers/pci.o utils/helpers/bitmask.o utils/helpers/cppc.o \
 	utils/idle_monitor/nhm_idle.o utils/idle_monitor/snb_idle.o \
 	utils/idle_monitor/hsw_ext_idle.o \
 	utils/idle_monitor/amd_fam14h_idle.o utils/idle_monitor/cpuidle_sysfs.o \
@@ -236,9 +236,9 @@ $(OUTPUT)%.o: %.c
 $(OUTPUT)cpupower: $(UTIL_OBJS) $(OUTPUT)$(LIBCPUPOWER)
 	$(ECHO) "  CC      " $@
 ifeq ($(strip $(STATIC)),true)
-	$(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lrt -lpci -L$(OUTPUT) -o $@
+	$(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lm -lrt -lpci -L$(OUTPUT) -o $@
 else
-	$(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lcpupower -lrt -lpci -L$(OUTPUT) -o $@
+	$(QUIET) $(CC) $(CFLAGS) $(LDFLAGS) $(UTIL_OBJS) -lm -lcpupower -lrt -lpci -L$(OUTPUT) -o $@
 endif
 	$(QUIET) $(STRIPCMD) $@
 
diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c
index 5a242b491a9d..11629ae49f98 100644
--- a/tools/power/cpupower/utils/cpufreq-info.c
+++ b/tools/power/cpupower/utils/cpufreq-info.c
@@ -270,10 +270,10 @@ static int get_freq_hardware(unsigned int cpu, unsigned int human)
 {
 	unsigned long freq;
 
-	if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF))
+	freq = cpufreq_get_freq_hardware(cpu);
+	if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_APERF) && !freq)
 		return -EINVAL;
 
-	freq = cpufreq_get_freq_hardware(cpu);
 	printf(_("  current CPU frequency: "));
 	if (!freq) {
 		printf("Unable to call hardware\n");
@@ -477,12 +477,13 @@ static int get_latency(unsigned int cpu, unsigned int human)
 }
 
 /* --performance / -c */
-
 static int get_perf_cap(unsigned int cpu)
 {
 	if (cpupower_cpu_info.vendor == X86_VENDOR_AMD &&
 	    cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATE)
 		amd_pstate_show_perf_and_freq(cpu, no_rounding);
+	else
+		cppc_show_perf_and_freq(cpu, no_rounding);
 
 	return 0;
 }
@@ -513,8 +514,8 @@ static void debug_output_one(unsigned int cpu)
 
 	get_available_governors(cpu);
 	get_policy(cpu);
-	if (get_freq_hardware(cpu, 1) < 0)
-		get_freq_kernel(cpu, 1);
+	get_freq_hardware(cpu, 1);
+	get_freq_kernel(cpu, 1);
 	get_boost_mode(cpu);
 	get_perf_cap(cpu);
 }
diff --git a/tools/power/cpupower/utils/helpers/cppc.c b/tools/power/cpupower/utils/helpers/cppc.c
new file mode 100644
index 000000000000..3493ce8551ea
--- /dev/null
+++ b/tools/power/cpupower/utils/helpers/cppc.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "helpers/helpers.h"
+#include "cpufreq.h"
+#include "acpi_cppc.h"
+
+#define cppc_to_frequency(perf) (roundf(slope * (perf) + intercept))
+
+void cppc_show_perf_and_freq(unsigned int cpu, int no_rounding)
+{
+	int64_t nominal = acpi_cppc_get_data(cpu, NOMINAL_PERF);
+	int64_t nominal_freq = acpi_cppc_get_data(cpu, NOMINAL_FREQ) * 1000;
+	int64_t lowest = acpi_cppc_get_data(cpu, LOWEST_PERF);
+	int64_t lowest_freq = acpi_cppc_get_data(cpu, LOWEST_FREQ) * 1000;
+	unsigned long non_linear = acpi_cppc_get_data(cpu, LOWEST_NONLINEAR_PERF);
+	unsigned long highest = acpi_cppc_get_data(cpu, HIGHEST_PERF);
+	float slope, intercept;
+
+	/* do the optional freq fields look invalid? */
+	if (!nominal_freq || !lowest_freq || nominal == lowest)
+		return;
+
+	slope = (float)(nominal_freq - lowest_freq) / (nominal - lowest);
+	intercept = lowest_freq - slope * lowest;
+
+	printf(_("  CPPC limits:\n"));
+	printf(_("    Highest Performance: %lu. Maximum Frequency: "),
+	       highest);
+	/*
+	 * If boost isn't active, the cpuinfo_max doesn't indicate real max
+	 * frequency.
+	 */
+	print_speed(cppc_to_frequency(highest), no_rounding);
+	printf(".\n");
+
+	printf(_("    Nominal Performance: %lu. Nominal Frequency: "),
+	       acpi_cppc_get_data(cpu, NOMINAL_PERF));
+	print_speed(nominal_freq,  no_rounding);
+	printf(".\n");
+
+	printf(_("    Lowest Non-linear Performance: %lu. Lowest Non-linear Frequency: "),
+	       non_linear);
+	print_speed(cppc_to_frequency(non_linear), no_rounding);
+	printf(".\n");
+
+	printf(_("    Lowest Performance: %lu. Lowest Frequency: "),
+	       acpi_cppc_get_data(cpu, LOWEST_PERF));
+	print_speed(lowest_freq, no_rounding);
+	printf(".\n");
+}
diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h
index a3ad80b9c2c2..9c5126b63966 100644
--- a/tools/power/cpupower/utils/helpers/helpers.h
+++ b/tools/power/cpupower/utils/helpers/helpers.h
@@ -221,4 +221,6 @@ void print_online_cpus(void);
 void print_offline_cpus(void);
 void print_speed(unsigned long speed, int no_rounding);
 
+void cppc_show_perf_and_freq(unsigned int cpu, int no_rounding);
+
 #endif /* __CPUPOWERUTILS_HELPERS__ */
diff --git a/tools/power/cpupower/utils/powercap-info.c b/tools/power/cpupower/utils/powercap-info.c
index e53033488218..88a5edb76315 100644
--- a/tools/power/cpupower/utils/powercap-info.c
+++ b/tools/power/cpupower/utils/powercap-info.c
@@ -47,8 +47,6 @@ static int powercap_print_one_zone(struct powercap_zone *zone)
 
 	printf("\n");
 
-	if (ret != 0)
-		return ret;
 	return ret;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.