Re: [PATCH 2/2] Fix console handling during suspend/resume

Benjamin Herrenschmidt
2006-06-16T01:09:06Z

On Thu, 2006-06-15 at 10:41 -0700, Linus Torvalds wrote:
>
> On Thu, 15 Jun 2006, Pavel Machek wrote:
> >
> > To have DMAs stopped, you need to "freeze" the devices.
>
> No you don't.
>
> You need to stop the high-level _queues_, but that's something totally
> different from actually stopping the _devices_.

Well, a bit of both in fact. USB controllers for example tend to
continuously DMA even when there is nothing to process... That must be
stopped.

But yeah, essentially, when I defined the freeze state back then, I
defined it as a driver state, not a device state. It's driver freeze.
Though it's up to the driver to make sure the device is quiescent. DMA
is deadly not only for STD but for kexec as well.

> So, for example, you want to make sure that nobody is writing to the disk
> cache, or reading from the disk, or writing to it (apart from the thing
> that writes the image, of course) any more.

Yup, and that's why I implemented old IDE suspend as a special reuquest
down the queue that blocks the queue processing when it reaches the
disk. By being a barrier type request, it allows proper synchronisation
with pending IOs and makes sure the queue is frozen. Resume is then
implemented as another special request that gets injected at the head of
the queue (using the same mecanism used for things like request sense on
error) and that unblocks it.

> But that's fundamental: and it has absolutely zero to do with device
> suspend (although you do want to tell the device about it - a number of
> devices that do polling even in the absense of user input should probably
> take the hint from "save your state").

Well, it's not about suspending the devices, but it is also about making
sure the controller doesn't does random DMA, and as I mentioned above,
the fine line is a bit blurry with some bits of hardware.

> The fact that you equate "suspend the devices" with "stop doing IO" shows
> how you think at the wrong level.
>
> The "stop doing IO" is at a much higher level.

Yes, though both are involved in the suspend process and can't be
separated completely due to the dependency between devices in the bus
hierarchy.

Ben.