Skip to content

Commit 167b95e

Browse files
committed
RDMA/ucma: Use refcount_t for the ctx->ref
Don't use an atomic as a refcount. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent b72bfc9 commit 167b95e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/infiniband/core/ucma.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct ucma_file {
8585
struct ucma_context {
8686
u32 id;
8787
struct completion comp;
88-
atomic_t ref;
88+
refcount_t ref;
8989
int events_reported;
9090
int backlog;
9191

@@ -152,15 +152,15 @@ static struct ucma_context *ucma_get_ctx(struct ucma_file *file, int id)
152152
if (ctx->closing)
153153
ctx = ERR_PTR(-EIO);
154154
else
155-
atomic_inc(&ctx->ref);
155+
refcount_inc(&ctx->ref);
156156
}
157157
xa_unlock(&ctx_table);
158158
return ctx;
159159
}
160160

161161
static void ucma_put_ctx(struct ucma_context *ctx)
162162
{
163-
if (atomic_dec_and_test(&ctx->ref))
163+
if (refcount_dec_and_test(&ctx->ref))
164164
complete(&ctx->comp);
165165
}
166166

@@ -212,7 +212,7 @@ static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file)
212212
return NULL;
213213

214214
INIT_WORK(&ctx->close_work, ucma_close_id);
215-
atomic_set(&ctx->ref, 1);
215+
refcount_set(&ctx->ref, 1);
216216
init_completion(&ctx->comp);
217217
INIT_LIST_HEAD(&ctx->mc_list);
218218
ctx->file = file;
@@ -1502,7 +1502,7 @@ static ssize_t ucma_leave_multicast(struct ucma_file *file,
15021502
mc = ERR_PTR(-ENOENT);
15031503
else if (mc->ctx->file != file)
15041504
mc = ERR_PTR(-EINVAL);
1505-
else if (!atomic_inc_not_zero(&mc->ctx->ref))
1505+
else if (!refcount_inc_not_zero(&mc->ctx->ref))
15061506
mc = ERR_PTR(-ENXIO);
15071507
else
15081508
__xa_erase(&multicast_table, mc->id);

0 commit comments

Comments
 (0)