lkml.org 
[lkml]   [2009]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch update] PM: Introduce core framework for run-time PM of I/O devices (rev. 6)
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



\
 
 \ /
  Last update: 2009-06-27 03:29    [W:0.160 / U:0.888 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site