All of lore.kernel.org
 help / color / mirror / Atom feed
* [pm] Add error handling to software_suspend
@ 2003-10-18 21:07 Pavel Machek
  2003-10-19 19:19 ` Aviram Jenik
  2003-10-20 18:44 ` Patrick Mochel
  0 siblings, 2 replies; 5+ messages in thread
From: Pavel Machek @ 2003-10-18 21:07 UTC (permalink / raw)
  To: kernel list, Patrick Mochel

Hi!

This adds error handling to software_suspend(), and kills
software_suspend_enabled variable; it is cleaner that
way. do_software_suspend() is now gone. __read_suspend_image can be
init, so mark it as such to avoid tool warnings. Add prototypes for
freeze_processes and thaw_proceses (or are those elsewhere,
already?). Please apply,
							Pavel

--- clean/kernel/power/swsusp.c	2003-10-18 20:26:48.000000000 +0200
+++ linux/kernel/power/swsusp.c	2003-10-18 20:46:48.000000000 +0200
@@ -694,11 +697,22 @@
 	mark_swapfiles(((swp_entry_t) {0}), MARK_SWAP_RESUME);
 }
 
-static void do_software_suspend(void)
+/*
+ * This is main interface to the outside world. It needs to be
+ * called from process context.
+ */
+int software_suspend(void)
 {
+	int res;
+	if (!software_suspend_enabled)
+		return -EAGAIN;
+
+	software_suspend_enabled = 0;
+	might_sleep();
+
 	if (arch_prepare_suspend()) {
 		printk("%sArchitecture failed to prepare\n", name_suspend);
-		return;
+		return -EPERM;
 	}		
 	if (pm_prepare_console())
 		printk( "%sCan't allocate a console... proceeding\n", name_suspend);
@@ -716,7 +730,7 @@
 		blk_run_queues();
 
 		/* Save state of all device drivers, and stop them. */		   
-		if(drivers_suspend()==0)
+		if ((res = drivers_suspend())==0)
 			/* If stopping device drivers worked, we proceed basically into
 			 * suspend_save_image.
 			 *
@@ -728,24 +742,12 @@
 			 */
 			do_magic(0);
 		thaw_processes();
-	}
+	} else
+		res = -EBUSY;
 	software_suspend_enabled = 1;
 	MDELAY(1000);
 	pm_restore_console();
-}
-
-/*
- * This is main interface to the outside world. It needs to be
- * called from process context.
- */
-void software_suspend(void)
-{
-	if(!software_suspend_enabled)
-		return;
-
-	software_suspend_enabled = 0;
-	might_sleep();
-	do_software_suspend();
+	return res;
 }
 
 /* More restore stuff */
@@ -915,7 +917,7 @@
 
 extern dev_t __init name_to_dev_t(const char *line);
 
-static int __read_suspend_image(struct block_device *bdev, union diskpage *cur, int noresume)
+static int __init __read_suspend_image(struct block_device *bdev, union diskpage *cur, int noresume)
 {
 	swp_entry_t next;
 	int i, nr_pgdir_pages;
--- clean/include/linux/suspend.h	2003-10-18 20:26:47.000000000 +0200
+++ linux/include/linux/suspend.h	2003-10-18 22:54:53.000000000 +0200
@@ -45,31 +44,43 @@
 /* mm/page_alloc.c */
 extern void drain_local_pages(void);
 
+/* kernel/power/swsusp.c */
+extern int software_suspend(void);
+
 extern unsigned int nr_copy_pages __nosavedata;
 extern suspend_pagedir_t *pagedir_nosave __nosavedata;
-#endif /* CONFIG_PM */
-
-#ifdef CONFIG_SOFTWARE_SUSPEND
-
-extern unsigned char software_suspend_enabled;
 
-extern void software_suspend(void);
 #else	/* CONFIG_SOFTWARE_SUSPEND */
-static inline void software_suspend(void)
+static inline int software_suspend(void)
 {
 	printk("Warning: fake suspend called\n");
+	return -EPERM;
 }
+#define software_resume()		do { } while(0)
 #endif	/* CONFIG_SOFTWARE_SUSPEND */
 
 
 #ifdef CONFIG_PM
 extern void refrigerator(unsigned long);
+extern int freeze_processes(void);
+extern void thaw_processes(void);
+
+extern int pm_prepare_console(void);
+extern void pm_restore_console(void);
 
 #else
 static inline void refrigerator(unsigned long flag)
 {
 
 }
+static inline int freeze_processes(void)
+{
+	return 0;
+}
+static inline void thaw_processes(void)
+{
+
+}
 #endif	/* CONFIG_PM */
 
 #endif /* _LINUX_SWSUSP_H */
--- clean/kernel/sys.c	2003-10-18 20:26:48.000000000 +0200
+++ linux/kernel/sys.c	2003-10-18 20:44:57.000000000 +0200
@@ -474,13 +474,11 @@
 
 #ifdef CONFIG_SOFTWARE_SUSPEND
 	case LINUX_REBOOT_CMD_SW_SUSPEND:
-		if (!software_suspend_enabled) {
+		{
+			int ret = software_suspend();
 			unlock_kernel();
-			return -EAGAIN;
+			return ret;
 		}
-		software_suspend();
-		do_exit(0);
-		break;
 #endif
 
 	default:

-- 
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]

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

* Re: [pm] Add error handling to software_suspend
  2003-10-18 21:07 [pm] Add error handling to software_suspend Pavel Machek
@ 2003-10-19 19:19 ` Aviram Jenik
  2003-10-19 19:27   ` Pavel Machek
  2003-10-20 18:44 ` Patrick Mochel
  1 sibling, 1 reply; 5+ messages in thread
From: Aviram Jenik @ 2003-10-19 19:19 UTC (permalink / raw)
  To: Pavel Machek, kernel list

On Saturday 18 October 2003 23:07, Pavel Machek wrote:
> Hi!
>
> This adds error handling to software_suspend(), 

Suspending to disk with this patch applied I can see the resume is stuck on:
"Waiting for DMAs to settle down..."
(previously it booted before I could see where the problem is).

I guess it's another evidence that the problem is with the i830 module?

- Aviram

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

* Re: [pm] Add error handling to software_suspend
  2003-10-19 19:19 ` Aviram Jenik
@ 2003-10-19 19:27   ` Pavel Machek
  0 siblings, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2003-10-19 19:27 UTC (permalink / raw)
  To: Aviram Jenik; +Cc: Pavel Machek, kernel list

Hi!

> > This adds error handling to software_suspend(), 
> 
> Suspending to disk with this patch applied I can see the resume is stuck on:
> "Waiting for DMAs to settle down..."
> (previously it booted before I could see where the problem is).
> 
> I guess it's another evidence that the problem is with the i830
> module?

I don't think so. Waiting for DMAs is gross hack where we sleep with
interrupts disabled -- waiting for any running DMAs to end / timeout
/etc.

You might want to add some more debug printks....
				Pavel 


-- 
Horseback riding is like software...
...vgf orggre jura vgf serr.

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

* Re: [pm] Add error handling to software_suspend
  2003-10-18 21:07 [pm] Add error handling to software_suspend Pavel Machek
  2003-10-19 19:19 ` Aviram Jenik
@ 2003-10-20 18:44 ` Patrick Mochel
  2003-10-20 19:13   ` Pavel Machek
  1 sibling, 1 reply; 5+ messages in thread
From: Patrick Mochel @ 2003-10-20 18:44 UTC (permalink / raw)
  To: Pavel Machek; +Cc: kernel list


> This adds error handling to software_suspend(), and kills
> software_suspend_enabled variable; it is cleaner that
> way. do_software_suspend() is now gone. __read_suspend_image can be
> init, so mark it as such to avoid tool warnings. Add prototypes for
> freeze_processes and thaw_proceses (or are those elsewhere,
> already?). 

They're in kernel/power/power.h, which swsusp.c already includes. I'll 
apply the rest. 

Thanks,


	Pat




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

* Re: [pm] Add error handling to software_suspend
  2003-10-20 18:44 ` Patrick Mochel
@ 2003-10-20 19:13   ` Pavel Machek
  0 siblings, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2003-10-20 19:13 UTC (permalink / raw)
  To: Patrick Mochel; +Cc: kernel list

Hi!

> > This adds error handling to software_suspend(), and kills
> > software_suspend_enabled variable; it is cleaner that
> > way. do_software_suspend() is now gone. __read_suspend_image can be
> > init, so mark it as such to avoid tool warnings. Add prototypes for
> > freeze_processes and thaw_proceses (or are those elsewhere,
> > already?). 
> 
> They're in kernel/power/power.h, which swsusp.c already includes. I'll 
> apply the rest. 

Thanks.
								Pavel
-- 
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]

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

end of thread, other threads:[~2003-10-20 19:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-18 21:07 [pm] Add error handling to software_suspend Pavel Machek
2003-10-19 19:19 ` Aviram Jenik
2003-10-19 19:27   ` Pavel Machek
2003-10-20 18:44 ` Patrick Mochel
2003-10-20 19:13   ` Pavel Machek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.