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




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:

Well, waiting for pending DMA and making sure to not trigger more
activity is what driver suspend() is supposed to do. With the ability
for simple drivers that can cope with it to just basically use a
late_suspend(), called after IRQs are off, that basically does what you
describe: wait for pending HW tasks to complete (polling) and turn the
damn thing off.

Note that the later is really a shortcut for somewhat dump and directly
accessible devices (PCI comes to mind). Things like USB has to use the
"normal" mechanism of blocking IOs etc... at suspend(), at least, USB
devices have to since the USB HC will not issue any new URBs. (And will
return them with a nice error code which is a perfect way to deal with
it in driver, been there, it works fine, once we fixed the races in the
USB host code itself, which I think we pretty much did by now).

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.

What you propose is basically a slightly over-simplistic version of what
I think (and Paulus think) should be done. We do need to do it via
driver callbacks down the tree since only drivers can know how to deal
with their DMA etc... and ordering need to be respected, but that's
basically it.

And guess what ? It's what we do on powerbooks, and it works fine,
without a freezer :-)

Ben.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [PATCH] Remove process freezer from suspend to RAM pathway
    ... activity is what driver suspend() is supposed to do. ... Things like USB has to use the ... controller to sleep and go to sleep ourselves. ...
    (Linux-Kernel)
  • Re: Using ISP1362 USB Controller on Lubbock Based Board (Intel DBPXA250) with Windows CE
    ... I created a new SYSINTR for USB device and implemented the code for USB ... Interrupt on OEMInterrupts routines. ... The driver is working for USB Hub, ... and Interrupts to GPIO23 and GPIO25. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: USB networking device slow removal
    ... We build a USB NDIS 6.20 WWAN device for Windows 7. ... to save power" is CHECKED on our networking device driver settings. ... the driver then disappears from Device Manager. ... Put the PC to sleep. ...
    (microsoft.public.development.device.drivers)
  • Re: Disabling interrupts in Windows
    ... code in some other part of the driver. ... > USB driver interrupts the Host PC and the OS schedules my DPC during ... > disable all other interrupts since DPC priority is low. ... > disabling interrupts from software. ...
    (microsoft.public.development.device.drivers)
  • Re: [PATCH] Remove process freezer from suspend to RAM pathway
    ... specifically the "suspend to RAM" parts:-D. ... Ensure that the other CPUs have finished any trailing interrupt handlers and put them to sleep ... 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 have asynchronous probing then proper suspend handling includes being able to postpone driver probe events until after resume. ...
    (Linux-Kernel)