From patchwork Wed Oct 26 08:01:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 79344 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp278835qge; Wed, 26 Oct 2016 01:01:34 -0700 (PDT) X-Received: by 10.99.110.14 with SMTP id j14mr1452410pgc.135.1477468894474; Wed, 26 Oct 2016 01:01:34 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si1272328pgd.148.2016.10.26.01.01.34; Wed, 26 Oct 2016 01:01:34 -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 S1759936AbcJZIB3 (ORCPT + 27 others); Wed, 26 Oct 2016 04:01:29 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:33122 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759799AbcJZIBZ (ORCPT ); Wed, 26 Oct 2016 04:01:25 -0400 Received: by mail-pf0-f171.google.com with SMTP id 197so11521341pfu.0 for ; Wed, 26 Oct 2016 01:01:25 -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=N8JVvah7/zwgNthUIKa5rvlvjnsze4hLhhWHatKwb6xd5mZFE7OC7e4Bp83BbfYLc1 0YxNlTD691wIk3jZkLEu6czo2Qw3tKdMMfvpCClcyeW0fXPnoZ63+c9rTWpnkWROQNnN T06sZbYReqkC72LKnvdOc7qHeAWnWq3bjExm4= 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=ZTFS+bA4bkBLjeqydPx+9FJIIRJnvSCpZtW/FIoZ5DwBygSOqbleUPaej3wDV9arSy /Jp8yEg5AwIQxR+8lH+oD1o+YPP2GI88dumG7qf1y+zKNL2sey1VrjmeWy4mHmKtOnSG V6JpXW2Te05El93d3+YXfyMYZJyKWHnAroGY/SXXaj3CQekxEQKTOm8BE+rBI1ehR1QC MLfQjpmsrKsTv8zQDhkqAw4yJQd7CnY2RRuILSZTeZGWl5B4GcDgL3LHDp+Qg/QIc1mS NYMh07LuQSNRFF9wQSRoZ78QUkbNmjxfnRMbT1eweYEisXcC8Dv3F7RTiHs4EdvbnOSa Q/5Q== X-Gm-Message-State: ABUngvf1E9AVc96YC1DbqtvokX6sLr3MjkoZXJCxW1SXkGybxlK88p2Bdv57SxTCLfIT+TcV X-Received: by 10.98.147.78 with SMTP id b75mr1740858pfe.167.1477468885209; Wed, 26 Oct 2016 01:01:25 -0700 (PDT) Received: from blr-ubuntu-59.ap.qualcomm.com ([202.46.23.61]) by smtp.gmail.com with ESMTPSA id 74sm2011923pfp.77.2016.10.26.01.01.22 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Oct 2016 01:01:24 -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 v3 1/9] IB/core: iwpm_nlmsg_request: Replace semaphore with completion Date: Wed, 26 Oct 2016 13:31:06 +0530 Message-Id: <1477468874-16328-2-git-send-email-binoy.jayan@linaro.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1477468874-16328-1-git-send-email-binoy.jayan@linaro.org> References: <1477468874-16328-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; };