From patchwork Tue Apr 18 09:03:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Barak X-Patchwork-Id: 9685213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 757E7602C9 for ; Tue, 18 Apr 2017 09:05:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62BB028387 for ; Tue, 18 Apr 2017 09:05:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 577D02839C; Tue, 18 Apr 2017 09:05:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED09428387 for ; Tue, 18 Apr 2017 09:05:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756218AbdDRJFH (ORCPT ); Tue, 18 Apr 2017 05:05:07 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:37707 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755884AbdDRJD7 (ORCPT ); Tue, 18 Apr 2017 05:03:59 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from matanb@mellanox.com) with ESMTPS (AES256-SHA encrypted); 18 Apr 2017 12:03:52 +0300 Received: from gen-l-vrt-078.mtl.labs.mlnx. (gen-l-vrt-078.mtl.labs.mlnx [10.137.78.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v3I93qSL011257; Tue, 18 Apr 2017 12:03:52 +0300 From: Matan Barak To: linux-rdma@vger.kernel.org Cc: Doug Ledford , Jason Gunthorpe , Sean Hefty , Liran Liss , Majd Dibbiny , Yishai Hadas , Ira Weiny , Christoph Lameter , Matan Barak Subject: [PATCH for-next 2/6] IB/core: Don't pass the lock state to _rdma_remove_commit_uobject Date: Tue, 18 Apr 2017 12:03:38 +0300 Message-Id: <1492506222-28999-3-git-send-email-matanb@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1492506222-28999-1-git-send-email-matanb@mellanox.com> References: <1492506222-28999-1-git-send-email-matanb@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The only scenario where this function was called while the lock is already taken is in the context cleanup scenario. Thus, in order not to pass the lock state to this function, we just call the remove logic straight from the cleanup context function. Fixes: 3832125624b7 ('IB/core: Add support for idr types') Signed-off-by: Matan Barak Reviewed-by: Sean Hefty --- drivers/infiniband/core/rdma_core.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c index 88d1e59..699a659 100644 --- a/drivers/infiniband/core/rdma_core.c +++ b/drivers/infiniband/core/rdma_core.c @@ -363,8 +363,7 @@ static void lockdep_check(struct ib_uobject *uobj, bool exclusive) } static int __must_check _rdma_remove_commit_uobject(struct ib_uobject *uobj, - enum rdma_remove_reason why, - bool lock) + enum rdma_remove_reason why) { int ret; struct ib_ucontext *ucontext = uobj->context; @@ -375,11 +374,9 @@ static int __must_check _rdma_remove_commit_uobject(struct ib_uobject *uobj, atomic_set(&uobj->usecnt, 0); uobj->type->type_class->lookup_put(uobj, true); } else { - if (lock) - mutex_lock(&ucontext->uobjects_lock); + mutex_lock(&ucontext->uobjects_lock); list_del(&uobj->list); - if (lock) - mutex_unlock(&ucontext->uobjects_lock); + mutex_unlock(&ucontext->uobjects_lock); /* put the ref we took when we created the object */ uverbs_uobject_put(uobj); } @@ -401,7 +398,7 @@ int __must_check rdma_remove_commit_uobject(struct ib_uobject *uobj) return 0; } lockdep_check(uobj, true); - ret = _rdma_remove_commit_uobject(uobj, RDMA_REMOVE_DESTROY, true); + ret = _rdma_remove_commit_uobject(uobj, RDMA_REMOVE_DESTROY); up_read(&ucontext->cleanup_rwsem); return ret; @@ -534,8 +531,7 @@ static void _uverbs_close_fd(struct ib_uobject_file *uobj_file) goto unlock; ucontext = uobj_file->uobj.context; - ret = _rdma_remove_commit_uobject(&uobj_file->uobj, RDMA_REMOVE_CLOSE, - true); + ret = _rdma_remove_commit_uobject(&uobj_file->uobj, RDMA_REMOVE_CLOSE); up_read(&ucontext->cleanup_rwsem); if (ret) pr_warn("uverbs: unable to clean up uobject file in uverbs_close_fd.\n"); @@ -583,7 +579,7 @@ void uverbs_cleanup_ucontext(struct ib_ucontext *ucontext, bool device_removed) */ mutex_lock(&ucontext->uobjects_lock); list_for_each_entry_safe(obj, next_obj, &ucontext->uobjects, - list) + list) { if (obj->type->destroy_order == cur_order) { int ret; @@ -592,15 +588,19 @@ void uverbs_cleanup_ucontext(struct ib_ucontext *ucontext, bool device_removed) * racing with a lookup_get. */ WARN_ON(uverbs_try_lock_object(obj, true)); - ret = _rdma_remove_commit_uobject(obj, reason, - false); + ret = obj->type->type_class->remove_commit(obj, + reason); + list_del(&obj->list); if (ret) pr_warn("ib_uverbs: failed to remove uobject id %d order %u\n", obj->id, cur_order); + /* put the ref we took when we created the object */ + uverbs_uobject_put(obj); } else { next_order = min(next_order, obj->type->destroy_order); } + } mutex_unlock(&ucontext->uobjects_lock); cur_order = next_order; }