mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] cpufreq: amd-pstate: fix kernel hang issue while amd-pstate unregistering
@ 2023-01-10 12:49 Perry Yuan
  2023-01-10 12:57 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Perry Yuan @ 2023-01-10 12:49 UTC (permalink / raw)
  To: rafael.j.wysocki, Mario.Limonciello, ray.huang, viresh.kumar
  Cc: Deepak.Sharma, Nathan.Fontenot, Alexander.Deucher, Shimmer.Huang,
	Xiaojian.Du, Li.Meng, wyes.karny, linux-pm, linux-kernel

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.

Acked-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Perry Yuan <perry.yuan@amd.com>
Tested-by: Wyes Karny <wyes.karny@amd.com>
Cc: stable@vger.kernel.org
---
 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)
-- 
2.34.1


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

* Re: [PATCH v2] cpufreq: amd-pstate: fix kernel hang issue while amd-pstate unregistering
  2023-01-10 12:49 [PATCH v2] cpufreq: amd-pstate: fix kernel hang issue while amd-pstate unregistering Perry Yuan
@ 2023-01-10 12:57 ` Rafael J. Wysocki
  2023-01-10 15:02   ` Yuan, Perry
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2023-01-10 12:57 UTC (permalink / raw)
  To: Perry Yuan
  Cc: rafael.j.wysocki, Mario.Limonciello, ray.huang, viresh.kumar,
	Deepak.Sharma, Nathan.Fontenot, Alexander.Deucher, Shimmer.Huang,
	Xiaojian.Du, Li.Meng, wyes.karny, linux-pm, linux-kernel

On Tue, Jan 10, 2023 at 1:50 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.
>
> Acked-by: Huang Rui <ray.huang@amd.com>
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> Signed-off-by: Perry Yuan <perry.yuan@amd.com>
> Tested-by: Wyes Karny <wyes.karny@amd.com>
> Cc: stable@vger.kernel.org

Can you provide a Fixes tag, please?

Also, what's the difference between this and the previous version?

> ---
>  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)
> --
> 2.34.1
>

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

* RE: [PATCH v2] cpufreq: amd-pstate: fix kernel hang issue while amd-pstate unregistering
  2023-01-10 12:57 ` Rafael J. Wysocki
@ 2023-01-10 15:02   ` Yuan, Perry
  0 siblings, 0 replies; 3+ messages in thread
From: Yuan, Perry @ 2023-01-10 15:02 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: rafael.j.wysocki, Limonciello, Mario, Huang, Ray, viresh.kumar,
	Sharma, Deepak, Fontenot, Nathan, Deucher, Alexander, Huang,
	Shimmer, Du, Xiaojian, Meng, Li (Jassmine),
	Karny, Wyes, linux-pm, linux-kernel

[AMD Official Use Only - General]

Hi Rafael:

> -----Original Message-----
> From: Rafael J. Wysocki <rafael@kernel.org>
> Sent: Tuesday, January 10, 2023 8:58 PM
> To: Yuan, Perry <Perry.Yuan@amd.com>
> Cc: rafael.j.wysocki@intel.com; Limonciello, Mario
> <Mario.Limonciello@amd.com>; Huang, Ray <Ray.Huang@amd.com>;
> viresh.kumar@linaro.org; Sharma, Deepak <Deepak.Sharma@amd.com>;
> Fontenot, Nathan <Nathan.Fontenot@amd.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>; Huang, Shimmer
> <Shimmer.Huang@amd.com>; Du, Xiaojian <Xiaojian.Du@amd.com>; Meng,
> Li (Jassmine) <Li.Meng@amd.com>; Karny, Wyes <Wyes.Karny@amd.com>;
> linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v2] cpufreq: amd-pstate: fix kernel hang issue while
> amd-pstate unregistering
> 
> On Tue, Jan 10, 2023 at 1:50 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.
> >
> > Acked-by: Huang Rui <ray.huang@amd.com>
> > Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> > Signed-off-by: Perry Yuan <perry.yuan@amd.com>
> > Tested-by: Wyes Karny <wyes.karny@amd.com>
> > Cc: stable@vger.kernel.org
> 
> Can you provide a Fixes tag, please?


Sure, let me add the Fixes tag in v3

> 
> Also, what's the difference between this and the previous version?

Just add the  "Tested-by: Wyes Karny <wyes.karny@amd.com>"  in v2. 

> 
> > ---
> >  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)
> > --
> > 2.34.1
> >

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

end of thread, other threads:[~2023-01-10 15:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 12:49 [PATCH v2] cpufreq: amd-pstate: fix kernel hang issue while amd-pstate unregistering Perry Yuan
2023-01-10 12:57 ` Rafael J. Wysocki
2023-01-10 15:02   ` Yuan, Perry

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®