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.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:
"Fix three issues related to the ->fast_switch callback in the AMD
P-state cpufreq driver (Gautham R. Shenoy and Wyes Karny)"

* tag 'pm-6.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
cpufreq: amd-pstate: Update policy->cur in amd_pstate_adjust_perf()
cpufreq: amd-pstate: Remove fast_switch_possible flag from active driver
cpufreq: amd-pstate: Add ->fast_switch() callback

+37 -9
+37 -9
drivers/cpufreq/amd-pstate.c
··· 444 444 return 0; 445 445 } 446 446 447 - static int amd_pstate_target(struct cpufreq_policy *policy, 448 - unsigned int target_freq, 449 - unsigned int relation) 447 + static int amd_pstate_update_freq(struct cpufreq_policy *policy, 448 + unsigned int target_freq, bool fast_switch) 450 449 { 451 450 struct cpufreq_freqs freqs; 452 451 struct amd_cpudata *cpudata = policy->driver_data; ··· 464 465 des_perf = DIV_ROUND_CLOSEST(target_freq * cap_perf, 465 466 cpudata->max_freq); 466 467 467 - cpufreq_freq_transition_begin(policy, &freqs); 468 + WARN_ON(fast_switch && !policy->fast_switch_enabled); 469 + /* 470 + * If fast_switch is desired, then there aren't any registered 471 + * transition notifiers. See comment for 472 + * cpufreq_enable_fast_switch(). 473 + */ 474 + if (!fast_switch) 475 + cpufreq_freq_transition_begin(policy, &freqs); 476 + 468 477 amd_pstate_update(cpudata, min_perf, des_perf, 469 - max_perf, false, policy->governor->flags); 470 - cpufreq_freq_transition_end(policy, &freqs, false); 478 + max_perf, fast_switch, policy->governor->flags); 479 + 480 + if (!fast_switch) 481 + cpufreq_freq_transition_end(policy, &freqs, false); 471 482 472 483 return 0; 484 + } 485 + 486 + static int amd_pstate_target(struct cpufreq_policy *policy, 487 + unsigned int target_freq, 488 + unsigned int relation) 489 + { 490 + return amd_pstate_update_freq(policy, target_freq, false); 491 + } 492 + 493 + static unsigned int amd_pstate_fast_switch(struct cpufreq_policy *policy, 494 + unsigned int target_freq) 495 + { 496 + return amd_pstate_update_freq(policy, target_freq, true); 473 497 } 474 498 475 499 static void amd_pstate_adjust_perf(unsigned int cpu, ··· 501 479 unsigned long capacity) 502 480 { 503 481 unsigned long max_perf, min_perf, des_perf, 504 - cap_perf, lowest_nonlinear_perf; 482 + cap_perf, lowest_nonlinear_perf, max_freq; 505 483 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); 506 484 struct amd_cpudata *cpudata = policy->driver_data; 485 + unsigned int target_freq; 507 486 508 487 cap_perf = READ_ONCE(cpudata->highest_perf); 509 488 lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf); 489 + max_freq = READ_ONCE(cpudata->max_freq); 510 490 511 491 des_perf = cap_perf; 512 492 if (target_perf < capacity) ··· 524 500 max_perf = cap_perf; 525 501 if (max_perf < min_perf) 526 502 max_perf = min_perf; 503 + 504 + des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf); 505 + target_freq = div_u64(des_perf * max_freq, max_perf); 506 + policy->cur = target_freq; 527 507 528 508 amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true, 529 509 policy->governor->flags); ··· 743 715 744 716 freq_qos_remove_request(&cpudata->req[1]); 745 717 freq_qos_remove_request(&cpudata->req[0]); 718 + policy->fast_switch_possible = false; 746 719 kfree(cpudata); 747 720 748 721 return 0; ··· 1108 1079 policy->policy = CPUFREQ_POLICY_POWERSAVE; 1109 1080 1110 1081 if (boot_cpu_has(X86_FEATURE_CPPC)) { 1111 - policy->fast_switch_possible = true; 1112 1082 ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value); 1113 1083 if (ret) 1114 1084 return ret; ··· 1130 1102 static int amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy) 1131 1103 { 1132 1104 pr_debug("CPU %d exiting\n", policy->cpu); 1133 - policy->fast_switch_possible = false; 1134 1105 return 0; 1135 1106 } 1136 1107 ··· 1336 1309 .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS, 1337 1310 .verify = amd_pstate_verify, 1338 1311 .target = amd_pstate_target, 1312 + .fast_switch = amd_pstate_fast_switch, 1339 1313 .init = amd_pstate_cpu_init, 1340 1314 .exit = amd_pstate_cpu_exit, 1341 1315 .suspend = amd_pstate_cpu_suspend,