On Thu, Jun 15, 2023 at 11:14:12AM +0000, Wei Hu wrote: Hi Wei Hu, some minor nits from my side. ... > @@ -69,11 +76,35 @@ 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; > + struct gdma_dev *gd; > + int err; > + > > mdev = container_of(ibdev, struct mana_ib_dev, ib_dev); > + gd = mdev->gdma_dev; > + gc = gd->gdma_context; > + > > - mana_ib_gd_destroy_dma_region(mdev, cq->gdma_region); > - ib_umem_release(cq->umem); > + > + if (atomic_read(&ibcq->usecnt) == 0) { > + err = mana_ib_gd_destroy_dma_region(mdev, cq->gdma_region); > + if (err) { > + ibdev_dbg(ibdev, > + "Faile to destroy dma region, %d\n", err); nit: Faile -> Failed > + return err; > + } > + kfree(gc->cq_table[cq->id]); > + gc->cq_table[cq->id] = NULL; > + ib_umem_release(cq->umem); > + } > > return 0; > } ... > diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c > index 7be4c3adb4e2..e2affb6ae5ad 100644 > --- a/drivers/infiniband/hw/mana/main.c > +++ b/drivers/infiniband/hw/mana/main.c > @@ -143,6 +143,79 @@ int mana_ib_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) > return err; > } > > +static void mana_ib_destroy_eq(struct mana_ib_ucontext *ucontext, > + struct mana_ib_dev *mdev) > +{ > + struct gdma_context *gc = mdev->gdma_dev->gdma_context; > + struct ib_device *ibdev = ucontext->ibucontext.device; nit: ibdev is set but unused. GCC 12.3.0 with W=1 says: drivers/infiniband/hw/mana/main.c: In function 'mana_ib_destroy_eq': drivers/infiniband/hw/mana/main.c:150:27: warning: unused variable 'ibdev' [-Wunused-variable] 150 | struct ib_device *ibdev = ucontext->ibucontext.device; > + struct gdma_queue *eq; > + int i; > + > + if (!ucontext->eqs) > + return; > + > + for (i = 0; i < gc->max_num_queues; i++) { > + eq = ucontext->eqs[i].eq; > + if (!eq) > + continue; > + > + mana_gd_destroy_queue(gc, eq); > + } > + > + kfree(ucontext->eqs); > + ucontext->eqs = NULL; > +} ...