diff mbox series

[for-next,5/8] RDMA/hns: Bugfix for calculating qp buffer size

Message ID 1561376872-111496-6-git-send-email-oulijun@huawei.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series Some fixes from hns | expand

Commit Message

Lijun Ou June 24, 2019, 11:47 a.m. UTC
From: o00290482 <o00290482@huawei.com>

The buffer size of qp which used to allocate qp buffer space for
storing sqwqe and rqwqe will be the length of buffer space. The
kernel driver will use the buffer address and the same size to
get the user memory. The same size named buff_size of qp. According
the algorithm of calculating, The size of the two is not equal
when users set the max sge of sq.

Fixes: b28ca7cceff8 ("RDMA/hns: Limit extend sq sge num")
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_qp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Lijun Ou July 6, 2019, 1:47 a.m. UTC | #1
在 2019/6/24 19:47, Lijun Ou 写道:
> From: o00290482 <o00290482@huawei.com>
Hi, Jason
   May be my local configuration error causing the wroong author.  How should I make changes?

The correct as follows:
From: Lijun Ou <oulijun@huawei.com>
> The buffer size of qp which used to allocate qp buffer space for
> storing sqwqe and rqwqe will be the length of buffer space. The
> kernel driver will use the buffer address and the same size to
> get the user memory. The same size named buff_size of qp. According
> the algorithm of calculating, The size of the two is not equal
> when users set the max sge of sq.
>
> Fixes: b28ca7cceff8 ("RDMA/hns: Limit extend sq sge num")
> Signed-off-by: Lijun Ou <oulijun@huawei.com>
> ---
>  drivers/infiniband/hw/hns/hns_roce_qp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
> index 305be42..d56c03d 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_qp.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
> @@ -392,8 +392,8 @@ static int hns_roce_set_user_sq_size(struct hns_roce_dev *hr_dev,
>  					     hr_qp->sq.wqe_shift), PAGE_SIZE);
>  	} else {
>  		page_size = 1 << (hr_dev->caps.mtt_buf_pg_sz + PAGE_SHIFT);
> -		hr_qp->sge.sge_cnt =
> -		       max(page_size / (1 << hr_qp->sge.sge_shift), ex_sge_num);
> +		hr_qp->sge.sge_cnt = ex_sge_num ?
> +		   max(page_size / (1 << hr_qp->sge.sge_shift), ex_sge_num) : 0;
>  		hr_qp->buff_size = HNS_ROCE_ALOGN_UP((hr_qp->rq.wqe_cnt <<
>  					     hr_qp->rq.wqe_shift), page_size) +
>  				   HNS_ROCE_ALOGN_UP((hr_qp->sge.sge_cnt <<
Jason Gunthorpe July 7, 2019, 12:21 p.m. UTC | #2
On Sat, Jul 06, 2019 at 09:47:09AM +0800, oulijun wrote:
> 在 2019/6/24 19:47, Lijun Ou 写道:
> > From: o00290482 <o00290482@huawei.com>
> Hi, Jason
>    May be my local configuration error causing the wroong author.  How should I make changes?
> 
> The correct as follows:
> From: Lijun Ou <oulijun@huawei.com>

I fixed it this once, but please check and fix it on your end in
future.

You should be able to set the patch author in git's config file:

[user]
        email = jgg@mellanox.com
        name = Jason Gunthorpe

Jason
Lijun Ou July 8, 2019, 1:46 p.m. UTC | #3
在 2019/7/7 20:21, Jason Gunthorpe 写道:
> On Sat, Jul 06, 2019 at 09:47:09AM +0800, oulijun wrote:
>> 在 2019/6/24 19:47, Lijun Ou 写道:
>>> From: o00290482 <o00290482@huawei.com>
>> Hi, Jason
>>    May be my local configuration error causing the wroong author.  How should I make changes?
>>
>> The correct as follows:
>> From: Lijun Ou <oulijun@huawei.com>
> I fixed it this once, but please check and fix it on your end in
> future.
>
> You should be able to set the patch author in git's config file:
>
> [user]
>         email = jgg@mellanox.com
>         name = Jason Gunthorpe
>
> Jason
>
> .
Thanks.
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
index 305be42..d56c03d 100644
--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
+++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
@@ -392,8 +392,8 @@  static int hns_roce_set_user_sq_size(struct hns_roce_dev *hr_dev,
 					     hr_qp->sq.wqe_shift), PAGE_SIZE);
 	} else {
 		page_size = 1 << (hr_dev->caps.mtt_buf_pg_sz + PAGE_SHIFT);
-		hr_qp->sge.sge_cnt =
-		       max(page_size / (1 << hr_qp->sge.sge_shift), ex_sge_num);
+		hr_qp->sge.sge_cnt = ex_sge_num ?
+		   max(page_size / (1 << hr_qp->sge.sge_shift), ex_sge_num) : 0;
 		hr_qp->buff_size = HNS_ROCE_ALOGN_UP((hr_qp->rq.wqe_cnt <<
 					     hr_qp->rq.wqe_shift), page_size) +
 				   HNS_ROCE_ALOGN_UP((hr_qp->sge.sge_cnt <<