]> git.baikalelectronics.ru Git - kernel.git/commit
IB/hfi1: Acquire lock to release TID entries when user file is closed
authorKaike Wan <kaike.wan@intel.com>
Mon, 10 Feb 2020 13:10:26 +0000 (08:10 -0500)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 11 Feb 2020 15:41:31 +0000 (11:41 -0400)
commit194227d44a9186f323b88575d494899f5b3a4203
tree536ab7b9d4e3d89d567008abac3ca2d444229c6f
parenta9eb0348e63f1280d7febe850167ff0588726371
IB/hfi1: Acquire lock to release TID entries when user file is closed

Each user context is allocated a certain number of RcvArray (TID)
entries and these entries are managed through TID groups. These groups
are put into one of three lists in each user context: tid_group_list,
tid_used_list, and tid_full_list, depending on the number of used TID
entries within each group. When TID packets are expected, one or more
TID groups will be allocated. After the packets are received, the TID
groups will be freed. Since multiple user threads may access the TID
groups simultaneously, a mutex exp_mutex is used to synchronize the
access. However, when the user file is closed, it tries to release
all TID groups without acquiring the mutex first, which risks a race
condition with another thread that may be releasing its TID groups,
leading to data corruption.

This patch addresses the issue by acquiring the mutex first before
releasing the TID groups when the file is closed.

Fixes: 2609843f393f ("staging/hfi1: Add TID cache receive init and free funcs")
Link: https://lore.kernel.org/r/20200210131026.87408.86853.stgit@awfm-01.aw.intel.com
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/hw/hfi1/user_exp_rcv.c