* [PATCH for-rc 0/2] Bugfix or cleanup for CQE size
@ 2021-09-27 12:55 Wenpeng Liang
2021-09-27 12:55 ` [PATCH for-rc 1/2] RDMA/hns: Fix the size setting error when copying CQE in clean_cq() Wenpeng Liang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Wenpeng Liang @ 2021-09-27 12:55 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm, liangwenpeng
Specify the size of CQE when copying CQE, and add the check of CQE size of
user space.
Wenpeng Liang (2):
RDMA/hns: Fix the size setting error when copying CQE in clean_cq()
RDMA/hns: Add the check of the CQE size of the user space
drivers/infiniband/hw/hns/hns_roce_cq.c | 31 +++++++++++++++-------
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +-
2 files changed, 23 insertions(+), 10 deletions(-)
--
2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH for-rc 1/2] RDMA/hns: Fix the size setting error when copying CQE in clean_cq()
2021-09-27 12:55 [PATCH for-rc 0/2] Bugfix or cleanup for CQE size Wenpeng Liang
@ 2021-09-27 12:55 ` Wenpeng Liang
2021-09-27 12:55 ` [PATCH for-rc 2/2] RDMA/hns: Add the check of the CQE size of the user space Wenpeng Liang
2021-09-27 19:17 ` [PATCH for-rc 0/2] Bugfix or cleanup for CQE size Jason Gunthorpe
2 siblings, 0 replies; 4+ messages in thread
From: Wenpeng Liang @ 2021-09-27 12:55 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm, liangwenpeng
The size of CQE is different for different versions of hardware, so the
driver needs to specify the size of CQE explicitly.
Fixes: 09a5f210f67e ("RDMA/hns: Add support for CQE in size of 64 Bytes")
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index a9c00a2e8ebd..d5f3faa1627a 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -3299,7 +3299,7 @@ static void __hns_roce_v2_cq_clean(struct hns_roce_cq *hr_cq, u32 qpn,
dest = get_cqe_v2(hr_cq, (prod_index + nfreed) &
hr_cq->ib_cq.cqe);
owner_bit = hr_reg_read(dest, CQE_OWNER);
- memcpy(dest, cqe, sizeof(*cqe));
+ memcpy(dest, cqe, hr_cq->cqe_size);
hr_reg_write(dest, CQE_OWNER, owner_bit);
}
}
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH for-rc 2/2] RDMA/hns: Add the check of the CQE size of the user space
2021-09-27 12:55 [PATCH for-rc 0/2] Bugfix or cleanup for CQE size Wenpeng Liang
2021-09-27 12:55 ` [PATCH for-rc 1/2] RDMA/hns: Fix the size setting error when copying CQE in clean_cq() Wenpeng Liang
@ 2021-09-27 12:55 ` Wenpeng Liang
2021-09-27 19:17 ` [PATCH for-rc 0/2] Bugfix or cleanup for CQE size Jason Gunthorpe
2 siblings, 0 replies; 4+ messages in thread
From: Wenpeng Liang @ 2021-09-27 12:55 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm, liangwenpeng
If the CQE size of the user space is not the size supported by the
hardware, the creation of CQ should be stopped.
Fixes: 09a5f210f67e ("RDMA/hns: Add support for CQE in size of 64 Bytes")
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_cq.c | 31 ++++++++++++++++++-------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_cq.c b/drivers/infiniband/hw/hns/hns_roce_cq.c
index 1e9c3c5bee68..d763f097599f 100644
--- a/drivers/infiniband/hw/hns/hns_roce_cq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_cq.c
@@ -326,19 +326,30 @@ static void set_cq_param(struct hns_roce_cq *hr_cq, u32 cq_entries, int vector,
INIT_LIST_HEAD(&hr_cq->rq_list);
}
-static void set_cqe_size(struct hns_roce_cq *hr_cq, struct ib_udata *udata,
- struct hns_roce_ib_create_cq *ucmd)
+static int set_cqe_size(struct hns_roce_cq *hr_cq, struct ib_udata *udata,
+ struct hns_roce_ib_create_cq *ucmd)
{
struct hns_roce_dev *hr_dev = to_hr_dev(hr_cq->ib_cq.device);
- if (udata) {
- if (udata->inlen >= offsetofend(typeof(*ucmd), cqe_size))
- hr_cq->cqe_size = ucmd->cqe_size;
- else
- hr_cq->cqe_size = HNS_ROCE_V2_CQE_SIZE;
- } else {
+ if (!udata) {
hr_cq->cqe_size = hr_dev->caps.cqe_sz;
+ return 0;
+ }
+
+ if (udata->inlen >= offsetofend(typeof(*ucmd), cqe_size)) {
+ if (ucmd->cqe_size != HNS_ROCE_V2_CQE_SIZE &&
+ ucmd->cqe_size != HNS_ROCE_V3_CQE_SIZE) {
+ ibdev_err(&hr_dev->ib_dev,
+ "invalid cqe size %u.\n", ucmd->cqe_size);
+ return -EINVAL;
+ }
+
+ hr_cq->cqe_size = ucmd->cqe_size;
+ } else {
+ hr_cq->cqe_size = HNS_ROCE_V2_CQE_SIZE;
}
+
+ return 0;
}
int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
@@ -366,7 +377,9 @@ int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
set_cq_param(hr_cq, attr->cqe, attr->comp_vector, &ucmd);
- set_cqe_size(hr_cq, udata, &ucmd);
+ ret = set_cqe_size(hr_cq, udata, &ucmd);
+ if (ret)
+ return ret;
ret = alloc_cq_buf(hr_dev, hr_cq, udata, ucmd.buf_addr);
if (ret) {
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH for-rc 0/2] Bugfix or cleanup for CQE size
2021-09-27 12:55 [PATCH for-rc 0/2] Bugfix or cleanup for CQE size Wenpeng Liang
2021-09-27 12:55 ` [PATCH for-rc 1/2] RDMA/hns: Fix the size setting error when copying CQE in clean_cq() Wenpeng Liang
2021-09-27 12:55 ` [PATCH for-rc 2/2] RDMA/hns: Add the check of the CQE size of the user space Wenpeng Liang
@ 2021-09-27 19:17 ` Jason Gunthorpe
2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2021-09-27 19:17 UTC (permalink / raw)
To: Wenpeng Liang; +Cc: dledford, linux-rdma, linuxarm
On Mon, Sep 27, 2021 at 08:55:55PM +0800, Wenpeng Liang wrote:
> Specify the size of CQE when copying CQE, and add the check of CQE size of
> user space.
>
> Wenpeng Liang (2):
> RDMA/hns: Fix the size setting error when copying CQE in clean_cq()
> RDMA/hns: Add the check of the CQE size of the user space
Applied to for-rc, thanks
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-27 19:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 12:55 [PATCH for-rc 0/2] Bugfix or cleanup for CQE size Wenpeng Liang
2021-09-27 12:55 ` [PATCH for-rc 1/2] RDMA/hns: Fix the size setting error when copying CQE in clean_cq() Wenpeng Liang
2021-09-27 12:55 ` [PATCH for-rc 2/2] RDMA/hns: Add the check of the CQE size of the user space Wenpeng Liang
2021-09-27 19:17 ` [PATCH for-rc 0/2] Bugfix or cleanup for CQE size 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).