Skip to contentSkip to conversation

Files shared with swsusp.

PATCH In review Nigel Cunningham 2 participants 6 messages Jun 26, 2006 – Jun 28, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Files shared with swsusp.

Modifications to files shared with swsusp. We implement CONFIG_SUSPEND_SHARED, which is selected by either swsusp or Suspend2 and causes the parts required by either implementation to be compiled in. Swsusp's kernel/power files are compiled in after Suspend2's because Suspend2 recognises swsusp files and ignores them, but swsusp doesn't recognise Suspend2 signatures and complains about them.

#1 lore raw

PATCH 1/4 Suspend2 Kconfig modifications.

Add Suspend2 Kconfig entries to the kernel/power/Kconfig file.

 kernel/power/Kconfig |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)
kernel/power/Kconfig +61 -0
index e8d57d1..cb5475a 100644
@@ -98,6 +98,67 @@ config SUSPEND_SMP
 	bool
 	depends on HOTPLUG_CPU && X86 && PM
 	default y
+
+config SUSPEND2_CRYPTO
+	bool
+	depends on SUSPEND2 && CRYPTO
+	default y
+
+menuconfig SUSPEND2
+	bool "Suspend2"
+	depends on PM
+	select DYN_PAGEFLAGS
+	select HOTPLUG_CPU if SMP
+	---help---
+	  Suspend2 is the 'new and improved' suspend support.
+	  
+	  See the Suspend2 home page (suspend2.net)
+	  for FAQs, HOWTOs and other documentation.
+
+	comment 'Image Storage (you need at least one writer)'
+		depends on SUSPEND2
+	
+	config SUSPEND2_FILEWRITER
+		bool '  File Writer'
+		depends on SUSPEND2
+		---help---
+		  This option enables support for storing an image in a
+		  simple file. This should be possible, but we're still
+		  testing it.
+
+	config SUSPEND2_SWAPWRITER
+		bool '  Swap Writer'
+		depends on SUSPEND2
+		select SWAP
+		---help---
+		  This option enables support for storing an image in your
+		  swap space.
+
+	comment 'General Options'
+		depends on SUSPEND2
+
+	config SUSPEND2_DEFAULT_RESUME2
+		string '  Default resume device name'
+		depends on SUSPEND2
+		---help---
+		  You normally need to add a resume2= parameter to your lilo.conf or
+		  equivalent. With this option properly set, the kernel has a value
+		  to default. No damage will be done if the value is invalid.
+
+	config SUSPEND2_KEEP_IMAGE
+		bool '  Allow Keep Image Mode'
+		depends on SUSPEND2
+		---help---
+		  This option allows you to keep and image and reuse it. It is intended
+		  __ONLY__ for use with systems where all filesystems are mounted read-
+		  only (kiosks, for example). To use it, compile this option in and boot
+		  normally. Set the KEEP_IMAGE flag in /proc/suspend2 and suspend.
+		  When you resume, the image will not be removed. You will be unable to turn
+		  off swap partitions (assuming you are using the swap writer), but future
+		  suspends simply do a power-down. The image can be updated using the
+		  kernel command line parameter suspend_act= to turn off the keep image
+		  bit. Keep image mode is a little less user friendly on purpose - it
+		  should not be used without thought!
  
 config SUSPEND_SHARED
 	bool

--
Nigel Cunningham nigel at suspend2 dot net

#2 lore raw

PATCH 2/4 kernel/power/Makefile Suspend2 modifications.

In reply to Nigel Cunningham

Add Makefile entries for suspend2 objects.

 kernel/power/Makefile |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
kernel/power/Makefile +20 -1
index 01f2230..0d0f132 100644
@@ -5,9 +5,28 @@ endif
 
 obj-y				:= main.o process.o console.o
 obj-$(CONFIG_PM_LEGACY)		+= pm.o
-obj-$(CONFIG_SOFTWARE_SUSPEND)	+= swsusp.o disk.o swap.o user.o
 
 obj-$(CONFIG_SUSPEND_SMP)	+= smp.o
 obj-$(CONFIG_SUSPEND_SHARED)	+= snapshot.o
 
+# Order is important for compression and encryption - we
+# compress before encrypting.
+
+suspend_core-objs := io.o pagedir.o prepare_image.o \
+		extent.o suspend.o modules.o \
+		pageflags.o ui.o proc.o \
+		power_off.o atomic_copy.o
+
+#ifdef CONFIG_NET
+suspend_core-objs += storage.o netlink.o
+#endif
+
+obj-$(CONFIG_SUSPEND2)			+= suspend_core.o
+obj-$(CONFIG_SUSPEND2_CRYPTO)		+= compression.o encryption.o
+
+obj-$(CONFIG_SUSPEND2_SWAPWRITER)	+= suspend_block_io.o suspend_swap.o
+obj-$(CONFIG_SUSPEND2_FILEWRITER)	+= suspend_block_io.o suspend_file.o
+
+obj-$(CONFIG_SOFTWARE_SUSPEND)	+= swsusp.o disk.o swap.o user.o
+
 obj-$(CONFIG_MAGIC_SYSRQ)	+= poweroff.o

--
Nigel Cunningham nigel at suspend2 dot net

#3 lore raw

PATCH 3/4 Correct kernel/power/smp.c credit.

In reply to Nigel Cunningham

Modify kernel/power/smp.c credit to my current address.

 kernel/power/smp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/power/smp.c +1 -1
index 5957312..c102e7c 100644
@@ -2,7 +2,7 @@
  * drivers/power/smp.c - Functions for stopping other CPUs.
  *
  * Copyright 2004 Pavel Machek <[email protected]>
- * Copyright (C) 2002-2003 Nigel Cunningham <[email protected]>
+ * Copyright (C) 2002-2003 Nigel Cunningham <[email protected]>
  *
  * This file is released under the GPLv2.
  */

--
Nigel Cunningham nigel at suspend2 dot net

#4 lore raw

Re: [Suspend2][ 3/4] [Suspend2] Correct kernel/power/smp.c credit.

Quoted 3 lines · Nigel Cunningham

Modify kernel/power/smp.c credit to my current address.

ACK on this one... if you have similar easy stuff, please retransmit just that.
Pavel

Quoted 21 lines
kernel/power/smp.c +1 -2
index 5957312..c102e7c 100644
@@ -2,7 +2,7 @@
  * drivers/power/smp.c - Functions for stopping other CPUs.
  *
  * Copyright 2004 Pavel Machek <[email protected]>
- * Copyright (C) 2002-2003 Nigel Cunningham <[email protected]>
+ * Copyright (C) 2002-2003 Nigel Cunningham <[email protected]>
  *
  * This file is released under the GPLv2.
  */
 
--

Nigel Cunningham nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#5 lore raw

PATCH 4/4 Build swsusp lowlevel code for Suspend2 as well

In reply to Nigel Cunningham

Suspend2 now uses the same lowlevel code as swsusp. This patch lets that lowlevel code be built when swsusp is disabled but Suspend2 is enabled.

 arch/i386/mm/init.c          |    2 +-
 arch/i386/power/Makefile     |    2 +-
 arch/powerpc/kernel/Makefile |    2 +-
 arch/x86_64/kernel/Makefile  |    2 +-
 arch/x86_64/kernel/suspend.c |    4 ++--
 kernel/power/Kconfig         |    5 +++++
 kernel/power/Makefile        |    3 ++-
 kernel/power/snapshot.c      |   17 ++++++++++++++++-
 8 files changed, 29 insertions(+), 8 deletions(-)
arch/i386/mm/init.c +1 -1
index 3df1371..1678ec4 100644
@@ -384,7 +384,7 @@ static void __init pagetable_init (void)
 #endif
 }
 
-#ifdef CONFIG_SOFTWARE_SUSPEND
+#ifdef CONFIG_SUSPEND_SHARED
 /*
  * Swap suspend & friends need this for resume because things like the intel-agp
  * driver might have split up a kernel 4MB mapping.
arch/i386/power/Makefile +1 -1
index 8cfa4e8..7f4efb1 100644
@@ -1,2 +1,2 @@
 obj-$(CONFIG_PM)		+= cpu.o
-obj-$(CONFIG_SOFTWARE_SUSPEND)	+= swsusp.o
+obj-$(CONFIG_SUSPEND_SHARED)	+= swsusp.o
arch/powerpc/kernel/Makefile +1 -1
index 803858e..86eabdc 100644
@@ -36,7 +36,7 @@ obj64-$(CONFIG_PPC_MULTIPLATFORM) += nvr
 obj-$(CONFIG_CRASH_DUMP)	+= crash_dump.o
 obj-$(CONFIG_6xx)		+= idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o
 obj-$(CONFIG_TAU)		+= tau_6xx.o
-obj32-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_32.o
+obj32-$(CONFIG_SUSPEND_SHARED)	+= swsusp_32.o
 obj32-$(CONFIG_MODULES)		+= module_32.o
 obj-$(CONFIG_E500)		+= perfmon_fsl_booke.o
 
arch/x86_64/kernel/Makefile +1 -1
index 059c883..81881b5 100644
@@ -25,7 +25,7 @@ obj-$(CONFIG_X86_IO_APIC)	+= io_apic.o m
 obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o crash.o
 obj-$(CONFIG_CRASH_DUMP)	+= crash_dump.o
 obj-$(CONFIG_PM)		+= suspend.o
-obj-$(CONFIG_SOFTWARE_SUSPEND)	+= suspend_asm.o
+obj-$(CONFIG_SUSPEND_SHARED)	+= suspend_asm.o
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 obj-$(CONFIG_GART_IOMMU)	+= pci-gart.o aperture.o
arch/x86_64/kernel/suspend.c +2 -2
index ecbd34c..510d369 100644
@@ -141,7 +141,7 @@ void fix_processor_context(void)
 
 }
 
-#ifdef CONFIG_SOFTWARE_SUSPEND
+#ifdef CONFIG_SUSPEND_SHARED
 /* Defined in arch/x86_64/kernel/suspend_asm.S */
 extern int restore_image(void);
 
@@ -220,4 +220,4 @@ int swsusp_arch_resume(void)
 	restore_image();
 	return 0;
 }
-#endif /* CONFIG_SOFTWARE_SUSPEND */
+#endif /* CONFIG_SUSPEND_SHARED */
kernel/power/Kconfig +5 -0
index ce0dfb8..e8d57d1 100644
@@ -98,3 +98,8 @@ config SUSPEND_SMP
 	bool
 	depends on HOTPLUG_CPU && X86 && PM
 	default y
+ 
+config SUSPEND_SHARED
+	bool
+	depends on SUSPEND2 || SOFTWARE_SUSPEND
+	default y
kernel/power/Makefile +2 -1
index 8d0af3d..01f2230 100644
@@ -5,8 +5,9 @@ endif
 
 obj-y				:= main.o process.o console.o
 obj-$(CONFIG_PM_LEGACY)		+= pm.o
-obj-$(CONFIG_SOFTWARE_SUSPEND)	+= swsusp.o disk.o snapshot.o swap.o user.o
+obj-$(CONFIG_SOFTWARE_SUSPEND)	+= swsusp.o disk.o swap.o user.o
 
 obj-$(CONFIG_SUSPEND_SMP)	+= smp.o
+obj-$(CONFIG_SUSPEND_SHARED)	+= snapshot.o
 
 obj-$(CONFIG_MAGIC_SYSRQ)	+= poweroff.o
kernel/power/snapshot.c +16 -1
index 3eeedbb..968b927 100644
@@ -34,6 +34,13 @@
 
 #include "power.h"
 
+#ifdef CONFIG_SUSPEND2
+#include "pagedir.h"
+
+extern int suspend2_running;
+int suspend_post_context_save(void);
+#endif
+
 struct pbe *pagedir_nosave;
 static unsigned int nr_copy_pages;
 static unsigned int nr_meta_pages;
@@ -177,7 +184,6 @@ static int saveable(struct zone *zone, u
 		return 0;
 
 	page = pfn_to_page(pfn);
-	BUG_ON(PageReserved(page) && PageNosave(page));
 	if (PageNosave(page))
 		return 0;
 	if (PageReserved(page) && pfn_is_nosave(pfn))
@@ -358,6 +364,10 @@ static inline void *alloc_image_page(gfp
 
 unsigned long get_safe_page(gfp_t gfp_mask)
 {
+#ifdef CONFIG_SUSPEND2
+	if (suspend2_running)
+		return suspend_get_nonconflicting_page();
+#endif
 	return (unsigned long)alloc_image_page(gfp_mask, 1);
 }
 
@@ -480,6 +490,11 @@ asmlinkage int swsusp_save(void)
 {
 	unsigned int nr_pages;
 
+#ifdef CONFIG_SUSPEND2
+	if (suspend2_running)
+		return suspend_post_context_save();
+#endif
+
 	pr_debug("swsusp: critical section: \n");
 
 	drain_local_pages();

--
Nigel Cunningham nigel at suspend2 dot net