Skip to content

Commit 09aa2ec

Browse files
Leon Romanovskygregkh
authored andcommitted
RDMA: Restore ability to return error for destroy WQ
[ Upstream commit add5353 ] Make this interface symmetrical to other destroy paths. Fixes: a49b1dc ("RDMA: Convert destroy_wq to be void") Link: https://lore.kernel.org/r/20200907120921.476363-9-leon@kernel.org Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7c2f769 commit 09aa2ec

9 files changed

Lines changed: 27 additions & 18 deletions

File tree

drivers/infiniband/core/uverbs_std_types_wq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static int uverbs_free_wq(struct ib_uobject *uobject,
1616
container_of(uobject, struct ib_uwq_object, uevent.uobject);
1717
int ret;
1818

19-
ret = ib_destroy_wq(wq, &attrs->driver_udata);
19+
ret = ib_destroy_wq_user(wq, &attrs->driver_udata);
2020
if (ib_is_destroy_retryable(ret, why, uobject))
2121
return ret;
2222

drivers/infiniband/core/verbs.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,25 +2387,28 @@ struct ib_wq *ib_create_wq(struct ib_pd *pd,
23872387
EXPORT_SYMBOL(ib_create_wq);
23882388

23892389
/**
2390-
* ib_destroy_wq - Destroys the specified user WQ.
2390+
* ib_destroy_wq_user - Destroys the specified user WQ.
23912391
* @wq: The WQ to destroy.
23922392
* @udata: Valid user data
23932393
*/
2394-
int ib_destroy_wq(struct ib_wq *wq, struct ib_udata *udata)
2394+
int ib_destroy_wq_user(struct ib_wq *wq, struct ib_udata *udata)
23952395
{
23962396
struct ib_cq *cq = wq->cq;
23972397
struct ib_pd *pd = wq->pd;
2398+
int ret;
23982399

23992400
if (atomic_read(&wq->usecnt))
24002401
return -EBUSY;
24012402

2402-
wq->device->ops.destroy_wq(wq, udata);
2403+
ret = wq->device->ops.destroy_wq(wq, udata);
2404+
if (ret)
2405+
return ret;
2406+
24032407
atomic_dec(&pd->usecnt);
24042408
atomic_dec(&cq->usecnt);
2405-
2406-
return 0;
2409+
return ret;
24072410
}
2408-
EXPORT_SYMBOL(ib_destroy_wq);
2411+
EXPORT_SYMBOL(ib_destroy_wq_user);
24092412

24102413
/**
24112414
* ib_modify_wq - Modifies the specified WQ.

drivers/infiniband/hw/mlx4/mlx4_ib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ void mlx4_ib_sl2vl_update(struct mlx4_ib_dev *mdev, int port);
892892
struct ib_wq *mlx4_ib_create_wq(struct ib_pd *pd,
893893
struct ib_wq_init_attr *init_attr,
894894
struct ib_udata *udata);
895-
void mlx4_ib_destroy_wq(struct ib_wq *wq, struct ib_udata *udata);
895+
int mlx4_ib_destroy_wq(struct ib_wq *wq, struct ib_udata *udata);
896896
int mlx4_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
897897
u32 wq_attr_mask, struct ib_udata *udata);
898898

drivers/infiniband/hw/mlx4/qp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4327,7 +4327,7 @@ int mlx4_ib_modify_wq(struct ib_wq *ibwq, struct ib_wq_attr *wq_attr,
43274327
return err;
43284328
}
43294329

4330-
void mlx4_ib_destroy_wq(struct ib_wq *ibwq, struct ib_udata *udata)
4330+
int mlx4_ib_destroy_wq(struct ib_wq *ibwq, struct ib_udata *udata)
43314331
{
43324332
struct mlx4_ib_dev *dev = to_mdev(ibwq->device);
43334333
struct mlx4_ib_qp *qp = to_mqp((struct ib_qp *)ibwq);
@@ -4338,6 +4338,7 @@ void mlx4_ib_destroy_wq(struct ib_wq *ibwq, struct ib_udata *udata)
43384338
destroy_qp_common(dev, qp, MLX4_IB_RWQ_SRC, udata);
43394339

43404340
kfree(qp);
4341+
return 0;
43414342
}
43424343

43434344
struct ib_rwq_ind_table

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask,
12381238
struct ib_wq *mlx5_ib_create_wq(struct ib_pd *pd,
12391239
struct ib_wq_init_attr *init_attr,
12401240
struct ib_udata *udata);
1241-
void mlx5_ib_destroy_wq(struct ib_wq *wq, struct ib_udata *udata);
1241+
int mlx5_ib_destroy_wq(struct ib_wq *wq, struct ib_udata *udata);
12421242
int mlx5_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
12431243
u32 wq_attr_mask, struct ib_udata *udata);
12441244
struct ib_rwq_ind_table *mlx5_ib_create_rwq_ind_table(struct ib_device *device,

drivers/infiniband/hw/mlx5/qp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5056,14 +5056,18 @@ struct ib_wq *mlx5_ib_create_wq(struct ib_pd *pd,
50565056
return ERR_PTR(err);
50575057
}
50585058

5059-
void mlx5_ib_destroy_wq(struct ib_wq *wq, struct ib_udata *udata)
5059+
int mlx5_ib_destroy_wq(struct ib_wq *wq, struct ib_udata *udata)
50605060
{
50615061
struct mlx5_ib_dev *dev = to_mdev(wq->device);
50625062
struct mlx5_ib_rwq *rwq = to_mrwq(wq);
5063+
int ret;
50635064

5064-
mlx5_core_destroy_rq_tracked(dev, &rwq->core_qp);
5065+
ret = mlx5_core_destroy_rq_tracked(dev, &rwq->core_qp);
5066+
if (ret)
5067+
return ret;
50655068
destroy_user_rq(dev, wq->pd, rwq, udata);
50665069
kfree(rwq);
5070+
return 0;
50675071
}
50685072

50695073
struct ib_rwq_ind_table *mlx5_ib_create_rwq_ind_table(struct ib_device *device,

drivers/infiniband/hw/mlx5/qp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ int mlx5_core_dct_query(struct mlx5_ib_dev *dev, struct mlx5_core_dct *dct,
2626

2727
int mlx5_core_set_delay_drop(struct mlx5_ib_dev *dev, u32 timeout_usec);
2828

29-
void mlx5_core_destroy_rq_tracked(struct mlx5_ib_dev *dev,
30-
struct mlx5_core_qp *rq);
29+
int mlx5_core_destroy_rq_tracked(struct mlx5_ib_dev *dev,
30+
struct mlx5_core_qp *rq);
3131
int mlx5_core_create_sq_tracked(struct mlx5_ib_dev *dev, u32 *in, int inlen,
3232
struct mlx5_core_qp *sq);
3333
void mlx5_core_destroy_sq_tracked(struct mlx5_ib_dev *dev,

drivers/infiniband/hw/mlx5/qpc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,12 @@ int mlx5_core_create_rq_tracked(struct mlx5_ib_dev *dev, u32 *in, int inlen,
576576
return err;
577577
}
578578

579-
void mlx5_core_destroy_rq_tracked(struct mlx5_ib_dev *dev,
580-
struct mlx5_core_qp *rq)
579+
int mlx5_core_destroy_rq_tracked(struct mlx5_ib_dev *dev,
580+
struct mlx5_core_qp *rq)
581581
{
582582
destroy_resource_common(dev, rq);
583583
destroy_rq_tracked(dev, rq->qpn, rq->uid);
584+
return 0;
584585
}
585586

586587
static void destroy_sq_tracked(struct mlx5_ib_dev *dev, u32 sqn, u16 uid)

include/rdma/ib_verbs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,7 +2496,7 @@ struct ib_device_ops {
24962496
struct ib_wq *(*create_wq)(struct ib_pd *pd,
24972497
struct ib_wq_init_attr *init_attr,
24982498
struct ib_udata *udata);
2499-
void (*destroy_wq)(struct ib_wq *wq, struct ib_udata *udata);
2499+
int (*destroy_wq)(struct ib_wq *wq, struct ib_udata *udata);
25002500
int (*modify_wq)(struct ib_wq *wq, struct ib_wq_attr *attr,
25012501
u32 wq_attr_mask, struct ib_udata *udata);
25022502
struct ib_rwq_ind_table *(*create_rwq_ind_table)(
@@ -4331,7 +4331,7 @@ struct net_device *ib_device_netdev(struct ib_device *dev, u8 port);
43314331

43324332
struct ib_wq *ib_create_wq(struct ib_pd *pd,
43334333
struct ib_wq_init_attr *init_attr);
4334-
int ib_destroy_wq(struct ib_wq *wq, struct ib_udata *udata);
4334+
int ib_destroy_wq_user(struct ib_wq *wq, struct ib_udata *udata);
43354335
int ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *attr,
43364336
u32 wq_attr_mask);
43374337
int ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *wq_ind_table);

0 commit comments

Comments
 (0)