From patchwork Thu Oct 27 06:59:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 79611 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp467580qge; Wed, 26 Oct 2016 23:59:49 -0700 (PDT) X-Received: by 10.99.208.21 with SMTP id z21mr9660546pgf.125.1477551589846; Wed, 26 Oct 2016 23:59:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 123si6338936pgb.296.2016.10.26.23.59.49; Wed, 26 Oct 2016 23:59:49 -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 S934305AbcJ0G72 (ORCPT + 27 others); Thu, 27 Oct 2016 02:59:28 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:35935 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933978AbcJ0G7Z (ORCPT ); Thu, 27 Oct 2016 02:59:25 -0400 Received: by mail-pf0-f174.google.com with SMTP id e6so11859051pfk.3 for ; Wed, 26 Oct 2016 23:59: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=Hu7C32RoDrrJZiF43s2IdTlnAMb+B89iOP9xo57jfESCjcv+FO1+Mq9ZX2wtYlI6ne 51vlUf1ia+iETesH+dGbFb60jVhdRGYNFZgwIhrwpL7XzqdK26vW/7dvgJBzFZB40OWk h7Rboo4sDGQCwyQhu/Ua/m0Oiig9pQd9uOrsY= 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=IZxlgDs3uYbIN0U6NtC6ZvmrHVGDNNB45Tlrc8IwfKtPRA+aDoYmnf7xCMujnz3Li2 yrPCeyX8xoQZK9t8mdb0OPRgzRacUzml0WtckKWZhI3O62jdvGQnLbUvMOdJ+4+4ruD9 FIN2LnGXjBwbvOZXsyyGc82TVadzH0ncQsSEn6VNiRcB0fjNOG9O5PrY59b8m2uOwHcX lyLZ+cgtnE9soSWWa1AhUFnJ/qPK3YmTS6d3okKFnze1bXPQYz0mdfnEOGJHOJufBHfv bQXhXYWXonIvpqhplqlnYLF2R1yTBMZ0ioi37qN96TAwAkQgPcQ0lNupWSGxRnu5l5Dc oBTw== X-Gm-Message-State: ABUngveJwSPUoe0K5i05j9SZEoQx70CES1g3j+XxdPCM5ue5aE0itjsqKReEphgbE2F4vTwb X-Received: by 10.98.205.207 with SMTP id o198mr11539610pfg.114.1477551564841; Wed, 26 Oct 2016 23:59:24 -0700 (PDT) Received: from blr-ubuntu-59.ap.qualcomm.com ([202.46.23.61]) by smtp.gmail.com with ESMTPSA id w24sm8795544pfa.12.2016.10.26.23.59.21 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Oct 2016 23:59: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 v4 01/10] IB/core: iwpm_nlmsg_request: Replace semaphore with completion Date: Thu, 27 Oct 2016 12:29:05 +0530 Message-Id: <1477551554-30349-2-git-send-email-binoy.jayan@linaro.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1477551554-30349-1-git-send-email-binoy.jayan@linaro.org> References: <1477551554-30349-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; };