Skip to content

Commit 4e4f600

Browse files
Perry Yuansuperm1
authored andcommitted
cpufreq: amd-pstate: auto-load pstate driver by default
If the `amd-pstate` driver is not loaded automatically by default, it is because the kernel command line parameter has not been added. To resolve this issue, it is necessary to call the `amd_pstate_set_driver()` function to enable the desired mode (passive/active/guided) before registering the driver instance. This ensures that the driver is loaded correctly without relying on the kernel command line parameter. When there is no parameter added to command line, Kernel config will provide the default mode to load. Meanwhile, user can add driver mode in command line which will override the kernel config default option. Reported-by: Andrei Amuraritei <[email protected]> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218705 Signed-off-by: Perry Yuan <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/83301c4cea4f92fb19e14b23f2bac7facfd8bdbb.1718811234.git.perry.yuan@amd.com Signed-off-by: Mario Limonciello <[email protected]>
1 parent 9182639 commit 4e4f600

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,8 +1801,13 @@ static int __init amd_pstate_init(void)
18011801
/* check if this machine need CPPC quirks */
18021802
dmi_check_system(amd_pstate_quirks_table);
18031803

1804-
switch (cppc_state) {
1805-
case AMD_PSTATE_UNDEFINED:
1804+
/*
1805+
* determine the driver mode from the command line or kernel config.
1806+
* If no command line input is provided, cppc_state will be AMD_PSTATE_UNDEFINED.
1807+
* command line options will override the kernel config settings.
1808+
*/
1809+
1810+
if (cppc_state == AMD_PSTATE_UNDEFINED) {
18061811
/* Disable on the following configs by default:
18071812
* 1. Undefined platforms
18081813
* 2. Server platforms
@@ -1812,15 +1817,20 @@ static int __init amd_pstate_init(void)
18121817
pr_info("driver load is disabled, boot with specific mode to enable this\n");
18131818
return -ENODEV;
18141819
}
1815-
ret = amd_pstate_set_driver(CONFIG_X86_AMD_PSTATE_DEFAULT_MODE);
1816-
if (ret)
1817-
return ret;
1818-
break;
1820+
/* get driver mode from kernel config option [1:4] */
1821+
cppc_state = CONFIG_X86_AMD_PSTATE_DEFAULT_MODE;
1822+
}
1823+
1824+
switch (cppc_state) {
18191825
case AMD_PSTATE_DISABLE:
1826+
pr_info("driver load is disabled, boot with specific mode to enable this\n");
18201827
return -ENODEV;
18211828
case AMD_PSTATE_PASSIVE:
18221829
case AMD_PSTATE_ACTIVE:
18231830
case AMD_PSTATE_GUIDED:
1831+
ret = amd_pstate_set_driver(cppc_state);
1832+
if (ret)
1833+
return ret;
18241834
break;
18251835
default:
18261836
return -EINVAL;
@@ -1841,7 +1851,7 @@ static int __init amd_pstate_init(void)
18411851
/* enable amd pstate feature */
18421852
ret = amd_pstate_enable(true);
18431853
if (ret) {
1844-
pr_err("failed to enable with return %d\n", ret);
1854+
pr_err("failed to enable driver mode(%d)\n", cppc_state);
18451855
return ret;
18461856
}
18471857

0 commit comments

Comments
 (0)