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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'pm-6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:
"These fix two cpufreq drivers and the cpupower utility.

Specifics:

- Fix the handling of scaling_max/min_freq sysfs attributes in the
AMD P-state cpufreq driver (Mario Limonciello)

- Make the intel_pstate cpufreq driver avoid unnecessary computation
of the HWP performance level corresponding to a given frequency in
the cases when it is known already, which also helps to avoid
reducing the maximum CPU capacity artificially on some systems
(Rafael J. Wysocki)

- Fix compilation of the cpupower utility when CFLAGS is passed as a
make argument for cpupower, but it does not take effect as expected
due to mishandling (Stanley Chan)"

* tag 'pm-6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
cpufreq/amd-pstate: Fix setting scaling max/min freq values
cpufreq: intel_pstate: Refine computation of P-state for given frequency
tools cpupower bench: Override CFLAGS assignments

+38 -26
+3 -4
drivers/cpufreq/amd-pstate.c
··· 1232 1232 max_limit_perf = div_u64(policy->max * cpudata->highest_perf, cpudata->max_freq); 1233 1233 min_limit_perf = div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq); 1234 1234 1235 + WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf); 1236 + WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf); 1237 + 1235 1238 max_perf = clamp_t(unsigned long, max_perf, cpudata->min_limit_perf, 1236 1239 cpudata->max_limit_perf); 1237 1240 min_perf = clamp_t(unsigned long, min_perf, cpudata->min_limit_perf, 1238 1241 cpudata->max_limit_perf); 1239 - 1240 - WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf); 1241 - WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf); 1242 - 1243 1242 value = READ_ONCE(cpudata->cppc_req_cached); 1244 1243 1245 1244 if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE)
+34 -21
drivers/cpufreq/intel_pstate.c
··· 529 529 } 530 530 #endif /* CONFIG_ACPI_CPPC_LIB */ 531 531 532 + static int intel_pstate_freq_to_hwp_rel(struct cpudata *cpu, int freq, 533 + unsigned int relation) 534 + { 535 + if (freq == cpu->pstate.turbo_freq) 536 + return cpu->pstate.turbo_pstate; 537 + 538 + if (freq == cpu->pstate.max_freq) 539 + return cpu->pstate.max_pstate; 540 + 541 + switch (relation) { 542 + case CPUFREQ_RELATION_H: 543 + return freq / cpu->pstate.scaling; 544 + case CPUFREQ_RELATION_C: 545 + return DIV_ROUND_CLOSEST(freq, cpu->pstate.scaling); 546 + } 547 + 548 + return DIV_ROUND_UP(freq, cpu->pstate.scaling); 549 + } 550 + 551 + static int intel_pstate_freq_to_hwp(struct cpudata *cpu, int freq) 552 + { 553 + return intel_pstate_freq_to_hwp_rel(cpu, freq, CPUFREQ_RELATION_L); 554 + } 555 + 532 556 /** 533 557 * intel_pstate_hybrid_hwp_adjust - Calibrate HWP performance levels. 534 558 * @cpu: Target CPU. ··· 570 546 int perf_ctl_scaling = cpu->pstate.perf_ctl_scaling; 571 547 int perf_ctl_turbo = pstate_funcs.get_turbo(cpu->cpu); 572 548 int scaling = cpu->pstate.scaling; 549 + int freq; 573 550 574 551 pr_debug("CPU%d: perf_ctl_max_phys = %d\n", cpu->cpu, perf_ctl_max_phys); 575 552 pr_debug("CPU%d: perf_ctl_turbo = %d\n", cpu->cpu, perf_ctl_turbo); ··· 584 559 cpu->pstate.max_freq = rounddown(cpu->pstate.max_pstate * scaling, 585 560 perf_ctl_scaling); 586 561 587 - cpu->pstate.max_pstate_physical = 588 - DIV_ROUND_UP(perf_ctl_max_phys * perf_ctl_scaling, 589 - scaling); 562 + freq = perf_ctl_max_phys * perf_ctl_scaling; 563 + cpu->pstate.max_pstate_physical = intel_pstate_freq_to_hwp(cpu, freq); 590 564 591 - cpu->pstate.min_freq = cpu->pstate.min_pstate * perf_ctl_scaling; 565 + freq = cpu->pstate.min_pstate * perf_ctl_scaling; 566 + cpu->pstate.min_freq = freq; 592 567 /* 593 568 * Cast the min P-state value retrieved via pstate_funcs.get_min() to 594 569 * the effective range of HWP performance levels. 595 570 */ 596 - cpu->pstate.min_pstate = DIV_ROUND_UP(cpu->pstate.min_freq, scaling); 571 + cpu->pstate.min_pstate = intel_pstate_freq_to_hwp(cpu, freq); 597 572 } 598 573 599 574 static inline void update_turbo_state(void) ··· 2553 2528 * abstract values to represent performance rather than pure ratios. 2554 2529 */ 2555 2530 if (hwp_active && cpu->pstate.scaling != perf_ctl_scaling) { 2556 - int scaling = cpu->pstate.scaling; 2557 2531 int freq; 2558 2532 2559 2533 freq = max_policy_perf * perf_ctl_scaling; 2560 - max_policy_perf = DIV_ROUND_UP(freq, scaling); 2534 + max_policy_perf = intel_pstate_freq_to_hwp(cpu, freq); 2561 2535 freq = min_policy_perf * perf_ctl_scaling; 2562 - min_policy_perf = DIV_ROUND_UP(freq, scaling); 2536 + min_policy_perf = intel_pstate_freq_to_hwp(cpu, freq); 2563 2537 } 2564 2538 2565 2539 pr_debug("cpu:%d min_policy_perf:%d max_policy_perf:%d\n", ··· 2932 2908 2933 2909 cpufreq_freq_transition_begin(policy, &freqs); 2934 2910 2935 - switch (relation) { 2936 - case CPUFREQ_RELATION_L: 2937 - target_pstate = DIV_ROUND_UP(freqs.new, cpu->pstate.scaling); 2938 - break; 2939 - case CPUFREQ_RELATION_H: 2940 - target_pstate = freqs.new / cpu->pstate.scaling; 2941 - break; 2942 - default: 2943 - target_pstate = DIV_ROUND_CLOSEST(freqs.new, cpu->pstate.scaling); 2944 - break; 2945 - } 2946 - 2911 + target_pstate = intel_pstate_freq_to_hwp_rel(cpu, freqs.new, relation); 2947 2912 target_pstate = intel_cpufreq_update_pstate(policy, target_pstate, false); 2948 2913 2949 2914 freqs.new = target_pstate * cpu->pstate.scaling; ··· 2950 2937 2951 2938 update_turbo_state(); 2952 2939 2953 - target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling); 2940 + target_pstate = intel_pstate_freq_to_hwp(cpu, target_freq); 2954 2941 2955 2942 target_pstate = intel_cpufreq_update_pstate(policy, target_pstate, true); 2956 2943
+1 -1
tools/power/cpupower/bench/Makefile
··· 15 15 OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o 16 16 endif 17 17 18 - CFLAGS += -D_GNU_SOURCE -I../lib -DDEFAULT_CONFIG_FILE=\"$(confdir)/cpufreq-bench.conf\" 18 + override CFLAGS += -D_GNU_SOURCE -I../lib -DDEFAULT_CONFIG_FILE=\"$(confdir)/cpufreq-bench.conf\" 19 19 20 20 $(OUTPUT)%.o : %.c 21 21 $(ECHO) " CC " $@