Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941832AbcJYPI3 (ORCPT ); Tue, 25 Oct 2016 11:08:29 -0400 Received: from mail-vk0-f46.google.com ([209.85.213.46]:34247 "EHLO mail-vk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S941857AbcJYPIX (ORCPT ); Tue, 25 Oct 2016 11:08:23 -0400 MIME-Version: 1.0 In-Reply-To: References: <1477396919-27669-1-git-send-email-binoy.jayan@linaro.org> <1477396919-27669-3-git-send-email-binoy.jayan@linaro.org> From: Binoy Jayan Date: Tue, 25 Oct 2016 20:38:21 +0530 Message-ID: Subject: Re: [PATCH v2 2/8] IB/core: Replace semaphore sm_sem with completion To: Jack Wang Cc: Doug Ledford , Sean Hefty , Hal Rosenstock , Arnd Bergmann , "linux-rdma@vger.kernel.org" , Linux kernel mailing list Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 745 Lines: 31 On 25 October 2016 at 18:13, Jack Wang 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