Commit 119181d1 authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Jason Gunthorpe

RDMA: Restore ability to fail on SRQ destroy

In similar way to other IB objects, restore the ability to return error on
SRQ destroy. Strictly speaking, this change is not necessary, and provided
here to ensure a symmetrical interface like other destroy functions.

Fixes: 68e326de ("RDMA: Handle SRQ allocations by IB/core")
Link: https://lore.kernel.org/r/20200907120921.476363-5-leon@kernel.orgSigned-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent fd89099d
...@@ -1068,10 +1068,14 @@ EXPORT_SYMBOL(ib_query_srq); ...@@ -1068,10 +1068,14 @@ EXPORT_SYMBOL(ib_query_srq);
int ib_destroy_srq_user(struct ib_srq *srq, struct ib_udata *udata) int ib_destroy_srq_user(struct ib_srq *srq, struct ib_udata *udata)
{ {
int ret;
if (atomic_read(&srq->usecnt)) if (atomic_read(&srq->usecnt))
return -EBUSY; return -EBUSY;
srq->device->ops.destroy_srq(srq, udata); ret = srq->device->ops.destroy_srq(srq, udata);
if (ret)
return ret;
atomic_dec(&srq->pd->usecnt); atomic_dec(&srq->pd->usecnt);
if (srq->srq_type == IB_SRQT_XRC) if (srq->srq_type == IB_SRQT_XRC)
...@@ -1080,7 +1084,7 @@ int ib_destroy_srq_user(struct ib_srq *srq, struct ib_udata *udata) ...@@ -1080,7 +1084,7 @@ int ib_destroy_srq_user(struct ib_srq *srq, struct ib_udata *udata)
atomic_dec(&srq->ext.cq->usecnt); atomic_dec(&srq->ext.cq->usecnt);
kfree(srq); kfree(srq);
return 0; return ret;
} }
EXPORT_SYMBOL(ib_destroy_srq_user); EXPORT_SYMBOL(ib_destroy_srq_user);
......
...@@ -1570,7 +1570,7 @@ static enum ib_mtu __to_ib_mtu(u32 mtu) ...@@ -1570,7 +1570,7 @@ static enum ib_mtu __to_ib_mtu(u32 mtu)
} }
/* Shared Receive Queues */ /* Shared Receive Queues */
void bnxt_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata) int bnxt_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata)
{ {
struct bnxt_re_srq *srq = container_of(ib_srq, struct bnxt_re_srq, struct bnxt_re_srq *srq = container_of(ib_srq, struct bnxt_re_srq,
ib_srq); ib_srq);
...@@ -1585,6 +1585,7 @@ void bnxt_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata) ...@@ -1585,6 +1585,7 @@ void bnxt_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata)
atomic_dec(&rdev->srq_count); atomic_dec(&rdev->srq_count);
if (nq) if (nq)
nq->budget--; nq->budget--;
return 0;
} }
static int bnxt_re_init_user_srq(struct bnxt_re_dev *rdev, static int bnxt_re_init_user_srq(struct bnxt_re_dev *rdev,
......
...@@ -176,7 +176,7 @@ int bnxt_re_modify_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr, ...@@ -176,7 +176,7 @@ int bnxt_re_modify_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr,
enum ib_srq_attr_mask srq_attr_mask, enum ib_srq_attr_mask srq_attr_mask,
struct ib_udata *udata); struct ib_udata *udata);
int bnxt_re_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr); int bnxt_re_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
void bnxt_re_destroy_srq(struct ib_srq *srq, struct ib_udata *udata); int bnxt_re_destroy_srq(struct ib_srq *srq, struct ib_udata *udata);
int bnxt_re_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *recv_wr, int bnxt_re_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *recv_wr,
const struct ib_recv_wr **bad_recv_wr); const struct ib_recv_wr **bad_recv_wr);
struct ib_qp *bnxt_re_create_qp(struct ib_pd *pd, struct ib_qp *bnxt_re_create_qp(struct ib_pd *pd,
......
...@@ -999,7 +999,7 @@ int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags); ...@@ -999,7 +999,7 @@ int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
int c4iw_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *attr, int c4iw_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *attr,
enum ib_srq_attr_mask srq_attr_mask, enum ib_srq_attr_mask srq_attr_mask,
struct ib_udata *udata); struct ib_udata *udata);
void c4iw_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata); int c4iw_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata);
int c4iw_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *attrs, int c4iw_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *attrs,
struct ib_udata *udata); struct ib_udata *udata);
int c4iw_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata); int c4iw_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata);
......
...@@ -2797,7 +2797,7 @@ int c4iw_create_srq(struct ib_srq *ib_srq, struct ib_srq_init_attr *attrs, ...@@ -2797,7 +2797,7 @@ int c4iw_create_srq(struct ib_srq *ib_srq, struct ib_srq_init_attr *attrs,
return ret; return ret;
} }
void c4iw_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) int c4iw_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
{ {
struct c4iw_dev *rhp; struct c4iw_dev *rhp;
struct c4iw_srq *srq; struct c4iw_srq *srq;
...@@ -2813,4 +2813,5 @@ void c4iw_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) ...@@ -2813,4 +2813,5 @@ void c4iw_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
srq->wr_waitp); srq->wr_waitp);
c4iw_free_srq_idx(&rhp->rdev, srq->idx); c4iw_free_srq_idx(&rhp->rdev, srq->idx);
c4iw_put_wr_wait(srq->wr_waitp); c4iw_put_wr_wait(srq->wr_waitp);
return 0;
} }
...@@ -1224,7 +1224,7 @@ int hns_roce_create_srq(struct ib_srq *srq, ...@@ -1224,7 +1224,7 @@ int hns_roce_create_srq(struct ib_srq *srq,
int hns_roce_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr, int hns_roce_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr,
enum ib_srq_attr_mask srq_attr_mask, enum ib_srq_attr_mask srq_attr_mask,
struct ib_udata *udata); struct ib_udata *udata);
void hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata); int hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata);
struct ib_qp *hns_roce_create_qp(struct ib_pd *ib_pd, struct ib_qp *hns_roce_create_qp(struct ib_pd *ib_pd,
struct ib_qp_init_attr *init_attr, struct ib_qp_init_attr *init_attr,
......
...@@ -363,7 +363,7 @@ int hns_roce_create_srq(struct ib_srq *ib_srq, ...@@ -363,7 +363,7 @@ int hns_roce_create_srq(struct ib_srq *ib_srq,
return ret; return ret;
} }
void hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) int hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
{ {
struct hns_roce_dev *hr_dev = to_hr_dev(ibsrq->device); struct hns_roce_dev *hr_dev = to_hr_dev(ibsrq->device);
struct hns_roce_srq *srq = to_hr_srq(ibsrq); struct hns_roce_srq *srq = to_hr_srq(ibsrq);
...@@ -372,6 +372,7 @@ void hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) ...@@ -372,6 +372,7 @@ void hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
free_srq_idx(hr_dev, srq); free_srq_idx(hr_dev, srq);
free_srq_wrid(srq); free_srq_wrid(srq);
free_srq_buf(hr_dev, srq); free_srq_buf(hr_dev, srq);
return 0;
} }
int hns_roce_init_srq_table(struct hns_roce_dev *hr_dev) int hns_roce_init_srq_table(struct hns_roce_dev *hr_dev)
......
...@@ -763,7 +763,7 @@ int mlx4_ib_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *init_attr, ...@@ -763,7 +763,7 @@ int mlx4_ib_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *init_attr,
int mlx4_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, int mlx4_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
enum ib_srq_attr_mask attr_mask, struct ib_udata *udata); enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
int mlx4_ib_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr); int mlx4_ib_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
void mlx4_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata); int mlx4_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata);
void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index); void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index);
int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
const struct ib_recv_wr **bad_wr); const struct ib_recv_wr **bad_wr);
......
...@@ -260,7 +260,7 @@ int mlx4_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr) ...@@ -260,7 +260,7 @@ int mlx4_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr)
return 0; return 0;
} }
void mlx4_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata) int mlx4_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata)
{ {
struct mlx4_ib_dev *dev = to_mdev(srq->device); struct mlx4_ib_dev *dev = to_mdev(srq->device);
struct mlx4_ib_srq *msrq = to_msrq(srq); struct mlx4_ib_srq *msrq = to_msrq(srq);
...@@ -282,6 +282,7 @@ void mlx4_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata) ...@@ -282,6 +282,7 @@ void mlx4_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata)
mlx4_db_free(dev->dev, &msrq->db); mlx4_db_free(dev->dev, &msrq->db);
} }
ib_umem_release(msrq->umem); ib_umem_release(msrq->umem);
return 0;
} }
void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index) void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index)
......
...@@ -1128,7 +1128,7 @@ int mlx5_ib_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *init_attr, ...@@ -1128,7 +1128,7 @@ int mlx5_ib_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *init_attr,
int mlx5_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, int mlx5_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
enum ib_srq_attr_mask attr_mask, struct ib_udata *udata); enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr); int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr);
void mlx5_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata); int mlx5_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata);
int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
const struct ib_recv_wr **bad_wr); const struct ib_recv_wr **bad_wr);
int mlx5_ib_enable_lb(struct mlx5_ib_dev *dev, bool td, bool qp); int mlx5_ib_enable_lb(struct mlx5_ib_dev *dev, bool td, bool qp);
......
...@@ -389,24 +389,21 @@ int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr) ...@@ -389,24 +389,21 @@ int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr)
return ret; return ret;
} }
void mlx5_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata) int mlx5_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata)
{ {
struct mlx5_ib_dev *dev = to_mdev(srq->device); struct mlx5_ib_dev *dev = to_mdev(srq->device);
struct mlx5_ib_srq *msrq = to_msrq(srq); struct mlx5_ib_srq *msrq = to_msrq(srq);
int ret;
ret = mlx5_cmd_destroy_srq(dev, &msrq->msrq);
if (ret)
return ret;
mlx5_cmd_destroy_srq(dev, &msrq->msrq); if (udata)
destroy_srq_user(srq->pd, msrq, udata);
if (srq->uobject) { else
mlx5_ib_db_unmap_user(
rdma_udata_to_drv_context(
udata,
struct mlx5_ib_ucontext,
ibucontext),
&msrq->db);
ib_umem_release(msrq->umem);
} else {
destroy_srq_kernel(dev, msrq); destroy_srq_kernel(dev, msrq);
} return 0;
} }
void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index) void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index)
......
...@@ -56,7 +56,7 @@ struct mlx5_srq_table { ...@@ -56,7 +56,7 @@ struct mlx5_srq_table {
int mlx5_cmd_create_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq, int mlx5_cmd_create_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
struct mlx5_srq_attr *in); struct mlx5_srq_attr *in);
void mlx5_cmd_destroy_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq); int mlx5_cmd_destroy_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq);
int mlx5_cmd_query_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq, int mlx5_cmd_query_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
struct mlx5_srq_attr *out); struct mlx5_srq_attr *out);
int mlx5_cmd_arm_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq, int mlx5_cmd_arm_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
......
...@@ -590,7 +590,7 @@ int mlx5_cmd_create_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq, ...@@ -590,7 +590,7 @@ int mlx5_cmd_create_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
return err; return err;
} }
void mlx5_cmd_destroy_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq) int mlx5_cmd_destroy_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq)
{ {
struct mlx5_srq_table *table = &dev->srq_table; struct mlx5_srq_table *table = &dev->srq_table;
struct mlx5_core_srq *tmp; struct mlx5_core_srq *tmp;
...@@ -599,7 +599,7 @@ void mlx5_cmd_destroy_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq) ...@@ -599,7 +599,7 @@ void mlx5_cmd_destroy_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq)
/* Delete entry, but leave index occupied */ /* Delete entry, but leave index occupied */
tmp = xa_cmpxchg_irq(&table->array, srq->srqn, srq, XA_ZERO_ENTRY, 0); tmp = xa_cmpxchg_irq(&table->array, srq->srqn, srq, XA_ZERO_ENTRY, 0);
if (WARN_ON(tmp != srq)) if (WARN_ON(tmp != srq))
return; return xa_err(tmp) ?: -EINVAL;
err = destroy_srq_split(dev, srq); err = destroy_srq_split(dev, srq);
if (err) { if (err) {
...@@ -609,12 +609,13 @@ void mlx5_cmd_destroy_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq) ...@@ -609,12 +609,13 @@ void mlx5_cmd_destroy_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq)
* entry and it can't fail at this stage. * entry and it can't fail at this stage.
*/ */
xa_cmpxchg_irq(&table->array, srq->srqn, XA_ZERO_ENTRY, srq, 0); xa_cmpxchg_irq(&table->array, srq->srqn, XA_ZERO_ENTRY, srq, 0);
return; return err;
} }
xa_erase_irq(&table->array, srq->srqn); xa_erase_irq(&table->array, srq->srqn);
mlx5_core_res_put(&srq->common); mlx5_core_res_put(&srq->common);
wait_for_completion(&srq->common.free); wait_for_completion(&srq->common.free);
return 0;
} }
int mlx5_cmd_query_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq, int mlx5_cmd_query_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
......
...@@ -442,7 +442,7 @@ static int mthca_create_srq(struct ib_srq *ibsrq, ...@@ -442,7 +442,7 @@ static int mthca_create_srq(struct ib_srq *ibsrq,
return 0; return 0;
} }
static void mthca_destroy_srq(struct ib_srq *srq, struct ib_udata *udata) static int mthca_destroy_srq(struct ib_srq *srq, struct ib_udata *udata)
{ {
if (udata) { if (udata) {
struct mthca_ucontext *context = struct mthca_ucontext *context =
...@@ -456,6 +456,7 @@ static void mthca_destroy_srq(struct ib_srq *srq, struct ib_udata *udata) ...@@ -456,6 +456,7 @@ static void mthca_destroy_srq(struct ib_srq *srq, struct ib_udata *udata)
} }
mthca_free_srq(to_mdev(srq->device), to_msrq(srq)); mthca_free_srq(to_mdev(srq->device), to_msrq(srq));
return 0;
} }
static struct ib_qp *mthca_create_qp(struct ib_pd *pd, static struct ib_qp *mthca_create_qp(struct ib_pd *pd,
......
...@@ -1858,7 +1858,7 @@ int ocrdma_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr) ...@@ -1858,7 +1858,7 @@ int ocrdma_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr)
return status; return status;
} }
void ocrdma_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) int ocrdma_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
{ {
struct ocrdma_srq *srq; struct ocrdma_srq *srq;
struct ocrdma_dev *dev = get_ocrdma_dev(ibsrq->device); struct ocrdma_dev *dev = get_ocrdma_dev(ibsrq->device);
...@@ -1873,6 +1873,7 @@ void ocrdma_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) ...@@ -1873,6 +1873,7 @@ void ocrdma_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
kfree(srq->idx_bit_fields); kfree(srq->idx_bit_fields);
kfree(srq->rqe_wr_id_tbl); kfree(srq->rqe_wr_id_tbl);
return 0;
} }
/* unprivileged verbs and their support functions. */ /* unprivileged verbs and their support functions. */
......
...@@ -92,7 +92,7 @@ int ocrdma_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *attr, ...@@ -92,7 +92,7 @@ int ocrdma_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *attr,
int ocrdma_modify_srq(struct ib_srq *, struct ib_srq_attr *, int ocrdma_modify_srq(struct ib_srq *, struct ib_srq_attr *,
enum ib_srq_attr_mask, struct ib_udata *); enum ib_srq_attr_mask, struct ib_udata *);
int ocrdma_query_srq(struct ib_srq *, struct ib_srq_attr *); int ocrdma_query_srq(struct ib_srq *, struct ib_srq_attr *);
void ocrdma_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata); int ocrdma_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata);
int ocrdma_post_srq_recv(struct ib_srq *, const struct ib_recv_wr *, int ocrdma_post_srq_recv(struct ib_srq *, const struct ib_recv_wr *,
const struct ib_recv_wr **bad_recv_wr); const struct ib_recv_wr **bad_recv_wr);
......
...@@ -1592,7 +1592,7 @@ int qedr_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *init_attr, ...@@ -1592,7 +1592,7 @@ int qedr_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *init_attr,
return -EFAULT; return -EFAULT;
} }
void qedr_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) int qedr_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
{ {
struct qed_rdma_destroy_srq_in_params in_params = {}; struct qed_rdma_destroy_srq_in_params in_params = {};
struct qedr_dev *dev = get_qedr_dev(ibsrq->device); struct qedr_dev *dev = get_qedr_dev(ibsrq->device);
...@@ -1610,6 +1610,7 @@ void qedr_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) ...@@ -1610,6 +1610,7 @@ void qedr_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
DP_DEBUG(dev, QEDR_MSG_SRQ, DP_DEBUG(dev, QEDR_MSG_SRQ,
"destroy srq: destroyed srq with srq_id=0x%0x\n", "destroy srq: destroyed srq with srq_id=0x%0x\n",
srq->srq_id); srq->srq_id);
return 0;
} }
int qedr_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, int qedr_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
......
...@@ -67,7 +67,7 @@ int qedr_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *attr, ...@@ -67,7 +67,7 @@ int qedr_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *attr,
int qedr_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, int qedr_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
enum ib_srq_attr_mask attr_mask, struct ib_udata *udata); enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
int qedr_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr); int qedr_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr);
void qedr_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata); int qedr_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata);
int qedr_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, int qedr_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
const struct ib_recv_wr **bad_recv_wr); const struct ib_recv_wr **bad_recv_wr);
int qedr_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, int qedr_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr,
......
...@@ -240,7 +240,7 @@ static void pvrdma_free_srq(struct pvrdma_dev *dev, struct pvrdma_srq *srq) ...@@ -240,7 +240,7 @@ static void pvrdma_free_srq(struct pvrdma_dev *dev, struct pvrdma_srq *srq)
* *
* @return: 0 for success. * @return: 0 for success.
*/ */
void pvrdma_destroy_srq(struct ib_srq *srq, struct ib_udata *udata) int pvrdma_destroy_srq(struct ib_srq *srq, struct ib_udata *udata)
{ {
struct pvrdma_srq *vsrq = to_vsrq(srq); struct pvrdma_srq *vsrq = to_vsrq(srq);
union pvrdma_cmd_req req; union pvrdma_cmd_req req;
...@@ -259,6 +259,7 @@ void pvrdma_destroy_srq(struct ib_srq *srq, struct ib_udata *udata) ...@@ -259,6 +259,7 @@ void pvrdma_destroy_srq(struct ib_srq *srq, struct ib_udata *udata)
ret); ret);
pvrdma_free_srq(dev, vsrq); pvrdma_free_srq(dev, vsrq);
return 0;
} }
/** /**
......
...@@ -423,7 +423,7 @@ int pvrdma_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *init_attr, ...@@ -423,7 +423,7 @@ int pvrdma_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *init_attr,
int pvrdma_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, int pvrdma_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
enum ib_srq_attr_mask attr_mask, struct ib_udata *udata); enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
int pvrdma_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr); int pvrdma_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
void pvrdma_destroy_srq(struct ib_srq *srq, struct ib_udata *udata); int pvrdma_destroy_srq(struct ib_srq *srq, struct ib_udata *udata);
struct ib_qp *pvrdma_create_qp(struct ib_pd *pd, struct ib_qp *pvrdma_create_qp(struct ib_pd *pd,
struct ib_qp_init_attr *init_attr, struct ib_qp_init_attr *init_attr,
......
...@@ -332,7 +332,7 @@ int rvt_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr) ...@@ -332,7 +332,7 @@ int rvt_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr)
* @ibsrq: srq object to destroy * @ibsrq: srq object to destroy
* *
*/ */
void rvt_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) int rvt_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
{ {
struct rvt_srq *srq = ibsrq_to_rvtsrq(ibsrq); struct rvt_srq *srq = ibsrq_to_rvtsrq(ibsrq);
struct rvt_dev_info *dev = ib_to_rvt(ibsrq->device); struct rvt_dev_info *dev = ib_to_rvt(ibsrq->device);
...@@ -343,4 +343,5 @@ void rvt_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) ...@@ -343,4 +343,5 @@ void rvt_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
if (srq->ip) if (srq->ip)
kref_put(&srq->ip->ref, rvt_release_mmap_info); kref_put(&srq->ip->ref, rvt_release_mmap_info);
kvfree(srq->rq.kwq); kvfree(srq->rq.kwq);
return 0;
} }
...@@ -56,6 +56,6 @@ int rvt_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, ...@@ -56,6 +56,6 @@ int rvt_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
enum ib_srq_attr_mask attr_mask, enum ib_srq_attr_mask attr_mask,
struct ib_udata *udata); struct ib_udata *udata);
int rvt_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr); int rvt_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr);
void rvt_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata); int rvt_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata);
#endif /* DEF_RVTSRQ_H */ #endif /* DEF_RVTSRQ_H */
...@@ -340,7 +340,7 @@ static int rxe_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr) ...@@ -340,7 +340,7 @@ static int rxe_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr)
return 0; return 0;
} }
static void rxe_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) static int rxe_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
{ {
struct rxe_srq *srq = to_rsrq(ibsrq); struct rxe_srq *srq = to_rsrq(ibsrq);
...@@ -349,6 +349,7 @@ static void rxe_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata) ...@@ -349,6 +349,7 @@ static void rxe_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
rxe_drop_ref(srq->pd); rxe_drop_ref(srq->pd);
rxe_drop_ref(srq); rxe_drop_ref(srq);
return 0;
} }
static int rxe_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, static int rxe_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
......
...@@ -1691,7 +1691,7 @@ int siw_query_srq(struct ib_srq *base_srq, struct ib_srq_attr *attrs) ...@@ -1691,7 +1691,7 @@ int siw_query_srq(struct ib_srq *base_srq, struct ib_srq_attr *attrs)
* QP anymore - the code trusts the RDMA core environment to keep track * QP anymore - the code trusts the RDMA core environment to keep track
* of QP references. * of QP references.
*/ */
void siw_destroy_srq(struct ib_srq *base_srq, struct ib_udata *udata) int siw_destroy_srq(struct ib_srq *base_srq, struct ib_udata *udata)
{ {
struct siw_srq *srq = to_siw_srq(base_srq); struct siw_srq *srq = to_siw_srq(base_srq);
struct siw_device *sdev = to_siw_dev(base_srq->device); struct siw_device *sdev = to_siw_dev(base_srq->device);
...@@ -1703,6 +1703,7 @@ void siw_destroy_srq(struct ib_srq *base_srq, struct ib_udata *udata) ...@@ -1703,6 +1703,7 @@ void siw_destroy_srq(struct ib_srq *base_srq, struct ib_udata *udata)
rdma_user_mmap_entry_remove(srq->srq_entry); rdma_user_mmap_entry_remove(srq->srq_entry);
vfree(srq->recvq); vfree(srq->recvq);
atomic_dec(&sdev->num_srq); atomic_dec(&sdev->num_srq);
return 0;
} }
/* /*
......
...@@ -78,7 +78,7 @@ int siw_create_srq(struct ib_srq *base_srq, struct ib_srq_init_attr *attr, ...@@ -78,7 +78,7 @@ int siw_create_srq(struct ib_srq *base_srq, struct ib_srq_init_attr *attr,
int siw_modify_srq(struct ib_srq *base_srq, struct ib_srq_attr *attr, int siw_modify_srq(struct ib_srq *base_srq, struct ib_srq_attr *attr,
enum ib_srq_attr_mask mask, struct ib_udata *udata); enum ib_srq_attr_mask mask, struct ib_udata *udata);
int siw_query_srq(struct ib_srq *base_srq, struct ib_srq_attr *attr); int siw_query_srq(struct ib_srq *base_srq, struct ib_srq_attr *attr);
void siw_destroy_srq(struct ib_srq *base_srq, struct ib_udata *udata); int siw_destroy_srq(struct ib_srq *base_srq, struct ib_udata *udata);
int siw_post_srq_recv(struct ib_srq *base_srq, const struct ib_recv_wr *wr, int siw_post_srq_recv(struct ib_srq *base_srq, const struct ib_recv_wr *wr,
const struct ib_recv_wr **bad_wr); const struct ib_recv_wr **bad_wr);
int siw_mmap(struct ib_ucontext *ctx, struct vm_area_struct *vma); int siw_mmap(struct ib_ucontext *ctx, struct vm_area_struct *vma);
......
...@@ -1647,17 +1647,13 @@ int ipoib_cm_dev_init(struct net_device *dev) ...@@ -1647,17 +1647,13 @@ int ipoib_cm_dev_init(struct net_device *dev)
void ipoib_cm_dev_cleanup(struct net_device *dev) void ipoib_cm_dev_cleanup(struct net_device *dev)
{ {
struct ipoib_dev_priv *priv = ipoib_priv(dev); struct ipoib_dev_priv *priv = ipoib_priv(dev);
int ret;
if (!priv->cm.srq) if (!priv->cm.srq)
return; return;
ipoib_dbg(priv, "Cleanup ipoib connected mode.\n"); ipoib_dbg(priv, "Cleanup ipoib connected mode.\n");
ret = ib_destroy_srq(priv->cm.srq); ib_destroy_srq(priv->cm.srq);
if (ret)
ipoib_warn(priv, "ib_destroy_srq failed: %d\n", ret);
priv->cm.srq = NULL; priv->cm.srq = NULL;
if (!priv->cm.srq_ring) if (!priv->cm.srq_ring)
return; return;
......
...@@ -2411,7 +2411,7 @@ struct ib_device_ops { ...@@ -2411,7 +2411,7 @@ struct ib_device_ops {
enum ib_srq_attr_mask srq_attr_mask, enum ib_srq_attr_mask srq_attr_mask,
struct ib_udata *udata); struct ib_udata *udata);
int (*query_srq)(struct ib_srq *srq, struct ib_srq_attr *srq_attr); int (*query_srq)(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
void (*destroy_srq)(struct ib_srq *srq, struct ib_udata *udata); int (*destroy_srq)(struct ib_srq *srq, struct ib_udata *udata);
struct ib_qp *(*create_qp)(struct ib_pd *pd, struct ib_qp *(*create_qp)(struct ib_pd *pd,
struct ib_qp_init_attr *qp_init_attr, struct ib_qp_init_attr *qp_init_attr,
struct ib_udata *udata); struct ib_udata *udata);
...@@ -3654,9 +3654,11 @@ int ib_destroy_srq_user(struct ib_srq *srq, struct ib_udata *udata); ...@@ -3654,9 +3654,11 @@ int ib_destroy_srq_user(struct ib_srq *srq, struct ib_udata *udata);
* *
* NOTE: for user srq use ib_destroy_srq_user with valid udata! * NOTE: for user srq use ib_destroy_srq_user with valid udata!
*/ */
static inline int ib_destroy_srq(struct ib_srq *srq) static inline void ib_destroy_srq(struct ib_srq *srq)
{ {
return ib_destroy_srq_user(srq, NULL); int ret = ib_destroy_srq_user(srq, NULL);
WARN_ONCE(ret, "Destroy of kernel SRQ shouldn't fail");
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment