public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] remove software_suspend() and fix compile w/ SOFTWARE_SUSPEND disabled
@ 2007-03-22 13:46 Johannes Berg
  2007-03-22 21:12 ` Rafael J. Wysocki
  2007-03-25 16:34 ` Pavel Machek
  0 siblings, 2 replies; 6+ messages in thread
From: Johannes Berg @ 2007-03-22 13:46 UTC (permalink / raw)
  To: linux-pm; +Cc: Pavel Machek

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.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Rafael J. Wysocki <rjw@sisk.pl>

---
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(-)

--- linux-2.6.orig/kernel/power/main.c	2007-03-22 14:37:07.564654656 +0100
+++ linux-2.6/kernel/power/main.c	2007-03-22 14:37:30.714654656 +0100
@@ -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.
--- linux-2.6.orig/include/linux/suspend.h	2007-03-22 14:34:58.344654656 +0100
+++ linux-2.6/include/linux/suspend.h	2007-03-22 14:37:30.714654656 +0100
@@ -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; }
--- linux-2.6.orig/drivers/acpi/sleep/proc.c	2007-03-22 14:34:58.444654656 +0100
+++ linux-2.6/drivers/acpi/sleep/proc.c	2007-03-22 14:37:30.724654656 +0100
@@ -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
--- linux-2.6.orig/drivers/i2c/chips/tps65010.c	2007-03-22 14:34:58.744654656 +0100
+++ linux-2.6/drivers/i2c/chips/tps65010.c	2007-03-22 14:37:30.724654656 +0100
@@ -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;
 		}
--- linux-2.6.orig/include/linux/init.h	2007-03-22 14:34:58.414654656 +0100
+++ linux-2.6/include/linux/init.h	2007-03-22 14:37:30.724654656 +0100
@@ -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
--- linux-2.6.orig/kernel/sys.c	2007-03-22 14:34:58.304654656 +0100
+++ linux-2.6/kernel/sys.c	2007-03-22 14:37:30.734654656 +0100
@@ -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;
 		}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] remove software_suspend() and fix compile w/ SOFTWARE_SUSPEND disabled
  2007-03-22 13:46 [PATCH] remove software_suspend() and fix compile w/ SOFTWARE_SUSPEND disabled Johannes Berg
@ 2007-03-22 21:12 ` Rafael J. Wysocki
  2007-03-23 13:46   ` Johannes Berg
  2007-03-25 16:34 ` Pavel Machek
  1 sibling, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2007-03-22 21:12 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-pm, Pavel Machek

On Thursday, 22 March 2007 14:46, Johannes Berg wrote:
> 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).

> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> Cc: Rafael J. Wysocki <rjw@sisk.pl>
> 
> ---
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] remove software_suspend() and fix compile w/ SOFTWARE_SUSPEND disabled
  2007-03-22 21:12 ` Rafael J. Wysocki
@ 2007-03-23 13:46   ` Johannes Berg
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2007-03-23 13:46 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: linux-pm, Pavel Machek


[-- Attachment #1.1: Type: text/plain, Size: 365 bytes --]

On Thu, 2007-03-22 at 22:12 +0100, Rafael J. Wysocki wrote:

> 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 :)

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

I'll respin then and post against -mm.

johannes

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] remove software_suspend() and fix compile w/ SOFTWARE_SUSPEND disabled
  2007-03-22 13:46 [PATCH] remove software_suspend() and fix compile w/ SOFTWARE_SUSPEND disabled Johannes Berg
  2007-03-22 21:12 ` Rafael J. Wysocki
@ 2007-03-25 16:34 ` Pavel Machek
  2007-03-25 18:18   ` Johannes Berg
  1 sibling, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2007-03-25 16:34 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-pm

Hi!

> 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.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> Cc: Rafael J. Wysocki <rjw@sisk.pl>


>  	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);
> -}
> -
> -
...
> @@ -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?

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] remove software_suspend() and fix compile w/ SOFTWARE_SUSPEND disabled
  2007-03-25 16:34 ` Pavel Machek
@ 2007-03-25 18:18   ` Johannes Berg
  2007-03-25 19:53     ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2007-03-25 18:18 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linux-pm


[-- Attachment #1.1: Type: text/plain, Size: 644 bytes --]

On Sun, 2007-03-25 at 16:34 +0000, Pavel Machek wrote:

> > @@ -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

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] remove software_suspend() and fix compile w/ SOFTWARE_SUSPEND disabled
  2007-03-25 18:18   ` Johannes Berg
@ 2007-03-25 19:53     ` Pavel Machek
  0 siblings, 0 replies; 6+ messages in thread
From: Pavel Machek @ 2007-03-25 19:53 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-pm

Hi!

> > > @@ -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.

Okay, then. ACK.
								Pavel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-03-25 19:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-22 13:46 [PATCH] remove software_suspend() and fix compile w/ SOFTWARE_SUSPEND disabled Johannes Berg
2007-03-22 21:12 ` Rafael J. Wysocki
2007-03-23 13:46   ` Johannes Berg
2007-03-25 16:34 ` Pavel Machek
2007-03-25 18:18   ` Johannes Berg
2007-03-25 19:53     ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox