From patchwork Mon May 7 17:23:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Boyer X-Patchwork-Id: 10384553 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 D4A5260236 for ; Mon, 7 May 2018 17:35:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D39CE2852C for ; Mon, 7 May 2018 17:35:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8351289D8; Mon, 7 May 2018 17:35:21 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 335DD2852C for ; Mon, 7 May 2018 17:35:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752773AbeEGRfU (ORCPT ); Mon, 7 May 2018 13:35:20 -0400 Received: from esa5.dell-outbound.iphmx.com ([68.232.153.95]:50135 "EHLO esa5.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752767AbeEGRfT (ORCPT ); Mon, 7 May 2018 13:35:19 -0400 X-Greylist: delayed 668 seconds by postgrey-1.27 at vger.kernel.org; Mon, 07 May 2018 13:35:13 EDT DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1525714129; x=1557250129; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=QDy/nlnulk6Z2jj/Ew+PKiljkq3Im4eNAKaOtjGHRr8=; b=kIZwOM2q4plhEegnFyTxuvwyb4WYdVnsDiuLMIJvXTd9CQsy7Oz0kgi5 doBaTFa1ZDKKMnlSpEAgNYeHORu0WlmmCRTrYl5SiUlRN2I4IFx+W94e4 PD5r5VY/KpG0we8eNiuPrb5NtA3rUCPLsuEfhpHTwGexQcITndQ97iO6M g=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2EbAQCmivBah8qZ6ERcGgEBAQEBAgEBA?= =?us-ascii?q?QEIAQEBAYUfKIxPjBaDCJMmgXgLhGwCglQhNhYBAgEBAQEBAQIBAQIQAQEBCgs?= =?us-ascii?q?JCCgvgjUiglQDAydSEFFXBxKFIapIM4RYg2uCSIglgVQ/gQ+CXYp1AocVkRUIg?= =?us-ascii?q?WWMaAKMYJAlAgQCBAUCFIElIwaBfjMaI1CCQ4IgDgmOM1OQRAEB?= X-IPAS-Result: =?us-ascii?q?A2EbAQCmivBah8qZ6ERcGgEBAQEBAgEBAQEIAQEBAYUfKIx?= =?us-ascii?q?PjBaDCJMmgXgLhGwCglQhNhYBAgEBAQEBAQIBAQIQAQEBCgsJCCgvgjUiglQDA?= =?us-ascii?q?ydSEFFXBxKFIapIM4RYg2uCSIglgVQ/gQ+CXYp1AocVkRUIgWWMaAKMYJAlAgQ?= =?us-ascii?q?CBAUCFIElIwaBfjMaI1CCQ4IgDgmOM1OQRAEB?= Received: from esa2.dell-outbound2.iphmx.com ([68.232.153.202]) by esa5.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 May 2018 12:19:25 -0500 Received: from mailuogwdur.emc.com ([128.221.224.79]) by esa2.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 May 2018 23:18:34 +0600 Received: from maildlpprd52.lss.emc.com (maildlpprd52.lss.emc.com [10.106.48.156]) by mailuogwprd53.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id w47HOBS7007349 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 7 May 2018 13:24:12 -0400 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd53.lss.emc.com w47HOBS7007349 Received: from mailapphubprd53.lss.emc.com (emcmail.lss.emc.com [10.106.83.172]) by maildlpprd52.lss.emc.com (RSA Interceptor); Mon, 7 May 2018 13:24:02 -0400 Received: from hopcyc-boyera-1-00.cec.lab.emc.com (hopcyc-boyera-1-00.cec.lab.emc.com [10.244.196.91]) by mailapphubprd53.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id w47HNkRi015171; Mon, 7 May 2018 13:24:02 -0400 From: Andrew Boyer To: shiraz.saleem@intel.com, linux-rdma@vger.kernel.org Cc: Andrew Boyer Subject: [PATCH 1/3] RDMA/i40iw: Avoid panic when objects are being created and destroyed Date: Mon, 7 May 2018 13:23:36 -0400 Message-Id: <1525713818-5771-2-git-send-email-andrew.boyer@dell.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525713818-5771-1-git-send-email-andrew.boyer@dell.com> References: <1525713818-5771-1-git-send-email-andrew.boyer@dell.com> X-RSA-Classifications: public X-Sentrion-Hostname: mailuogwprd53.lss.emc.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 A panic occurs when there is a newly-registered element on the QP/CQ MR list waiting to be attached, but a different MR is deregistered. The current code only checks for whether the list is empty, not whether the element being deregistered is actually on the list. Fix the panic by adding a boolean to track if the object is on the list. Fixes: d37498417947 ("i40iw: add files for iwarp interface") Signed-off-by: Andrew Boyer Reviewed-by: Shiraz Saleem --- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 11 +++++++++-- drivers/infiniband/hw/i40iw/i40iw_verbs.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c index 40e4f5a..b9aa2be 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_verbs.c +++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c @@ -394,6 +394,7 @@ static struct i40iw_pbl *i40iw_get_pbl(unsigned long va, list_for_each_entry(iwpbl, pbl_list, list) { if (iwpbl->user_base == va) { + iwpbl->on_list = false; list_del(&iwpbl->list); return iwpbl; } @@ -1898,6 +1899,7 @@ static struct ib_mr *i40iw_reg_user_mr(struct ib_pd *pd, goto error; spin_lock_irqsave(&ucontext->qp_reg_mem_list_lock, flags); list_add_tail(&iwpbl->list, &ucontext->qp_reg_mem_list); + iwpbl->on_list = true; spin_unlock_irqrestore(&ucontext->qp_reg_mem_list_lock, flags); break; case IW_MEMREG_TYPE_CQ: @@ -1908,6 +1910,7 @@ static struct ib_mr *i40iw_reg_user_mr(struct ib_pd *pd, spin_lock_irqsave(&ucontext->cq_reg_mem_list_lock, flags); list_add_tail(&iwpbl->list, &ucontext->cq_reg_mem_list); + iwpbl->on_list = true; spin_unlock_irqrestore(&ucontext->cq_reg_mem_list_lock, flags); break; case IW_MEMREG_TYPE_MEM: @@ -2045,14 +2048,18 @@ static void i40iw_del_memlist(struct i40iw_mr *iwmr, switch (iwmr->type) { case IW_MEMREG_TYPE_CQ: spin_lock_irqsave(&ucontext->cq_reg_mem_list_lock, flags); - if (!list_empty(&ucontext->cq_reg_mem_list)) + if (iwpbl->on_list) { + iwpbl->on_list = false; list_del(&iwpbl->list); + } spin_unlock_irqrestore(&ucontext->cq_reg_mem_list_lock, flags); break; case IW_MEMREG_TYPE_QP: spin_lock_irqsave(&ucontext->qp_reg_mem_list_lock, flags); - if (!list_empty(&ucontext->qp_reg_mem_list)) + if (iwpbl->on_list) { + iwpbl->on_list = false; list_del(&iwpbl->list); + } spin_unlock_irqrestore(&ucontext->qp_reg_mem_list_lock, flags); break; default: diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.h b/drivers/infiniband/hw/i40iw/i40iw_verbs.h index 9067443..76cf173 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_verbs.h +++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.h @@ -78,6 +78,7 @@ struct i40iw_pbl { }; bool pbl_allocated; + bool on_list; u64 user_base; struct i40iw_pble_alloc pble_alloc; struct i40iw_mr *iwmr;