Skip to contentSkip to conversation

remove software_suspend() and fix compile w/ SOFTWARE_SUSPEND disabled

PATCH In review Johannes Berg 3 participants 6 messages Mar 22, 2007 – Mar 25, 2007

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

PATCH 1/1 remove software_suspend() and fix compile w/ SOFTWARE_SUSPEND disabled

This patch kills off software_suspend() and all it's users, pm_suspend(PM_SUSPEND_DISK) is much cleaner anyway. Also, this makes the kernel compile again w/o CONFIG_SOFTWARE_SUSPEND after Rafael's patches to kill the suspend pageflags broke it.

Cc Rafael J. Wysocki <[email protected]>

---
Have the pageflags removal patches been applied anywhere already? If so please just apply this on top. If not, could you (Rafael) then fix your patches to compile w/o software suspend and then I'll post the removal of software_suspend() as an extra patch.

Alternatively we can just change the order of these patches, i.e. do the removal of software_suspend() first and then your patches (since the compile error your patches introduce is related to software_suspend()).

 drivers/acpi/sleep/proc.c    |    2 +-
 drivers/i2c/chips/tps65010.c |    4 +++-
 include/linux/init.h         |    2 +-
 include/linux/suspend.h      |    8 --------
 kernel/power/main.c          |   21 ++++++++-------------
 kernel/sys.c                 |    2 +-
 6 files changed, 14 insertions(+), 25 deletions(-)
kernel/power/main.c +8 -13
@@ -172,17 +172,22 @@ static void suspend_finish(suspend_state
 static const char * const pm_states[PM_SUSPEND_MAX] = {
 	[PM_SUSPEND_STANDBY]	= "standby",
 	[PM_SUSPEND_MEM]	= "mem",
-#ifdef CONFIG_SOFTWARE_SUSPEND
 	[PM_SUSPEND_DISK]	= "disk",
-#endif
 };
 
 static inline int valid_state(suspend_state_t state)
 {
 	/* Suspend-to-disk does not really need low-level support.
-	 * It can work with reboot if needed. */
+	 * It can work with shutdown/reboot if needed. If it isn't
+	 * configured, then it cannot be supported (this prevents
+	 * rogue pm_ops from marking it valid which would cause it
+	 * to show up in /sys/power/state.) */
 	if (state == PM_SUSPEND_DISK)
+#ifdef CONFIG_SOFTWARE_SUSPEND
 		return 1;
+#else
+		return 0;
+#endif
 
 	/* all other states need lowlevel support and need to be
 	 * valid to the lowlevel implementation, no valid callback
@@ -232,16 +237,6 @@ static int enter_state(suspend_state_t s
 	return error;
 }
 
-/*
- * This is main interface to the outside world. It needs to be
- * called from process context.
- */
-int software_suspend(void)
-{
-	return enter_state(PM_SUSPEND_DISK);
-}
-
-
 /**
  *	pm_suspend - Externally visible function for suspending system.
  *	@state:		Enumarted value of state to enter.
include/linux/suspend.h +0 -8
@@ -33,8 +33,6 @@ static inline void pm_restore_console(vo
 #endif
 
 #if defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND)
-/* kernel/power/swsusp.c */
-extern int software_suspend(void);
 /* kernel/power/snapshot.c */
 extern void __register_nosave_region(unsigned long b, unsigned long e, int km);
 static inline void register_nosave_region(unsigned long b, unsigned long e)
@@ -50,12 +48,6 @@ extern void swsusp_set_page_free(struct 
 extern void swsusp_unset_page_free(struct page *);
 extern unsigned long get_safe_page(gfp_t gfp_mask);
 #else
-static inline int software_suspend(void)
-{
-	printk("Warning: fake suspend called\n");
-	return -ENOSYS;
-}
-
 static inline void register_nosave_region(unsigned long b, unsigned long e) {}
 static inline void register_nosave_region_late(unsigned long b, unsigned long e) {}
 static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
drivers/acpi/sleep/proc.c +1 -1
@@ -60,7 +60,7 @@ acpi_system_write_sleep(struct file *fil
 	state = simple_strtoul(str, NULL, 0);
 #ifdef CONFIG_SOFTWARE_SUSPEND
 	if (state == 4) {
-		error = software_suspend();
+		error = pm_suspend(PM_SUSPEND_DISK);
 		goto Done;
 	}
 #endif
drivers/i2c/chips/tps65010.c +3 -1
@@ -351,8 +351,10 @@ static void tps65010_interrupt(struct tp
 #if 0
 			/* REVISIT:  this might need its own workqueue
 			 * plus tweaks including deadlock avoidance ...
+			 * also needs to get error handling and probably
+			 * an #ifdef CONFIG_SOFTWARE_SUSPEND
 			 */
-			software_suspend();
+			pm_suspend(PM_SUSPEND_DISK);
 #endif
 			poll = 1;
 		}
include/linux/init.h +1 -1
@@ -228,7 +228,7 @@ void __init parse_early_param(void);
 #define __obsolete_setup(str) 			/* nothing */
 #endif
 
-/* Data marked not to be saved by software_suspend() */
+/* Data marked not to be saved by software suspend */
 #define __nosavedata __attribute__ ((__section__ (".data.nosave")))
 
 /* This means "can be init if no module support, otherwise module load
kernel/sys.c +1 -1
@@ -881,7 +881,7 @@ asmlinkage long sys_reboot(int magic1, i
 #ifdef CONFIG_SOFTWARE_SUSPEND
 	case LINUX_REBOOT_CMD_SW_SUSPEND:
 		{
-			int ret = software_suspend();
+			int ret = pm_suspend(PM_SUSPEND_DISK);
 			unlock_kernel();
 			return ret;
 		}
#1 lore raw
Quoted 4 lines · Johannes Berg

This patch kills off software_suspend() and all it's users, pm_suspend(PM_SUSPEND_DISK) is much cleaner anyway. Also, this makes the kernel compile again w/o CONFIG_SOFTWARE_SUSPEND after Rafael's patches to kill the suspend pageflags broke it.

The patches have been reworked after Andrew rejected them due to this breakage. The current versions are in the -mm tree (http://lkml.org/lkml/2007/3/20/327).

Quoted 8 lines
Cc Rafael J. Wysocki <[email protected]>

---
Have the pageflags removal patches been applied anywhere already? If so please just apply this on top. If not, could you (Rafael) then fix your patches to compile w/o software suspend and then I'll post the removal of software_suspend() as an extra patch.

See above. :-)

As far as the rest of the patch is concerned, I have no objections.

Rafael

#2 lore raw
Quoted 2 lines · Rafael J. Wysocki

The patches have been reworked after Andrew rejected them due to this breakage. The current versions are in the -mm tree (http://lkml.org/lkml/2007/3/20/327).

Aha :)

Quoted 1 line

As far as the rest of the patch is concerned, I have no objections.

I'll respin then and post against -mm.

johannes

#3 lore raw
In reply to Johannes Berg

Hi!

Quoted 22 lines

This patch kills off software_suspend() and all it's users, pm_suspend(PM_SUSPEND_DISK) is much cleaner anyway. Also, this makes the kernel compile again w/o CONFIG_SOFTWARE_SUSPEND after Rafael's patches to kill the suspend pageflags broke it.

Cc Rafael J. Wysocki <[email protected]>
kernel/power/main.c +0 -10
 	return error;
 }
 
-/*
- * This is main interface to the outside world. It needs to be
- * called from process context.
- */
-int software_suspend(void)
-{
-	return enter_state(PM_SUSPEND_DISK);
-}
-
-

...

drivers/acpi/sleep/proc.c acpi_system_write_sleep(struct file *fil · line 65

Quoted 8 lines
drivers/acpi/sleep/proc.c +1 -1
@@ -60,7 +60,7 @@ acpi_system_write_sleep(struct file *fil
 	state = simple_strtoul(str, NULL, 0);
 #ifdef CONFIG_SOFTWARE_SUSPEND
 	if (state == 4) {
-		error = software_suspend();
+		error = pm_suspend(PM_SUSPEND_DISK);
 		goto Done;
 	}

Is enter_state and pm_suspend equivalent? Why the change?

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

drivers/acpi/sleep/proc.c acpi_system_write_sleep(struct file *fil · line 65

Quoted 8 lines
drivers/acpi/sleep/proc.c +1 -1
@@ -60,7 +60,7 @@ acpi_system_write_sleep(struct file *fil
 	state = simple_strtoul(str, NULL, 0);
 #ifdef CONFIG_SOFTWARE_SUSPEND
 	if (state == 4) {
-		error = software_suspend();
+		error = pm_suspend(PM_SUSPEND_DISK);
 		goto Done;
 	}

Is enter_state and pm_suspend equivalent? Why the change?

Yeah, except that enter_state() has more argument checking. The change was just because I didn't see much point in having two entry points for the same thing and killed off software_suspend() completely. Don't really care.

johannes

#5 lore raw

Hi!

Quoted 11 lines
Quoted 10 lines

drivers/acpi/sleep/proc.c acpi_system_write_sleep(struct file *fil · line 65

Quoted 8 lines
drivers/acpi/sleep/proc.c +1 -1
@@ -60,7 +60,7 @@ acpi_system_write_sleep(struct file *fil
 	state = simple_strtoul(str, NULL, 0);
 #ifdef CONFIG_SOFTWARE_SUSPEND
 	if (state == 4) {
-		error = software_suspend();
+		error = pm_suspend(PM_SUSPEND_DISK);
 		goto Done;
 	}

Is enter_state and pm_suspend equivalent? Why the change?

Quoted 4 lines

Yeah, except that enter_state() has more argument checking. The change was just because I didn't see much point in having two entry points for the same thing and killed off software_suspend() completely. Don't really care.

Okay, then. ACK.
Pavel

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