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: Alan Stern <stern@...>
Cc: Nigel Cunningham <nigel@...>, Benjamin Herrenschmidt <benh@...>, Pavel Machek <pavel@...>, Rafael J. Wysocki <rjw@...>, Matthew Garrett <mjg59@...>, <linux-kernel@...>, <linux-pm@...>
Date: Friday, July 6, 2007 - 8:43 pm

On Jul 06, 2007, at 11:42:33, Alan Stern wrote:

Except Linus already decreed (and I heartily agree) that hibernation  
and suspend-to-RAM were fundamentally completely different operations  
and therefore any attempts to share code were basically just making a  
big muddy mess of things.  Would a thread "Remove phase-of-the-moon  
calculations from network-recv code" be relevant to lunar observation  
just because the two had to do with the phases of the moon?  No!


Why do we care?  If the wakeup request arrives before we go to sleep,  
we obviously aren't asleep and so can't wake up.  If it arrives after  
we go to sleep then it will wake us up.  Anything that depends on a  
wakeup arriving mid-sequence is 100% masochistic race condition.


(1a) As I describe below, step (1) includes setting NO_BIND and NO_IO  
flags on devices as they are processed.  Anybody who wants to do IO  
while those flags are set should just go sleep on a waitqueue.


(1b) Again, that's where the NO_BIND flag comes in.  If its set then  
any device probe events must sleep, otherwise they can go through.


See points (1a) and (1b) above.


If any of those things screw up suspend-to-RAM then it is 100% the  
drivers fault and no "process freezer" is going to fix it, end of  
story.  And "A" cannot be made reliable.  At some point you shut off  
interrupts right before going to sleep, and at that point any remote  
wakeup event is just going to get dropped until you actually enter  
sleep mode and the hardware takes over again.  If you miss a wakeup  
event then whatever sent it should just retry, just as with *every*  
other kind of network packet.


That would be a driver bug.  If you have asynchronous probing then  
proper suspend handling includes being able to postpone driver probe  
events until after resume.  If you have synchronous probing then the  
problem doesn't exist because "set_no_bind_flag" is just telling the  
device not to raise any more device probe interrupts.


While binding it will clearly be holding a mutex/spinlock on the  
parent device, so the suspend process will wait for it.  When binding  
is done the suspend_device() code will take the device lock and tell  
everything else to postpone further bind requests as above.


Oh, so you're calling every waitqueue in the kernel a "freezer" now?   
We do these things at the driver level *all* *the* *time*.  For  
instance, you can't submit new IOs to an ATA controller while it's  
renegotiating the bus speed, but that's never been a problem before.


Most drivers have an implicit NO_BIND flag:  The device's interrupts  
are off and/or its in a low-power state.  USB is already terribly  
buggy with regards to suspend:  If you hotplug a device during  
suspend (like the touchpad in my powerbook powering down/up), then  
the USB stack will basically hang that controller.  The device is off  
and the hotplug triggers interrupts and IO, *EVEN* *WITHOUT*  
*USERSPACE*.

So if your driver doesn't already have a proper way of blocking IO  
during suspend then it probably doesn't suspend 50% of the time  
anyways.  A bug which bites *every* *time* is easy to fix, one which  
only bites when things hit a race condition is much harder.


That responsibility has been there ever since suspend-to-RAM support  
was added.  Nobody ever denied that writing a proper driver wasn't  
tricky.  You have to simultaneously be able to handle handle hot- 
unplug, IO errors, interrupts, IO requests, suspend-to-RAM, and  
hibernation.  If your driver mutual-exclusion is buggy then it  
probably already bites you during hotplug or other similar  
scenarios.  Let's at least make the problems much more reproducible  
so we can fix the drivers properly instead of continuing to kludge  
around it for all eternity.

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, (Fri Jul 6, 8:43 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)