Message ID | 1536223781-21169-3-git-send-email-liuyixian@huawei.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Jason Gunthorpe |
Headers | show |
Series | Add mw support for hip08 in kernel space | expand |
On Thu, Sep 06, 2018 at 04:49:41PM +0800, Yixian Liu wrote: > This patch adds memory window (mw) deallocation support in > kernel space driver. > > Signed-off-by: Yixian Liu <liuyixian@huawei.com> > drivers/infiniband/hw/hns/hns_roce_device.h | 1 + > drivers/infiniband/hw/hns/hns_roce_main.c | 5 ++++- > drivers/infiniband/hw/hns/hns_roce_mr.c | 21 ++++++++++++++------- > 3 files changed, 19 insertions(+), 8 deletions(-) > > diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h > index 4fe4a3b..a7e2408 100644 > +++ b/drivers/infiniband/hw/hns/hns_roce_device.h > @@ -995,6 +995,7 @@ unsigned long key_to_hw_index(u32 key); > > struct ib_mw *hns_roce_alloc_mw(struct ib_pd *pd, enum ib_mw_type, > struct ib_udata *udata); > +int hns_roce_dealloc_mw(struct ib_mw *ibmw); > > void hns_roce_buf_free(struct hns_roce_dev *hr_dev, u32 size, > struct hns_roce_buf *buf); > diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c > index ff71d91..de45da3 100644 > +++ b/drivers/infiniband/hw/hns/hns_roce_main.c > @@ -587,7 +587,10 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev) > /* MW */ > if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_MW) { > ib_dev->alloc_mw = hns_roce_alloc_mw; > - ib_dev->uverbs_cmd_mask |= (1ULL << IB_USER_VERBS_CMD_ALLOC_MW); > + ib_dev->dealloc_mw = hns_roce_dealloc_mw; > + ib_dev->uverbs_cmd_mask |= > + (1ULL << IB_USER_VERBS_CMD_ALLOC_MW) | > + (1ULL << IB_USER_VERBS_CMD_DEALLOC_MW); > } > > /* OTHERS */ > diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c > index 84779dd..767a25a 100644 > +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c > @@ -1202,19 +1202,17 @@ int hns_roce_dereg_mr(struct ib_mr *ibmr) > return ret; > } > > -static int hns_roce_mw_free(struct hns_roce_dev *hr_dev, > +static void hns_roce_mw_free(struct hns_roce_dev *hr_dev, > struct hns_roce_mw *mw) > { don't change stuff you newly introduced in the patch before Jason
On 2018/9/7 2:47, Jason Gunthorpe wrote: > On Thu, Sep 06, 2018 at 04:49:41PM +0800, Yixian Liu wrote: >> This patch adds memory window (mw) deallocation support in >> kernel space driver. >> >> Signed-off-by: Yixian Liu <liuyixian@huawei.com> >> drivers/infiniband/hw/hns/hns_roce_device.h | 1 + >> drivers/infiniband/hw/hns/hns_roce_main.c | 5 ++++- >> drivers/infiniband/hw/hns/hns_roce_mr.c | 21 ++++++++++++++------- >> 3 files changed, 19 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h >> index 4fe4a3b..a7e2408 100644 >> +++ b/drivers/infiniband/hw/hns/hns_roce_device.h >> @@ -995,6 +995,7 @@ unsigned long key_to_hw_index(u32 key); >> >> struct ib_mw *hns_roce_alloc_mw(struct ib_pd *pd, enum ib_mw_type, >> struct ib_udata *udata); >> +int hns_roce_dealloc_mw(struct ib_mw *ibmw); >> >> void hns_roce_buf_free(struct hns_roce_dev *hr_dev, u32 size, >> struct hns_roce_buf *buf); >> diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c >> index ff71d91..de45da3 100644 >> +++ b/drivers/infiniband/hw/hns/hns_roce_main.c >> @@ -587,7 +587,10 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev) >> /* MW */ >> if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_MW) { >> ib_dev->alloc_mw = hns_roce_alloc_mw; >> - ib_dev->uverbs_cmd_mask |= (1ULL << IB_USER_VERBS_CMD_ALLOC_MW); >> + ib_dev->dealloc_mw = hns_roce_dealloc_mw; >> + ib_dev->uverbs_cmd_mask |= >> + (1ULL << IB_USER_VERBS_CMD_ALLOC_MW) | >> + (1ULL << IB_USER_VERBS_CMD_DEALLOC_MW); >> } >> >> /* OTHERS */ >> diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c >> index 84779dd..767a25a 100644 >> +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c >> @@ -1202,19 +1202,17 @@ int hns_roce_dereg_mr(struct ib_mr *ibmr) >> return ret; >> } >> >> -static int hns_roce_mw_free(struct hns_roce_dev *hr_dev, >> +static void hns_roce_mw_free(struct hns_roce_dev *hr_dev, >> struct hns_roce_mw *mw) >> { > > don't change stuff you newly introduced in the patch before Thanks, I will fix it next version. > > Jason > > . >
diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h index 4fe4a3b..a7e2408 100644 --- a/drivers/infiniband/hw/hns/hns_roce_device.h +++ b/drivers/infiniband/hw/hns/hns_roce_device.h @@ -995,6 +995,7 @@ unsigned long key_to_hw_index(u32 key); struct ib_mw *hns_roce_alloc_mw(struct ib_pd *pd, enum ib_mw_type, struct ib_udata *udata); +int hns_roce_dealloc_mw(struct ib_mw *ibmw); void hns_roce_buf_free(struct hns_roce_dev *hr_dev, u32 size, struct hns_roce_buf *buf); diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index ff71d91..de45da3 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -587,7 +587,10 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev) /* MW */ if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_MW) { ib_dev->alloc_mw = hns_roce_alloc_mw; - ib_dev->uverbs_cmd_mask |= (1ULL << IB_USER_VERBS_CMD_ALLOC_MW); + ib_dev->dealloc_mw = hns_roce_dealloc_mw; + ib_dev->uverbs_cmd_mask |= + (1ULL << IB_USER_VERBS_CMD_ALLOC_MW) | + (1ULL << IB_USER_VERBS_CMD_DEALLOC_MW); } /* OTHERS */ diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c index 84779dd..767a25a 100644 --- a/drivers/infiniband/hw/hns/hns_roce_mr.c +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c @@ -1202,19 +1202,17 @@ int hns_roce_dereg_mr(struct ib_mr *ibmr) return ret; } -static int hns_roce_mw_free(struct hns_roce_dev *hr_dev, +static void hns_roce_mw_free(struct hns_roce_dev *hr_dev, struct hns_roce_mw *mw) { struct device *dev = hr_dev->dev; - int ret = 0; + int ret; if (mw->enabled) { ret = hns_roce_hw2sw_mpt(hr_dev, NULL, key_to_hw_index(mw->rkey) & (hr_dev->caps.num_mtpts - 1)); - if (ret) { + if (ret) dev_warn(dev, "MW HW2SW_MPT failed (%d)\n", ret); - return ret; - } } if (mw->enabled) @@ -1223,8 +1221,6 @@ static int hns_roce_mw_free(struct hns_roce_dev *hr_dev, hns_roce_bitmap_free(&hr_dev->mr_table.mtpt_bitmap, key_to_hw_index(mw->rkey), BITMAP_NO_RR); - - return ret; } static int hns_roce_mw_enable(struct hns_roce_dev *hr_dev, @@ -1321,3 +1317,14 @@ struct ib_mw *hns_roce_alloc_mw(struct ib_pd *ib_pd, enum ib_mw_type type, return ERR_PTR(ret); } + +int hns_roce_dealloc_mw(struct ib_mw *ibmw) +{ + struct hns_roce_dev *hr_dev = to_hr_dev(ibmw->device); + struct hns_roce_mw *mw = to_hr_mw(ibmw); + + hns_roce_mw_free(hr_dev, mw); + kfree(mw); + + return 0; +}
This patch adds memory window (mw) deallocation support in kernel space driver. Signed-off-by: Yixian Liu <liuyixian@huawei.com> --- drivers/infiniband/hw/hns/hns_roce_device.h | 1 + drivers/infiniband/hw/hns/hns_roce_main.c | 5 ++++- drivers/infiniband/hw/hns/hns_roce_mr.c | 21 ++++++++++++++------- 3 files changed, 19 insertions(+), 8 deletions(-)