From patchwork Mon Oct 17 16:30:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 77777 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp477409qge; Mon, 17 Oct 2016 09:33:44 -0700 (PDT) X-Received: by 10.98.153.204 with SMTP id t73mr24597030pfk.144.1476722024099; Mon, 17 Oct 2016 09:33:44 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sn9si26284129pab.296.2016.10.17.09.33.43; Mon, 17 Oct 2016 09:33:44 -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 S1030211AbcJQQdi (ORCPT + 27 others); Mon, 17 Oct 2016 12:33:38 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:33436 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935315AbcJQQbq (ORCPT ); Mon, 17 Oct 2016 12:31:46 -0400 Received: by mail-pa0-f45.google.com with SMTP id vu5so63904093pab.0 for ; Mon, 17 Oct 2016 09:31:45 -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=h9Iyc6bi0O6sVt4GMseAZ83e8GmsXV8KKQJ4B4qQ+48=; b=iaYHendJYn8omWl97NoL3kSnxPZGag4LWa2xY8MlulxZ0qDFiRIQBqbHabmsX9hl97 /y0LorJcjVyoZnvPX15k4A+D8wuDIm9BN0Mk8Bb6IHJTFY8ULk+RO4rarBqgHNrL9U/m aSi/a6XNDPxShUY96HcmzAhh2PNlHO3kKuPuo= 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=h9Iyc6bi0O6sVt4GMseAZ83e8GmsXV8KKQJ4B4qQ+48=; b=DtBg0TuMZKGxdjEmdmh/oinqkl2RYst8+7ZT5tvgtNRUJ9FD0W+y9OpsNChOr0dqYZ AQY4RWSryJS+0VAxXqXYYkSkBgiTpduffdkUt/cXAsLoXv2DVoldKXPxBq+YCAqSJRgC j2CKK5EctV+zCGbuBPI5SnPagCa59GX6yDmhwUoMiyBAiOhkMbCjCdOchYSq06Z6wYOs rw6rdDdZzn1Bq8jRKGU0ibqS2II83JQpMiNIdyV2OWVz04ZPKzPE0Ogclj+vIoX4qpES P/Rtj68267Y09vkbz9LI9JMtsaWWXCajiCcD9cu/ByWUwvC3f1TvODJsfjOEzXUqqeBA IfCw== X-Gm-Message-State: AA6/9Rks062unU1/Nv3NFdp9DG6r96stpc4hVNT74F8ONj0PoPGscAe7IsZvnMgzYC8kgWyA X-Received: by 10.66.146.193 with SMTP id te1mr28563835pab.47.1476721905028; Mon, 17 Oct 2016 09:31:45 -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.42 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Oct 2016 09:31:44 -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 3/8] IB/hns: Replace semaphore poll_sem with mutex Date: Mon, 17 Oct 2016 22:00:57 +0530 Message-Id: <1476721862-7070-4-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/hns/hns_roce_cmd.c | 12 ++++++------ drivers/infiniband/hw/hns/hns_roce_device.h | 3 ++- 2 files changed, 8 insertions(+), 7 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/hns/hns_roce_cmd.c b/drivers/infiniband/hw/hns/hns_roce_cmd.c index 2a0b6c0..1421fdb 100644 --- a/drivers/infiniband/hw/hns/hns_roce_cmd.c +++ b/drivers/infiniband/hw/hns/hns_roce_cmd.c @@ -119,7 +119,7 @@ static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev, u64 in_param, return ret; } -/* this should be called with "poll_sem" */ +/* this should be called with "poll_mutex" */ static int __hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param, unsigned long in_modifier, u8 op_modifier, u16 op, @@ -167,10 +167,10 @@ static int hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, u64 in_param, { int ret; - down(&hr_dev->cmd.poll_sem); + mutex_lock(&hr_dev->cmd.poll_mutex); ret = __hns_roce_cmd_mbox_poll(hr_dev, in_param, out_param, in_modifier, op_modifier, op, timeout); - up(&hr_dev->cmd.poll_sem); + mutex_unlock(&hr_dev->cmd.poll_mutex); return ret; } @@ -275,7 +275,7 @@ int hns_roce_cmd_init(struct hns_roce_dev *hr_dev) struct device *dev = &hr_dev->pdev->dev; mutex_init(&hr_dev->cmd.hcr_mutex); - sema_init(&hr_dev->cmd.poll_sem, 1); + mutex_init(&hr_dev->cmd.poll_mutex); hr_dev->cmd.use_events = 0; hr_dev->cmd.toggle = 1; hr_dev->cmd.max_cmds = CMD_MAX_NUM; @@ -319,7 +319,7 @@ int hns_roce_cmd_use_events(struct hns_roce_dev *hr_dev) hr_cmd->token_mask = CMD_TOKEN_MASK; hr_cmd->use_events = 1; - down(&hr_cmd->poll_sem); + mutex_lock(&hr_cmd->poll_mutex); return 0; } @@ -335,7 +335,7 @@ void hns_roce_cmd_use_polling(struct hns_roce_dev *hr_dev) down(&hr_cmd->event_sem); kfree(hr_cmd->context); - up(&hr_cmd->poll_sem); + mutex_unlock(&hr_cmd->poll_mutex); } struct hns_roce_cmd_mailbox diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h index 3417315..2afe075 100644 --- a/drivers/infiniband/hw/hns/hns_roce_device.h +++ b/drivers/infiniband/hw/hns/hns_roce_device.h @@ -34,6 +34,7 @@ #define _HNS_ROCE_DEVICE_H #include +#include #define DRV_NAME "hns_roce" @@ -358,7 +359,7 @@ struct hns_roce_cmdq { struct dma_pool *pool; u8 __iomem *hcr; struct mutex hcr_mutex; - struct semaphore poll_sem; + struct mutex poll_mutex; /* * Event mode: cmd register mutex protection, * ensure to not exceed max_cmds and user use limit region