From patchwork Mon Oct 17 16:30:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 77775 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp477093qge; Mon, 17 Oct 2016 09:33:02 -0700 (PDT) X-Received: by 10.98.129.130 with SMTP id t124mr38820338pfd.5.1476721982865; Mon, 17 Oct 2016 09:33:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l78si31499519pfi.288.2016.10.17.09.33.01; Mon, 17 Oct 2016 09:33:02 -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 S935790AbcJQQct (ORCPT + 27 others); Mon, 17 Oct 2016 12:32:49 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:33442 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936027AbcJQQby (ORCPT ); Mon, 17 Oct 2016 12:31:54 -0400 Received: by mail-pa0-f52.google.com with SMTP id vu5so63904384pab.0 for ; Mon, 17 Oct 2016 09:31:48 -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=HJOrd8LXWu9+azZovAVcLwJ/aC4J5k2s/6VkWwpb/4c=; b=gedDRsTRRAz83hDc+jS50L1hfBiJ/MNGLS+xxMmZAVAtRcoetII5Qdu0n5qIRJjsuU BjGaaTIjThkwLpq1P4A+fA/5CMz0iTqeTWp6xmiANYBPxqaooYxnop/ZcE40BWSb6nnC C0hlROmJXisbFyKQ4ZIPa1BvpTYb7Rh+cKNYg= 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=HJOrd8LXWu9+azZovAVcLwJ/aC4J5k2s/6VkWwpb/4c=; b=IQuPZCV2uliQcdx/j+iQj1nPgGwabTLaRCatuDnupsvzpF9rqS05yyGrLowla0YKyM AUuAa2j36Mw7tGNKW0R/0BbWnBWsXn4F7RLBeWDw3QKu2H7iH9AfT4ssavQAayLq9J+s iPcSIjdxY4dGNFO/aCAsLi+D5AFjUyAlAjdFxrhrFd68j4l5me8fr7fHZf9eV7Q322Ey FVCEmtodkLa3nm7tQbr2DTZW9hF0eAjkRHPFR+ZLHqDUv4w8sxvkRT2HMZ5caF+LeRax NkvS6Sw7jpmNOgMadJYFIYw3nmBkjadZrafrxefGVVNRVTsxMyv3ysfjBo2ckYp3UIDb hVGQ== X-Gm-Message-State: AA6/9RkGT22u6c9qRPwdLqjmmZGs7mW5hTvz+37e9q2J/zTa08QRM9dV7cdE3Ltwutu014by X-Received: by 10.66.249.39 with SMTP id yr7mr33303169pac.46.1476721908020; Mon, 17 Oct 2016 09:31:48 -0700 (PDT) Received: from blr-ubuntu-59.ap.qualcomm.com ([202.46.23.61]) by smtp.gmail.com with ESMTPSA id o9sm43009638pac.27.2016.10.17.09.31.45 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Oct 2016 09:31:47 -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 4/8] IB/mthca: Replace semaphore poll_sem with mutex Date: Mon, 17 Oct 2016 22:00:58 +0530 Message-Id: <1476721862-7070-5-git-send-email-binoy.jayan@linaro.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1476721862-7070-1-git-send-email-binoy.jayan@linaro.org> References: <1476721862-7070-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. 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, 7 insertions(+), 6 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..0cb58ea 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,7 +582,7 @@ int mthca_cmd_use_events(struct mthca_dev *dev) dev->cmd.flags |= MTHCA_CMD_USE_EVENTS; - down(&dev->cmd.poll_sem); + mutex_lock(&dev->cmd.poll_mutex); return 0; } @@ -601,7 +601,7 @@ void mthca_cmd_use_polling(struct mthca_dev *dev) kfree(dev->cmd.context); - up(&dev->cmd.poll_sem); + mutex_unlock(&dev->cmd.poll_mutex); } 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;