[v3] cpufreq: amd-pstate: fix kernel hang issue while amd-pstate unregistering

Message ID 20230110151029.1945544-1-perry.yuan@amd.com
State New
Headers
Series [v3] cpufreq: amd-pstate: fix kernel hang issue while amd-pstate unregistering |

Commit Message

Yuan, Perry Jan. 10, 2023, 3:10 p.m. UTC
  In the amd_pstate_adjust_perf(), there is one cpufreq_cpu_get() call to
increase increments the kobject reference count of policy and make it as
busy. Therefore, a corresponding call to cpufreq_cpu_put() is needed to
decrement the kobject reference count back, it will resolve the kernel
hang issue when unregistering the amd-pstate driver and register the
`amd_pstate_epp` driver instance.

Fixes: 1d215f0319 ("cpufreq: amd-pstate: Add fast switch function for AMD P-State")
Acked-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Tested-by: Wyes Karny <wyes.karny@amd.com>
Signed-off-by: Perry Yuan <perry.yuan@amd.com>
Cc: stable@vger.kernel.org

v3: add Fixes tag
v2: add test-by flag from Wyes.
---
 drivers/cpufreq/amd-pstate.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Rafael J. Wysocki Jan. 12, 2023, 7:24 p.m. UTC | #1
On Tue, Jan 10, 2023 at 4:11 PM Perry Yuan <perry.yuan@amd.com> wrote:
>
> In the amd_pstate_adjust_perf(), there is one cpufreq_cpu_get() call to
> increase increments the kobject reference count of policy and make it as
> busy. Therefore, a corresponding call to cpufreq_cpu_put() is needed to
> decrement the kobject reference count back, it will resolve the kernel
> hang issue when unregistering the amd-pstate driver and register the
> `amd_pstate_epp` driver instance.
>
> Fixes: 1d215f0319 ("cpufreq: amd-pstate: Add fast switch function for AMD P-State")
> Acked-by: Huang Rui <ray.huang@amd.com>
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> Tested-by: Wyes Karny <wyes.karny@amd.com>
> Signed-off-by: Perry Yuan <perry.yuan@amd.com>
> Cc: stable@vger.kernel.org
>
> v3: add Fixes tag
> v2: add test-by flag from Wyes.
> ---
>  drivers/cpufreq/amd-pstate.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 204e39006dda..c17bd845f5fc 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -307,6 +307,7 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
>                 max_perf = min_perf;
>
>         amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true);
> +       cpufreq_cpu_put(policy);
>  }
>
>  static int amd_get_min_freq(struct amd_cpudata *cpudata)
> --

Applied as 6.2-rc material, thanks!
  

Patch

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 204e39006dda..c17bd845f5fc 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -307,6 +307,7 @@  static void amd_pstate_adjust_perf(unsigned int cpu,
 		max_perf = min_perf;
 
 	amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true);
+	cpufreq_cpu_put(policy);
 }
 
 static int amd_get_min_freq(struct amd_cpudata *cpudata)