Hello Rafael,

Yet another patch in the suspend2 feature-set series.
It sets cpufreq to maximum during the cycle.
It is important to finish the process as quickly as possible (human engineer 
issue :) )
When running on batteries it may take forever without this...

Please consider to apply.

If you accept this, I will update the HOWTO later.

BTW: It is starting to be very difficult to provide patches without
conflict... This one conflicts with the compress one at Makefile.

Queue:
suspend-lzo.patch
suspend-pciutils.patch
suspend-prefix.patch
suspend-reboot.patch
suspend-cpufreq.patch

Future: fbsplash support.

Best Regards,
Alon Bar-Lev

---

diff -urNp suspend.org/cpufreql.c suspend/cpufreql.c
--- suspend.org/cpufreql.c      1970-01-01 02:00:00.000000000 +0200
+++ suspend/cpufreql.c  2007-07-20 20:34:10.000000000 +0300
@@ -0,0 +1,76 @@
+
+#include <cpufreq.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "cpufreql.h"
+
+#define MAX_CPU 16
+struct cpufreq_policy *saved_policy[MAX_CPU];
+
+void cpufreql_save_and_boost (void) {
+       memset (saved_policy, 0, sizeof (saved_policy));
+       int cpu;
+
+       for (cpu=0;cpu<MAX_CPU;cpu++) {
+               if (!cpufreq_cpu_exists (cpu)) {
+                       struct cpufreq_available_governors *govs;
+                       struct cpufreq_available_governors *govsi;
+                       struct cpufreq_available_frequencies *freqs;
+                       struct cpufreq_available_frequencies *freqsi;
+
+                       govs = cpufreq_get_available_governors (cpu);
+                       freqs = cpufreq_get_available_frequencies (cpu);
+                       saved_policy[cpu] = cpufreq_get_policy (cpu);
+
+                       if (govs != NULL && freqs != NULL && saved_policy[cpu] 
!= NULL) {
+                               struct cpufreq_policy new_policy;
+                               unsigned long max_freq = 0;
+                               int has_performance = 0;
+
+                               for 
(govsi=govs->first;govsi!=NULL;govsi=govsi->next) {
+                                       if (!strcmp (govsi->governor, 
"performance")) {
+                                               has_performance = 1;
+                                       }
+                               }
+
+                               for 
(freqsi=freqs->first;freqsi!=NULL;freqsi=freqsi->next) {
+                                       if (freqsi->frequency > max_freq) {
+                                               max_freq = freqsi->frequency;
+                                       }
+                               }
+
+                               if (has_performance) {
+                                       new_policy.governor = "performance";
+                               }
+                               else {
+                                       new_policy.governor = 
saved_policy[cpu]->governor;
+                               }
+
+                               new_policy.min = new_policy.max = max_freq;
+
+                               cpufreq_set_policy (cpu, &new_policy);
+                       }
+
+                       if (freqs != NULL) {
+                               cpufreq_put_available_frequencies (freqs);
+                       }
+                       if (govs != NULL) {
+                               cpufreq_put_available_governors (govs);
+                       }
+               }
+       }
+}
+
+void cpufreql_restore (void) {
+       int cpu;
+
+       for (cpu=0;cpu<MAX_CPU;cpu++) {
+               if (saved_policy != NULL) {
+                       cpufreq_set_policy (cpu, saved_policy[cpu]);
+                       cpufreq_put_policy (saved_policy[cpu]);
+                       saved_policy[cpu] = NULL;
+               }
+       }
+}
+
diff -urNp suspend.org/cpufreql.h suspend/cpufreql.h
--- suspend.org/cpufreql.h      1970-01-01 02:00:00.000000000 +0200
+++ suspend/cpufreql.h  2007-07-20 19:46:36.000000000 +0300
@@ -0,0 +1,7 @@
+#ifndef CPUFREQL_H
+#define CPUFREQL_H
+
+void cpufreql_save_and_boost (void);
+void cpufreql_restore (void);
+
+#endif
diff -urNp suspend.org/Makefile suspend/Makefile
--- suspend.org/Makefile        2007-05-15 22:32:48.000000000 +0300
+++ suspend/Makefile    2007-07-20 19:56:08.000000000 +0300
@@ -23,8 +24,10 @@ BINARIES=s2disk s2both s2ram swap-offset
 BINARIES_MIN=s2disk swap-offset
 
 S2RAM_OBJ=vt.o config.o
-SWSUSP_OBJ=vt.o md5.o encrypt.o config.o loglevel.o splash.o bootsplash.o 
+SWSUSP_OBJ=vt.o md5.o encrypt.o cpufreql.o config.o loglevel.o splash.o 
bootsplash.o 
 
 S2RAM_LD_FLAGS = $(LD_FLAGS)
 SWSUSP_LD_FLAGS = $(LD_FLAGS)
+CPUFREQ_LDFLAGS=-lcpufreq -lsysfs
+SWSUSP_LD_FLAGS += $(CPUFREQ_LDFLAGS)
 ifeq ($(ARCH), x86)
@@ -93,7 +107,7 @@ md5.o encrypt.o: %.o : %.c %.h md5.h
        $(CC) $(CC_FLAGS) -DHAVE_INTTYPES_H -DHAVE_STDINT_H -c $< -o $@
 
 # Simple objects with header
-config.o vt.o bootsplash.o splash.o splashy_funcs.o vbetool/vbetool.o 
s2ram-ppc.o: %.o : %.c %.h
+config.o vt.o cpufreql.o bootsplash.o splash.o splashy_funcs.o 
vbetool/vbetool.o s2ram-ppc.o: %.o : %.c %.h
        $(CC) $(CC_FLAGS) -c $< -o $@
 
 # Simple object without header
diff -urNp suspend.org/resume.c suspend/resume.c
--- suspend.org/resume.c        2007-05-13 20:53:13.000000000 +0300
+++ suspend/resume.c    2007-07-20 20:03:33.000000000 +0300
@@ -32,5 +32,6 @@
 #include "swsusp.h"
 #include "config.h"
 #include "md5.h"
+#include "cpufreql.h"
 #include "splash.h"
 #include "loglevel.h"
@@ -854,6 +857,8 @@ int main(int argc, char *argv[])
                        resume_dev_name[n] = '\0';
        }
 
+       cpufreql_save_and_boost ();
+
        setvbuf(stdout, NULL, _IONBF, 0);
        setvbuf(stderr, NULL, _IONBF, 0);
 
@@ -921,6 +926,8 @@ Free:
 
        close_printk();
 
+       cpufreql_restore ();
+
        free(mem_pool);
 
        return error;
diff -urNp suspend.org/suspend.c suspend/suspend.c
--- suspend.org/suspend.c       2007-05-13 23:16:53.000000000 +0300
+++ suspend/suspend.c   2007-07-20 19:53:50.000000000 +0300
@@ -41,6 +41,7 @@
 #include "swsusp.h"
 #include "config.h"
 #include "md5.h"
+#include "cpufreql.h"
 #include "splash.h"
 #include "vt.h"
 #include "loglevel.h"
@@ -1354,6 +1368,8 @@ int main(int argc, char *argv[])
        }
 #endif
 
+       cpufreql_save_and_boost ();
+
        setvbuf(stdout, NULL, _IONBF, 0);
        setvbuf(stderr, NULL, _IONBF, 0);
 
@@ -1498,6 +1514,9 @@ Umount:
        } else {
                umount(chroot_path);
        }
+
+       cpufreql_restore ();
+
 #ifdef CONFIG_ENCRYPT
        if (encrypt)
                gcry_cipher_close(cipher_handle);

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Suspend-devel mailing list
Suspend-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/suspend-devel

Reply via email to