Skip to content

Commit 93887e6

Browse files
committed
RDMA/mlx5: Simplify devx async commands
With the new FD structure the async commands do not need to hold any references while running. The existing mlx5_cmd_exec_cb() and mlx5_cmd_cleanup_async_ctx() provide enough synchronization to ensure that all outstanding commands are completed before the uobject can be destructed. Remove the now confusing get_file() and the type erasure of the devx_async_cmd_event_file. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Yishai Hadas <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent f7c8416 commit 93887e6

File tree

1 file changed

+10
-14
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+10
-14
lines changed

drivers/infiniband/hw/mlx5/devx.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ enum devx_obj_flags {
3030
struct devx_async_data {
3131
struct mlx5_ib_dev *mdev;
3232
struct list_head list;
33-
struct ib_uobject *fd_uobj;
33+
struct devx_async_cmd_event_file *ev_file;
3434
struct mlx5_async_work cb_work;
3535
u16 cmd_out_len;
3636
/* must be last field in this structure */
@@ -1673,21 +1673,20 @@ static void devx_query_callback(int status, struct mlx5_async_work *context)
16731673
{
16741674
struct devx_async_data *async_data =
16751675
container_of(context, struct devx_async_data, cb_work);
1676-
struct ib_uobject *fd_uobj = async_data->fd_uobj;
1677-
struct devx_async_cmd_event_file *ev_file;
1678-
struct devx_async_event_queue *ev_queue;
1676+
struct devx_async_cmd_event_file *ev_file = async_data->ev_file;
1677+
struct devx_async_event_queue *ev_queue = &ev_file->ev_queue;
16791678
unsigned long flags;
16801679

1681-
ev_file = container_of(fd_uobj, struct devx_async_cmd_event_file,
1682-
uobj);
1683-
ev_queue = &ev_file->ev_queue;
1684-
1680+
/*
1681+
* Note that if the struct devx_async_cmd_event_file uobj begins to be
1682+
* destroyed it will block at mlx5_cmd_cleanup_async_ctx() until this
1683+
* routine returns, ensuring that it always remains valid here.
1684+
*/
16851685
spin_lock_irqsave(&ev_queue->lock, flags);
16861686
list_add_tail(&async_data->list, &ev_queue->event_list);
16871687
spin_unlock_irqrestore(&ev_queue->lock, flags);
16881688

16891689
wake_up_interruptible(&ev_queue->poll_wait);
1690-
fput(fd_uobj->object);
16911690
}
16921691

16931692
#define MAX_ASYNC_BYTES_IN_USE (1024 * 1024) /* 1MB */
@@ -1756,9 +1755,8 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_ASYNC_QUERY)(
17561755

17571756
async_data->cmd_out_len = cmd_out_len;
17581757
async_data->mdev = mdev;
1759-
async_data->fd_uobj = fd_uobj;
1758+
async_data->ev_file = ev_file;
17601759

1761-
get_file(fd_uobj->object);
17621760
MLX5_SET(general_obj_in_cmd_hdr, cmd_in, uid, uid);
17631761
err = mlx5_cmd_exec_cb(&ev_file->async_ctx, cmd_in,
17641762
uverbs_attr_get_len(attrs,
@@ -1768,12 +1766,10 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_ASYNC_QUERY)(
17681766
devx_query_callback, &async_data->cb_work);
17691767

17701768
if (err)
1771-
goto cb_err;
1769+
goto free_async;
17721770

17731771
return 0;
17741772

1775-
cb_err:
1776-
fput(fd_uobj->object);
17771773
free_async:
17781774
kvfree(async_data);
17791775
sub_bytes:

0 commit comments

Comments
 (0)