From patchwork Mon Nov 21 06:08:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 83182 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1326899qge; Sun, 20 Nov 2016 22:15:06 -0800 (PST) X-Received: by 10.13.199.193 with SMTP id j184mr11718696ywd.339.1479708906331; Sun, 20 Nov 2016 22:15:06 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n123si4312480ywe.57.2016.11.20.22.15.06; Sun, 20 Nov 2016 22:15:06 -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 S1753273AbcKUGO5 (ORCPT + 26 others); Mon, 21 Nov 2016 01:14:57 -0500 Received: from mail-pf0-f170.google.com ([209.85.192.170]:34725 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750744AbcKUGO4 (ORCPT ); Mon, 21 Nov 2016 01:14:56 -0500 Received: by mail-pf0-f170.google.com with SMTP id c4so50660893pfb.1 for ; Sun, 20 Nov 2016 22:14:55 -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=12a21p2+1RiYUopa37cnypnfhyrPKY6Dt+DxTvKqxL4=; b=ZDxMC64LZFzDiLT+xoUN4z/wvjwyXE7uwedNJJAdRrt8QuUwMcZnI9EQRos0Nn361L 8NJYb5FelNDT+nWUesYqpy3NeR8OmB0uduY7/5itSbrw8zwxyNnPuwKKGuHUoMNFurm5 dmmnveEkmcGrazmUB1nd2T/AyiREfqN6qSjRo= 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=12a21p2+1RiYUopa37cnypnfhyrPKY6Dt+DxTvKqxL4=; b=D/HBp4OwY1Bt5W8pvPIEy/hREnbzWshPLRCHmwSVQuloMHYx6CDuDLFYa/w0durFBE v92NSQyIxfuT/LBoV0iMDJrvKivPRZEgOv2m5Lbdz1dDsnWpDZ6bA/ngRcXf7KhPqX+S x5rdo06Ju4rHypgiQ6m8IeJdI+36nX48MEUFZaWhak1DshmXlmETBvH0taB/h79PEfnT EkOODiSeo64bj/Jluca4zFzMWpSn9Jn/n9lwjwmCZHRe090/K3wxmJnqyB1jM+K7txpK w5oCmrPRyC1fnYE8oxcHP4nVnHu8IeQZOhSGOZh73AiexBduBnlTs/iPekpK25zddb3C suOQ== X-Gm-Message-State: AKaTC03w9JOvDCB6/v4xMRz+tkETDlGFXjGDAZA0XmSNUWQ9QTscGq6ZzteyZ09D7JeiIuUv X-Received: by 10.98.204.72 with SMTP id a69mr15985338pfg.76.1479708549489; Sun, 20 Nov 2016 22:09:09 -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.02 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 20 Nov 2016 22:09:09 -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 4/9] IB/mthca: Replace semaphore poll_sem with mutex Date: Mon, 21 Nov 2016 11:38:11 +0530 Message-Id: <1479708496-9828-5-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 'poll_sem' is a simple mutex, so it should be written as one. Semaphores are going away in the future. So replace it with a mutex. Also, remove mutex_[un]lock from mthca_cmd_use_events and mthca_cmd_use_polling respectively. Signed-off-by: Binoy Jayan --- drivers/infiniband/hw/mthca/mthca_cmd.c | 10 +++------- drivers/infiniband/hw/mthca/mthca_cmd.h | 1 + drivers/infiniband/hw/mthca/mthca_dev.h | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c index c7f49bb..49c6e19 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c @@ -347,7 +347,7 @@ static int mthca_cmd_poll(struct mthca_dev *dev, unsigned long end; u8 status; - down(&dev->cmd.poll_sem); + mutex_lock(&dev->cmd.poll_mutex); err = mthca_cmd_post(dev, in_param, out_param ? *out_param : 0, @@ -382,7 +382,7 @@ static int mthca_cmd_poll(struct mthca_dev *dev, } out: - up(&dev->cmd.poll_sem); + mutex_unlock(&dev->cmd.poll_mutex); return err; } @@ -520,7 +520,7 @@ static int mthca_cmd_imm(struct mthca_dev *dev, int mthca_cmd_init(struct mthca_dev *dev) { mutex_init(&dev->cmd.hcr_mutex); - sema_init(&dev->cmd.poll_sem, 1); + mutex_init(&dev->cmd.poll_mutex); dev->cmd.flags = 0; dev->hcr = ioremap(pci_resource_start(dev->pdev, 0) + MTHCA_HCR_BASE, @@ -582,8 +582,6 @@ int mthca_cmd_use_events(struct mthca_dev *dev) dev->cmd.flags |= MTHCA_CMD_USE_EVENTS; - down(&dev->cmd.poll_sem); - return 0; } @@ -600,8 +598,6 @@ void mthca_cmd_use_polling(struct mthca_dev *dev) down(&dev->cmd.event_sem); kfree(dev->cmd.context); - - up(&dev->cmd.poll_sem); } struct mthca_mailbox *mthca_alloc_mailbox(struct mthca_dev *dev, diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.h b/drivers/infiniband/hw/mthca/mthca_cmd.h index d2e5b19..a7f197e 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.h +++ b/drivers/infiniband/hw/mthca/mthca_cmd.h @@ -35,6 +35,7 @@ #ifndef MTHCA_CMD_H #define MTHCA_CMD_H +#include #include #define MTHCA_MAILBOX_SIZE 4096 diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h index 4393a02..87ab964 100644 --- a/drivers/infiniband/hw/mthca/mthca_dev.h +++ b/drivers/infiniband/hw/mthca/mthca_dev.h @@ -120,7 +120,7 @@ enum { struct mthca_cmd { struct pci_pool *pool; struct mutex hcr_mutex; - struct semaphore poll_sem; + struct mutex poll_mutex; struct semaphore event_sem; int max_cmds; spinlock_t context_lock;