Suspend without the freezer

Alan Stern
2007-07-30T20:48:12Z

Dmitry:

I'm trying to help eliminate the need for the freezer during suspend.
For it to work, we have to prevent threads which otherwise would have
been frozen from trying to bind drivers to suspended devices or trying
to register new devices whose parents are already suspended.

To help accomplish this, the PM core can acquire the device semaphores
for all existing devices before suspending any of them. That will
prevent attempts at binding. It would also prevent registration of new
children, _if_ the driver doing the registration had to acquire the
parent's semaphore first. But many drivers don't do this.

One thought was to have the PM core acquire and hold the dpm_list_mutex
throughout the suspend. This would block registration attempts at the
point where the new device is added to the PM core's device-list.

Unfortunately it creates several lockdep violations. For example, the
serio core holds serio->drv_mutex while input_register_device is
called (which acquires dpm_list_mutex), and it acquires
serio->drv_mutex in serio_suspend and serio_resume (which would be
called while the PM core holds dpm_list_mutex).

I'm having trouble coming up with a way to block registrations during
suspend that won't create a possibility for deadlock. Do you have any
suggestions? A scheme that would work for the input layer ought to be
generally applicable.

Alan Stern