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

When system resumes from S3, the CPPC enable register will be
cleared and reset to 0. So sets 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 | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 7be38bc6a673..9ac75c1cde9c 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -566,6 +566,28 @@ 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;
+}
+
+static int amd_pstate_cpu_suspend(struct cpufreq_policy *policy)
+{
+	int ret;
+
+	ret = amd_pstate_enable(false);
+	if (ret)
+		pr_err("failed to disable amd-pstate during suspend, return %d\n", ret);
+
+	return ret;
+}
+
 /* Sysfs attributes */
 
 /*
@@ -636,6 +658,8 @@ static struct cpufreq_driver amd_pstate_driver = {
 	.target		= amd_pstate_target,
 	.init		= amd_pstate_cpu_init,
 	.exit		= amd_pstate_cpu_exit,
+	.suspend	= amd_pstate_cpu_suspend,
+	.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] 4+ messages in thread

* Re: [PATCH] cpufreq: amd-pstate: Add resume and suspend callback for amd-pstate
  2022-06-23  3:15 [PATCH] cpufreq: amd-pstate: Add resume and suspend callback for amd-pstate Jinzhou Su
@ 2022-06-23  7:52 ` Huang Rui
  2022-06-23 19:24   ` Rafael J. Wysocki
  2022-06-23  7:57 ` Greg KH
  1 sibling, 1 reply; 4+ messages in thread
From: Huang Rui @ 2022-06-23  7:52 UTC (permalink / raw)
  To: Su, Jinzhou (Joe)
  Cc: rjw@rjwysocki.net, linux-pm@vger.kernel.org, Deucher, Alexander,
	Du, Xiaojian, Yuan, Perry, Meng, Li (Jassmine), Liang, Richard qi,
	stable@vger.kernel.org

On Thu, Jun 23, 2022 at 11:15:09AM +0800, Su, Jinzhou (Joe) wrote:
> When system resumes from S3, the CPPC enable register will be
> cleared and reset to 0. So sets this bit to enable CPPC
> interface by writing 1 to this register.
> 
> Signed-off-by: Jinzhou Su <Jinzhou.Su@amd.com>

Signed-off-by: Jinzhou Su <Jinzhou.Su@amd.com>
Cc: stable@vger.kernel.org

You can add one line below your commit description to Cc stable mailing
list. And next time in V2, it's better to use subject-prefix optional to
mark it as v2 like below:

git format-patch --subject-prefix="PATCH v2" HEAD~

Other looks good for me, patch is

Acked-by: Huang Rui <ray.huang@amd.com>

> ---
>  drivers/cpufreq/amd-pstate.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 7be38bc6a673..9ac75c1cde9c 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -566,6 +566,28 @@ 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;
> +}
> +
> +static int amd_pstate_cpu_suspend(struct cpufreq_policy *policy)
> +{
> +	int ret;
> +
> +	ret = amd_pstate_enable(false);
> +	if (ret)
> +		pr_err("failed to disable amd-pstate during suspend, return %d\n", ret);
> +
> +	return ret;
> +}
> +
>  /* Sysfs attributes */
>  
>  /*
> @@ -636,6 +658,8 @@ static struct cpufreq_driver amd_pstate_driver = {
>  	.target		= amd_pstate_target,
>  	.init		= amd_pstate_cpu_init,
>  	.exit		= amd_pstate_cpu_exit,
> +	.suspend	= amd_pstate_cpu_suspend,
> +	.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] 4+ messages in thread

* Re: [PATCH] cpufreq: amd-pstate: Add resume and suspend callback for amd-pstate
  2022-06-23  3:15 [PATCH] cpufreq: amd-pstate: Add resume and suspend callback for amd-pstate Jinzhou Su
  2022-06-23  7:52 ` Huang Rui
@ 2022-06-23  7:57 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2022-06-23  7:57 UTC (permalink / raw)
  To: Jinzhou Su
  Cc: rjw, linux-pm, ray.huang, alexander.deucher, xiaojian.du,
	perry.yuan, li.meng, richardqi.liang, stable

On Thu, Jun 23, 2022 at 11:15:09AM +0800, Jinzhou Su wrote:
> When system resumes from S3, the CPPC enable register will be
> cleared and reset to 0. So sets 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 | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 7be38bc6a673..9ac75c1cde9c 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -566,6 +566,28 @@ 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;
> +}
> +
> +static int amd_pstate_cpu_suspend(struct cpufreq_policy *policy)
> +{
> +	int ret;
> +
> +	ret = amd_pstate_enable(false);
> +	if (ret)
> +		pr_err("failed to disable amd-pstate during suspend, return %d\n", ret);
> +
> +	return ret;
> +}
> +
>  /* Sysfs attributes */
>  
>  /*
> @@ -636,6 +658,8 @@ static struct cpufreq_driver amd_pstate_driver = {
>  	.target		= amd_pstate_target,
>  	.init		= amd_pstate_cpu_init,
>  	.exit		= amd_pstate_cpu_exit,
> +	.suspend	= amd_pstate_cpu_suspend,
> +	.resume		= amd_pstate_cpu_resume,
>  	.set_boost	= amd_pstate_set_boost,
>  	.name		= "amd-pstate",
>  	.attr           = amd_pstate_attr,
> -- 
> 2.32.0
> 

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

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

* Re: [PATCH] cpufreq: amd-pstate: Add resume and suspend callback for amd-pstate
  2022-06-23  7:52 ` Huang Rui
@ 2022-06-23 19:24   ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2022-06-23 19:24 UTC (permalink / raw)
  To: Huang Rui, Su, Jinzhou (Joe)
  Cc: rjw@rjwysocki.net, linux-pm@vger.kernel.org, Deucher, Alexander,
	Du, Xiaojian, Yuan, Perry, Meng, Li (Jassmine), Liang, Richard qi,
	stable@vger.kernel.org

On Thu, Jun 23, 2022 at 9:53 AM Huang Rui <ray.huang@amd.com> wrote:
>
> On Thu, Jun 23, 2022 at 11:15:09AM +0800, Su, Jinzhou (Joe) wrote:
> > When system resumes from S3, the CPPC enable register will be
> > cleared and reset to 0. So sets this bit to enable CPPC
> > interface by writing 1 to this register.
> >
> > Signed-off-by: Jinzhou Su <Jinzhou.Su@amd.com>
>
> Signed-off-by: Jinzhou Su <Jinzhou.Su@amd.com>
> Cc: stable@vger.kernel.org
>
> You can add one line below your commit description to Cc stable mailing
> list. And next time in V2, it's better to use subject-prefix optional to
> mark it as v2 like below:
>
> git format-patch --subject-prefix="PATCH v2" HEAD~
>
> Other looks good for me, patch is
>
> Acked-by: Huang Rui <ray.huang@amd.com>
>
> > ---
> >  drivers/cpufreq/amd-pstate.c | 24 ++++++++++++++++++++++++
> >  1 file changed, 24 insertions(+)
> >
> > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> > index 7be38bc6a673..9ac75c1cde9c 100644
> > --- a/drivers/cpufreq/amd-pstate.c
> > +++ b/drivers/cpufreq/amd-pstate.c
> > @@ -566,6 +566,28 @@ 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;
> > +}
> > +
> > +static int amd_pstate_cpu_suspend(struct cpufreq_policy *policy)
> > +{
> > +     int ret;
> > +
> > +     ret = amd_pstate_enable(false);
> > +     if (ret)
> > +             pr_err("failed to disable amd-pstate during suspend, return %d\n", ret);
> > +
> > +     return ret;
> > +}
> > +
> >  /* Sysfs attributes */
> >
> >  /*
> > @@ -636,6 +658,8 @@ static struct cpufreq_driver amd_pstate_driver = {
> >       .target         = amd_pstate_target,
> >       .init           = amd_pstate_cpu_init,
> >       .exit           = amd_pstate_cpu_exit,
> > +     .suspend        = amd_pstate_cpu_suspend,
> > +     .resume         = amd_pstate_cpu_resume,
> >       .set_boost      = amd_pstate_set_boost,
> >       .name           = "amd-pstate",
> >       .attr           = amd_pstate_attr,
> > --

Applied with some edits in the subject and changelog, and a CC:stable
tag added, as 5.19-rc material.

Thanks!

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-23  3:15 [PATCH] cpufreq: amd-pstate: Add resume and suspend callback for amd-pstate Jinzhou Su
2022-06-23  7:52 ` Huang Rui
2022-06-23 19:24   ` Rafael J. Wysocki
2022-06-23  7:57 ` Greg KH

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