Ubuntu – CPU clock slower after each resume from sleep

15.10cpufreqkubuntususpend

I'm running kubuntu 15.10 on a Lenovo Y50-70, and I have a very annoying problem with the CPU clock:
Whenever the computer resumes from sleep, the CPU clock has a lower maximum, and this does not happen only once, but after every resume the clock is slower, until it's down from initially 3.6 GHz to ~600 MHz.

alain@alain-Y50-70:~$ sudo -i
[sudo] password for alain: 
root@alain-Y50-70:~# cpupower frequency-info
analyzing CPU 0:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 0.97 ms.
  hardware limits: 800 MHz - 3.60 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 800 MHz and 3.60 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 817 MHz (asserted by call to hardware).
  boost state support:
    Supported: yes
    Active: yes
root@alain-Y50-70:~# cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
100
root@alain-Y50-70:~# cpupower frequency-info
analyzing CPU 0:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 0.97 ms.
  hardware limits: 800 MHz - 3.60 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 800 MHz and 2.88 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 800 MHz (asserted by call to hardware).
  boost state support:
    Supported: yes
    Active: yes
root@alain-Y50-70:~# cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
80
root@alain-Y50-70:~# cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
60
root@alain-Y50-70:~# cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
40
root@alain-Y50-70:~# cat /sys/devices/system/cpu/intel_pstate/max_perf_pct                                 
40                                                                                                         
root@alain-Y50-70:~# cpupower frequency-info                                 
analyzing CPU 0:                                                                                           
  driver: intel_pstate                                                                                     
  CPUs which run at the same hardware frequency: 0                                                         
  CPUs which need to have their frequency coordinated by software: 0                                       
  maximum transition latency: 0.97 ms.                                                                     
  hardware limits: 800 MHz - 3.60 GHz                                                                      
  available cpufreq governors: performance, powersave                                                      
  current policy: frequency should be within 800 MHz and 1.44 GHz.                                         
                  The governor "powersave" may decide which speed to use                                   
                  within this range.                                                                       
  current CPU frequency is 699 MHz (asserted by call to hardware).                                         
  boost state support:                                                                                     
    Supported: yes                                                                                         
    Active: yes                                                                                            
root@alain-Y50-70:~# cat /sys/devices/system/cpu/intel_pstate/max_perf_pct                                 
40                                                                                                         
root@alain-Y50-70:~# cpupower frequency-info                                 
analyzing CPU 0:                                                                                           
  driver: intel_pstate                                                                                     
  CPUs which run at the same hardware frequency: 0                                                         
  CPUs which need to have their frequency coordinated by software: 0                                       
  maximum transition latency: 0.97 ms.                                                                     
  hardware limits: 800 MHz - 3.60 GHz                                                                      
  available cpufreq governors: performance, powersave                                                      
  current policy: frequency should be within 800 MHz and 1.44 GHz.                                         
                  The governor "powersave" may decide which speed to use                                   
                  within this range.                                                                       
  current CPU frequency is 605 MHz (asserted by call to hardware).                                         
  boost state support:                                                                                     
    Supported: yes                                                                                         
    Active: yes                                                                                            
root@alain-Y50-70:~#                                                                                       

I put the computer asleep between the commands above. As you can see, first the max_perf_pct is reduced in steps until it reaches 40, then it stays 40 but the clock speed continues to be reduced. It doesn't matter if the laptop is plugged in or not, and the temperature is normal.

I think it may be related to this bug:
https://bugzilla.kernel.org/show_bug.cgi?id=90421


The biggest problem is that I can't find a way to manually set the max clock back to 3.6 GHz. First I tried cpupower frequency-set -u 3.60GHz:

root@alain-Y50-70:~# cpupower frequency-set -u 3.60GHz
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
Setting cpu: 4
Setting cpu: 5
Setting cpu: 6
Setting cpu: 7
root@alain-Y50-70:~# cpupower frequency-info
analyzing CPU 0:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 0.97 ms.
  hardware limits: 800 MHz - 3.60 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 800 MHz and 1.44 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 699 MHz (asserted by call to hardware).
  boost state support:
    Supported: yes
    Active: yes
root@alain-Y50-70:~# cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
40

but that seems to be the wrong way because the Intel P-State driver is used, so I tried echo 100 >/sys/devices/system/cpu/intel_pstate/max_perf_pct with no effect:

root@alain-Y50-70:~# echo 100 >/sys/devices/system/cpu/intel_pstate/max_perf_pct
root@alain-Y50-70:~# cpupower frequency-info
analyzing CPU 0:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 0.97 ms.
  hardware limits: 800 MHz - 3.60 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 800 MHz and 1.44 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency is 700 MHz (asserted by call to hardware).
  boost state support:
    Supported: yes
    Active: yes
root@alain-Y50-70:~# cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
40

I also tried the performance governor, with no success.

How can I set the maximum clock frequency back to 3.6 GHz?

Best Answer

The issue you are experiencing has been reported many times.
Please refer to this bugzilla bug report.

The issue has been isolated to a particular commit in the kernel tree. That commit has also been backported to some previous stable kernel versions.
However, the actual real root cause is a Lenovo BIOS problem. Quoting from the linux-pm e-mail thread:

BIOS reports bogus passive trip point value, which is 0 degree Celsius ... In order to workaround this bogus BIOS, we should disable those invalid trip points by checking the trip point value,

If you go back a version of or two, your Lenovo will work properly (4.2.0-19 is known to work properly).

Your issue is not clock modulation (register 0x19A) related, unless your battery is below 30% (unproven, but suspected).

References:
http://ubuntuforums.org/showthread.php?t=2316101
Strange cpufreq scaling issues: regardless of governor, max cpufreq drops incrementally on wake
i3 throttled at 500Mhz when battery under 30%
http://marc.info/?t=145816738700001&r=1&w=2