lkml.org 
[lkml]   [2016]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 2/8] IB/core: Replace semaphore sm_sem with completion
Hi Binoy,
2016-10-25 17:08 GMT+02:00 Binoy Jayan <binoy.jayan@linaro.org>:
> On 25 October 2016 at 18:13, Jack Wang <xjtuwjp@gmail.com> wrote:
>> Hi Binoy,
>>
>> snip
>>>
>>> port->ib_dev = device;
>>> port->port_num = port_num;
>>> - sema_init(&port->sm_sem, 1);
>>> + init_completion(&port->sm_comp);
>>> + complete(&port->sm_comp);
>>
>> Why complete here?
>>
>>> mutex_init(&port->file_mutex);
>>> INIT_LIST_HEAD(&port->file_list);
>>>
>>> --
>> KR,
>> Jinpu
>
>
> Hi Jack,
>
> ib_umad_sm_open() calls wait_for_completion_interruptible() which comes before
> ib_umad_sm_close() that calls complete(). In the initial open() there
> will not be
> anybody to signal the completion, so the complete is called to mark
> the initial state.
> I am not sure if this is the right way to do it, though.
>
> -Binoy

From Documentation/scheduler/completion.txt ,
"
117 This is not implying any temporal order on wait_for_completion() and the
118 call to complete() - if the call to complete() happened before the call
119 to wait_for_completion() then the waiting side simply will continue
120 immediately as all dependencies are satisfied if not it will block until
121 completion is signaled by complete().
"
In this case here, if sm_open/sm_close are paired, it should work.

KR
Jack

\
 
 \ /
  Last update: 2016-10-25 17:49    [W:0.057 / U:1.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site