• Jason Gunthorpe's avatar
    RDMA/mlx5: Fix MR cache size and limit debugfs · a1d8854a
    Jason Gunthorpe authored
    The size_write function is supposed to adjust the total_mr's to match the
    user's request, but lacks locking and safety checking.
    
    total_mrs can only be adjusted by at most available_mrs. mrs already
    assigned to users cannot be revoked. Ensure that the user provides a
    target value within the range of available_mrs and within the high/low
    water mark.
    
    limit_write has confusing and wrong sanity checking, and doesn't have the
    ability to deallocate on limit reduction.
    
    Since both functions use the same algorithm to adjust the available_mrs,
    consolidate it into one function and write it correctly. Fix the locking
    and by holding the spinlock for all accesses to ent->X.
    
    Always fail if the user provides a malformed string.
    
    Fixes: e126ba97 ("mlx5: Add driver for Mellanox Connect-IB adapters")
    Link: https://lore.kernel.org/r/20200310082238.239865-9-leon@kernel.orgSigned-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
    Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
    a1d8854a
mr.c 58.8 KB