linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rdma-rc 0/3] Fixes for 5.5
@ 2019-12-12  9:12 Leon Romanovsky
  2019-12-12  9:12 ` [PATCH rdma-rc 1/3] RDMA/counter: Prevent auto-binding a QP which are not tracked with res Leon Romanovsky
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Leon Romanovsky @ 2019-12-12  9:12 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Eli Cohen, Ido Kalir,
	Maor Gottlieb, Mark Zhang, Parav Pandit, Raed Salem

From: Leon Romanovsky <leonro@mellanox.com>

Hi,

Three unrelated fixes packed together.

Thanks

Maor Gottlieb (1):
  IB/mlx5: Fix steering rule of drop and count

Mark Zhang (1):
  RDMA/counter: Prevent auto-binding a QP which are not tracked with res

Parav Pandit (1):
  IB/mlx4: Follow mirror sequence of device add during device removal

 drivers/infiniband/core/counters.c |  3 +++
 drivers/infiniband/hw/mlx4/main.c  |  9 +++++----
 drivers/infiniband/hw/mlx5/main.c  | 13 ++++++-------
 3 files changed, 14 insertions(+), 11 deletions(-)

--
2.20.1


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

* [PATCH rdma-rc 1/3] RDMA/counter: Prevent auto-binding a QP which are not tracked with res
  2019-12-12  9:12 [PATCH rdma-rc 0/3] Fixes for 5.5 Leon Romanovsky
@ 2019-12-12  9:12 ` Leon Romanovsky
  2019-12-12  9:12 ` [PATCH rdma-rc 2/3] IB/mlx4: Follow mirror sequence of device add during device removal Leon Romanovsky
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Leon Romanovsky @ 2019-12-12  9:12 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Eli Cohen, Ido Kalir,
	Maor Gottlieb, Mark Zhang, Parav Pandit, Raed Salem

From: Mark Zhang <markz@mellanox.com>

Some QPs (e.g. XRC QP) are not tracked in kernel, in this case they have
an invalid res and should not be bound to any dynamically-allocated
counter in auto mode.

This fixes below call trace:
BUG: kernel NULL pointer dereference, address: 0000000000000390
PGD 80000001a7233067 P4D 80000001a7233067 PUD 1a7215067 PMD 0
Oops: 0000 [#1] SMP PTI
CPU: 2 PID: 24822 Comm: ibv_xsrq_pingpo Not tainted 5.4.0-rc5+ #21
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-2.fc27 04/01/2014
RIP: 0010:rdma_counter_bind_qp_auto+0x142/0x270 [ib_core]
Code: e1 48 85 c0 48 89 c2 0f 84 bc 00 00 00 49 8b 06 48 39 42 48 75 d6 40 3a aa 90 00 00 00 75 cd 49 8b 86 00 01 00 00 48 8b 4a 28 <8b> 80 90 03 00 00 39 81 90 03 00 00 75 b4 85 c0 74 b0 48 8b 04 24
RSP: 0018:ffffc900003f39c0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000000
RDX: ffff88820020ec00 RSI: 0000000000000004 RDI: ffffffffffffffc0
RBP: 0000000000000001 R08: ffff888224149ff0 R09: ffffc900003f3968
R10: ffffffffffffffff R11: ffff8882249c5848 R12: ffffffffffffffff
R13: ffff88821d5aca50 R14: ffff8881f7690800 R15: ffff8881ff890000
FS:  00007fe53a3e1740(0000) GS:ffff888237b00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000390 CR3: 00000001a7292006 CR4: 00000000003606a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 _ib_modify_qp+0x3a4/0x3f0 [ib_core]
 ? lookup_get_idr_uobject.part.8+0x23/0x40 [ib_uverbs]
 modify_qp+0x322/0x3e0 [ib_uverbs]
 ib_uverbs_modify_qp+0x43/0x70 [ib_uverbs]
 ib_uverbs_handler_UVERBS_METHOD_INVOKE_WRITE+0xb1/0xf0 [ib_uverbs]
 ib_uverbs_run_method+0x6be/0x760 [ib_uverbs]
 ? uverbs_disassociate_api+0xd0/0xd0 [ib_uverbs]
 ib_uverbs_cmd_verbs+0x18d/0x3a0 [ib_uverbs]
 ? get_acl+0x1a/0x120
 ? __alloc_pages_nodemask+0x15d/0x2c0
 ib_uverbs_ioctl+0xa7/0x110 [ib_uverbs]
 do_vfs_ioctl+0xa5/0x610
 ksys_ioctl+0x60/0x90
 __x64_sys_ioctl+0x16/0x20
 do_syscall_64+0x48/0x110
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fixes: 99fa331dc862 ("RDMA/counter: Add "auto" configuration mode support")
Signed-off-by: Mark Zhang <markz@mellanox.com>
Reviewed-by: Maor Gottlieb <maorg@mellanox.com>
Reviewed-by: Ido Kalir <idok@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/core/counters.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/infiniband/core/counters.c b/drivers/infiniband/core/counters.c
index 8434ec082c3a..2257d7f7810f 100644
--- a/drivers/infiniband/core/counters.c
+++ b/drivers/infiniband/core/counters.c
@@ -286,6 +286,9 @@ int rdma_counter_bind_qp_auto(struct ib_qp *qp, u8 port)
 	struct rdma_counter *counter;
 	int ret;
 
+	if (!qp->res.valid)
+		return 0;
+
 	if (!rdma_is_port_valid(dev, port))
 		return -EINVAL;
 
-- 
2.20.1


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

* [PATCH rdma-rc 2/3] IB/mlx4: Follow mirror sequence of device add during device removal
  2019-12-12  9:12 [PATCH rdma-rc 0/3] Fixes for 5.5 Leon Romanovsky
  2019-12-12  9:12 ` [PATCH rdma-rc 1/3] RDMA/counter: Prevent auto-binding a QP which are not tracked with res Leon Romanovsky
@ 2019-12-12  9:12 ` Leon Romanovsky
  2019-12-12  9:12 ` [PATCH rdma-rc 3/3] IB/mlx5: Fix steering rule of drop and count Leon Romanovsky
  2019-12-12 20:40 ` [PATCH rdma-rc 0/3] Fixes for 5.5 Doug Ledford
  3 siblings, 0 replies; 5+ messages in thread
From: Leon Romanovsky @ 2019-12-12  9:12 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Eli Cohen, Ido Kalir,
	Maor Gottlieb, Mark Zhang, Parav Pandit, Raed Salem

From: Parav Pandit <parav@mellanox.com>

Current code device add sequence is:

ib_register_device()
ib_mad_init()
init_sriov_init()
register_netdev_notifier()

Therefore, the remove sequence should be,

unregister_netdev_notifier()
close_sriov()
mad_cleanup()
ib_unregister_device()

However it is not above.
Hence, make do above remove sequence.

Fixes: fa417f7b520ee ("IB/mlx4: Add support for IBoE")
Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx4/main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 0b5dc1d5928f..34055cbab38c 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -3018,16 +3018,17 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr)
 	ibdev->ib_active = false;
 	flush_workqueue(wq);
 
-	mlx4_ib_close_sriov(ibdev);
-	mlx4_ib_mad_cleanup(ibdev);
-	ib_unregister_device(&ibdev->ib_dev);
-	mlx4_ib_diag_cleanup(ibdev);
 	if (ibdev->iboe.nb.notifier_call) {
 		if (unregister_netdevice_notifier(&ibdev->iboe.nb))
 			pr_warn("failure unregistering notifier\n");
 		ibdev->iboe.nb.notifier_call = NULL;
 	}
 
+	mlx4_ib_close_sriov(ibdev);
+	mlx4_ib_mad_cleanup(ibdev);
+	ib_unregister_device(&ibdev->ib_dev);
+	mlx4_ib_diag_cleanup(ibdev);
+
 	mlx4_qp_release_range(dev, ibdev->steer_qpn_base,
 			      ibdev->steer_qpn_count);
 	kfree(ibdev->ib_uc_qpns_bitmap);
-- 
2.20.1


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

* [PATCH rdma-rc 3/3] IB/mlx5: Fix steering rule of drop and count
  2019-12-12  9:12 [PATCH rdma-rc 0/3] Fixes for 5.5 Leon Romanovsky
  2019-12-12  9:12 ` [PATCH rdma-rc 1/3] RDMA/counter: Prevent auto-binding a QP which are not tracked with res Leon Romanovsky
  2019-12-12  9:12 ` [PATCH rdma-rc 2/3] IB/mlx4: Follow mirror sequence of device add during device removal Leon Romanovsky
@ 2019-12-12  9:12 ` Leon Romanovsky
  2019-12-12 20:40 ` [PATCH rdma-rc 0/3] Fixes for 5.5 Doug Ledford
  3 siblings, 0 replies; 5+ messages in thread
From: Leon Romanovsky @ 2019-12-12  9:12 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Eli Cohen, Ido Kalir,
	Maor Gottlieb, Mark Zhang, Parav Pandit, Raed Salem

From: Maor Gottlieb <maorg@mellanox.com>

There are two flow rule destinations: QP and packet. While users are
setting DROP packet rule, the QP should not be set as a destination.

Fixes: 3b3233fbf02e ("IB/mlx5: Add flow counters binding support")
Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Reviewed-by: Raed Salem <raeds@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx5/main.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 51100350b688..2f5a159cbe1c 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -3544,10 +3544,6 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
 	}
 
 	INIT_LIST_HEAD(&handler->list);
-	if (dst) {
-		memcpy(&dest_arr[0], dst, sizeof(*dst));
-		dest_num++;
-	}
 
 	for (spec_index = 0; spec_index < flow_attr->num_of_specs; spec_index++) {
 		err = parse_flow_attr(dev->mdev, spec,
@@ -3560,6 +3556,11 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
 		ib_flow += ((union ib_flow_spec *)ib_flow)->size;
 	}
 
+	if (dst && !(flow_act.action & MLX5_FLOW_CONTEXT_ACTION_DROP)) {
+		memcpy(&dest_arr[0], dst, sizeof(*dst));
+		dest_num++;
+	}
+
 	if (!flow_is_multicast_only(flow_attr))
 		set_underlay_qp(dev, spec, underlay_qpn);
 
@@ -3600,10 +3601,8 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
 	}
 
 	if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_DROP) {
-		if (!(flow_act.action & MLX5_FLOW_CONTEXT_ACTION_COUNT)) {
+		if (!dest_num)
 			rule_dst = NULL;
-			dest_num = 0;
-		}
 	} else {
 		if (is_egress)
 			flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_ALLOW;
-- 
2.20.1


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

* Re: [PATCH rdma-rc 0/3] Fixes for 5.5
  2019-12-12  9:12 [PATCH rdma-rc 0/3] Fixes for 5.5 Leon Romanovsky
                   ` (2 preceding siblings ...)
  2019-12-12  9:12 ` [PATCH rdma-rc 3/3] IB/mlx5: Fix steering rule of drop and count Leon Romanovsky
@ 2019-12-12 20:40 ` Doug Ledford
  3 siblings, 0 replies; 5+ messages in thread
From: Doug Ledford @ 2019-12-12 20:40 UTC (permalink / raw)
  To: Leon Romanovsky, Jason Gunthorpe
  Cc: Leon Romanovsky, RDMA mailing list, Eli Cohen, Ido Kalir,
	Maor Gottlieb, Mark Zhang, Parav Pandit, Raed Salem

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

On Thu, 2019-12-12 at 11:12 +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
> 
> Hi,
> 
> Three unrelated fixes packed together.
> 
> Thanks
> 
> Maor Gottlieb (1):
>   IB/mlx5: Fix steering rule of drop and count
> 
> Mark Zhang (1):
>   RDMA/counter: Prevent auto-binding a QP which are not tracked with
> res
> 
> Parav Pandit (1):
>   IB/mlx4: Follow mirror sequence of device add during device removal
> 
>  drivers/infiniband/core/counters.c |  3 +++
>  drivers/infiniband/hw/mlx4/main.c  |  9 +++++----
>  drivers/infiniband/hw/mlx5/main.c  | 13 ++++++-------
>  3 files changed, 14 insertions(+), 11 deletions(-)
> 
> --
> 2.20.1
> 

Thanks, applied to for-rc.

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
    Fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2019-12-12 20:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-12  9:12 [PATCH rdma-rc 0/3] Fixes for 5.5 Leon Romanovsky
2019-12-12  9:12 ` [PATCH rdma-rc 1/3] RDMA/counter: Prevent auto-binding a QP which are not tracked with res Leon Romanovsky
2019-12-12  9:12 ` [PATCH rdma-rc 2/3] IB/mlx4: Follow mirror sequence of device add during device removal Leon Romanovsky
2019-12-12  9:12 ` [PATCH rdma-rc 3/3] IB/mlx5: Fix steering rule of drop and count Leon Romanovsky
2019-12-12 20:40 ` [PATCH rdma-rc 0/3] Fixes for 5.5 Doug Ledford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).