]> git.ipfire.org Git - people/ms/linux.git/commitdiff
IB/rdmavt: Fix alloc_qpn() WARN_ON()
authorMike Marciniszyn <mike.marciniszyn@intel.com>
Fri, 24 May 2019 15:44:38 +0000 (11:44 -0400)
committerJason Gunthorpe <jgg@mellanox.com>
Wed, 29 May 2019 15:56:05 +0000 (12:56 -0300)
The qpn allocation logic has a WARN_ON() that intends to detect the use of
an index that will introduce bits in the lower order bits of the QOS bits
in the QPN.

Unfortunately, it has the following bugs:
- it misfires when wrapping QPN allocation for non-QOS
- it doesn't correctly detect low order QOS bits (despite the comment)

The WARN_ON() should not be applied to non-QOS (qos_shift == 1).

Additionally, it SHOULD test the qpn bits per the table below:

2 data VLs:   [qp7, qp6, qp5, qp4, qp3, qp2, qp1] ^
              [  0,   0,   0,   0,   0,   0, sc0],  qp bit 1 always 0*
3-4 data VLs: [qp7, qp6, qp5, qp4, qp3, qp2, qp1] ^
              [  0,   0,   0,   0,   0, sc1, sc0], qp bits [21] always 0
5-8 data VLs: [qp7, qp6, qp5, qp4, qp3, qp2, qp1] ^
              [  0,   0,   0,   0, sc2, sc1, sc0] qp bits [321] always 0

Fix by qualifying the warning for qos_shift > 1 and producing the correct
mask to insure the above bits are zero without generating a superfluous
warning.

Fixes: 501edc42446e ("IB/rdmavt: Correct warning during QPN allocation")
Reviewed-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/sw/rdmavt/qp.c

index 31a2e65e490614422fe13413635d3511b7750576..c5a50614a6c630b34a1ccbe6fea431b43bf04613 100644 (file)
@@ -594,7 +594,8 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
                        offset = qpt->incr | ((offset & 1) ^ 1);
                }
                /* there can be no set bits in low-order QoS bits */
-               WARN_ON(offset & (BIT(rdi->dparms.qos_shift) - 1));
+               WARN_ON(rdi->dparms.qos_shift > 1 &&
+                       offset & ((BIT(rdi->dparms.qos_shift - 1) - 1) << 1));
                qpn = mk_qpn(qpt, map, offset);
        }