Skip to content

Commit b376471

Browse files
JinzhouSurafaeljw
authored andcommitted
cpufreq: amd-pstate: Add resume and suspend callbacks
When system resumes from S3, the CPPC enable register will be cleared and reset to 0. So enable the CPPC interface by writing 1 to this register on system resume and disable it during system suspend. Signed-off-by: Jinzhou Su <[email protected]> Signed-off-by: Jinzhou Su <[email protected]> Acked-by: Huang Rui <[email protected]> [ rjw: Subject and changelog edits ] Cc: All applicable <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent a111daf commit b376471

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,28 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy *policy)
566566
return 0;
567567
}
568568

569+
static int amd_pstate_cpu_resume(struct cpufreq_policy *policy)
570+
{
571+
int ret;
572+
573+
ret = amd_pstate_enable(true);
574+
if (ret)
575+
pr_err("failed to enable amd-pstate during resume, return %d\n", ret);
576+
577+
return ret;
578+
}
579+
580+
static int amd_pstate_cpu_suspend(struct cpufreq_policy *policy)
581+
{
582+
int ret;
583+
584+
ret = amd_pstate_enable(false);
585+
if (ret)
586+
pr_err("failed to disable amd-pstate during suspend, return %d\n", ret);
587+
588+
return ret;
589+
}
590+
569591
/* Sysfs attributes */
570592

571593
/*
@@ -636,6 +658,8 @@ static struct cpufreq_driver amd_pstate_driver = {
636658
.target = amd_pstate_target,
637659
.init = amd_pstate_cpu_init,
638660
.exit = amd_pstate_cpu_exit,
661+
.suspend = amd_pstate_cpu_suspend,
662+
.resume = amd_pstate_cpu_resume,
639663
.set_boost = amd_pstate_set_boost,
640664
.name = "amd-pstate",
641665
.attr = amd_pstate_attr,

0 commit comments

Comments
 (0)