Skip to contentSkip to conversation

New: amd-pstate stops working after S3 suspend

Bug 216189 [email protected] 1 participant 5 messages Jun 29, 2022 – Jun 30, 2022

lore
Share & tools
lore
#0 lore raw

https://bugzilla.kernel.org/show_bug.cgi?id=216189

            Bug ID: 216189
           Summary: amd-pstate stops working after S3 suspend
           Product: Power Management
           Version: 2.5
    Kernel Version: 5.18.8
          Hardware: AMD
                OS: Linux
              Tree: Mainline
            Status: NEW
          Severity: normal
          Priority: P1
         Component: cpufreq
          Assignee: [email protected]
          Reporter: [email protected]
        Regression: No

Hardware: Lenovo Thinkpad T14 Gen2 AMD
CPU: AMD Ryzen 7 PRO 5850U
Kernel: 5.18.8 (tried linux-next too)

I've managed to get new amd-pstate driver working on my system, but after suspend (S3) it stops working and CPU frequency and Boost state control is not working.

Falling back to acpi-cpufreq driver solves the issue — suspend no longer breaks CPU frequency and Boost controls.

```
    ~ sudo cpupower frequency-info                                              
    analyzing CPU 0:
      driver: amd-pstate
      CPUs which run at the same hardware frequency: 0
      CPUs which need to have their frequency coordinated by software: 0
      maximum transition latency: 131 us
      hardware limits: 400 MHz - 1.90 GHz
      available cpufreq governors: ondemand performance schedutil
      current policy: frequency should be within 800 MHz and 1.50 GHz.
                      The governor "ondemand" may decide which speed to use
                      within this range.
      current CPU frequency: Unable to call hardware
      current CPU frequency: 3.41 GHz (asserted by call to kernel)

     boost state support:
        Supported: yes
        Active: no
        AMD PSTATE Highest Performance: 166. Maximum Frequency: 4.51 GHz.
        AMD PSTATE Nominal Performance: 70. Nominal Frequency: 1.90 GHz.
        AMD PSTATE Lowest Non-linear Performance: 41. Lowest Non-linear
Frequency: 1.11 GHz.
        AMD PSTATE Lowest Performance: 15. Lowest Frequency: 400 MHz.
```

As we see here, frequency limits are set to 800 MHz - 1.50 GHz and boost stats is inactive, but actual CPU frequency 3.41 GHz (that means boost is on and limits are ignored)

The things starts working again only after reboot.

Any commands such as

```
echo 1 > /sys/devices/system/cpu/cpufreq/boost
echo 0 > /sys/devices/system/cpu/cpufreq/boost
cpupower frequency-set -g ondemand -d 400MHz -u 800MHz
cpupower frequency-set -g performance -d 1.9GHz -u 1.9GHz

```

just does nothing. (after reboot they start working again of course)

There are no mentions of pstate module in dmesg, but maybe I have to enable some debug (how to do it?)

Simillar bug for intel_pstate:
https://bugzilla.kernel.org/show_bug.cgi?id=90421
Maybe it is related some way.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#2 lore raw

[Bug 216189] amd-pstate stops working after S3 suspend

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=216189

[email protected] changed:

What |Removed |Added
----------------------------------------------------------------------------

             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from [email protected] ---

*** This bug has been marked as a duplicate of bug 215938 ***

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#3 lore raw

[Bug 216189] amd-pstate stops working after S3 suspend

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=216189

Joe ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]

--- Comment #3 from Joe ([email protected]) --- Hello,

The fixed patch has been accepted. It will be updated in 5.19.

Here is the detail

Quoted 59 lines · Huang Rui
Quoted 5 lines · Jinzhou (Joe)

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.

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

drivers/cpufreq/amd-pstate.c static int amd_pstate_cpu_exit(struct cpufreq_policy

Quoted 10 lines
---
 drivers/cpufreq/amd-pstate.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
(quoted diff) +0 -0

b/drivers/cpufreq/amd-pstate.c index 7be38bc6a673..9ac75c1cde9c 100644

drivers/cpufreq/amd-pstate.c +0 -0
@@ -566,6 +566,28 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy

*policy)

Quoted 27 lines
drivers/cpufreq/amd-pstate.c +22 -0
      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 */
 
Quoted 11 lines

drivers/cpufreq/amd-pstate.c static struct cpufreq_driver amd_pstate_driver = {

Quoted 11 lines
drivers/cpufreq/amd-pstate.c +2 -1
 /*
@@ -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!

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.