aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/restrack.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-03-11 20:06:18 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2019-03-11 20:06:18 -0700
commitea295481b6e313b4ea3ca2720ffcafd6005b5643 (patch)
tree85cade73987615fb5d86acdf2c7eac0a0378e255 /drivers/infiniband/core/restrack.c
parentMerge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu (diff)
parentXArray: Fix xa_reserve for 2-byte aligned entries (diff)
downloadlinux-dev-ea295481b6e313b4ea3ca2720ffcafd6005b5643.tar.xz
linux-dev-ea295481b6e313b4ea3ca2720ffcafd6005b5643.zip
Merge tag 'xarray-5.1-rc1' of git://git.infradead.org/users/willy/linux-dax
Pull XArray updates from Matthew Wilcox: "This pull request changes the xa_alloc() API. I'm only aware of one subsystem that has started trying to use it, and we agree on the fixup as part of the merge. The xa_insert() error code also changed to match xa_alloc() (EEXIST to EBUSY), and I added xa_alloc_cyclic(). Beyond that, the usual bugfixes, optimisations and tweaking. I now have a git tree with all users of the radix tree and IDR converted over to the XArray that I'll be feeding to maintainers over the next few weeks" * tag 'xarray-5.1-rc1' of git://git.infradead.org/users/willy/linux-dax: XArray: Fix xa_reserve for 2-byte aligned entries XArray: Fix xa_erase of 2-byte aligned entries XArray: Use xa_cmpxchg to implement xa_reserve XArray: Fix xa_release in allocating arrays XArray: Mark xa_insert and xa_reserve as must_check XArray: Add cyclic allocation XArray: Redesign xa_alloc API XArray: Add support for 1s-based allocation XArray: Change xa_insert to return -EBUSY XArray: Update xa_erase family descriptions XArray tests: RCU lock prohibits GFP_KERNEL
Diffstat (limited to 'drivers/infiniband/core/restrack.c')
-rw-r--r--drivers/infiniband/core/restrack.c25
1 files changed, 2 insertions, 23 deletions
diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c
index fa804093fafb..3b5ff2f7b5f8 100644
--- a/drivers/infiniband/core/restrack.c
+++ b/drivers/infiniband/core/restrack.c
@@ -13,28 +13,6 @@
#include "cma_priv.h"
#include "restrack.h"
-static int rt_xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry,
- u32 *next)
-{
- int err;
-
- *id = *next;
- if (*next == U32_MAX)
- *id = 0;
-
- xa_lock(xa);
- err = __xa_alloc(xa, id, U32_MAX, entry, GFP_KERNEL);
- if (err && *next != U32_MAX) {
- *id = 0;
- err = __xa_alloc(xa, id, *next, entry, GFP_KERNEL);
- }
-
- if (!err)
- *next = *id + 1;
- xa_unlock(xa);
- return err;
-}
-
/**
* rdma_restrack_init() - initialize and allocate resource tracking
* @dev: IB device
@@ -226,7 +204,8 @@ static void rdma_restrack_add(struct rdma_restrack_entry *res)
kref_init(&res->kref);
init_completion(&res->comp);
if (res->type != RDMA_RESTRACK_QP)
- ret = rt_xa_alloc_cyclic(&rt->xa, &res->id, res, &rt->next_id);
+ ret = xa_alloc_cyclic(&rt->xa, &res->id, res, xa_limit_32b,
+ &rt->next_id, GFP_KERNEL);
else {
/* Special case to ensure that LQPN points to right QP */
struct ib_qp *qp = container_of(res, struct ib_qp, res);