From patchwork Mon Nov 21 06:08:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 83183 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1327190qge; Sun, 20 Nov 2016 22:15:50 -0800 (PST) X-Received: by 10.129.159.71 with SMTP id w68mr13382894ywg.240.1479708950502; Sun, 20 Nov 2016 22:15:50 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 18si4315286ybc.155.2016.11.20.22.15.50; Sun, 20 Nov 2016 22:15:50 -0800 (PST) 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 S1753393AbcKUGPr (ORCPT + 26 others); Mon, 21 Nov 2016 01:15:47 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:35612 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750744AbcKUGPq (ORCPT ); Mon, 21 Nov 2016 01:15:46 -0500 Received: by mail-pf0-f182.google.com with SMTP id i88so62424154pfk.2 for ; Sun, 20 Nov 2016 22:15:45 -0800 (PST) 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=e3bturvT1S4ZAKCkmUeb8Ra6hk6hRWpAkHnpYXlcpc4=; b=d3AtAMFVTUtaJ0VcDkunbJYK4pT5hW7p260FmVpe25AYyV/QjVnUxK2Xg1SCfPbi37 Rjb5rLiA8lnnxYurBukXUWVSa3/ELWN994P44haVt3zdL9NnlaLxhbMAM/QkeukuClBj 4ya9LGWtrCuRyzx/bmOtshCosYDyPyNqDrhSo= 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=e3bturvT1S4ZAKCkmUeb8Ra6hk6hRWpAkHnpYXlcpc4=; b=VHSblLZlLXs7vm8QARCKotDyZlUnBbsiUGIQezDS8D3/nJbJmbUKCdnlneYKQ9Xag0 h6E8QkbvNRrb8wCyOYTKf1ThWMI4on1/bC3gEcBD0vtSrW6W7Srlzw7XUAg3GZNM0w73 7N2+sqfSrodlxohAVbVd6NT4nAdbhfSAfO0zOJXk3de+SoQhsURQxGbYWV+nQAEInguG zkfcvul7iG/mzHLX2vZ+FQz8uifuw2KGVnVjs/a+0Dz4NC0kQwgi3IE/NWxcfyIjR3PV pR27UGAx6bpF0+Vs5q5nbb/IE9h/oCcuKDzJCfDfSRBvcECCMDpfB1+K/nrpYHubRjhQ qR8A== X-Gm-Message-State: AKaTC01I8lmAGuXApKsEF9aFqKvMEaIeinmE4YJVYcJqdpDZPLkhQd1WQRmcVJ6ICfzKXAi9 X-Received: by 10.98.7.83 with SMTP id b80mr15779635pfd.79.1479708556380; Sun, 20 Nov 2016 22:09:16 -0800 (PST) Received: from blr-ubuntu-59.ap.qualcomm.com ([202.46.23.61]) by smtp.gmail.com with ESMTPSA id 74sm16068432pge.2.2016.11.20.22.09.09 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 20 Nov 2016 22:09:15 -0800 (PST) From: Binoy Jayan To: Doug Ledford , Sean Hefty , Sagi Grimberg , Hal Rosenstock , Leon Romanovsky , Sagi Grimberg , Bart Van Assche , Nicholas Bellinger , Jenny Derzhavetz , Ira Weiny , Steve Wise , Mark Bloch , Tatyana E Nikolova , Matan Barak , Lijun Ou , "Wei Hu(Xavier)" Cc: Faisal Latif , Mustafa Ismail , Mark Brown , Arnd Bergmann , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, target-devel@vger.kernel.org, Binoy Jayan Subject: [PATCH v5 5/9] IB/isert: Replace semaphore sem with completion Date: Mon, 21 Nov 2016 11:38:12 +0530 Message-Id: <1479708496-9828-6-git-send-email-binoy.jayan@linaro.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1479708496-9828-1-git-send-email-binoy.jayan@linaro.org> References: <1479708496-9828-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 The semaphore 'sem' in isert_device is used as completion, but in a counting fashion as isert_connected_handler could be called multiple times during which it allows for that number of waiters (isert_accept_np) to continue without blocking, each consuming one node out from the list isert_np-pending in the same order in which they were enqueued (FIFO). So, convert it to struct completion. Semaphores are going away in the future. Signed-off-by: Binoy Jayan --- drivers/infiniband/ulp/isert/ib_isert.c | 6 +++--- drivers/infiniband/ulp/isert/ib_isert.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 6dd43f6..de80f56 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -619,7 +619,7 @@ mutex_unlock(&isert_np->mutex); isert_info("np %p: Allow accept_np to continue\n", isert_np); - up(&isert_np->sem); + complete(&isert_np->comp); } static void @@ -2311,7 +2311,7 @@ struct rdma_cm_id * isert_err("Unable to allocate struct isert_np\n"); return -ENOMEM; } - sema_init(&isert_np->sem, 0); + init_completion(&isert_np->comp); mutex_init(&isert_np->mutex); INIT_LIST_HEAD(&isert_np->accepted); INIT_LIST_HEAD(&isert_np->pending); @@ -2427,7 +2427,7 @@ struct rdma_cm_id * int ret; accept_wait: - ret = down_interruptible(&isert_np->sem); + ret = wait_for_completion_interruptible(&isert_np->comp); if (ret) return -ENODEV; diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h index c02ada5..a1277c0 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.h +++ b/drivers/infiniband/ulp/isert/ib_isert.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -190,7 +191,7 @@ struct isert_device { struct isert_np { struct iscsi_np *np; - struct semaphore sem; + struct completion comp; struct rdma_cm_id *cm_id; struct mutex mutex; struct list_head accepted;