Messages in this thread | | | Date | Tue, 15 Jan 2013 10:50:18 -0500 (EST) | From | Alan Stern <> | Subject | RE: [PATCH] PM / Runtime: Fix the twice judgement in rpm_suspend/resume() |
| |
On Tue, 15 Jan 2013, Liu, Chuansheng wrote:
> > Indeed, this patch introduces a race. If runtime_status changes from > > RPM_SUSPENDING and power.wait_queue is signalled in between the test at > > the end of the loop and the prepare_to_wait() call, the loop will never > > end. > Checking the race case, it should not happen? > Updating runtime_status and wake_up wait_queue are protected by power.lock. > spin_lock(&power.lock) > ... > __update_runtime_status() > ... > wake_up_all(&dev->power.wait_queue) > ... > spin_unlock(&power.lock)
You're right, the lock prevents this race from happening.
On the other hand, with your change we would end up calling finish_wait() without calling prepare_to_wait() first. And as Rafael mentioned, the current code fits the pattern that people expect to see.
Alan Stern
| |