Message ID | 17-v2-270386b7e60b+28f4-umem_1_jgg@nvidia.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Jason Gunthorpe |
Headers | show |
Series | RDMA: Improve use of umem in DMA drivers | expand |
On Fri, Sep 04, 2020 at 07:41:58PM -0300, Jason Gunthorpe wrote: > This is always the same value as IOVA masked by the page size, just use > that clearer calculation directly. > > It is unclear of ocrdma hardware can actually support a true fbo, if so it > could use a different algorithm to compute the best page size. > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > --- > drivers/infiniband/hw/ocrdma/ocrdma.h | 1 - > drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 5 +++-- > drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 1 - > 3 files changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h > index fcfe0e82197a24..5eb61c1100900d 100644 > --- a/drivers/infiniband/hw/ocrdma/ocrdma.h > +++ b/drivers/infiniband/hw/ocrdma/ocrdma.h > @@ -185,7 +185,6 @@ struct ocrdma_hw_mr { > u32 num_pbes; > u32 pbl_size; > u32 pbe_size; > - u64 fbo; > u64 va; > }; > > diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c > index e07bf0b2209a4c..18ed658f8dba10 100644 > --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c > +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c > @@ -1962,6 +1962,7 @@ static int ocrdma_mbx_reg_mr(struct ocrdma_dev *dev, struct ocrdma_hw_mr *hwmr, > int i; > struct ocrdma_reg_nsmr *cmd; > struct ocrdma_reg_nsmr_rsp *rsp; > + u64 fbo = hwmr->va & (hwmr->pbe_size - 1); > > cmd = ocrdma_init_emb_mqe(OCRDMA_CMD_REGISTER_NSMR, sizeof(*cmd)); > if (!cmd) > @@ -1987,8 +1988,8 @@ static int ocrdma_mbx_reg_mr(struct ocrdma_dev *dev, struct ocrdma_hw_mr *hwmr, > OCRDMA_REG_NSMR_HPAGE_SIZE_SHIFT; > cmd->totlen_low = hwmr->len; > cmd->totlen_high = upper_32_bits(hwmr->len); > - cmd->fbo_low = (u32) (hwmr->fbo & 0xffffffff); > - cmd->fbo_high = (u32) upper_32_bits(hwmr->fbo); > + cmd->fbo_low = (u32) (fbo & 0xffffffff); lower_32_bits(fbo) > + cmd->fbo_high = (u32) upper_32_bits(fbo); u32 casting is not necessary. > cmd->va_loaddr = (u32) hwmr->va; > cmd->va_hiaddr = (u32) upper_32_bits(hwmr->va); > > diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c > index 1fb8da6d613674..3b98a3b3e2272d 100644 > --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c > +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c > @@ -870,7 +870,6 @@ struct ib_mr *ocrdma_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len, > goto umem_err; > > mr->hwmr.pbe_size = PAGE_SIZE; > - mr->hwmr.fbo = ib_umem_offset(mr->umem); > mr->hwmr.va = usr_addr; > mr->hwmr.len = len; > mr->hwmr.remote_wr = (acc & IB_ACCESS_REMOTE_WRITE) ? 1 : 0; > -- > 2.28.0 >
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h index fcfe0e82197a24..5eb61c1100900d 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma.h +++ b/drivers/infiniband/hw/ocrdma/ocrdma.h @@ -185,7 +185,6 @@ struct ocrdma_hw_mr { u32 num_pbes; u32 pbl_size; u32 pbe_size; - u64 fbo; u64 va; }; diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index e07bf0b2209a4c..18ed658f8dba10 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c @@ -1962,6 +1962,7 @@ static int ocrdma_mbx_reg_mr(struct ocrdma_dev *dev, struct ocrdma_hw_mr *hwmr, int i; struct ocrdma_reg_nsmr *cmd; struct ocrdma_reg_nsmr_rsp *rsp; + u64 fbo = hwmr->va & (hwmr->pbe_size - 1); cmd = ocrdma_init_emb_mqe(OCRDMA_CMD_REGISTER_NSMR, sizeof(*cmd)); if (!cmd) @@ -1987,8 +1988,8 @@ static int ocrdma_mbx_reg_mr(struct ocrdma_dev *dev, struct ocrdma_hw_mr *hwmr, OCRDMA_REG_NSMR_HPAGE_SIZE_SHIFT; cmd->totlen_low = hwmr->len; cmd->totlen_high = upper_32_bits(hwmr->len); - cmd->fbo_low = (u32) (hwmr->fbo & 0xffffffff); - cmd->fbo_high = (u32) upper_32_bits(hwmr->fbo); + cmd->fbo_low = (u32) (fbo & 0xffffffff); + cmd->fbo_high = (u32) upper_32_bits(fbo); cmd->va_loaddr = (u32) hwmr->va; cmd->va_hiaddr = (u32) upper_32_bits(hwmr->va); diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index 1fb8da6d613674..3b98a3b3e2272d 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c @@ -870,7 +870,6 @@ struct ib_mr *ocrdma_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len, goto umem_err; mr->hwmr.pbe_size = PAGE_SIZE; - mr->hwmr.fbo = ib_umem_offset(mr->umem); mr->hwmr.va = usr_addr; mr->hwmr.len = len; mr->hwmr.remote_wr = (acc & IB_ACCESS_REMOTE_WRITE) ? 1 : 0;
This is always the same value as IOVA masked by the page size, just use that clearer calculation directly. It is unclear of ocrdma hardware can actually support a true fbo, if so it could use a different algorithm to compute the best page size. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> --- drivers/infiniband/hw/ocrdma/ocrdma.h | 1 - drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 5 +++-- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 1 - 3 files changed, 3 insertions(+), 4 deletions(-)