linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-rc 0/2] RDMA/hns: Fix incorrect assignments
@ 2019-11-01  2:33 Weihang Li
  2019-11-01  2:33 ` [PATCH for-rc 1/2] RDMA/hns: Correct the value of HNS_ROCE_HEM_CHUNK_LEN Weihang Li
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Weihang Li @ 2019-11-01  2:33 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

1. HNS_ROCE_HEM_CHUNK_LEN in patch 1/2 is used to initialize sg table, its
current value is larger than needed.
2. srq_desc_size in patch 2/2 is used to allocate srq buffer, buffer size
may be less than expected.

Sirong Wang (1):
  RDMA/hns: Correct the value of HNS_ROCE_HEM_CHUNK_LEN

Wenpeng Liang (1):
  RDMA/hns: Correct the value of srq_desc_size

 drivers/infiniband/hw/hns/hns_roce_hem.h | 2 +-
 drivers/infiniband/hw/hns/hns_roce_srq.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.8.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH for-rc 1/2] RDMA/hns: Correct the value of HNS_ROCE_HEM_CHUNK_LEN
  2019-11-01  2:33 [PATCH for-rc 0/2] RDMA/hns: Fix incorrect assignments Weihang Li
@ 2019-11-01  2:33 ` Weihang Li
  2019-11-01  2:33 ` [PATCH for-rc 2/2] RDMA/hns: Correct the value of srq_desc_size Weihang Li
  2019-11-06 17:44 ` [PATCH for-rc 0/2] RDMA/hns: Fix incorrect assignments Jason Gunthorpe
  2 siblings, 0 replies; 4+ messages in thread
From: Weihang Li @ 2019-11-01  2:33 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

From: Sirong Wang <wangsirong@huawei.com>

Size of pointer to buf field of struct hns_roce_hem_chunk should be
considered when calculating HNS_ROCE_HEM_CHUNK_LEN, or sg table size
will be larger than expected when allocating hem.

Fixes: 9a4435375cd1 ("IB/hns: Add driver files for hns RoCE driver")
Signed-off-by: Sirong Wang <wangsirong@huawei.com>
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
---
 drivers/infiniband/hw/hns/hns_roce_hem.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.h b/drivers/infiniband/hw/hns/hns_roce_hem.h
index 8678327..3bb8f78 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hem.h
+++ b/drivers/infiniband/hw/hns/hns_roce_hem.h
@@ -59,7 +59,7 @@ enum {
 
 #define HNS_ROCE_HEM_CHUNK_LEN	\
 	 ((256 - sizeof(struct list_head) - 2 * sizeof(int)) /	 \
-	 (sizeof(struct scatterlist)))
+	 (sizeof(struct scatterlist) + sizeof(void *)))
 
 #define check_whether_bt_num_3(type, hop_num) \
 	(type < HEM_TYPE_MTT && hop_num == 2)
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH for-rc 2/2] RDMA/hns: Correct the value of srq_desc_size
  2019-11-01  2:33 [PATCH for-rc 0/2] RDMA/hns: Fix incorrect assignments Weihang Li
  2019-11-01  2:33 ` [PATCH for-rc 1/2] RDMA/hns: Correct the value of HNS_ROCE_HEM_CHUNK_LEN Weihang Li
@ 2019-11-01  2:33 ` Weihang Li
  2019-11-06 17:44 ` [PATCH for-rc 0/2] RDMA/hns: Fix incorrect assignments Jason Gunthorpe
  2 siblings, 0 replies; 4+ messages in thread
From: Weihang Li @ 2019-11-01  2:33 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

From: Wenpeng Liang <liangwenpeng@huawei.com>

srq_desc_size should be rounded up to pow of two before used, or related
calculation may cause allocating wrong size of memory for srq buffer.

Fixes: c7bcb13442e1 ("RDMA/hns: Add SRQ support for hip08 kernel mode")
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
---
 drivers/infiniband/hw/hns/hns_roce_srq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
index 9591457..43ea2c1 100644
--- a/drivers/infiniband/hw/hns/hns_roce_srq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
@@ -376,7 +376,7 @@ int hns_roce_create_srq(struct ib_srq *ib_srq,
 	srq->max = roundup_pow_of_two(srq_init_attr->attr.max_wr + 1);
 	srq->max_gs = srq_init_attr->attr.max_sge;
 
-	srq_desc_size = max(16, 16 * srq->max_gs);
+	srq_desc_size = roundup_pow_of_two(max(16, 16 * srq->max_gs));
 
 	srq->wqe_shift = ilog2(srq_desc_size);
 
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH for-rc 0/2] RDMA/hns: Fix incorrect assignments
  2019-11-01  2:33 [PATCH for-rc 0/2] RDMA/hns: Fix incorrect assignments Weihang Li
  2019-11-01  2:33 ` [PATCH for-rc 1/2] RDMA/hns: Correct the value of HNS_ROCE_HEM_CHUNK_LEN Weihang Li
  2019-11-01  2:33 ` [PATCH for-rc 2/2] RDMA/hns: Correct the value of srq_desc_size Weihang Li
@ 2019-11-06 17:44 ` Jason Gunthorpe
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2019-11-06 17:44 UTC (permalink / raw)
  To: Weihang Li; +Cc: dledford, linux-rdma, linuxarm

On Fri, Nov 01, 2019 at 10:33:28AM +0800, Weihang Li wrote:
> 1. HNS_ROCE_HEM_CHUNK_LEN in patch 1/2 is used to initialize sg table, its
> current value is larger than needed.
> 2. srq_desc_size in patch 2/2 is used to allocate srq buffer, buffer size
> may be less than expected.
> 
> Sirong Wang (1):
>   RDMA/hns: Correct the value of HNS_ROCE_HEM_CHUNK_LEN
> 
> Wenpeng Liang (1):
>   RDMA/hns: Correct the value of srq_desc_size

Applied to for-next, thanks

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-06 17:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-01  2:33 [PATCH for-rc 0/2] RDMA/hns: Fix incorrect assignments Weihang Li
2019-11-01  2:33 ` [PATCH for-rc 1/2] RDMA/hns: Correct the value of HNS_ROCE_HEM_CHUNK_LEN Weihang Li
2019-11-01  2:33 ` [PATCH for-rc 2/2] RDMA/hns: Correct the value of srq_desc_size Weihang Li
2019-11-06 17:44 ` [PATCH for-rc 0/2] RDMA/hns: Fix incorrect assignments Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).