IB: Improve uverbs_cleanup_ucontext algorithm
commit1c77483e4c50339b0306572167ccbff6b55d051b
authorYishai Hadas <yishaih@mellanox.com>
Wed, 20 Jun 2018 14:11:39 +0000 (20 17:11 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Fri, 29 Jun 2018 20:35:46 +0000 (29 14:35 -0600)
tree3d7396f283f4d903364c949a9d133dfda1c6aebf
parente620ebfc228dcbef7519e3d16f43c6c6f1a1d0cb
IB: Improve uverbs_cleanup_ucontext algorithm

Improve uverbs_cleanup_ucontext algorithm to work properly when the
topology graph of the objects cannot be determined at compile time.  This
is the case with objects created via the devx interface in mlx5.

Typically uverbs objects must be created in a strict topologically sorted
order, so that LIFO ordering will generally cause them to be freed
properly. There are only a few cases (eg memory windows) where objects can
point to things out of the strict LIFO order.

Instead of using an explicit ordering scheme where the HW destroy is not
allowed to fail, go over the list multiple times and allow the destroy
function to fail. If progress halts then a final, desperate, cleanup is
done before leaking the memory. This indicates a driver bug.

Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
12 files changed:
drivers/infiniband/core/rdma_core.c
drivers/infiniband/core/uverbs.h
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/core/uverbs_std_types.c
drivers/infiniband/core/uverbs_std_types_counters.c
drivers/infiniband/core/uverbs_std_types_cq.c
drivers/infiniband/core/uverbs_std_types_dm.c
drivers/infiniband/core/uverbs_std_types_flow_action.c
drivers/infiniband/core/uverbs_std_types_mr.c
drivers/infiniband/hw/mlx5/devx.c
include/rdma/ib_verbs.h
include/rdma/uverbs_types.h