mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] amd-pstate: Fix amd_pstate mode switch
@ 2023-03-30 14:13 Wyes Karny
  2023-03-30 18:19 ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Wyes Karny @ 2023-03-30 14:13 UTC (permalink / raw)
  To: rafael, viresh.kumar, ray.huang
  Cc: linux-pm, linux-kernel, Wyes Karny, Alexey Kardashevskiy,
	Mario Limonciello, Perry Yuan

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

Fixes: abd61c08ef349 ("cpufreq: amd-pstate: add driver working mode switch support")

Acked-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Alexey Kardashevskiy <aik@amd.com>
Signed-off-by: Wyes Karny <wyes.karny@amd.com>

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Perry Yuan <Perry.Yuan@amd.com>

---
 drivers/cpufreq/amd-pstate.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 73c7643b2697..8dd46fad151e 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] amd-pstate: Fix amd_pstate mode switch
  2023-03-30 14:13 [PATCH] amd-pstate: Fix amd_pstate mode switch Wyes Karny
@ 2023-03-30 18:19 ` Rafael J. Wysocki
  2023-03-31  6:12   ` Wyes Karny
  0 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2023-03-30 18:19 UTC (permalink / raw)
  To: Wyes Karny
  Cc: rafael, viresh.kumar, ray.huang, linux-pm, linux-kernel,
	Alexey Kardashevskiy, Mario Limonciello, Perry Yuan

On Thu, Mar 30, 2023 at 4:13 PM Wyes Karny <wyes.karny@amd.com> wrote:
>
> 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
>
> Fixes: abd61c08ef349 ("cpufreq: amd-pstate: add driver working mode switch support")
>
> Acked-by: Huang Rui <ray.huang@amd.com>
> Reviewed-by: Alexey Kardashevskiy <aik@amd.com>
> Signed-off-by: Wyes Karny <wyes.karny@amd.com>
>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: Mario Limonciello <mario.limonciello@amd.com>
> Cc: Perry Yuan <Perry.Yuan@amd.com>

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?

> ---
>  drivers/cpufreq/amd-pstate.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 73c7643b2697..8dd46fad151e 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] amd-pstate: Fix amd_pstate mode switch
  2023-03-30 18:19 ` Rafael J. Wysocki
@ 2023-03-31  6:12   ` Wyes Karny
  2023-03-31  9:11     ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Wyes Karny @ 2023-03-31  6:12 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: viresh.kumar, ray.huang, linux-pm, linux-kernel,
	Alexey Kardashevskiy, Mario Limonciello, Perry Yuan

Hi Rafael,

On 30 Mar 20:19, Rafael J. Wysocki wrote:
> On Thu, Mar 30, 2023 at 4:13 PM Wyes Karny <wyes.karny@amd.com> wrote:
> >
> > 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
> >
> > Fixes: abd61c08ef349 ("cpufreq: amd-pstate: add driver working mode switch support")
> >
> > Acked-by: Huang Rui <ray.huang@amd.com>
> > Reviewed-by: Alexey Kardashevskiy <aik@amd.com>
> > Signed-off-by: Wyes Karny <wyes.karny@amd.com>
> >
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > Cc: Mario Limonciello <mario.limonciello@amd.com>
> > Cc: Perry Yuan <Perry.Yuan@amd.com>
> 
> 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/20230307112740.132338-1-wyes.karny@amd.com/

Thanks,
Wyes
> > ---
> >  drivers/cpufreq/amd-pstate.c | 18 ++++++++----------
> >  1 file changed, 8 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> > index 73c7643b2697..8dd46fad151e 100644
> > --- a/drivers/cpufreq/amd-pstate.c
> > +++ b/drivers/cpufreq/amd-pstate.c
> > @@ -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
> >

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] amd-pstate: Fix amd_pstate mode switch
  2023-03-31  6:12   ` Wyes Karny
@ 2023-03-31  9:11     ` Rafael J. Wysocki
  2023-03-31 10:18       ` Wyes Karny
  0 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2023-03-31  9:11 UTC (permalink / raw)
  To: Wyes Karny
  Cc: Rafael J. Wysocki, viresh.kumar, ray.huang, linux-pm,
	linux-kernel, Alexey Kardashevskiy, Mario Limonciello,
	Perry Yuan

On Fri, Mar 31, 2023 at 8:12 AM Wyes Karny <wyes.karny@amd.com> wrote:
>
> Hi Rafael,
>
> On 30 Mar 20:19, Rafael J. Wysocki wrote:
> > On Thu, Mar 30, 2023 at 4:13 PM Wyes Karny <wyes.karny@amd.com> wrote:
> > >
> > > 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
> > >
> > > Fixes: abd61c08ef349 ("cpufreq: amd-pstate: add driver working mode switch support")
> > >
> > > Acked-by: Huang Rui <ray.huang@amd.com>
> > > Reviewed-by: Alexey Kardashevskiy <aik@amd.com>
> > > Signed-off-by: Wyes Karny <wyes.karny@amd.com>
> > >
> > > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > > Cc: Mario Limonciello <mario.limonciello@amd.com>
> > > Cc: Perry Yuan <Perry.Yuan@amd.com>
> >
> > 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/20230307112740.132338-1-wyes.karny@amd.com/

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?

> > > ---
> > >  drivers/cpufreq/amd-pstate.c | 18 ++++++++----------
> > >  1 file changed, 8 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> > > index 73c7643b2697..8dd46fad151e 100644
> > > --- a/drivers/cpufreq/amd-pstate.c
> > > +++ b/drivers/cpufreq/amd-pstate.c
> > > @@ -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
> > >

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] amd-pstate: Fix amd_pstate mode switch
  2023-03-31  9:11     ` Rafael J. Wysocki
@ 2023-03-31 10:18       ` Wyes Karny
  2023-04-11 18:49         ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Wyes Karny @ 2023-03-31 10:18 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: viresh.kumar, ray.huang, linux-pm, linux-kernel,
	Alexey Kardashevskiy, Mario Limonciello, Perry Yuan

On 31 Mar 11:11, Rafael J. Wysocki wrote:
> On Fri, Mar 31, 2023 at 8:12 AM Wyes Karny <wyes.karny@amd.com> wrote:
> >
> > Hi Rafael,
> >
> > On 30 Mar 20:19, Rafael J. Wysocki wrote:
> > > On Thu, Mar 30, 2023 at 4:13 PM Wyes Karny <wyes.karny@amd.com> wrote:
> > > >
> > > > 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
> > > >
> > > > Fixes: abd61c08ef349 ("cpufreq: amd-pstate: add driver working mode switch support")
> > > >
> > > > Acked-by: Huang Rui <ray.huang@amd.com>
> > > > Reviewed-by: Alexey Kardashevskiy <aik@amd.com>
> > > > Signed-off-by: Wyes Karny <wyes.karny@amd.com>
> > > >
> > > > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > > > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > > > Cc: Mario Limonciello <mario.limonciello@amd.com>
> > > > Cc: Perry Yuan <Perry.Yuan@amd.com>
> > >
> > > 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/20230307112740.132338-1-wyes.karny@amd.com/
> 
> 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?

Yes, commit 3ca7bc818d8c replaces the whole `amd_pstate_update_status`
function with new implementation.

> 
> > > > ---
> > > >  drivers/cpufreq/amd-pstate.c | 18 ++++++++----------
> > > >  1 file changed, 8 insertions(+), 10 deletions(-)
> > > >
> > > > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> > > > index 73c7643b2697..8dd46fad151e 100644
> > > > --- a/drivers/cpufreq/amd-pstate.c
> > > > +++ b/drivers/cpufreq/amd-pstate.c
> > > > @@ -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
> > > >

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] amd-pstate: Fix amd_pstate mode switch
  2023-03-31 10:18       ` Wyes Karny
@ 2023-04-11 18:49         ` Rafael J. Wysocki
  0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2023-04-11 18:49 UTC (permalink / raw)
  To: Wyes Karny
  Cc: Rafael J. Wysocki, viresh.kumar, ray.huang, linux-pm,
	linux-kernel, Alexey Kardashevskiy, Mario Limonciello,
	Perry Yuan

On Fri, Mar 31, 2023 at 12:18 PM Wyes Karny <wyes.karny@amd.com> wrote:
>
> On 31 Mar 11:11, Rafael J. Wysocki wrote:
> > On Fri, Mar 31, 2023 at 8:12 AM Wyes Karny <wyes.karny@amd.com> wrote:
> > >
> > > Hi Rafael,
> > >
> > > On 30 Mar 20:19, Rafael J. Wysocki wrote:
> > > > On Thu, Mar 30, 2023 at 4:13 PM Wyes Karny <wyes.karny@amd.com> wrote:
> > > > >
> > > > > 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
> > > > >
> > > > > Fixes: abd61c08ef349 ("cpufreq: amd-pstate: add driver working mode switch support")
> > > > >
> > > > > Acked-by: Huang Rui <ray.huang@amd.com>
> > > > > Reviewed-by: Alexey Kardashevskiy <aik@amd.com>
> > > > > Signed-off-by: Wyes Karny <wyes.karny@amd.com>
> > > > >
> > > > > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > > > > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > > > > Cc: Mario Limonciello <mario.limonciello@amd.com>
> > > > > Cc: Perry Yuan <Perry.Yuan@amd.com>
> > > >
> > > > 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/20230307112740.132338-1-wyes.karny@amd.com/
> >
> > 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?
>
> Yes, commit 3ca7bc818d8c replaces the whole `amd_pstate_update_status`
> function with new implementation.

OK, thanks!

$subject patch has been queued up for 6.3-rc7, thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-04-11 18:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30 14:13 [PATCH] amd-pstate: Fix amd_pstate mode switch Wyes Karny
2023-03-30 18:19 ` Rafael J. Wysocki
2023-03-31  6:12   ` Wyes Karny
2023-03-31  9:11     ` Rafael J. Wysocki
2023-03-31 10:18       ` Wyes Karny
2023-04-11 18:49         ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®