Re: Re: Suspend without the freezer

Alan Stern
2007-07-31T15:24:21Z

On Tue, 31 Jul 2007, Rafael J. Wysocki wrote:

> > > 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.
> > >
> >
> > I think blocking at this point is too late - many drivers muck with
> > the device in different ways before registering the "result" with
> > driver core. The device may be half-awaken by then.

> An alternative could be to have a rwsem taken for writing by the PM core and
> for reading by registration/binding/unbinding (and other suspend-sensitive code
> paths).

I think this is subject to the same weakness Dmitry mentions: By the
time the driver would block on the new rwsem, it has already started
mucking with the device. Worse yet, it may hold a mutex that the
suspend method needs, thereby deadlocking the suspend. (That's what
would happen with serio->drv_mutex in the input layer.)

Maybe the best answer is simply to fail all attempts at device
registration while a suspend is underway. At least that is a known
error path which drivers are prepared (in theory) to deal with. It
could be implemented quite easily with an rwsem, by making the
registration code use down_read_trylock.

Binding and unbinding aren't an issue once the PM core owns all the
device semaphores.

Alan Stern