public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/core: Fix two kernel warnings triggered by rxe registration
@ 2017-12-22 21:38 Bart Van Assche
  2017-12-25 10:28 ` Leon Romanovsky
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Van Assche @ 2017-12-22 21:38 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Doug Ledford, linux-rdma, Bart Van Assche, Leon Romanovsky,
	stable

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")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Leon Romanovsky <leon@kernel.org>
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
--- 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) {
 		/*
@@ -465,6 +464,7 @@ int ib_register_device(struct ib_device *device,
 		 * 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;
 	}
 
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index e30d86fa1855..8ae1308eecc7 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -1276,7 +1276,6 @@ int ib_device_register_sysfs(struct ib_device *device,
 	int ret;
 	int i;
 
-	WARN_ON_ONCE(!device->dev.parent);
 	ret = dev_set_name(class_dev, "%s", device->name);
 	if (ret)
 		return ret;
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] IB/core: Fix two kernel warnings triggered by rxe registration
  2017-12-22 21:38 [PATCH] IB/core: Fix two kernel warnings triggered by rxe registration Bart Van Assche
@ 2017-12-25 10:28 ` Leon Romanovsky
       [not found]   ` <20171225102839.GD2942-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2017-12-25 10:28 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Jason Gunthorpe, Doug Ledford, linux-rdma, stable

[-- Attachment #1: Type: text/plain, Size: 3410 bytes --]

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 <bart.vanassche@wdc.com>
> Cc: Leon Romanovsky <leon@kernel.org>
> 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
> --- 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) {

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.

>  		/*
> @@ -465,6 +464,7 @@ int ib_register_device(struct ib_device *device,
>  		 * 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;
>  	}
>
> diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
> index e30d86fa1855..8ae1308eecc7 100644
> --- a/drivers/infiniband/core/sysfs.c
> +++ b/drivers/infiniband/core/sysfs.c
> @@ -1276,7 +1276,6 @@ int ib_device_register_sysfs(struct ib_device *device,
>  	int ret;
>  	int i;
>
> -	WARN_ON_ONCE(!device->dev.parent);
>  	ret = dev_set_name(class_dev, "%s", device->name);
>  	if (ret)
>  		return ret;
> --
> 2.15.1
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] IB/core: Fix two kernel warnings triggered by rxe registration
       [not found]   ` <20171225102839.GD2942-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
@ 2017-12-27 22:56     ` Jason Gunthorpe
  2018-01-03 17:08       ` Bart Van Assche
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2017-12-27 22:56 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Bart Van Assche, Doug Ledford, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	stable-u79uwXL29TY76Z2rM5mHXA

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 <bart.vanassche-Sjgp3cTcYWE@public.gmane.org>
> > Cc: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> > Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.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?

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
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] IB/core: Fix two kernel warnings triggered by rxe registration
  2017-12-27 22:56     ` Jason Gunthorpe
@ 2018-01-03 17:08       ` Bart Van Assche
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2018-01-03 17:08 UTC (permalink / raw)
  To: jgg@ziepe.ca, leon@kernel.org
  Cc: linux-rdma@vger.kernel.org, stable@vger.kernel.org,
	dledford@redhat.com

On Wed, 2017-12-27 at 15:56 -0700, Jason Gunthorpe wrote:
> I'm a little more worried about the ib_device_register_sysfs - why was
> the WARN_ON ever there?

That WARN_ON() statement was introduced by commit 97a9ea848016 ("IB/core:
Initialize ib_device.dev.parent earlier"):

[ ... ]
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index c1fb545e8d78..daadf3130c9f 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -1258,7 +1258,7 @@ int ib_device_register_sysfs(struct ib_device *device,
        int ret;
        int i;
  
-       device->dev.parent = device->dma_device;
+       WARN_ON_ONCE(!device->dev.parent);
        ret = dev_set_name(class_dev, "%s", device->name);
        if (ret)
                return ret;
[ ... ]

Since ib_device_register_sysfs() does not use the parent pointer in any way
I think it is sufficient to check the parent pointer in ib_register_device()
and to leave out any parent pointer checks from ib_device_register_sysfs().

> What do you think about this as a clarification Bart?
> [ ... ]

OK, I will add a parent pointer check in the code paths that dereference that
pointer.

Bart.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-03 17:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-22 21:38 [PATCH] IB/core: Fix two kernel warnings triggered by rxe registration Bart Van Assche
2017-12-25 10:28 ` Leon Romanovsky
     [not found]   ` <20171225102839.GD2942-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-12-27 22:56     ` Jason Gunthorpe
2018-01-03 17:08       ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox