linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: amd-pstate: Add resume callback for amd-pstate
@ 2022-06-15  8:45 Jinzhou Su
  2022-06-16  8:23 ` Huang Rui
  0 siblings, 1 reply; 2+ messages in thread
From: Jinzhou Su @ 2022-06-15  8:45 UTC (permalink / raw)
  To: rjw, linux-pm
  Cc: ray.huang, alexander.deucher, xiaojian.du, perry.yuan, li.meng,
	jinzhou.su, richardqi.liang, Jinzhou Su

When system resumes from S3, the CPPC enable register will be
cleared and reset to 0. So set this bit to enable CPPC
interface by writing 1 to this register.

Signed-off-by: Jinzhou Su <Jinzhou.Su@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 7be38bc6a673..e60dd51264a7 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -566,6 +566,17 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
+static int amd_pstate_cpu_resume(struct cpufreq_policy *policy)
+{
+	int ret;
+
+	ret = amd_pstate_enable(true);
+	if (ret)
+		pr_err("failed to enable amd-pstate during resume, return %d\n", ret);
+
+	return ret;
+}
+
 /* Sysfs attributes */
 
 /*
@@ -636,6 +647,7 @@ static struct cpufreq_driver amd_pstate_driver = {
 	.target		= amd_pstate_target,
 	.init		= amd_pstate_cpu_init,
 	.exit		= amd_pstate_cpu_exit,
+	.resume		= amd_pstate_cpu_resume,
 	.set_boost	= amd_pstate_set_boost,
 	.name		= "amd-pstate",
 	.attr           = amd_pstate_attr,
-- 
2.32.0


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

* Re: [PATCH] cpufreq: amd-pstate: Add resume callback for amd-pstate
  2022-06-15  8:45 [PATCH] cpufreq: amd-pstate: Add resume callback for amd-pstate Jinzhou Su
@ 2022-06-16  8:23 ` Huang Rui
  0 siblings, 0 replies; 2+ messages in thread
From: Huang Rui @ 2022-06-16  8:23 UTC (permalink / raw)
  To: Su, Jinzhou (Joe)
  Cc: rjw, linux-pm, Deucher, Alexander, Du, Xiaojian, Yuan, Perry,
	Meng, Li (Jassmine),
	Liang, Richard qi

On Wed, Jun 15, 2022 at 04:45:26PM +0800, Su, Jinzhou (Joe) wrote:
> When system resumes from S3, the CPPC enable register will be
> cleared and reset to 0. So set this bit to enable CPPC
> interface by writing 1 to this register.
> 
> Signed-off-by: Jinzhou Su <Jinzhou.Su@amd.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 7be38bc6a673..e60dd51264a7 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -566,6 +566,17 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy *policy)
>  	return 0;
>  }
>  
> +static int amd_pstate_cpu_resume(struct cpufreq_policy *policy)
> +{
> +	int ret;
> +
> +	ret = amd_pstate_enable(true);
> +	if (ret)
> +		pr_err("failed to enable amd-pstate during resume, return %d\n", ret);
> +
> +	return ret;
> +}

It's a nice catch, Joe. We should implement the suspend callback as well
which is pairing with the resume.

And please CC stable mailing list stable@vger.kernel.org, because it's the
fix for amd-pstate restore in S3.

Thanks,
Ray

> +
>  /* Sysfs attributes */
>  
>  /*
> @@ -636,6 +647,7 @@ static struct cpufreq_driver amd_pstate_driver = {
>  	.target		= amd_pstate_target,
>  	.init		= amd_pstate_cpu_init,
>  	.exit		= amd_pstate_cpu_exit,
> +	.resume		= amd_pstate_cpu_resume,
>  	.set_boost	= amd_pstate_set_boost,
>  	.name		= "amd-pstate",
>  	.attr           = amd_pstate_attr,
> -- 
> 2.32.0
> 

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

end of thread, other threads:[~2022-06-16  8:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15  8:45 [PATCH] cpufreq: amd-pstate: Add resume callback for amd-pstate Jinzhou Su
2022-06-16  8:23 ` Huang Rui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).