From patchwork Tue Oct 25 12:01:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 79162 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp3072774qge; Tue, 25 Oct 2016 05:03:52 -0700 (PDT) X-Received: by 10.98.61.85 with SMTP id k82mr38832060pfa.7.1477397032123; Tue, 25 Oct 2016 05:03:52 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r133si20339180pgr.239.2016.10.25.05.03.51; Tue, 25 Oct 2016 05:03:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750841AbcJYMCR (ORCPT + 27 others); Tue, 25 Oct 2016 08:02:17 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:33948 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753566AbcJYMCM (ORCPT ); Tue, 25 Oct 2016 08:02:12 -0400 Received: by mail-pf0-f173.google.com with SMTP id n85so2143153pfi.1 for ; Tue, 25 Oct 2016 05:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RYPHOySoRQb2rkglM8Qvi72JH3knWUvXqmC5kaOwoi0=; b=EjG0Kd9gAn/GE9VqPkspBdHPld9zl7xq696d5CF6BrrS+EQQCQROiGcV6pmQRJDacM QBSN0bWYOTMwKCnioHu9xbz1ga11bcKpIDyCy2BPmMvDEBBk7pwtZX0yysg+y5PHyeZ+ Ee3X2/80iSiuInmc5DqzWifrZ7P1ZnJ7NIBlI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RYPHOySoRQb2rkglM8Qvi72JH3knWUvXqmC5kaOwoi0=; b=MP6Nvuu85IHwCJkceoMyPh99+bu5aEBLt16O0g4QHBlvAoLQLVrF0XqhKIn1RiR9OD t08hIrh2t6EPfkbKxzU2FdQaC4TV5IgIe5GKtk1ShZPiMJo92eg/80PiCx1vxLQca354 /MOr8gdw5uuWFV+37iYKfXrfrKrwHf+AyF9p+vG7po00IXApjZHN4Gdthn6PfZj+8ekc pIu5fRzq0R/lE3AWVXubkpkRHqUQCTqjfY2UPdCM0uC3TLtek64rJ3iXRmaBgH/XTF7F nCYeqmEQ61e+BAXVHMUP1zW40VhucqJirnuAZ1I/6w8SGTrckT1cExouKKHdyeWxm+pa 4+Cw== X-Gm-Message-State: ABUngvclNmu2kG6mRAEU+V13aM+R2WnZsRzJYk8vsV/EFY5ZYQb39IZHAlHkfvSO0tHatdNT X-Received: by 10.98.154.10 with SMTP id o10mr5827753pfe.79.1477396930598; Tue, 25 Oct 2016 05:02:10 -0700 (PDT) Received: from blr-ubuntu-59.ap.qualcomm.com ([202.46.23.61]) by smtp.gmail.com with ESMTPSA id ij5sm33051828pab.2.2016.10.25.05.02.07 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Oct 2016 05:02:10 -0700 (PDT) From: Binoy Jayan To: Doug Ledford , Sean Hefty , Hal Rosenstock Cc: Arnd Bergmann , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Binoy Jayan Subject: [PATCH v2 1/8] IB/core: iwpm_nlmsg_request: Replace semaphore with completion Date: Tue, 25 Oct 2016 17:31:52 +0530 Message-Id: <1477396919-27669-2-git-send-email-binoy.jayan@linaro.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1477396919-27669-1-git-send-email-binoy.jayan@linaro.org> References: <1477396919-27669-1-git-send-email-binoy.jayan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Semaphore sem in iwpm_nlmsg_request is used as completion, so convert it to a struct completion type. Semaphores are going away in the future. Signed-off-by: Binoy Jayan --- drivers/infiniband/core/iwpm_msg.c | 8 ++++---- drivers/infiniband/core/iwpm_util.c | 7 +++---- drivers/infiniband/core/iwpm_util.h | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project diff --git a/drivers/infiniband/core/iwpm_msg.c b/drivers/infiniband/core/iwpm_msg.c index 1c41b95..761358f 100644 --- a/drivers/infiniband/core/iwpm_msg.c +++ b/drivers/infiniband/core/iwpm_msg.c @@ -394,7 +394,7 @@ int iwpm_register_pid_cb(struct sk_buff *skb, struct netlink_callback *cb) /* always for found nlmsg_request */ kref_put(&nlmsg_request->kref, iwpm_free_nlmsg_request); barrier(); - up(&nlmsg_request->sem); + complete(&nlmsg_request->comp); return 0; } EXPORT_SYMBOL(iwpm_register_pid_cb); @@ -463,7 +463,7 @@ int iwpm_add_mapping_cb(struct sk_buff *skb, struct netlink_callback *cb) /* always for found request */ kref_put(&nlmsg_request->kref, iwpm_free_nlmsg_request); barrier(); - up(&nlmsg_request->sem); + complete(&nlmsg_request->comp); return 0; } EXPORT_SYMBOL(iwpm_add_mapping_cb); @@ -555,7 +555,7 @@ int iwpm_add_and_query_mapping_cb(struct sk_buff *skb, /* always for found request */ kref_put(&nlmsg_request->kref, iwpm_free_nlmsg_request); barrier(); - up(&nlmsg_request->sem); + complete(&nlmsg_request->comp); return 0; } EXPORT_SYMBOL(iwpm_add_and_query_mapping_cb); @@ -749,7 +749,7 @@ int iwpm_mapping_error_cb(struct sk_buff *skb, struct netlink_callback *cb) /* always for found request */ kref_put(&nlmsg_request->kref, iwpm_free_nlmsg_request); barrier(); - up(&nlmsg_request->sem); + complete(&nlmsg_request->comp); return 0; } EXPORT_SYMBOL(iwpm_mapping_error_cb); diff --git a/drivers/infiniband/core/iwpm_util.c b/drivers/infiniband/core/iwpm_util.c index ade71e7..08ddd2e 100644 --- a/drivers/infiniband/core/iwpm_util.c +++ b/drivers/infiniband/core/iwpm_util.c @@ -323,8 +323,7 @@ struct iwpm_nlmsg_request *iwpm_get_nlmsg_request(__u32 nlmsg_seq, nlmsg_request->nl_client = nl_client; nlmsg_request->request_done = 0; nlmsg_request->err_code = 0; - sema_init(&nlmsg_request->sem, 1); - down(&nlmsg_request->sem); + init_completion(&nlmsg_request->comp); return nlmsg_request; } @@ -368,8 +367,8 @@ int iwpm_wait_complete_req(struct iwpm_nlmsg_request *nlmsg_request) { int ret; - ret = down_timeout(&nlmsg_request->sem, IWPM_NL_TIMEOUT); - if (ret) { + ret = wait_for_completion_timeout(&nlmsg_request->comp, IWPM_NL_TIMEOUT); + if (!ret) { ret = -EINVAL; pr_info("%s: Timeout %d sec for netlink request (seq = %u)\n", __func__, (IWPM_NL_TIMEOUT/HZ), nlmsg_request->nlmsg_seq); diff --git a/drivers/infiniband/core/iwpm_util.h b/drivers/infiniband/core/iwpm_util.h index af1fc14..ea6c299 100644 --- a/drivers/infiniband/core/iwpm_util.h +++ b/drivers/infiniband/core/iwpm_util.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -69,7 +70,7 @@ struct iwpm_nlmsg_request { u8 nl_client; u8 request_done; u16 err_code; - struct semaphore sem; + struct completion comp; struct kref kref; };