RE: [PATCH rdma-next 4/6] RDMA/mana_ib: introduce a helper to remove cq callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Subject: [PATCH rdma-next 4/6] RDMA/mana_ib: introduce a helper to
> remove cq callbacks
> 
> From: Konstantin Taranov <kotaranov@xxxxxxxxxxxxx>
> 
> Intoduce the mana_ib_remove_cq_cb helper to remove cq callbacks.
> The helper removes code duplicates.
> 
> Signed-off-by: Konstantin Taranov <kotaranov@xxxxxxxxxxxxx>
> ---
>  drivers/infiniband/hw/mana/cq.c      | 19 ++++++++++++-------
>  drivers/infiniband/hw/mana/mana_ib.h |  1 +
>  drivers/infiniband/hw/mana/qp.c      | 26 ++++----------------------
>  3 files changed, 17 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mana/cq.c
> b/drivers/infiniband/hw/mana/cq.c index 0467ee8..6c3bb8c 100644
> --- a/drivers/infiniband/hw/mana/cq.c
> +++ b/drivers/infiniband/hw/mana/cq.c
> @@ -48,16 +48,10 @@ int mana_ib_destroy_cq(struct ib_cq *ibcq, struct
> ib_udata *udata)
>  	struct mana_ib_cq *cq = container_of(ibcq, struct mana_ib_cq, ibcq);
>  	struct ib_device *ibdev = ibcq->device;
>  	struct mana_ib_dev *mdev;
> -	struct gdma_context *gc;
> 
>  	mdev = container_of(ibdev, struct mana_ib_dev, ib_dev);
> -	gc = mdev_to_gc(mdev);
> -
> -	if (cq->queue.id != INVALID_QUEUE_ID) {
> -		kfree(gc->cq_table[cq->queue.id]);
> -		gc->cq_table[cq->queue.id] = NULL;
> -	}
> 
> +	mana_ib_remove_cq_cb(mdev, cq);
>  	mana_ib_destroy_queue(mdev, &cq->queue);
> 
>  	return 0;
> @@ -89,3 +83,14 @@ int mana_ib_install_cq_cb(struct mana_ib_dev *mdev,
> struct mana_ib_cq *cq)
>  	gc->cq_table[cq->queue.id] = gdma_cq;
>  	return 0;
>  }
> +
> +void mana_ib_remove_cq_cb(struct mana_ib_dev *mdev, struct
> mana_ib_cq
> +*cq) {
> +	struct gdma_context *gc = mdev_to_gc(mdev);
> +
> +	if (cq->queue.id >= gc->max_num_cqs)
> +		return;
> +
> +	kfree(gc->cq_table[cq->queue.id]);
> +	gc->cq_table[cq->queue.id] = NULL;

Why the check for (cq->queue.id != INVALID_QUEUE_ID) is removed?

> +}
> diff --git a/drivers/infiniband/hw/mana/mana_ib.h
> b/drivers/infiniband/hw/mana/mana_ib.h
> index 9c07021..6c19f4f 100644
> --- a/drivers/infiniband/hw/mana/mana_ib.h
> +++ b/drivers/infiniband/hw/mana/mana_ib.h
> @@ -255,6 +255,7 @@ static inline void copy_in_reverse(u8 *dst, const u8
> *src, u32 size)  }
> 
>  int mana_ib_install_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq
> *cq);
> +void mana_ib_remove_cq_cb(struct mana_ib_dev *mdev, struct
> mana_ib_cq
> +*cq);
> 
>  int mana_ib_create_zero_offset_dma_region(struct mana_ib_dev *dev,
> struct ib_umem *umem,
>  					  mana_handle_t *gdma_region);
> diff --git a/drivers/infiniband/hw/mana/qp.c
> b/drivers/infiniband/hw/mana/qp.c index c4fb8b4..169b286 100644
> --- a/drivers/infiniband/hw/mana/qp.c
> +++ b/drivers/infiniband/hw/mana/qp.c
> @@ -95,11 +95,9 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp,
> struct ib_pd *pd,
>  	struct mana_ib_qp *qp = container_of(ibqp, struct mana_ib_qp,
> ibqp);
>  	struct mana_ib_dev *mdev =
>  		container_of(pd->device, struct mana_ib_dev, ib_dev);
> -	struct gdma_context *gc = mdev_to_gc(mdev);
>  	struct ib_rwq_ind_table *ind_tbl = attr->rwq_ind_tbl;
>  	struct mana_ib_create_qp_rss_resp resp = {};
>  	struct mana_ib_create_qp_rss ucmd = {};
> -	struct gdma_queue **gdma_cq_allocated;
>  	mana_handle_t *mana_ind_table;
>  	struct mana_port_context *mpc;
>  	unsigned int ind_tbl_size;
> @@ -173,13 +171,6 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp,
> struct ib_pd *pd,
>  		goto fail;
>  	}
> 
> -	gdma_cq_allocated = kcalloc(ind_tbl_size,
> sizeof(*gdma_cq_allocated),
> -				    GFP_KERNEL);
> -	if (!gdma_cq_allocated) {
> -		ret = -ENOMEM;
> -		goto fail;
> -	}
> -

Why the allocation for CQs is removed? This is not related to this patch.






[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux