Re: [patch update] PM: Introduce core framework for run-time PM ofI/O devices (rev. 6)

From: Alan Stern
Date: Fri Jun 26 2009 - 21:26:04 EST


On Sat, 27 Jun 2009, Rafael J. Wysocki wrote:

> > Speaking of races, have you noticed that the way power.work_done gets
> > used is racy?
>
> Not really. :-)
>
> > You can't wait for the completion before releasing the
> > lock, but then anything could happen.
> >
> > A safer approach would be to use a wait_queue.
>
> I'm not sure what you mean exactly. What's the race?

Somebody calls pm_runtime_suspend when a suspend is already in
progress. The routine sees that the status is RPM_SUSPENDING, so it
prepares to wait until the suspend is finished. It drops the lock and
calls wait_for_completion.

But in between those last two steps, the suspend could finish and
a resume could start up. Then the wait_for_completion wouldn't return
until the device was fully resumed!

Now I admit this isn't as bad as it sounds. The same sort of thing
could happen even if there weren't two suspends going on at the same
time; a resume could occur between when the routine drops the lock and
when it returns. So okay, forget I mentioned it.

Alan Stern

--
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/