From patchwork Thu Apr 26 06:46:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 10364721 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 8868F60225 for ; Thu, 26 Apr 2018 06:13:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79B3D28FC6 for ; Thu, 26 Apr 2018 06:13:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DEEB29056; Thu, 26 Apr 2018 06:13:22 +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.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 E56E529058 for ; Thu, 26 Apr 2018 06:13:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753074AbeDZGNT (ORCPT ); Thu, 26 Apr 2018 02:13:19 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7209 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753043AbeDZGNG (ORCPT ); Thu, 26 Apr 2018 02:13:06 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2F1A077CDB601; Thu, 26 Apr 2018 14:12:53 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.361.1; Thu, 26 Apr 2018 14:12:46 +0800 From: Lijun Ou To: , CC: , , Subject: [PATCH for-rc 01/11] IB/core: Avoid a calltrace for an unsupported device memory registration Date: Thu, 26 Apr 2018 14:46:14 +0800 Message-ID: <1524725184-79590-2-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524725184-79590-1-git-send-email-oulijun@huawei.com> References: <1524725184-79590-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected 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 if device memory(DM) is not supported that the dm flow should be taken. the calltrace as follows: [ 101.064379] Unable to handle kernel paging request at virtual address 0001bc20 [ 101.071589] Mem abort info: [ 101.074370] ESR = 0x96000006 [ 101.077413] Exception class = DABT (current EL), IL = 32 bits [ 101.083321] SET = 0, FnV = 0 [ 101.086364] EA = 0, S1PTW = 0 [ 101.089494] Data abort info: [ 101.092364] ISV = 0, ISS = 0x00000006 [ 101.096189] CM = 0, WnR = 0 [ 101.099146] user pgtable: 4k pages, 48-bit VAs, pgdp = 00000000cb2914c6 [ 101.105749] [000000000001bc20] pgd=00000023ce5ae003, pud=00000023ce058003, pmd=0000000000000000 [ 101.114439] Internal error: Oops: 96000006 [#1] PREEMPT SMP [ 101.119998] Modules linked in: hns_roce_hw_v2 hns_roce rdma_ucm rdma_cm iw_cm ib_uverbs ib_cm ib_core [ 101.129215] CPU: 2 PID: 1994 Comm: ib_send_bw Not tainted 4.17.0-rc1-00028-g87ef120-dirty #3 [ 101.137638] Hardware name: Huawei D06/D06, BIOS Hisilicon D06 UEFI Nemo 2.0 RC0 - B205 04/19/2018 [ 101.146496] pstate: 60400009 (nZCv daif +PAN -UAO) [ 101.151298] pc : ib_dereg_mr+0x12c/0x150 [ib_core] [ 101.156087] lr : ib_dereg_mr+0x124/0x150 [ib_core] [ 101.160863] sp : ffff000015153b70 [ 101.164165] x29: ffff000015153b70 x28: 0000000000000000 [ 101.169465] x27: 000000000000000d x26: ffff000000b3d000 [ 101.174764] x25: ffff8023cbd2ce80 x24: 000000000001bc08 [ 101.180063] x23: ffff000000af4a18 x22: ffff000000af4000 [ 101.185363] x21: ffff000000af1638 x20: ffff000000af1000 [ 101.190662] x19: 0000000000000000 x18: ffff00008924b567 [ 101.195961] x17: 0000ffff8c8636d0 x16: ffff000008229968 [ 101.201260] x15: 00000000fffffffe x14: 0000000000000004 [ 101.206559] x13: ffff00000924b575 x12: ffff00000924d990 [ 101.211858] x11: ffff0000090f1000 x10: 0000000005f5e0ff [ 101.217157] x9 : ffff000015153870 x8 : 3631202c726d5f67 [ 101.222456] x7 : 657265645f62695b x6 : 0000000000000293 [ 101.227756] x5 : 0000000000000000 x4 : 0000000000000000 [ 101.233055] x3 : ffffffffffffffff x2 : 000000000001bc20 [ 101.238354] x1 : 0000000000000000 x0 : 0000000000000019 [ 101.243654] Process ib_send_bw (pid: 1994, stack limit = 0x0000000053eb9878) [ 101.250688] Call trace: [ 101.253134] ib_dereg_mr+0x12c/0x150 [ib_core] [ 101.257572] uverbs_free_mr+0x30/0x40 [ib_uverbs] [ 101.262267] remove_commit_idr_uobject+0x24/0x58 [ib_uverbs] [ 101.267915] _rdma_remove_commit_uobject+0x2c/0xc0 [ib_uverbs] [ 101.273737] rdma_remove_commit_uobject+0x38/0x80 [ib_uverbs] [ 101.279473] ib_uverbs_dereg_mr+0xd4/0x138 [ib_uverbs] [ 101.284601] ib_uverbs_write+0x3b4/0x408 [ib_uverbs] [ 101.289554] __vfs_write+0x34/0x140 [ 101.293029] vfs_write+0xa4/0x1b0 [ 101.296331] ksys_write+0x5c/0xc8 [ 101.299633] sys_write+0xc/0x18 [ 101.302762] el0_svc_naked+0x30/0x34 [ 101.306324] Code: 5280cc02 95d95b1f 91006302 f9800051 (885f7c40) [ 101.312405] ---[ end trace a9e4d13346a1e97f ]--- Signed-off-by: Lijun Ou Signed-off-by: Leon Romanovsky Tested-by: Lijun Ou --- drivers/infiniband/core/uverbs_std_types_dm.c | 7 ++++++- drivers/infiniband/core/verbs.c | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/core/uverbs_std_types_dm.c b/drivers/infiniband/core/uverbs_std_types_dm.c index 8b68157..b83ccbd 100644 --- a/drivers/infiniband/core/uverbs_std_types_dm.c +++ b/drivers/infiniband/core/uverbs_std_types_dm.c @@ -37,11 +37,16 @@ static int uverbs_free_dm(struct ib_uobject *uobject, enum rdma_remove_reason why) { struct ib_dm *dm = uobject->object; + int ret; if (why == RDMA_REMOVE_DESTROY && atomic_read(&dm->usecnt)) return -EBUSY; - return dm->device->dealloc_dm(dm); + ret = dm->device->dealloc_dm(dm); + if (!ret) + atomic_dec(&dm->usecnt); + + return ret; } static int UVERBS_HANDLER(UVERBS_METHOD_DM_ALLOC)(struct ib_device *ib_dev, diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index 7eff3ae..50a3b20 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -1616,15 +1616,12 @@ int ib_resize_cq(struct ib_cq *cq, int cqe) int ib_dereg_mr(struct ib_mr *mr) { struct ib_pd *pd = mr->pd; - struct ib_dm *dm = mr->dm; int ret; rdma_restrack_del(&mr->res); ret = mr->device->dereg_mr(mr); if (!ret) { atomic_dec(&pd->usecnt); - if (dm) - atomic_dec(&dm->usecnt); } return ret;