Received: by 10.223.185.116 with SMTP id b49csp1029601wrg; Wed, 21 Feb 2018 10:51:27 -0800 (PST) X-Google-Smtp-Source: AH8x225abYY+1t8HyaEI0TVC7iPlJo58mvv4G+zgdHV+7g6tzzCEOLsiHMOBSi8Hlha1jK765Zb1 X-Received: by 10.99.135.65 with SMTP id i62mr3456312pge.331.1519239087120; Wed, 21 Feb 2018 10:51:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519239087; cv=none; d=google.com; s=arc-20160816; b=NoUZgnUkHJqIZSuCqt7a8YXG0TCszcYC8V7v++81baSfSaLWhoxzx6P/UDzFQL80Ad gnWCsCOjIE6X3zfRBddA7+6g9NYKJfGHe0J+pH/Q1GPUPEi1/qVDlGRsvPSln/z7GP9v yt283/gPvuqsHawlAU49887K+5eQRPR8B5bU/u2+oJbwHIvsHnD5TLwhRM3kOJ3WVTvh R/TFSo4IHsBYGcoBJUbKgSmRlQaEeZ/wXxlUxkjLw4zP+aitPg7GbYfZpuAJRMxJllyP +M7fK2Cas9Crtjla0nLywuSIkDdGi4SWkgJIsc1fBVKJOdIIwu1obtgC64i1mhLsp/NY Eq/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=AxoKYY8xBb9S9RlkrS8pZb3msP7Dx4hwi54jW05z6Uw=; b=AqXFTeznTDipX6lvmo7oFl4msLIDz07l0I/RWQLF5Cg6tOnmOyzWyREVuFph8vikDH Sw9hfZ6NMYvx6CXu3wJVeNirLOqGeDn1ALXmNcRbTLzdgWja4C9aeD/KWHslcTcJJhHz wfjGU0umORNT85oPaziH8nerXp2mm9utcVOIiyY6htKtIpYc6Nah7P2d+j+OrF7wr2Vu RRMfVlDegeSghur9PO106IoKLOL7g9CbG4Q6yQe9BDu1tKuy4KzW5qijtgUkREbJwHiy QPgnNhGQc+FAbn95GR+WDW4fk77W/M5slH12QG6LVJLOKV9aD4+okyp2hDztjMZ1tiyR wnHg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j185si13764pfc.44.2018.02.21.10.51.12; Wed, 21 Feb 2018 10:51:27 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964884AbeBUOTg (ORCPT + 99 others); Wed, 21 Feb 2018 09:19:36 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36386 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935037AbeBUM7G (ORCPT ); Wed, 21 Feb 2018 07:59:06 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E1B92FCF; Wed, 21 Feb 2018 12:59:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Leon Romanovsky , Jason Gunthorpe Subject: [PATCH 4.14 006/167] IB/core: Fix two kernel warnings triggered by rxe registration Date: Wed, 21 Feb 2018 13:46:57 +0100 Message-Id: <20180221124524.979876308@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124524.639039577@linuxfoundation.org> References: <20180221124524.639039577@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bart Van Assche commit 02ee9da347873699603d9ce0112a80b5dd69dea1 upstream. Eliminate the WARN_ONs that create following two warnings when registering an rxe device: WARNING: CPU: 2 PID: 1005 at drivers/infiniband/core/device.c:449 ib_register_device+0x591/0x640 [ib_core] CPU: 2 PID: 1005 Comm: run_tests Not tainted 4.15.0-rc4-dbg+ #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 RIP: 0010:ib_register_device+0x591/0x640 [ib_core] Call Trace: rxe_register_device+0x3c6/0x470 [rdma_rxe] rxe_add+0x543/0x5e0 [rdma_rxe] rxe_net_add+0x37/0xb0 [rdma_rxe] rxe_param_set_add+0x5a/0x120 [rdma_rxe] param_attr_store+0x5e/0xc0 module_attr_store+0x19/0x30 sysfs_kf_write+0x3d/0x50 kernfs_fop_write+0x116/0x1a0 __vfs_write+0x23/0x120 vfs_write+0xbe/0x1b0 SyS_write+0x44/0xa0 entry_SYSCALL_64_fastpath+0x23/0x9a WARNING: CPU: 2 PID: 1005 at drivers/infiniband/core/sysfs.c:1279 ib_device_register_sysfs+0x11d/0x160 [ib_core] CPU: 2 PID: 1005 Comm: run_tests Tainted: G W 4.15.0-rc4-dbg+ #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 RIP: 0010:ib_device_register_sysfs+0x11d/0x160 [ib_core] Call Trace: ib_register_device+0x3f7/0x640 [ib_core] rxe_register_device+0x3c6/0x470 [rdma_rxe] rxe_add+0x543/0x5e0 [rdma_rxe] rxe_net_add+0x37/0xb0 [rdma_rxe] rxe_param_set_add+0x5a/0x120 [rdma_rxe] param_attr_store+0x5e/0xc0 module_attr_store+0x19/0x30 sysfs_kf_write+0x3d/0x50 kernfs_fop_write+0x116/0x1a0 __vfs_write+0x23/0x120 vfs_write+0xbe/0x1b0 SyS_write+0x44/0xa0 entry_SYSCALL_64_fastpath+0x23/0x9a The code should accept either a parent pointer or a fully specified DMA specification without producing warnings. Fixes: 99db9494035f ("IB/core: Remove ib_device.dma_device") Signed-off-by: Bart Van Assche Cc: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/device.c | 20 ++++++++++++++------ drivers/infiniband/core/sysfs.c | 1 - 2 files changed, 14 insertions(+), 7 deletions(-) --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -446,7 +446,6 @@ int ib_register_device(struct ib_device struct ib_udata uhw = {.outlen = 0, .inlen = 0}; struct device *parent = device->dev.parent; - WARN_ON_ONCE(!parent); WARN_ON_ONCE(device->dma_device); if (device->dev.dma_ops) { /* @@ -455,16 +454,25 @@ int ib_register_device(struct ib_device * into device->dev. */ device->dma_device = &device->dev; - if (!device->dev.dma_mask) - device->dev.dma_mask = parent->dma_mask; - if (!device->dev.coherent_dma_mask) - device->dev.coherent_dma_mask = - parent->coherent_dma_mask; + if (!device->dev.dma_mask) { + if (parent) + device->dev.dma_mask = parent->dma_mask; + else + WARN_ON_ONCE(true); + } + if (!device->dev.coherent_dma_mask) { + if (parent) + device->dev.coherent_dma_mask = + parent->coherent_dma_mask; + else + WARN_ON_ONCE(true); + } } else { /* * The caller did not provide custom DMA operations. Use the * DMA mapping operations of the parent device. */ + WARN_ON_ONCE(!parent); device->dma_device = parent; } --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -1262,7 +1262,6 @@ int ib_device_register_sysfs(struct ib_d int ret; int i; - WARN_ON_ONCE(!device->dev.parent); ret = dev_set_name(class_dev, "%s", device->name); if (ret) return ret;