amd-pstate: Fix amd_pstate mode switch
Subsystems (2)
PATCH 1/1 amd-pstate: Fix amd_pstate mode switch
amd_pstate mode can be changed by writing the mode name to the status sysfs. But some combinations are not working. Fix this issue by taking care of the edge cases.
Before the fix the mode change combination test fails:
#./pst_test.sh
Test passed: from: disable, to
Test passed: from: disable, to disable
Test failed: 1, From mode: disable, to mode: passive Test failed: 1, From mode: disable, to mode: active Test failed: 1, From mode: passive, to mode: active Test passed: from: passive, to disable
Test failed: 1, From mode: passive, to mode: passive Test failed: 1, From mode: passive, to mode: active Test failed: 1, From mode: active, to mode: active Test passed: from: active, to disable
Test failed: 1, From mode: active, to mode: passive Test failed: 1, From mode: active, to mode: active
After the fix test passes:
#./pst_test.sh
Test passed: from: disable, to
Test passed: from: disable, to disable
Test passed: from: disable, to passive
Test passed: from: disable, to active
Test passed: from: passive, to active
Test passed: from: passive, to disable
Test passed: from: passive, to passive
Test passed: from: passive, to active
Test passed: from: active, to active
Test passed: from: active, to disable
Test passed: from: active, to passive
Test passed: from: active, to active
--- drivers/cpufreq/amd-pstate.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/cpufreq/amd-pstate.c +8 -10
@@ -840,22 +840,20 @@ static int amd_pstate_update_status(const char *buf, size_t size)switch (mode_idx) {case AMD_PSTATE_DISABLE : -if (!current_pstate_driver) -return -EINVAL ; -if (cppc_state ==AMD_PSTATE_ACTIVE ) -return -EBUSY ; -cpufreq_unregister_driver (current_pstate_driver); -amd_pstate_driver_cleanup (); +if (current_pstate_driver) { +cpufreq_unregister_driver (current_pstate_driver); +amd_pstate_driver_cleanup (); + }break ;case AMD_PSTATE_PASSIVE :if (current_pstate_driver) {if (current_pstate_driver == &amd_pstate_driver)return 0 ;cpufreq_unregister_driver (current_pstate_driver); - cppc_state =AMD_PSTATE_PASSIVE ; - current_pstate_driver = &amd_pstate_driver; } + current_pstate_driver = &amd_pstate_driver; + cppc_state =AMD_PSTATE_PASSIVE ; ret =cpufreq_register_driver (current_pstate_driver);break ;case AMD_PSTATE_ACTIVE :
@@ -863,10 +861,10 @@ static int amd_pstate_update_status(const char *buf, size_t size)if (current_pstate_driver == &amd_pstate_epp_driver)return 0 ;cpufreq_unregister_driver (current_pstate_driver); - current_pstate_driver = &amd_pstate_epp_driver; - cppc_state =AMD_PSTATE_ACTIVE ; } + current_pstate_driver = &amd_pstate_epp_driver; + cppc_state =AMD_PSTATE_ACTIVE ; ret =cpufreq_register_driver (current_pstate_driver);break ;default :
Signature · 1 line
2.34.1
Rafael J. Wysocki
maintainerQuoted 39 lines · Wyes Karny
amd_pstatemode can be changed by writing the mode name to thestatussysfs. But some combinations are not working. Fix this issue by taking care of the edge cases.Before the fix the mode change combination test fails:
#./pst_test.sh
Test passed: from: disable, to
Test passed: from: disable, to disable
Test failed: 1, From mode: disable, to mode: passive Test failed: 1, From mode: disable, to mode: active Test failed: 1, From mode: passive, to mode: active Test passed: from: passive, to disable
Test failed: 1, From mode: passive, to mode: passive Test failed: 1, From mode: passive, to mode: active Test failed: 1, From mode: active, to mode: active Test passed: from: active, to disable
Test failed: 1, From mode: active, to mode: passive Test failed: 1, From mode: active, to mode: activeAfter the fix test passes:
#./pst_test.sh
Test passed: from: disable, to
Test passed: from: disable, to disable
Test passed: from: disable, to passive
Test passed: from: disable, to active
Test passed: from: passive, to active
Test passed: from: passive, to disable
Test passed: from: passive, to passive
Test passed: from: passive, to active
Test passed: from: active, to active
Test passed: from: active, to disable
Test passed: from: active, to passive
Test passed: from: active, to activeFixes abd61c08ef349 ("cpufreq: amd-pstate: add driver working mode switch support")
Quoted 8 lines
Acked-by Huang Rui <[email protected]>Reviewed-by Alexey Kardashevskiy <[email protected]>Signed-off-by Wyes Karny <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Viresh Kumar <[email protected]>Cc Mario Limonciello <[email protected]>Cc Perry Yuan <[email protected]>
This is all fine, but you need to tell me how it interacts with the amd-pstate changes in linux-next.
Does it affect the code in linux-next at all or is it only for 6.3-rc?
Quoted 53 lines
--- drivers/cpufreq/amd-pstate.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)drivers/cpufreq/amd-pstate.c +8
-11@@ -840,22 +840,20 @@ static int amd_pstate_update_status(const char *buf, size_t size)switch (mode_idx) {case AMD_PSTATE_DISABLE : -if (!current_pstate_driver) -return -EINVAL ; -if (cppc_state ==AMD_PSTATE_ACTIVE ) -return -EBUSY ; -cpufreq_unregister_driver (current_pstate_driver); -amd_pstate_driver_cleanup (); +if (current_pstate_driver) { +cpufreq_unregister_driver (current_pstate_driver); +amd_pstate_driver_cleanup (); + }break ;case AMD_PSTATE_PASSIVE :if (current_pstate_driver) {if (current_pstate_driver == &amd_pstate_driver)return 0 ;cpufreq_unregister_driver (current_pstate_driver); - cppc_state =AMD_PSTATE_PASSIVE ; - current_pstate_driver = &amd_pstate_driver; } + current_pstate_driver = &amd_pstate_driver; + cppc_state =AMD_PSTATE_PASSIVE ; ret =cpufreq_register_driver (current_pstate_driver);break ;case AMD_PSTATE_ACTIVE :@@ -863,10 +861,10 @@ static int amd_pstate_update_status(const char *buf, size_t size)if (current_pstate_driver == &amd_pstate_epp_driver)return 0 ;cpufreq_unregister_driver (current_pstate_driver); - current_pstate_driver = &amd_pstate_epp_driver; - cppc_state =AMD_PSTATE_ACTIVE ; } + current_pstate_driver = &amd_pstate_epp_driver; + cppc_state =AMD_PSTATE_ACTIVE ; ret =cpufreq_register_driver (current_pstate_driver);break ;default : --2.34.1
Hi Rafael,
Quoted 49 lines · Rafael J. Wysocki
Quoted 39 lines · Wyes Karny
amd_pstatemode can be changed by writing the mode name to thestatussysfs. But some combinations are not working. Fix this issue by taking care of the edge cases.Before the fix the mode change combination test fails:
#./pst_test.sh
Test passed: from: disable, to
Test passed: from: disable, to disable
Test failed: 1, From mode: disable, to mode: passive Test failed: 1, From mode: disable, to mode: active Test failed: 1, From mode: passive, to mode: active Test passed: from: passive, to disable
Test failed: 1, From mode: passive, to mode: passive Test failed: 1, From mode: passive, to mode: active Test failed: 1, From mode: active, to mode: active Test passed: from: active, to disable
Test failed: 1, From mode: active, to mode: passive Test failed: 1, From mode: active, to mode: activeAfter the fix test passes:
#./pst_test.sh
Test passed: from: disable, to
Test passed: from: disable, to disable
Test passed: from: disable, to passive
Test passed: from: disable, to active
Test passed: from: passive, to active
Test passed: from: passive, to disable
Test passed: from: passive, to passive
Test passed: from: passive, to active
Test passed: from: active, to active
Test passed: from: active, to disable
Test passed: from: active, to passive
Test passed: from: active, to activeFixes abd61c08ef349 ("cpufreq: amd-pstate: add driver working mode switch support")Quoted 8 lines
Acked-by Huang Rui <[email protected]>Reviewed-by Alexey Kardashevskiy <[email protected]>Signed-off-by Wyes Karny <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Viresh Kumar <[email protected]>Cc Mario Limonciello <[email protected]>Cc Perry Yuan <[email protected]>
Quoted 5 lines
This is all fine, but you need to tell me how it interacts with the amd-pstate changes in linux-next.
Does it affect the code in linux-next at all or is it only for 6.3-rc?
This is only for 6.3-rc.
The commit 3ca7bc818d8c ("cpufreq: amd-pstate: Add guided mode control support via sysfs") in linux-next may not apply cleanly after this fix. Please let me know if I need to rebase and send the guided mode patches [1].
[1]: https://lore.kernel.org/linux-pm/[email protected]/
Thanks,
Wyes
Quoted 53 lines
Quoted 53 lines
--- drivers/cpufreq/amd-pstate.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)drivers/cpufreq/amd-pstate.c +8
-11@@ -840,22 +840,20 @@ static int amd_pstate_update_status(const char *buf, size_t size)switch (mode_idx) {case AMD_PSTATE_DISABLE : -if (!current_pstate_driver) -return -EINVAL ; -if (cppc_state ==AMD_PSTATE_ACTIVE ) -return -EBUSY ; -cpufreq_unregister_driver (current_pstate_driver); -amd_pstate_driver_cleanup (); +if (current_pstate_driver) { +cpufreq_unregister_driver (current_pstate_driver); +amd_pstate_driver_cleanup (); + }break ;case AMD_PSTATE_PASSIVE :if (current_pstate_driver) {if (current_pstate_driver == &amd_pstate_driver)return 0 ;cpufreq_unregister_driver (current_pstate_driver); - cppc_state =AMD_PSTATE_PASSIVE ; - current_pstate_driver = &amd_pstate_driver; } + current_pstate_driver = &amd_pstate_driver; + cppc_state =AMD_PSTATE_PASSIVE ; ret =cpufreq_register_driver (current_pstate_driver);break ;case AMD_PSTATE_ACTIVE :@@ -863,10 +861,10 @@ static int amd_pstate_update_status(const char *buf, size_t size)if (current_pstate_driver == &amd_pstate_epp_driver)return 0 ;cpufreq_unregister_driver (current_pstate_driver); - current_pstate_driver = &amd_pstate_epp_driver; - cppc_state =AMD_PSTATE_ACTIVE ; } + current_pstate_driver = &amd_pstate_epp_driver; + cppc_state =AMD_PSTATE_ACTIVE ; ret =cpufreq_register_driver (current_pstate_driver);break ;default : --2.34.1
Rafael J. Wysocki
maintainerQuoted 59 lines · Wyes Karny
Hi Rafael,
Quoted 49 lines · Rafael J. Wysocki
Quoted 39 lines · Wyes Karny
amd_pstatemode can be changed by writing the mode name to thestatussysfs. But some combinations are not working. Fix this issue by taking care of the edge cases.Before the fix the mode change combination test fails:
#./pst_test.sh
Test passed: from: disable, to
Test passed: from: disable, to disable
Test failed: 1, From mode: disable, to mode: passive Test failed: 1, From mode: disable, to mode: active Test failed: 1, From mode: passive, to mode: active Test passed: from: passive, to disable
Test failed: 1, From mode: passive, to mode: passive Test failed: 1, From mode: passive, to mode: active Test failed: 1, From mode: active, to mode: active Test passed: from: active, to disable
Test failed: 1, From mode: active, to mode: passive Test failed: 1, From mode: active, to mode: activeAfter the fix test passes:
#./pst_test.sh
Test passed: from: disable, to
Test passed: from: disable, to disable
Test passed: from: disable, to passive
Test passed: from: disable, to active
Test passed: from: passive, to active
Test passed: from: passive, to disable
Test passed: from: passive, to passive
Test passed: from: passive, to active
Test passed: from: active, to active
Test passed: from: active, to disable
Test passed: from: active, to passive
Test passed: from: active, to activeFixes abd61c08ef349 ("cpufreq: amd-pstate: add driver working mode switch support")Quoted 8 lines
Acked-by Huang Rui <[email protected]>Reviewed-by Alexey Kardashevskiy <[email protected]>Signed-off-by Wyes Karny <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Viresh Kumar <[email protected]>Cc Mario Limonciello <[email protected]>Cc Perry Yuan <[email protected]>Quoted 5 lines
This is all fine, but you need to tell me how it interacts with the amd-pstate changes in linux-next.
Does it affect the code in linux-next at all or is it only for 6.3-rc?
Quoted 6 lines
This is only for 6.3-rc.
The commit3ca7bc818d8c("cpufreq: amd-pstate: Add guided mode control support via sysfs") in linux-next may not apply cleanly after this fix. Please let me know if I need to rebase and send the guided mode patches [1].
Well, instead, you please let me know how to resolve the merge conflict between the patch below and your series.
Can I simply assume that the code added by commit 3ca7bc818d8c replaces the code modified by the $subject patch?
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
--- drivers/cpufreq/amd-pstate.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)drivers/cpufreq/amd-pstate.c +8
-11@@ -840,22 +840,20 @@ static int amd_pstate_update_status(const char *buf, size_t size)switch (mode_idx) {case AMD_PSTATE_DISABLE : -if (!current_pstate_driver) -return -EINVAL ; -if (cppc_state ==AMD_PSTATE_ACTIVE ) -return -EBUSY ; -cpufreq_unregister_driver (current_pstate_driver); -amd_pstate_driver_cleanup (); +if (current_pstate_driver) { +cpufreq_unregister_driver (current_pstate_driver); +amd_pstate_driver_cleanup (); + }break ;case AMD_PSTATE_PASSIVE :if (current_pstate_driver) {if (current_pstate_driver == &amd_pstate_driver)return 0 ;cpufreq_unregister_driver (current_pstate_driver); - cppc_state =AMD_PSTATE_PASSIVE ; - current_pstate_driver = &amd_pstate_driver; } + current_pstate_driver = &amd_pstate_driver; + cppc_state =AMD_PSTATE_PASSIVE ; ret =cpufreq_register_driver (current_pstate_driver);break ;case AMD_PSTATE_ACTIVE :@@ -863,10 +861,10 @@ static int amd_pstate_update_status(const char *buf, size_t size)if (current_pstate_driver == &amd_pstate_epp_driver)return 0 ;cpufreq_unregister_driver (current_pstate_driver); - current_pstate_driver = &amd_pstate_epp_driver; - cppc_state =AMD_PSTATE_ACTIVE ; } + current_pstate_driver = &amd_pstate_epp_driver; + cppc_state =AMD_PSTATE_ACTIVE ; ret =cpufreq_register_driver (current_pstate_driver);break ;default : --2.34.1
Quoted 65 lines · Rafael J. Wysocki
Quoted 64 lines · Wyes Karny
Hi Rafael,
Quoted 49 lines · Rafael J. Wysocki
Quoted 39 lines · Wyes Karny
amd_pstatemode can be changed by writing the mode name to thestatussysfs. But some combinations are not working. Fix this issue by taking care of the edge cases.Before the fix the mode change combination test fails:
#./pst_test.sh
Test passed: from: disable, to
Test passed: from: disable, to disable
Test failed: 1, From mode: disable, to mode: passive Test failed: 1, From mode: disable, to mode: active Test failed: 1, From mode: passive, to mode: active Test passed: from: passive, to disable
Test failed: 1, From mode: passive, to mode: passive Test failed: 1, From mode: passive, to mode: active Test failed: 1, From mode: active, to mode: active Test passed: from: active, to disable
Test failed: 1, From mode: active, to mode: passive Test failed: 1, From mode: active, to mode: activeAfter the fix test passes:
#./pst_test.sh
Test passed: from: disable, to
Test passed: from: disable, to disable
Test passed: from: disable, to passive
Test passed: from: disable, to active
Test passed: from: passive, to active
Test passed: from: passive, to disable
Test passed: from: passive, to passive
Test passed: from: passive, to active
Test passed: from: active, to active
Test passed: from: active, to disable
Test passed: from: active, to passive
Test passed: from: active, to activeFixes abd61c08ef349 ("cpufreq: amd-pstate: add driver working mode switch support")Quoted 8 lines
Acked-by Huang Rui <[email protected]>Reviewed-by Alexey Kardashevskiy <[email protected]>Signed-off-by Wyes Karny <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Viresh Kumar <[email protected]>Cc Mario Limonciello <[email protected]>Cc Perry Yuan <[email protected]>Quoted 5 lines
This is all fine, but you need to tell me how it interacts with the amd-pstate changes in linux-next.
Does it affect the code in linux-next at all or is it only for 6.3-rc?
This is only for 6.3-rc.
The commit3ca7bc818d8c("cpufreq: amd-pstate: Add guided mode control support via sysfs") in linux-next may not apply cleanly after this fix. Please let me know if I need to rebase and send the guided mode patches [1].
Quoted 7 lines
Quoted 1 line
Well, instead, you please let me know how to resolve the merge conflict between the patch below and your series.
Can I simply assume that the code added by commit
3ca7bc818d8creplaces the code modified by the $subject patch?
Yes, commit 3ca7bc818d8c replaces the whole amd_pstate_update_status function with new implementation.
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
--- drivers/cpufreq/amd-pstate.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)drivers/cpufreq/amd-pstate.c +8
-11@@ -840,22 +840,20 @@ static int amd_pstate_update_status(const char *buf, size_t size)switch (mode_idx) {case AMD_PSTATE_DISABLE : -if (!current_pstate_driver) -return -EINVAL ; -if (cppc_state ==AMD_PSTATE_ACTIVE ) -return -EBUSY ; -cpufreq_unregister_driver (current_pstate_driver); -amd_pstate_driver_cleanup (); +if (current_pstate_driver) { +cpufreq_unregister_driver (current_pstate_driver); +amd_pstate_driver_cleanup (); + }break ;case AMD_PSTATE_PASSIVE :if (current_pstate_driver) {if (current_pstate_driver == &amd_pstate_driver)return 0 ;cpufreq_unregister_driver (current_pstate_driver); - cppc_state =AMD_PSTATE_PASSIVE ; - current_pstate_driver = &amd_pstate_driver; } + current_pstate_driver = &amd_pstate_driver; + cppc_state =AMD_PSTATE_PASSIVE ; ret =cpufreq_register_driver (current_pstate_driver);break ;case AMD_PSTATE_ACTIVE :@@ -863,10 +861,10 @@ static int amd_pstate_update_status(const char *buf, size_t size)if (current_pstate_driver == &amd_pstate_epp_driver)return 0 ;cpufreq_unregister_driver (current_pstate_driver); - current_pstate_driver = &amd_pstate_epp_driver; - cppc_state =AMD_PSTATE_ACTIVE ; } + current_pstate_driver = &amd_pstate_epp_driver; + cppc_state =AMD_PSTATE_ACTIVE ; ret =cpufreq_register_driver (current_pstate_driver);break ;default : --2.34.1
Rafael J. Wysocki
maintainerQuoted 69 lines · Wyes Karny
Quoted 67 lines · Rafael J. Wysocki
Quoted 65 lines · Wyes Karny
Hi Rafael,
Quoted 49 lines · Rafael J. Wysocki
Quoted 39 lines · Wyes Karny
amd_pstatemode can be changed by writing the mode name to thestatussysfs. But some combinations are not working. Fix this issue by taking care of the edge cases.Before the fix the mode change combination test fails:
#./pst_test.sh
Test passed: from: disable, to
Test passed: from: disable, to disable
Test failed: 1, From mode: disable, to mode: passive Test failed: 1, From mode: disable, to mode: active Test failed: 1, From mode: passive, to mode: active Test passed: from: passive, to disable
Test failed: 1, From mode: passive, to mode: passive Test failed: 1, From mode: passive, to mode: active Test failed: 1, From mode: active, to mode: active Test passed: from: active, to disable
Test failed: 1, From mode: active, to mode: passive Test failed: 1, From mode: active, to mode: activeAfter the fix test passes:
#./pst_test.sh
Test passed: from: disable, to
Test passed: from: disable, to disable
Test passed: from: disable, to passive
Test passed: from: disable, to active
Test passed: from: passive, to active
Test passed: from: passive, to disable
Test passed: from: passive, to passive
Test passed: from: passive, to active
Test passed: from: active, to active
Test passed: from: active, to disable
Test passed: from: active, to passive
Test passed: from: active, to activeFixes abd61c08ef349 ("cpufreq: amd-pstate: add driver working mode switch support")Quoted 8 lines
Acked-by Huang Rui <[email protected]>Reviewed-by Alexey Kardashevskiy <[email protected]>Signed-off-by Wyes Karny <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Viresh Kumar <[email protected]>Cc Mario Limonciello <[email protected]>Cc Perry Yuan <[email protected]>Quoted 5 lines
This is all fine, but you need to tell me how it interacts with the amd-pstate changes in linux-next.
Does it affect the code in linux-next at all or is it only for 6.3-rc?
This is only for 6.3-rc.
The commit3ca7bc818d8c("cpufreq: amd-pstate: Add guided mode control support via sysfs") in linux-next may not apply cleanly after this fix. Please let me know if I need to rebase and send the guided mode patches [1].
Quoted 8 lines
Quoted 5 lines
Well, instead, you please let me know how to resolve the merge conflict between the patch below and your series.
Can I simply assume that the code added by commit
3ca7bc818d8creplaces the code modified by the $subject patch?Yes, commit
3ca7bc818d8creplaces the wholeamd_pstate_update_statusfunction with new implementation.
OK, thanks!
$subject patch has been queued up for 6.3-rc7, thanks!