• Mike Marciniszyn's avatar
    IB/rdmavt: Fix alloc_qpn() WARN_ON() · 5a8810db
    Mike Marciniszyn authored
    [ Upstream commit 2abae62a ]
    
    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: 501edc42 ("IB/rdmavt: Correct warning during QPN allocation")
    Reviewed-by: default avatarKaike Wan <kaike.wan@intel.com>
    Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
    Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
    Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
    Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
    5a8810db
qp.c 78.8 KB