cpufreq doesn't keep over suspend/resume
I recently updated my FC2 kernel from the release kernel to 2.6.6-1.435, my cpu is a "Intel(R) Pentium(R) M processor 1600MHz" in a Thinkpad T40p. When I suspend and resume, the hardware does not always resume at the same speed it suspended at. It often will resume at full speed regardless of the speed prior to suspend. Occasionally it will resume at low speed while operating on battery. In prior kernels, the cpufreq driver's resume would reassert the speed policy and reset the processor speed to what it was prior to suspend. Now though, the driver prints a warning about the cpu speed not matching the expected speed:
Warning: CPU frequency out of sync: cpufreq and timing core thinks of 600000, is 1600000 kHz.
Also, this warning is somewhat confusing since "of" appears to refer to "old_freq" rather than actually being a use of the word "of" so it wasn't entirely clear what it was trying to say at first.
To reproduce this:
1. Plug in AC power
2. echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
3. echo 600000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_speed
4. echo 600000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
5. echo mem > /sys/power/state
6. press power button to resume
-- Gerald
Hi!
Quoted 10 lines · Gerald Britton
I recently updated my FC2 kernel from the release kernel to 2.6.6-1.435, my cpu is a "Intel(R) Pentium(R) M processor 1600MHz" in a Thinkpad T40p. When I suspend and resume, the hardware does not always resume at the same speed it suspended at. It often will resume at full speed regardless of the speed prior to suspend. Occasionally it will resume at low speed while operating on battery. In prior kernels, the cpufreq driver's resume would reassert the speed policy and reset the processor speed to what it was prior to suspend. Now though, the driver prints a warning about the cpu speed not matching the expected speed:
Quoted 6 lines
Warning: CPU frequency out of sync: cpufreq and timing core thinks of 600000, is 1600000 kHz.
Also, this warning is somewhat confusing since "of" appears to refer to "
old_freq" rather than actually being a use of the word "of" so it wasn't entirely clear what it was trying to say at first.
As you seem to be a "native speaker": how should we rephrase this message so it is clear what it is trying to say?
Quoted 8 lines
To reproduce this:
1. Plug in AC power
2. echo userspace >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
3. echo 600000 >/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_speed
4. echo 600000 >/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
5. echo mem >/sys/power/state
6. press power button to resume
It's not a bug, it's a feature: the BIOS decides at what speed to boot and/or to resume. Often this depends on whether the AC adapter is plugged in or not. If the system resumes, it tries to go back to the state it was when suspending -- but it's bad if the timing core thinks the CPU runs at full speed when it is only running at half speed, or otherwise. So, upon resuming, cpufreq tries to determine the current speed, and to adapt the timing core and other affected subsystems to the new speed. Once the system is "alive", the previous set _policy_ is restored.
This policy consists of the _governor_ (in your case: userspace) and the min and max frequencies -- not the actual frequencies echo'ed into scaling_setspeed. So, if you indeed do step 3. above (but with scaling_max_freq not _speed), it should return to run at 600000 kHz (check /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
). If not, please say so, and I'll cook up a debug patch to zero in on a possible BUG.
Thanks,
Dominik
Quoted 6 lines · Dominik Brodowski
Hi!
Quoted 3 lines · Gerald Britton
Warning: CPU frequency out of sync: cpufreq and timing core thinks of 600000, is 1600000 kHz.
Quoted 6 lines
Quoted 3 lines
Also, this warning is somewhat confusing since "of" appears to refer to "
old_freq" rather than actually being a use of the word "of" so it wasn't entirely clear what it was trying to say at first.As you seem to be a "native speaker": how should we rephrase this message so it is clear what it is trying to say?
"actual cpu speed 1600000 kHz, cpufreq assumed 600000 kHz" perhaps, I'm not sure there's a good concise way to word this. This is likely a normal state on resume though, so screaming about a warning might not be the right solution here. Checking with things, it seems that my thinkpad may infact always resume from ACPI S3 with the speed at 1.6Ghz.
Quoted 18 lines
Quoted 8 lines
To reproduce this:
1. Plug in AC power
2. echo userspace >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
3. echo 600000 >/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_speed
4. echo 600000 >/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
5. echo mem >/sys/power/state
6. press power button to resumeIt's not a bug, it's a feature: the BIOS decides at what speed to boot and/or to resume. Often this depends on whether the AC adapter is plugged in or not. If the system resumes, it tries to go back to the state it was when suspending -- but it's bad if the timing core thinks the CPU runs at full speed when it is only running at half speed, or otherwise. So, upon resuming, cpufreq tries to determine the current speed, and to adapt the timing core and other affected subsystems to the new speed. Once the system is "alive", the previous set _policy_ is restored.
Quoted 7 lines
This policy consists of the _governor_ (in your case: userspace) and the min and max frequencies -- not the actual frequencies echo'ed into
scaling_setspeed. So, if you indeed do step 3. above (but withscaling_max_freqnot_speed), it should return to run at 600000 kHz (check/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
). If not, please say so, and I'll cook up a debug patch to zero in on a possible BUG.
Prior to suspend:
# cat scaling_cur_freq scaling_max_freq scaling_min_freq scaling_setspeed 600000 600000 600000 600000 # grep 'cpu MHz' < /proc/cpuinfo cpu MHz : 598.244
After resume:
# cat scaling_cur_freq scaling_max_freq scaling_min_freq scaling_setspeed 600000 600000 600000 600000 # grep 'cpu MHz' < /proc/cpuinfo cpu MHz : 1595.318
I was examining the value in /proc/cpuinfo on resume and noticing the difference.
-- Gerald
Quoted 11 lines · Gerald Britton
Quoted 10 lines · Dominik Brodowski
Hi!
Quoted 6 lines · Gerald Britton
Warning: CPU frequency out of sync: cpufreq and timing core thinks of 600000, is 1600000 kHz.
Also, this warning is somewhat confusing since "of" appears to refer to "
old_freq" rather than actually being a use of the word "of" so it wasn't entirely clear what it was trying to say at first.
Quoted 7 lines
Quoted 2 lines
As you seem to be a "native speaker": how should we rephrase this message so it is clear what it is trying to say?
"actual cpu speed 1600000 kHz, cpufreq assumed 600000 kHz" perhaps, I'm not sure there's a good concise way to word this. This is likely a normal state on resume though, so screaming about a warning might not be the right solution here.
Normal but broken, and it definitely needs a warning. In fact, some cpufreq drivers on some architectures will even _panic_ on such an event. However, the amount of such warnings will likely be reduced once the pstate_cnt patch I posted yesterday on this and the acpi-devel lists is merged.
Quoted 18 lines
# cat scaling_cur_freq scaling_max_freq scaling_min_freq scaling_setspeed 600000 600000 600000 600000 # grep 'cpu MHz' < /proc/cpuinfo cpu MHz : 598.244After resume:
# cat scaling_cur_freq scaling_max_freq scaling_min_freq scaling_setspeed 600000 600000 600000 600000 # grep 'cpu MHz' < /proc/cpuinfo cpu MHz : 1595.318
Quoted 2 lines
I was examining the value in
/proc/cpuinfoon resume and noticing the difference.
... and this constitutes a BUG. Will investigate.
Thanks,
Dominik
_______________________________________________
Cpufreq mailing list
[email protected]
http://www.linux.org.uk/mailman/listinfo/cpufreq
PATCH 1/1 fix double "out-of-sync" warning on resume [Was: Re: cpufreq doesn't keep over suspend/resume]
In reply to Gerald Britton- Rephrase "out-of-sync" warning (partly) based upon Gerald Britton's suggestion
- Also update cpufreq's opinion of current cpu frequency upon resume, else the "out-of-sync" warning will appear twice. Thanks to Gerald Britton for noting this.
drivers/cpufreq/cpufreq.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
drivers/cpufreq/cpufreq.c +6 -5
@@ -617,8 +617,8 @@if (cpufreq_driver->flags &CPUFREQ_PANIC_RESUME_OUTOFSYNC )panic ("CPU Frequency is out of sync." ); -printk (KERN_WARNING "Warning: CPU frequency out of sync: cpufreq and timing" -"core thinks of %u, is %u kHz.\n" , cpu_policy->cur, cur_freq); +printk (KERN_WARNING "Warning: CPU frequency is %u, " +"cpufreq assumed %u kHz.\n" , cur_freq, cpu_policy->cur); freqs.cpu = cpu; freqs.old = cpu_policy->cur;
@@ -626,6 +626,8 @@notifier_call_chain (&cpufreq_transition_notifier_list,CPUFREQ_RESUMECHANGE , &freqs);adjust_jiffies (CPUFREQ_RESUMECHANGE , &freqs); + + cpu_policy->cur = cur_freq; } }
@@ -1065,9 +1067,8 @@if (cpufreq_driver->flags &CPUFREQ_PANIC_OUTOFSYNC )panic ("CPU Frequency is out of sync." ); -printk (KERN_WARNING "Warning: CPU frequency out of sync: " -"cpufreq and timing core thinks of %u, is %u kHz.\n" , - cpufreq_cpu_data[freqs->cpu]->cur, freqs->old); +printk (KERN_WARNING "Warning: CPU frequency is %u, " +"cpufreq assumed %u kHz.\n" , freqs->old, cpufreq_cpu_data[freqs->cpu]->cur); freqs->old = cpufreq_cpu_data[freqs->cpu]->cur; } }
PATCH 1/1 fix userspace resume support [Was: Re: cpufreq doesn't keep over suspend/resume]
In reply to Gerald BrittonFix resume support in the userspace cpufreq governor: we need to set the CPU to the frequency last echo'ed by userspace into this governor's files.
drivers/cpufreq/cpufreq_userspace.c | 10 ++++++++++ 1 files changed, 10 insertions(+)
drivers/cpufreq/cpufreq_userspace.c +10 -0
@@ -82,6 +82,13 @@ {struct cpufreq_freqs *freq = data; +/* Don't update cur_freq if CPU is managed and we're +* waking up: else we won't remember what frequency +* we need to set the CPU to. +*/ +if (cpu_is_managed[freq->cpu] && (val ==CPUFREQ_RESUMECHANGE )) +return 0 ; + cpu_cur_freq[freq->cpu] = freq->new;return 0 ;
@@ -522,6 +529,9 @@else if (policy->min > cpu_cur_freq[cpu])__cpufreq_driver_target (¤t_policy[cpu], policy->min,CPUFREQ_RELATION_L ); +else +__cpufreq_driver_target (¤t_policy[cpu], cpu_cur_freq[cpu], +CPUFREQ_RELATION_L );memcpy (¤t_policy[cpu], policy,sizeof (struct cpufreq_policy ));up (&userspace_sem);break ;