]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/ib-rdmavt-fix-alloc_qpn-warn_on.patch
Linux 4.19.56
[thirdparty/kernel/stable-queue.git] / queue-4.14 / ib-rdmavt-fix-alloc_qpn-warn_on.patch
1 From 66d7aab68c302abb0e8511eaabd722964a681fb7 Mon Sep 17 00:00:00 2001
2 From: Mike Marciniszyn <mike.marciniszyn@intel.com>
3 Date: Fri, 24 May 2019 11:44:38 -0400
4 Subject: IB/rdmavt: Fix alloc_qpn() WARN_ON()
5
6 [ Upstream commit 2abae62a26a265129b364d8c1ef3be55e2c01309 ]
7
8 The qpn allocation logic has a WARN_ON() that intends to detect the use of
9 an index that will introduce bits in the lower order bits of the QOS bits
10 in the QPN.
11
12 Unfortunately, it has the following bugs:
13 - it misfires when wrapping QPN allocation for non-QOS
14 - it doesn't correctly detect low order QOS bits (despite the comment)
15
16 The WARN_ON() should not be applied to non-QOS (qos_shift == 1).
17
18 Additionally, it SHOULD test the qpn bits per the table below:
19
20 2 data VLs: [qp7, qp6, qp5, qp4, qp3, qp2, qp1] ^
21 [ 0, 0, 0, 0, 0, 0, sc0], qp bit 1 always 0*
22 3-4 data VLs: [qp7, qp6, qp5, qp4, qp3, qp2, qp1] ^
23 [ 0, 0, 0, 0, 0, sc1, sc0], qp bits [21] always 0
24 5-8 data VLs: [qp7, qp6, qp5, qp4, qp3, qp2, qp1] ^
25 [ 0, 0, 0, 0, sc2, sc1, sc0] qp bits [321] always 0
26
27 Fix by qualifying the warning for qos_shift > 1 and producing the correct
28 mask to insure the above bits are zero without generating a superfluous
29 warning.
30
31 Fixes: 501edc42446e ("IB/rdmavt: Correct warning during QPN allocation")
32 Reviewed-by: Kaike Wan <kaike.wan@intel.com>
33 Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
34 Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
35 Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
36 Signed-off-by: Sasha Levin <sashal@kernel.org>
37 ---
38 drivers/infiniband/sw/rdmavt/qp.c | 3 ++-
39 1 file changed, 2 insertions(+), 1 deletion(-)
40
41 diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
42 index 22df09ae809e..b0309876f4bb 100644
43 --- a/drivers/infiniband/sw/rdmavt/qp.c
44 +++ b/drivers/infiniband/sw/rdmavt/qp.c
45 @@ -412,7 +412,8 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
46 offset = qpt->incr | ((offset & 1) ^ 1);
47 }
48 /* there can be no set bits in low-order QoS bits */
49 - WARN_ON(offset & (BIT(rdi->dparms.qos_shift) - 1));
50 + WARN_ON(rdi->dparms.qos_shift > 1 &&
51 + offset & ((BIT(rdi->dparms.qos_shift - 1) - 1) << 1));
52 qpn = mk_qpn(qpt, map, offset);
53 }
54
55 --
56 2.20.1
57