login
Header Space

 
 

Re: [PATCH] Remove process freezer from suspend to RAM pathway

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Nigel Cunningham <nigel@...>
Cc: Benjamin Herrenschmidt <benh@...>, Pavel Machek <pavel@...>, Rafael J. Wysocki <rjw@...>, Matthew Garrett <mjg59@...>, <linux-kernel@...>, <linux-pm@...>, Alan Stern <stern@...>
Date: Thursday, July 5, 2007 - 9:19 pm

On Jul 05, 2007, at 19:35:11, Nigel Cunningham wrote:

Umm, this thread is NOT ABOUT HIBERNATING!!!  Please go back and read  
the subject, specifically the "suspend to RAM" parts :-D.  When your  
hardware can put itself to sleep and atomically preserve memory as it  
does so, you don't need an atomic copy.  For Real Suspend(TM) (IE:  
Suspend-to-RAM), the list of things to do is short and simple:

1)  Stop DMA and put most hardware into low-power states (stops all  
interrupt sources)
2)  Ensure that the other CPUs have finished any trailing interrupt  
handlers and put them to sleep
3)  Put the interrupt-controllers into low-power state
4)  Go to sleep


How about a freezer whose job it is to "wait for pending hard  
interrupts to complete when we have already guaranteed that we won't  
get any more"?  That part should be really *REALLY* easy.  You don't  
need to care about either userspace processes or kernel threads at  
all.  Specifically, Step 1 consists of:

suspend_device(dev)
{
	set_no_bind_flag(dev);
	for (dev->subdevices)
		suspend_device(dev);
	set_no_io_flag(dev);
	wait_for_in_progress_dma(dev);
	turn_off_interrupts(dev);
	go_to_low_power_state(dev);
}

After you've set the "no_bind" flag, you won't get any *new*  
subdevices trying to bind, therefore it's safe to iterate over the  
list of present sub-devices and suspend them.  Once those are  
suspended and in low-power states you can set a "no_io" flag to  
prevent the driver from submitting more IO.  At that point you can  
lazily wait for existing DMA/IO/interrupts to finish on the device,  
since *NOBODY* will be submitting them anymore, and we certainly  
aren't probing for new devices.  Then you can just turn off the power  
to the device.  When all the leaf devices are off, the parent device  
can be turned off because everything waiting on the leaf devices is  
blocked on them and won't unblock until the parent device *AND* the  
leaf device are turned on again, in that order.

Scheduling and userspace are all still fully enabled in this  
scenario.  Once all your devices are turned off, the only remaining  
running threads will be those which haven't done IO since the  
beginning of the suspend.  We can then disable preemption, turn off  
the timer interrupts, and tell the other CPUs to park all their  
remaining threads in schedule() and sleep.  Then we put the IRQ  
controller to sleep and go to sleep ourselves.  If our driver model  
locking is sufficient to handle putting a parent device to sleep  
while threads are sleeping on a child device then there are exactly 0  
problems.

Resuming is basically running the whole process in reverse.  Runtime- 
suspend is achieved by not setting the 'no_io' or 'no_bind' flags and  
putting selective device-subtrees to sleep without doing anything to  
the rest of the system.

Cheers,
Kyle Moffett

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Remove process freezer from suspend to RAM pathway, Matthew Garrett, (Tue Jul 3, 12:29 am)
Re: sysrq-t dumps of s2ram/fuse deadlock, Jeremy Maitin-Shepard, (Wed Jul 11, 9:45 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Tue Jul 3, 1:48 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Tue Jul 3, 3:19 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Tue Jul 3, 5:14 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Thu Jul 5, 6:46 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Thu Jul 5, 7:20 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Thu Jul 5, 11:54 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Fri Jul 6, 12:41 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Kyle Moffett, (Thu Jul 5, 9:19 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sat Jul 7, 12:06 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sat Jul 7, 8:48 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 1:14 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 5:20 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Mon Jul 9, 6:05 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Mon Jul 9, 5:13 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Mon Jul 9, 5:33 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 8:33 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 9:32 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 5:03 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 5:54 pm)
Re: hibernation/snapshot design, Jeremy Maitin-Shepard, (Mon Jul 9, 11:23 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 1:19 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Thu Jul 5, 11:59 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Fri Jul 6, 11:44 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sat Jul 7, 8:42 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 12:39 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sun Jul 8, 5:21 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Mon Jul 9, 5:14 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Sat Jul 7, 8:40 pm)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Fri Jul 6, 5:03 am)
The big suspend mess, Adrian Bunk, (Wed Jul 4, 6:19 pm)
Re: [linux-pm] The big suspend mess, Alan Stern, (Thu Jul 5, 10:14 am)
Re: The big suspend mess, Pavel Machek, (Wed Jul 4, 8:27 pm)
Re: The big suspend mess, Adrian Bunk, (Wed Jul 4, 9:22 pm)
Re: The big suspend mess, Rafael J. Wysocki, (Thu Jul 5, 8:18 am)
Re: The big suspend mess, Paul Mackerras, (Wed Jul 4, 8:53 pm)
Re: The big suspend mess, Pavel Machek, (Thu Jul 5, 5:32 am)
Re: The big suspend mess, Gabriel C, (Thu Jul 5, 6:29 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Wed Jul 4, 10:30 am)
Re: [PATCH] Remove process freezer from suspend to RAM pathway, Benjamin Herrenschmidt, (Tue Jul 3, 5:35 pm)
Re: removing refrigerator does not help with s2ram vs. fuse ..., Rafael J. Wysocki, (Thu Jul 5, 10:28 am)
Re: removing refrigerator does not help with s2ram vs. fuse ..., Rafael J. Wysocki, (Thu Jul 5, 10:41 am)
Re: removing refrigerator does not help with s2ram vs. fuse ..., Rafael J. Wysocki, (Thu Jul 5, 11:04 am)
Re: removing refrigerator does not help with s2ram vs. fuse ..., Rafael J. Wysocki, (Thu Jul 5, 11:27 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Thu Jul 5, 6:59 pm)
Re: malicious filesystems (was Re: [linux-pm] Re: [PATCH] Re..., Rafael J. Wysocki, (Sun Jul 8, 10:06 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Thu Jul 5, 7:05 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Jeremy Maitin-Shepard, (Thu Jul 5, 11:59 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Fri Jul 6, 4:59 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Fri Jul 6, 10:44 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Sat Jul 7, 8:50 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Fri Jul 6, 10:46 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Thu Jul 5, 10:14 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Thu Jul 5, 6:38 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Thu Jul 5, 10:02 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Thu Jul 5, 10:09 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Jeremy Maitin-Shepard, (Thu Jul 5, 12:06 pm)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Thu Jul 5, 10:59 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Tue Jul 3, 11:22 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Rafael J. Wysocki, (Tue Jul 3, 10:51 am)
Re: [linux-pm] Re: [PATCH] Remove process freezer from suspe..., Benjamin Herrenschmidt, (Tue Jul 3, 7:45 am)