Skip to content

Commit 202e683

Browse files
Perry Yuanrafaeljw
authored andcommitted
cpufreq: amd-pstate: add amd-pstate driver parameter for mode selection
When the amd_pstate driver is built-in users still need a method to be able enable or disable it depending upon their circumstance. Add support for an early parameter to do this. There is some performance degradation on a number of ASICs in the passive mode. This performance issue was originally discovered in shared memory systems but it has been proven that certain workloads on MSR systems also suffer performance issues. Set the amd-pstate driver as disabled by default to temporarily mitigate the performance problem. 1) with `amd_pstate=disable`, pstate driver will be disabled to load at kernel booting. 2) with `amd_pstate=passive`, pstate driver will be enabled and loaded as non-autonomous working mode supported in the low-level power management firmware. 3) If neither parameter is specified, the driver will be disabled by default to avoid triggering performance regressions in certain ASICs Acked-by: Huang Rui <[email protected]> Reviewed-by: Gautham R. Shenoy <[email protected]> Tested-by: Wyes Karny <[email protected]> Signed-off-by: Perry Yuan <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 456ca88 commit 202e683

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,8 @@
5959
* we disable it by default to go acpi-cpufreq on these processors and add a
6060
* module parameter to be able to enable it manually for debugging.
6161
*/
62-
static bool shared_mem = false;
63-
module_param(shared_mem, bool, 0444);
64-
MODULE_PARM_DESC(shared_mem,
65-
"enable amd-pstate on processors with shared memory solution (false = disabled (default), true = enabled)");
66-
6762
static struct cpufreq_driver amd_pstate_driver;
63+
static int cppc_load __initdata;
6864

6965
static inline int pstate_enable(bool enable)
7066
{
@@ -626,6 +622,15 @@ static int __init amd_pstate_init(void)
626622

627623
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
628624
return -ENODEV;
625+
/*
626+
* by default the pstate driver is disabled to load
627+
* enable the amd_pstate passive mode driver explicitly
628+
* with amd_pstate=passive in kernel command line
629+
*/
630+
if (!cppc_load) {
631+
pr_debug("driver load is disabled, boot with amd_pstate=passive to enable this\n");
632+
return -ENODEV;
633+
}
629634

630635
if (!acpi_cpc_valid()) {
631636
pr_warn_once("the _CPC object is not present in SBIOS or ACPI disabled\n");
@@ -640,13 +645,11 @@ static int __init amd_pstate_init(void)
640645
if (boot_cpu_has(X86_FEATURE_CPPC)) {
641646
pr_debug("AMD CPPC MSR based functionality is supported\n");
642647
amd_pstate_driver.adjust_perf = amd_pstate_adjust_perf;
643-
} else if (shared_mem) {
648+
} else {
649+
pr_debug("AMD CPPC shared memory based functionality is supported\n");
644650
static_call_update(amd_pstate_enable, cppc_enable);
645651
static_call_update(amd_pstate_init_perf, cppc_init_perf);
646652
static_call_update(amd_pstate_update_perf, cppc_update_perf);
647-
} else {
648-
pr_info("This processor supports shared memory solution, you can enable it with amd_pstate.shared_mem=1\n");
649-
return -ENODEV;
650653
}
651654

652655
/* enable amd pstate feature */
@@ -665,6 +668,21 @@ static int __init amd_pstate_init(void)
665668
}
666669
device_initcall(amd_pstate_init);
667670

671+
static int __init amd_pstate_param(char *str)
672+
{
673+
if (!str)
674+
return -EINVAL;
675+
676+
if (!strcmp(str, "disable")) {
677+
cppc_load = 0;
678+
pr_info("driver is explicitly disabled\n");
679+
} else if (!strcmp(str, "passive"))
680+
cppc_load = 1;
681+
682+
return 0;
683+
}
684+
early_param("amd_pstate", amd_pstate_param);
685+
668686
MODULE_AUTHOR("Huang Rui <[email protected]>");
669687
MODULE_DESCRIPTION("AMD Processor P-state Frequency Driver");
670688
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)