提交 43d781b9 编写于 作者: L Leon Romanovsky 提交者: Jason Gunthorpe

RDMA: Allow fail of destroy CQ

Like any other verbs objects, CQ shouldn't fail during destroy, but
mlx5_ib didn't follow this contract with mixed IB verbs objects with
DEVX. Such mix causes to the situation where FW and kernel are fully
interdependent on the reference counting of each side.

Kernel verbs and drivers that don't have DEVX flows shouldn't fail.

Fixes: e39afe3d ("RDMA: Convert CQ allocations to be under core responsibility")
Link: https://lore.kernel.org/r/20200907120921.476363-7-leon@kernel.orgSigned-off-by: NLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
上级 7e3c66c9
...@@ -319,6 +319,8 @@ EXPORT_SYMBOL(__ib_alloc_cq_any); ...@@ -319,6 +319,8 @@ EXPORT_SYMBOL(__ib_alloc_cq_any);
*/ */
void ib_free_cq(struct ib_cq *cq) void ib_free_cq(struct ib_cq *cq)
{ {
int ret;
if (WARN_ON_ONCE(atomic_read(&cq->usecnt))) if (WARN_ON_ONCE(atomic_read(&cq->usecnt)))
return; return;
if (WARN_ON_ONCE(cq->cqe_used)) if (WARN_ON_ONCE(cq->cqe_used))
...@@ -340,8 +342,9 @@ void ib_free_cq(struct ib_cq *cq) ...@@ -340,8 +342,9 @@ void ib_free_cq(struct ib_cq *cq)
rdma_dim_destroy(cq); rdma_dim_destroy(cq);
trace_cq_free(cq); trace_cq_free(cq);
ret = cq->device->ops.destroy_cq(cq, NULL);
WARN_ONCE(ret, "Destroy of kernel CQ shouldn't fail");
rdma_restrack_del(&cq->res); rdma_restrack_del(&cq->res);
cq->device->ops.destroy_cq(cq, NULL);
kfree(cq->wc); kfree(cq->wc);
kfree(cq); kfree(cq);
} }
......
...@@ -2023,16 +2023,21 @@ EXPORT_SYMBOL(rdma_set_cq_moderation); ...@@ -2023,16 +2023,21 @@ EXPORT_SYMBOL(rdma_set_cq_moderation);
int ib_destroy_cq_user(struct ib_cq *cq, struct ib_udata *udata) int ib_destroy_cq_user(struct ib_cq *cq, struct ib_udata *udata)
{ {
int ret;
if (WARN_ON_ONCE(cq->shared)) if (WARN_ON_ONCE(cq->shared))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (atomic_read(&cq->usecnt)) if (atomic_read(&cq->usecnt))
return -EBUSY; return -EBUSY;
ret = cq->device->ops.destroy_cq(cq, udata);
if (ret)
return ret;
rdma_restrack_del(&cq->res); rdma_restrack_del(&cq->res);
cq->device->ops.destroy_cq(cq, udata);
kfree(cq); kfree(cq);
return 0; return ret;
} }
EXPORT_SYMBOL(ib_destroy_cq_user); EXPORT_SYMBOL(ib_destroy_cq_user);
......
...@@ -2803,7 +2803,7 @@ int bnxt_re_post_recv(struct ib_qp *ib_qp, const struct ib_recv_wr *wr, ...@@ -2803,7 +2803,7 @@ int bnxt_re_post_recv(struct ib_qp *ib_qp, const struct ib_recv_wr *wr,
} }
/* Completion Queues */ /* Completion Queues */
void bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata) int bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
{ {
struct bnxt_re_cq *cq; struct bnxt_re_cq *cq;
struct bnxt_qplib_nq *nq; struct bnxt_qplib_nq *nq;
...@@ -2819,6 +2819,7 @@ void bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata) ...@@ -2819,6 +2819,7 @@ void bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
atomic_dec(&rdev->cq_count); atomic_dec(&rdev->cq_count);
nq->budget--; nq->budget--;
kfree(cq->cql); kfree(cq->cql);
return 0;
} }
int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
......
...@@ -193,7 +193,7 @@ int bnxt_re_post_recv(struct ib_qp *qp, const struct ib_recv_wr *recv_wr, ...@@ -193,7 +193,7 @@ int bnxt_re_post_recv(struct ib_qp *qp, const struct ib_recv_wr *recv_wr,
const struct ib_recv_wr **bad_recv_wr); const struct ib_recv_wr **bad_recv_wr);
int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
struct ib_udata *udata); struct ib_udata *udata);
void bnxt_re_destroy_cq(struct ib_cq *cq, struct ib_udata *udata); int bnxt_re_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
int bnxt_re_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc); int bnxt_re_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc);
int bnxt_re_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags); int bnxt_re_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
struct ib_mr *bnxt_re_get_dma_mr(struct ib_pd *pd, int mr_access_flags); struct ib_mr *bnxt_re_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
......
...@@ -967,7 +967,7 @@ int c4iw_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) ...@@ -967,7 +967,7 @@ int c4iw_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
return !err || err == -ENODATA ? npolled : err; return !err || err == -ENODATA ? npolled : err;
} }
void c4iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata) int c4iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
{ {
struct c4iw_cq *chp; struct c4iw_cq *chp;
struct c4iw_ucontext *ucontext; struct c4iw_ucontext *ucontext;
...@@ -985,6 +985,7 @@ void c4iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata) ...@@ -985,6 +985,7 @@ void c4iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
ucontext ? &ucontext->uctx : &chp->cq.rdev->uctx, ucontext ? &ucontext->uctx : &chp->cq.rdev->uctx,
chp->destroy_skb, chp->wr_waitp); chp->destroy_skb, chp->wr_waitp);
c4iw_put_wr_wait(chp->wr_waitp); c4iw_put_wr_wait(chp->wr_waitp);
return 0;
} }
int c4iw_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, int c4iw_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
......
...@@ -992,7 +992,7 @@ struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start, ...@@ -992,7 +992,7 @@ struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start,
struct ib_udata *udata); struct ib_udata *udata);
struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc); struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc);
int c4iw_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata); int c4iw_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata);
void c4iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata); int c4iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata);
int c4iw_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, int c4iw_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
struct ib_udata *udata); struct ib_udata *udata);
int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags); int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
......
...@@ -139,7 +139,7 @@ int efa_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata); ...@@ -139,7 +139,7 @@ int efa_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata);
struct ib_qp *efa_create_qp(struct ib_pd *ibpd, struct ib_qp *efa_create_qp(struct ib_pd *ibpd,
struct ib_qp_init_attr *init_attr, struct ib_qp_init_attr *init_attr,
struct ib_udata *udata); struct ib_udata *udata);
void efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata); int efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata);
int efa_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, int efa_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
struct ib_udata *udata); struct ib_udata *udata);
struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length, struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length,
......
...@@ -973,7 +973,7 @@ static int efa_destroy_cq_idx(struct efa_dev *dev, int cq_idx) ...@@ -973,7 +973,7 @@ static int efa_destroy_cq_idx(struct efa_dev *dev, int cq_idx)
return efa_com_destroy_cq(&dev->edev, &params); return efa_com_destroy_cq(&dev->edev, &params);
} }
void efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) int efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
{ {
struct efa_dev *dev = to_edev(ibcq->device); struct efa_dev *dev = to_edev(ibcq->device);
struct efa_cq *cq = to_ecq(ibcq); struct efa_cq *cq = to_ecq(ibcq);
...@@ -986,6 +986,7 @@ void efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) ...@@ -986,6 +986,7 @@ void efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
efa_destroy_cq_idx(dev, cq->cq_idx); efa_destroy_cq_idx(dev, cq->cq_idx);
efa_free_mapped(dev, cq->cpu_addr, cq->dma_addr, cq->size, efa_free_mapped(dev, cq->cpu_addr, cq->dma_addr, cq->size,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
return 0;
} }
static int cq_mmap_entries_setup(struct efa_dev *dev, struct efa_cq *cq, static int cq_mmap_entries_setup(struct efa_dev *dev, struct efa_cq *cq,
......
...@@ -311,7 +311,7 @@ int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr, ...@@ -311,7 +311,7 @@ int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
return ret; return ret;
} }
void hns_roce_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata) int hns_roce_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
{ {
struct hns_roce_dev *hr_dev = to_hr_dev(ib_cq->device); struct hns_roce_dev *hr_dev = to_hr_dev(ib_cq->device);
struct hns_roce_cq *hr_cq = to_hr_cq(ib_cq); struct hns_roce_cq *hr_cq = to_hr_cq(ib_cq);
...@@ -322,6 +322,7 @@ void hns_roce_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata) ...@@ -322,6 +322,7 @@ void hns_roce_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
free_cq_buf(hr_dev, hr_cq); free_cq_buf(hr_dev, hr_cq);
free_cq_db(hr_dev, hr_cq, udata); free_cq_db(hr_dev, hr_cq, udata);
free_cqc(hr_dev, hr_cq); free_cqc(hr_dev, hr_cq);
return 0;
} }
void hns_roce_cq_completion(struct hns_roce_dev *hr_dev, u32 cqn) void hns_roce_cq_completion(struct hns_roce_dev *hr_dev, u32 cqn)
......
...@@ -931,7 +931,7 @@ struct hns_roce_hw { ...@@ -931,7 +931,7 @@ struct hns_roce_hw {
int (*poll_cq)(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); int (*poll_cq)(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
int (*dereg_mr)(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr, int (*dereg_mr)(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr,
struct ib_udata *udata); struct ib_udata *udata);
void (*destroy_cq)(struct ib_cq *ibcq, struct ib_udata *udata); int (*destroy_cq)(struct ib_cq *ibcq, struct ib_udata *udata);
int (*modify_cq)(struct ib_cq *cq, u16 cq_count, u16 cq_period); int (*modify_cq)(struct ib_cq *cq, u16 cq_count, u16 cq_period);
int (*init_eq)(struct hns_roce_dev *hr_dev); int (*init_eq)(struct hns_roce_dev *hr_dev);
void (*cleanup_eq)(struct hns_roce_dev *hr_dev); void (*cleanup_eq)(struct hns_roce_dev *hr_dev);
...@@ -1251,7 +1251,7 @@ int to_hr_qp_type(int qp_type); ...@@ -1251,7 +1251,7 @@ int to_hr_qp_type(int qp_type);
int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr, int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
struct ib_udata *udata); struct ib_udata *udata);
void hns_roce_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata); int hns_roce_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata);
int hns_roce_db_map_user(struct hns_roce_ucontext *context, int hns_roce_db_map_user(struct hns_roce_ucontext *context,
struct ib_udata *udata, unsigned long virt, struct ib_udata *udata, unsigned long virt,
struct hns_roce_db *db); struct hns_roce_db *db);
......
...@@ -3572,7 +3572,7 @@ int hns_roce_v1_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) ...@@ -3572,7 +3572,7 @@ int hns_roce_v1_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
return 0; return 0;
} }
static void hns_roce_v1_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) static int hns_roce_v1_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
{ {
struct hns_roce_dev *hr_dev = to_hr_dev(ibcq->device); struct hns_roce_dev *hr_dev = to_hr_dev(ibcq->device);
struct hns_roce_cq *hr_cq = to_hr_cq(ibcq); struct hns_roce_cq *hr_cq = to_hr_cq(ibcq);
...@@ -3603,6 +3603,7 @@ static void hns_roce_v1_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) ...@@ -3603,6 +3603,7 @@ static void hns_roce_v1_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
} }
wait_time++; wait_time++;
} }
return 0;
} }
static void set_eq_cons_index_v1(struct hns_roce_eq *eq, int req_not) static void set_eq_cons_index_v1(struct hns_roce_eq *eq, int req_not)
......
...@@ -1053,7 +1053,7 @@ void i40iw_cq_wq_destroy(struct i40iw_device *iwdev, struct i40iw_sc_cq *cq) ...@@ -1053,7 +1053,7 @@ void i40iw_cq_wq_destroy(struct i40iw_device *iwdev, struct i40iw_sc_cq *cq)
* @ib_cq: cq pointer * @ib_cq: cq pointer
* @udata: user data or NULL for kernel object * @udata: user data or NULL for kernel object
*/ */
static void i40iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata) static int i40iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
{ {
struct i40iw_cq *iwcq; struct i40iw_cq *iwcq;
struct i40iw_device *iwdev; struct i40iw_device *iwdev;
...@@ -1065,6 +1065,7 @@ static void i40iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata) ...@@ -1065,6 +1065,7 @@ static void i40iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
i40iw_cq_wq_destroy(iwdev, cq); i40iw_cq_wq_destroy(iwdev, cq);
cq_free_resources(iwdev, iwcq); cq_free_resources(iwdev, iwcq);
i40iw_rem_devusecount(iwdev); i40iw_rem_devusecount(iwdev);
return 0;
} }
/** /**
......
...@@ -475,7 +475,7 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata) ...@@ -475,7 +475,7 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
return err; return err;
} }
void mlx4_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata) int mlx4_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)
{ {
struct mlx4_ib_dev *dev = to_mdev(cq->device); struct mlx4_ib_dev *dev = to_mdev(cq->device);
struct mlx4_ib_cq *mcq = to_mcq(cq); struct mlx4_ib_cq *mcq = to_mcq(cq);
...@@ -495,6 +495,7 @@ void mlx4_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata) ...@@ -495,6 +495,7 @@ void mlx4_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)
mlx4_db_free(dev->dev, &mcq->db); mlx4_db_free(dev->dev, &mcq->db);
} }
ib_umem_release(mcq->umem); ib_umem_release(mcq->umem);
return 0;
} }
static void dump_cqe(void *cqe) static void dump_cqe(void *cqe)
......
...@@ -742,7 +742,7 @@ int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); ...@@ -742,7 +742,7 @@ int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata); int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata);
int mlx4_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, int mlx4_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
struct ib_udata *udata); struct ib_udata *udata);
void mlx4_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata); int mlx4_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
int mlx4_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); int mlx4_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
int mlx4_ib_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags); int mlx4_ib_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
void __mlx4_ib_cq_clean(struct mlx4_ib_cq *cq, u32 qpn, struct mlx4_ib_srq *srq); void __mlx4_ib_cq_clean(struct mlx4_ib_cq *cq, u32 qpn, struct mlx4_ib_srq *srq);
......
...@@ -1024,16 +1024,21 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, ...@@ -1024,16 +1024,21 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
return err; return err;
} }
void mlx5_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata) int mlx5_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)
{ {
struct mlx5_ib_dev *dev = to_mdev(cq->device); struct mlx5_ib_dev *dev = to_mdev(cq->device);
struct mlx5_ib_cq *mcq = to_mcq(cq); struct mlx5_ib_cq *mcq = to_mcq(cq);
int ret;
ret = mlx5_core_destroy_cq(dev->mdev, &mcq->mcq);
if (ret)
return ret;
mlx5_core_destroy_cq(dev->mdev, &mcq->mcq);
if (udata) if (udata)
destroy_cq_user(mcq, udata); destroy_cq_user(mcq, udata);
else else
destroy_cq_kernel(dev, mcq); destroy_cq_kernel(dev, mcq);
return 0;
} }
static int is_equal_rsn(struct mlx5_cqe64 *cqe64, u32 rsn) static int is_equal_rsn(struct mlx5_cqe64 *cqe64, u32 rsn)
......
...@@ -1151,7 +1151,7 @@ int mlx5_ib_read_wqe_srq(struct mlx5_ib_srq *srq, int wqe_index, void *buffer, ...@@ -1151,7 +1151,7 @@ int mlx5_ib_read_wqe_srq(struct mlx5_ib_srq *srq, int wqe_index, void *buffer,
size_t buflen, size_t *bc); size_t buflen, size_t *bc);
int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
struct ib_udata *udata); struct ib_udata *udata);
void mlx5_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata); int mlx5_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags); int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
......
...@@ -792,7 +792,7 @@ static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *uda ...@@ -792,7 +792,7 @@ static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *uda
return ret; return ret;
} }
static void mthca_destroy_cq(struct ib_cq *cq, struct ib_udata *udata) static int mthca_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)
{ {
if (udata) { if (udata) {
struct mthca_ucontext *context = struct mthca_ucontext *context =
...@@ -811,6 +811,7 @@ static void mthca_destroy_cq(struct ib_cq *cq, struct ib_udata *udata) ...@@ -811,6 +811,7 @@ static void mthca_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)
to_mcq(cq)->set_ci_db_index); to_mcq(cq)->set_ci_db_index);
} }
mthca_free_cq(to_mdev(cq->device), to_mcq(cq)); mthca_free_cq(to_mdev(cq->device), to_mcq(cq));
return 0;
} }
static inline u32 convert_access(int acc) static inline u32 convert_access(int acc)
......
...@@ -1057,7 +1057,7 @@ static void ocrdma_flush_cq(struct ocrdma_cq *cq) ...@@ -1057,7 +1057,7 @@ static void ocrdma_flush_cq(struct ocrdma_cq *cq)
spin_unlock_irqrestore(&cq->cq_lock, flags); spin_unlock_irqrestore(&cq->cq_lock, flags);
} }
void ocrdma_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) int ocrdma_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
{ {
struct ocrdma_cq *cq = get_ocrdma_cq(ibcq); struct ocrdma_cq *cq = get_ocrdma_cq(ibcq);
struct ocrdma_eq *eq = NULL; struct ocrdma_eq *eq = NULL;
...@@ -1082,6 +1082,7 @@ void ocrdma_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) ...@@ -1082,6 +1082,7 @@ void ocrdma_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
ocrdma_get_db_addr(dev, pdid), ocrdma_get_db_addr(dev, pdid),
dev->nic_info.db_page_size); dev->nic_info.db_page_size);
} }
return 0;
} }
static int ocrdma_add_qpn_map(struct ocrdma_dev *dev, struct ocrdma_qp *qp) static int ocrdma_add_qpn_map(struct ocrdma_dev *dev, struct ocrdma_qp *qp)
......
...@@ -72,7 +72,7 @@ int ocrdma_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata); ...@@ -72,7 +72,7 @@ int ocrdma_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata);
int ocrdma_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, int ocrdma_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
struct ib_udata *udata); struct ib_udata *udata);
int ocrdma_resize_cq(struct ib_cq *, int cqe, struct ib_udata *); int ocrdma_resize_cq(struct ib_cq *, int cqe, struct ib_udata *);
void ocrdma_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata); int ocrdma_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata);
struct ib_qp *ocrdma_create_qp(struct ib_pd *, struct ib_qp *ocrdma_create_qp(struct ib_pd *,
struct ib_qp_init_attr *attrs, struct ib_qp_init_attr *attrs,
......
...@@ -1052,7 +1052,7 @@ int qedr_resize_cq(struct ib_cq *ibcq, int new_cnt, struct ib_udata *udata) ...@@ -1052,7 +1052,7 @@ int qedr_resize_cq(struct ib_cq *ibcq, int new_cnt, struct ib_udata *udata)
#define QEDR_DESTROY_CQ_MAX_ITERATIONS (10) #define QEDR_DESTROY_CQ_MAX_ITERATIONS (10)
#define QEDR_DESTROY_CQ_ITER_DURATION (10) #define QEDR_DESTROY_CQ_ITER_DURATION (10)
void qedr_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) int qedr_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
{ {
struct qedr_dev *dev = get_qedr_dev(ibcq->device); struct qedr_dev *dev = get_qedr_dev(ibcq->device);
struct qed_rdma_destroy_cq_out_params oparams; struct qed_rdma_destroy_cq_out_params oparams;
...@@ -1067,7 +1067,7 @@ void qedr_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) ...@@ -1067,7 +1067,7 @@ void qedr_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
/* GSIs CQs are handled by driver, so they don't exist in the FW */ /* GSIs CQs are handled by driver, so they don't exist in the FW */
if (cq->cq_type == QEDR_CQ_TYPE_GSI) { if (cq->cq_type == QEDR_CQ_TYPE_GSI) {
qedr_db_recovery_del(dev, cq->db_addr, &cq->db.data); qedr_db_recovery_del(dev, cq->db_addr, &cq->db.data);
return; return 0;
} }
iparams.icid = cq->icid; iparams.icid = cq->icid;
...@@ -1115,6 +1115,7 @@ void qedr_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) ...@@ -1115,6 +1115,7 @@ void qedr_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
* Since the destroy CQ ramrod has also been received on the EQ we can * Since the destroy CQ ramrod has also been received on the EQ we can
* be certain that there's no event handler in process. * be certain that there's no event handler in process.
*/ */
return 0;
} }
static inline int get_gid_info_from_table(struct ib_qp *ibqp, static inline int get_gid_info_from_table(struct ib_qp *ibqp,
......
...@@ -52,7 +52,7 @@ int qedr_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata); ...@@ -52,7 +52,7 @@ int qedr_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata);
int qedr_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, int qedr_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
struct ib_udata *udata); struct ib_udata *udata);
int qedr_resize_cq(struct ib_cq *, int cqe, struct ib_udata *); int qedr_resize_cq(struct ib_cq *, int cqe, struct ib_udata *);
void qedr_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata); int qedr_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata);
int qedr_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags); int qedr_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
struct ib_qp *qedr_create_qp(struct ib_pd *, struct ib_qp_init_attr *attrs, struct ib_qp *qedr_create_qp(struct ib_pd *, struct ib_qp_init_attr *attrs,
struct ib_udata *); struct ib_udata *);
......
...@@ -586,9 +586,9 @@ int usnic_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, ...@@ -586,9 +586,9 @@ int usnic_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
return 0; return 0;
} }
void usnic_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata) int usnic_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)
{ {
return; return 0;
} }
struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length, struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length,
......
...@@ -58,7 +58,7 @@ int usnic_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, ...@@ -58,7 +58,7 @@ int usnic_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
int attr_mask, struct ib_udata *udata); int attr_mask, struct ib_udata *udata);
int usnic_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, int usnic_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
struct ib_udata *udata); struct ib_udata *udata);
void usnic_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata); int usnic_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length, struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length,
u64 virt_addr, int access_flags, u64 virt_addr, int access_flags,
struct ib_udata *udata); struct ib_udata *udata);
......
...@@ -235,7 +235,7 @@ static void pvrdma_free_cq(struct pvrdma_dev *dev, struct pvrdma_cq *cq) ...@@ -235,7 +235,7 @@ static void pvrdma_free_cq(struct pvrdma_dev *dev, struct pvrdma_cq *cq)
* @cq: the completion queue to destroy. * @cq: the completion queue to destroy.
* @udata: user data or null for kernel object * @udata: user data or null for kernel object
*/ */
void pvrdma_destroy_cq(struct ib_cq *cq, struct ib_udata *udata) int pvrdma_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)
{ {
struct pvrdma_cq *vcq = to_vcq(cq); struct pvrdma_cq *vcq = to_vcq(cq);
union pvrdma_cmd_req req; union pvrdma_cmd_req req;
...@@ -261,6 +261,7 @@ void pvrdma_destroy_cq(struct ib_cq *cq, struct ib_udata *udata) ...@@ -261,6 +261,7 @@ void pvrdma_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)
pvrdma_free_cq(dev, vcq); pvrdma_free_cq(dev, vcq);
atomic_dec(&dev->num_cqs); atomic_dec(&dev->num_cqs);
return 0;
} }
static inline struct pvrdma_cqe *get_cqe(struct pvrdma_cq *cq, int i) static inline struct pvrdma_cqe *get_cqe(struct pvrdma_cq *cq, int i)
......
...@@ -411,7 +411,7 @@ int pvrdma_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, ...@@ -411,7 +411,7 @@ int pvrdma_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
int sg_nents, unsigned int *sg_offset); int sg_nents, unsigned int *sg_offset);
int pvrdma_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, int pvrdma_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
struct ib_udata *udata); struct ib_udata *udata);
void pvrdma_destroy_cq(struct ib_cq *cq, struct ib_udata *udata); int pvrdma_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
int pvrdma_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); int pvrdma_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
int pvrdma_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags); int pvrdma_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
int pvrdma_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr, int pvrdma_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr,
......
...@@ -315,7 +315,7 @@ int rvt_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, ...@@ -315,7 +315,7 @@ int rvt_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
* *
* Called by ib_destroy_cq() in the generic verbs code. * Called by ib_destroy_cq() in the generic verbs code.
*/ */
void rvt_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) int rvt_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
{ {
struct rvt_cq *cq = ibcq_to_rvtcq(ibcq); struct rvt_cq *cq = ibcq_to_rvtcq(ibcq);
struct rvt_dev_info *rdi = cq->rdi; struct rvt_dev_info *rdi = cq->rdi;
...@@ -328,6 +328,7 @@ void rvt_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) ...@@ -328,6 +328,7 @@ void rvt_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
kref_put(&cq->ip->ref, rvt_release_mmap_info); kref_put(&cq->ip->ref, rvt_release_mmap_info);
else else
vfree(cq->kqueue); vfree(cq->kqueue);
return 0;
} }
/** /**
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
int rvt_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, int rvt_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
struct ib_udata *udata); struct ib_udata *udata);
void rvt_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata); int rvt_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata);
int rvt_req_notify_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags notify_flags); int rvt_req_notify_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags notify_flags);
int rvt_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata); int rvt_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata);
int rvt_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry); int rvt_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry);
......
...@@ -779,13 +779,14 @@ static int rxe_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, ...@@ -779,13 +779,14 @@ static int rxe_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
return rxe_add_to_pool(&rxe->cq_pool, &cq->pelem); return rxe_add_to_pool(&rxe->cq_pool, &cq->pelem);
} }
static void rxe_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) static int rxe_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
{ {
struct rxe_cq *cq = to_rcq(ibcq); struct rxe_cq *cq = to_rcq(ibcq);
rxe_cq_disable(cq); rxe_cq_disable(cq);
rxe_drop_ref(cq); rxe_drop_ref(cq);
return 0;
} }
static int rxe_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata) static int rxe_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata)
......
...@@ -1056,7 +1056,7 @@ int siw_post_receive(struct ib_qp *base_qp, const struct ib_recv_wr *wr, ...@@ -1056,7 +1056,7 @@ int siw_post_receive(struct ib_qp *base_qp, const struct ib_recv_wr *wr,
return rv > 0 ? 0 : rv; return rv > 0 ? 0 : rv;
} }
void siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata) int siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata)
{ {
struct siw_cq *cq = to_siw_cq(base_cq); struct siw_cq *cq = to_siw_cq(base_cq);
struct siw_device *sdev = to_siw_dev(base_cq->device); struct siw_device *sdev = to_siw_dev(base_cq->device);
...@@ -1074,6 +1074,7 @@ void siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata) ...@@ -1074,6 +1074,7 @@ void siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata)
atomic_dec(&sdev->num_cq); atomic_dec(&sdev->num_cq);
vfree(cq->queue); vfree(cq->queue);
return 0;
} }
/* /*
......
...@@ -62,7 +62,7 @@ int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr, ...@@ -62,7 +62,7 @@ int siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr,
const struct ib_send_wr **bad_wr); const struct ib_send_wr **bad_wr);
int siw_post_receive(struct ib_qp *base_qp, const struct ib_recv_wr *wr, int siw_post_receive(struct ib_qp *base_qp, const struct ib_recv_wr *wr,
const struct ib_recv_wr **bad_wr); const struct ib_recv_wr **bad_wr);
void siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata); int siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata);
int siw_poll_cq(struct ib_cq *base_cq, int num_entries, struct ib_wc *wc); int siw_poll_cq(struct ib_cq *base_cq, int num_entries, struct ib_wc *wc);
int siw_req_notify_cq(struct ib_cq *base_cq, enum ib_cq_notify_flags flags); int siw_req_notify_cq(struct ib_cq *base_cq, enum ib_cq_notify_flags flags);
struct ib_mr *siw_reg_user_mr(struct ib_pd *base_pd, u64 start, u64 len, struct ib_mr *siw_reg_user_mr(struct ib_pd *base_pd, u64 start, u64 len,
......
...@@ -2423,7 +2423,7 @@ struct ib_device_ops { ...@@ -2423,7 +2423,7 @@ struct ib_device_ops {
int (*create_cq)(struct ib_cq *cq, const struct ib_cq_init_attr *attr, int (*create_cq)(struct ib_cq *cq, const struct ib_cq_init_attr *attr,
struct ib_udata *udata); struct ib_udata *udata);
int (*modify_cq)(struct ib_cq *cq, u16 cq_count, u16 cq_period); int (*modify_cq)(struct ib_cq *cq, u16 cq_count, u16 cq_period);
void (*destroy_cq)(struct ib_cq *cq, struct ib_udata *udata); int (*destroy_cq)(struct ib_cq *cq, struct ib_udata *udata);
int (*resize_cq)(struct ib_cq *cq, int cqe, struct ib_udata *udata); int (*resize_cq)(struct ib_cq *cq, int cqe, struct ib_udata *udata);
struct ib_mr *(*get_dma_mr)(struct ib_pd *pd, int mr_access_flags); struct ib_mr *(*get_dma_mr)(struct ib_pd *pd, int mr_access_flags);
struct ib_mr *(*reg_user_mr)(struct ib_pd *pd, u64 start, u64 length, struct ib_mr *(*reg_user_mr)(struct ib_pd *pd, u64 start, u64 length,
...@@ -3890,7 +3890,9 @@ int ib_destroy_cq_user(struct ib_cq *cq, struct ib_udata *udata); ...@@ -3890,7 +3890,9 @@ int ib_destroy_cq_user(struct ib_cq *cq, struct ib_udata *udata);
*/ */
static inline void ib_destroy_cq(struct ib_cq *cq) static inline void ib_destroy_cq(struct ib_cq *cq)
{ {
ib_destroy_cq_user(cq, NULL); int ret = ib_destroy_cq_user(cq, NULL);
WARN_ONCE(ret, "Destroy of kernel CQ shouldn't fail");
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册