Re: Re: Hotplug events during sleep transition

Dmitry Torokhov
2005-12-23T18:32:15Z

On Friday 23 December 2005 10:35, Patrick Mochel wrote:
> > > Quite often unbinding is easiest and also correct way. I would love to be
> > > able to just unbind serio port/input device and have it recreated later.
> > > Unfortunately X/GPM do not [yet?] support hotplugging of devices so kernel
> > > has to compensate.
> >
> > I agree with Dmitry.  Many drivers don't need to do anything special for
> > suspend, or only need to cancel an outstanding input request.  Rather than
> > go through every single driver and add a minimal (and possibly erroneous)
> > suspend routine, it's much easier just to unbind these drivers.
>
> So why not fix the subsystems to do the equivalent of an unbinding, from
> a tear-down and reinitialization standpoint? That way, you don't have to
> force the core to contort itself simply for the fact that you want to push
> in a thumbtack with a sledgehammer?
>
> Think about what is happening. It's been discovered that shutting down the
> device and reinitializing the device performs all the correct actions to
> get the device up and running again after a suspend/resume cycle. All you
> have to do for each suspend routine is mimic that effect. It arguably
> doesn't require any serious knowledge about the device - it only needs a
> copy of the ->probe() and ->remove() routines (or the functional
> equivalent for those devices), without the allocation and freeing of data
> structures.

That's all good except that it overly complicates things. Look for example
at psmouse driver - it can't just reinitialize the hardware, it also has to
make sure that device connected to the port is the same device there was
before suspending. And if it is not the same we still have to go though
deardown and re-creating input device to make sure that it reports correct
capabilities to userspace. Again, I would _love_ just to unbind the driver
and have it bind again after resume.

"Full" resume is only required when you have to maintain full state of the
device in question (like a drive may have outstanding requests to complete).
With some devices we can safely drop all outstanding requests.

--
Dmitry