From patchwork Wed Dec 27 22:56:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10134113 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 A539A60318 for ; Wed, 27 Dec 2017 22:56:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E9F82C920 for ; Wed, 27 Dec 2017 22:56:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8317C2D479; Wed, 27 Dec 2017 22:56:57 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 3B3D32C920 for ; Wed, 27 Dec 2017 22:56:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752175AbdL0W4x (ORCPT ); Wed, 27 Dec 2017 17:56:53 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:44145 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751881AbdL0W4w (ORCPT ); Wed, 27 Dec 2017 17:56:52 -0500 Received: by mail-wm0-f68.google.com with SMTP id t8so41414995wmc.3 for ; Wed, 27 Dec 2017 14:56:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=lPMAuxeZ/jx89RaTEnlsFK1QX8Z1LUKhEeoBSDtSF+4=; b=Tf9B7AiVjB+EbmX6ra90NjWWOkKuNnjbdfOpG5p0a8yOEnUZwRPWO2O61z0iSuzjgP sQWgqxbTrz9kV01j0/+uh3V/jhb3x+kAW37JgMyBQjDR0wBl1UBd74am6KPd8IzMgKEd 1xgS7X66ALp4W5UjcC6wQmHITyX3BcCxAZ5Nl4CWZPGwQ+PTfxfnECeO8kdGFsjwIarw V9cXsjNyBvl/LSE55oaq6USvWRxi/MzGmGGwhSvqoEqhLoENQNKPXSLBaFMOOv2GPSac FDF+8EA4DC7cqvikd/tHQ8yS6wZW8H/yX430aQ3yh1LZq/7rbuhbGbwdqMBciVwgiTEa dQ6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=lPMAuxeZ/jx89RaTEnlsFK1QX8Z1LUKhEeoBSDtSF+4=; b=bYZ2vB3qfAPpEkxF+WoEhAIRb8aEIktui1phrfIszrA4f7Nsj0vPt4vY1sZ6mciKFC Rm637ilUhvPv38qx++i3SdhMW5xld09jOcDaU2pxVPb2KwLNQH/bYDufzfhOPQSTHPSI TaMKbD0QwCzwrUTTHgCC6cIjirq0cvw4WkDnPrXbxg21qnifzdGDYAkQS7zU5eEbGJ3n DyiSGJcABBIavxQFpvgiUKKaNC0qq/2e+tEiZKViok++ix7FywqO/u4bcOq8jyEtNY9+ LaRX/FjYDagPVPvJrJjJ2XlSX8FA7WWDKkQXPiwkkORbzSUwMkfHkxmb3M3jLvNr9BF/ 0Pxg== X-Gm-Message-State: AKGB3mKJLqhvKKNmuJ52Vnvt8BIEVY3P4ZR2h89Clu76JmpNWmLfHrTL J9XVv9OS6V46/bLOzZHXeb0l2g== X-Google-Smtp-Source: ACJfBosPtIDiIQGZ0JXW2WHy0qq9Jf6vNcHd74KzbLSTvQwBz7BHMaX5tjbwG5YHaegaAu4zUJVgPw== X-Received: by 10.28.108.3 with SMTP id h3mr22443055wmc.129.1514415411518; Wed, 27 Dec 2017 14:56:51 -0800 (PST) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [70.74.179.152]) by smtp.gmail.com with ESMTPSA id d7sm42823349wrd.54.2017.12.27.14.56.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Dec 2017 14:56:50 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1eUKcx-0000ki-Js; Wed, 27 Dec 2017 15:56:47 -0700 Date: Wed, 27 Dec 2017 15:56:47 -0700 From: Jason Gunthorpe To: Leon Romanovsky Cc: Bart Van Assche , Doug Ledford , linux-rdma@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] IB/core: Fix two kernel warnings triggered by rxe registration Message-ID: <20171227225647.GJ25436@ziepe.ca> References: <20171222213852.3481-1-bart.vanassche@wdc.com> <20171225102839.GD2942@mtr-leonro.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171225102839.GD2942@mtr-leonro.local> User-Agent: Mutt/1.5.24 (2015-08-30) 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 On Mon, Dec 25, 2017 at 12:28:39PM +0200, Leon Romanovsky wrote: > On Fri, Dec 22, 2017 at 01:38:52PM -0800, Bart Van Assche wrote: > > Avoid that the following two warnings are reported 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 > > > > Fixes: commit 99db9494035f ("IB/core: Remove ib_device.dma_device") > > ^^^^^^ redundant > > > Signed-off-by: Bart Van Assche > > Cc: Leon Romanovsky > > Cc: stable@vger.kernel.org # v4.11 > > drivers/infiniband/core/device.c | 2 +- > > drivers/infiniband/core/sysfs.c | 1 - > > 2 files changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c > > index 30914f3baa5f..b9d7570e9989 100644 > > +++ b/drivers/infiniband/core/device.c > > @@ -446,7 +446,6 @@ int ib_register_device(struct ib_device *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) { > > I understand that it fixed warning for you, but why is it correct? > You are using "parent" in this "if (device->dev.dma_ops)" too. If no parent is specified then the caller must provide a full set of DMA data and none should be copied from the parent. Presumably rxe does this, and has no parent because it is a virtual device. I'm a little more worried about the ib_device_register_sysfs - why was the WARN_ON ever there? What do you think about this as a clarification Bart? the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index bb2686d56d3c65..c535c7803d80a7 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -446,7 +446,6 @@ int ib_register_device(struct ib_device *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,20 @@ int ib_register_device(struct ib_device *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 (parent) { + 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; + } } 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; } -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in