From patchwork Thu Dec 17 07:00:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 7869871 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 470B6BEEE5 for ; Thu, 17 Dec 2015 07:01:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6500F20260 for ; Thu, 17 Dec 2015 07:01:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6339B2025A for ; Thu, 17 Dec 2015 07:01:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754871AbbLQHBN (ORCPT ); Thu, 17 Dec 2015 02:01:13 -0500 Received: from mga01.intel.com ([192.55.52.88]:30275 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753389AbbLQHBM (ORCPT ); Thu, 17 Dec 2015 02:01:12 -0500 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP; 16 Dec 2015 23:01:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,440,1444719600"; d="scan'208";a="14708251" Received: from phlsvsds.ph.intel.com ([10.228.195.38]) by fmsmga004.fm.intel.com with ESMTP; 16 Dec 2015 23:01:11 -0800 Received: from phlsvsds.ph.intel.com (localhost.localdomain [127.0.0.1]) by phlsvsds.ph.intel.com (8.13.8/8.13.8) with ESMTP id tBH71AIR013325; Thu, 17 Dec 2015 02:01:10 -0500 Received: (from iweiny@localhost) by phlsvsds.ph.intel.com (8.13.8/8.13.8/Submit) id tBH71Akp013322; Thu, 17 Dec 2015 02:01:10 -0500 X-Authentication-Warning: phlsvsds.ph.intel.com: iweiny set sender to ira.weiny@intel.com using -f From: ira.weiny@intel.com To: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org Cc: dledford@redhat.com, linux-rdma@vger.kernel.org, Mitko Haralanov Subject: [PATCH 09/14] staging/rdma/hfi1: Convert lock to mutex Date: Thu, 17 Dec 2015 02:00:19 -0500 Message-Id: <1450335624-12134-10-git-send-email-ira.weiny@intel.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1450335624-12134-1-git-send-email-ira.weiny@intel.com> References: <1450335624-12134-1-git-send-email-ira.weiny@intel.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mitko Haralanov The exp_lock lock does not need to be a spinlock as all its uses are in process context and allowing the process to sleep when the mutex is contended might be benefitial. Reviewed-by: Ira Weiny Signed-off-by: Mitko Haralanov --- drivers/staging/rdma/hfi1/file_ops.c | 12 ++++++------ drivers/staging/rdma/hfi1/hfi.h | 2 +- drivers/staging/rdma/hfi1/init.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rdma/hfi1/file_ops.c b/drivers/staging/rdma/hfi1/file_ops.c index 76fe60315bb4..b0348263b901 100644 --- a/drivers/staging/rdma/hfi1/file_ops.c +++ b/drivers/staging/rdma/hfi1/file_ops.c @@ -1611,14 +1611,14 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo) * reserved, we don't need the lock anymore since we * are guaranteed the groups. */ - spin_lock(&uctxt->exp_lock); + mutex_lock(&uctxt->exp_lock); if (uctxt->tidusemap[useidx] == -1ULL || bitidx >= BITS_PER_LONG) { /* no free groups in the set, use the next */ useidx = (useidx + 1) % uctxt->tidmapcnt; idx++; bitidx = 0; - spin_unlock(&uctxt->exp_lock); + mutex_unlock(&uctxt->exp_lock); continue; } ngroups = ((npages - mapped) / dd->rcv_entries.group_size) + @@ -1635,13 +1635,13 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo) * as 0 because we don't check the entire bitmap but * we start from bitidx. */ - spin_unlock(&uctxt->exp_lock); + mutex_unlock(&uctxt->exp_lock); continue; } bits_used = min(free, ngroups); tidmap[useidx] |= ((1ULL << bits_used) - 1) << bitidx; uctxt->tidusemap[useidx] |= tidmap[useidx]; - spin_unlock(&uctxt->exp_lock); + mutex_unlock(&uctxt->exp_lock); /* * At this point, we know where in the map we have free bits. @@ -1677,10 +1677,10 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo) * Let go of the bits that we reserved since we are not * going to use them. */ - spin_lock(&uctxt->exp_lock); + mutex_lock(&uctxt->exp_lock); uctxt->tidusemap[useidx] &= ~(((1ULL << bits_used) - 1) << bitidx); - spin_unlock(&uctxt->exp_lock); + mutex_unlock(&uctxt->exp_lock); goto done; } /* diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h index 996dd520cf41..8ae914aab9bf 100644 --- a/drivers/staging/rdma/hfi1/hfi.h +++ b/drivers/staging/rdma/hfi1/hfi.h @@ -258,7 +258,7 @@ struct hfi1_ctxtdata { struct exp_tid_set tid_full_list; /* lock protecting all Expected TID data */ - spinlock_t exp_lock; + struct mutex exp_lock; /* number of pio bufs for this ctxt (all procs, if shared) */ u32 piocnt; /* first pio buffer for this ctxt */ diff --git a/drivers/staging/rdma/hfi1/init.c b/drivers/staging/rdma/hfi1/init.c index 98aaa0ebff51..503dc7a397a5 100644 --- a/drivers/staging/rdma/hfi1/init.c +++ b/drivers/staging/rdma/hfi1/init.c @@ -227,7 +227,7 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u32 ctxt) rcd->numa_id = numa_node_id(); rcd->rcv_array_groups = dd->rcv_entries.ngroups; - spin_lock_init(&rcd->exp_lock); + mutex_init(&rcd->exp_lock); /* * Calculate the context's RcvArray entry starting point.