lkml.org 
[lkml]   [2013]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRE: [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



\
 
 \ /
  Last update: 2013-01-15 19:21    [W:0.057 / U:1.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site