Skip to contentSkip to conversation

cpufreq: amd-pstate: Add resume callback for amd-pstate

PATCH In review Jinzhou Su 2 participants 2 messages Jun 15, 2022 – Jun 16, 2022

Subsystems (2)
lore
Share & tools
lore

Jinzhou Su

author
#0 lore raw

PATCH 1/1 cpufreq: amd-pstate: Add resume callback for amd-pstate

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.

---
 drivers/cpufreq/amd-pstate.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/cpufreq/amd-pstate.c +12 -0
index 7be38bc6a673..e60dd51264a7 100644
@@ -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,
Signature · 1 line
2.32.0
maintainer
#1 lore raw
Quoted 17 lines · Jinzhou (Joe)

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.

---
 drivers/cpufreq/amd-pstate.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/cpufreq/amd-pstate.c +0 -0
index 7be38bc6a673..e60dd51264a7 100644
@@ -566,6 +566,17 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 

drivers/cpufreq/amd-pstate.c static int amd_pstate_cpu_exit(struct cpufreq_policy *policy) · line 578

Quoted 10 lines
drivers/cpufreq/amd-pstate.c +10 -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 [email protected], because it's the fix for amd-pstate restore in S3.

Thanks,
Ray

Quoted 15 lines
drivers/cpufreq/amd-pstate.c +2 -0
+
 /* 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,
Signature · 1 line
2.32.0