History

RDMA/hns: Fix cqn type and init resp

This patch changes the type of cqn from u32 to u64 to keep userspace and kernel consistent, initializes resp both for cq and qp to zeros, and also changes the condition judgment of outlen considering future caps extension.

Yixian Liu committed 8 years ago

Commit 7b482211 parent e41a7c43 files · +12 −14Browse files

Unified · Split

3 files
  1. drivers/infiniband/hw/hns/hns_roce_cq.c +7 −8
  2. drivers/infiniband/hw/hns/hns_roce_qp.c +4 −4
  3. include/uapi/rdma/hns-abi.h +1 −2
drivers/infiniband/hw/hns/hns_roce_cq.c+7−8
@@ -315,7 +315,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev, · 314 unmodified lines
315315 struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev);
316316 struct device *dev = hr_dev->dev;
317317 struct hns_roce_ib_create_cq ucmd;
318− struct hns_roce_ib_create_cq_resp resp;
318+ struct hns_roce_ib_create_cq_resp resp = {};
319319 struct hns_roce_cq *hr_cq = NULL;
320320 struct hns_roce_uar *uar = NULL;
321321 int vector = attr->comp_vector;
@@ -389,7 +389,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev, · 67 unmodified lines
389389 }
390390
391391 if (context && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
392− (udata->outlen == sizeof(resp))) {
392+ (udata->outlen >= sizeof(resp))) {
393393 ret = hns_roce_db_map_user(to_hr_ucontext(context),
394394 ucmd.db_addr, &hr_cq->db);
395395 if (ret) {
@@ -413,15 +413,14 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev, · 17 unmodified lines
413413 hr_cq->cq_depth = cq_entries;
414414
415415 if (context) {
416+ resp.cqn = hr_cq->cqn;
416417 if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
417− (udata->outlen == sizeof(resp))) {
418+ (udata->outlen >= sizeof(resp))) {
418419 hr_cq->db_en = 1;
419− resp.cqn = hr_cq->cqn;
420420 resp.cap_flags |= HNS_ROCE_SUPPORT_CQ_RECORD_DB;
421− ret = ib_copy_to_udata(udata, &resp, sizeof(resp));
422− } else
423− ret = ib_copy_to_udata(udata, &hr_cq->cqn, sizeof(u64));
421+ }
424422
423+ ret = ib_copy_to_udata(udata, &resp, sizeof(resp));
425424 if (ret)
426425 goto err_dbmap;
427426 }
@@ -430,7 +429,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev, · 2 unmodified lines
430429
431430 err_dbmap:
432431 if (context && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
433− (udata->outlen == sizeof(resp)))
432+ (udata->outlen >= sizeof(resp)))
434433 hns_roce_db_unmap_user(to_hr_ucontext(context),
435434 &hr_cq->db);
436435
drivers/infiniband/hw/hns/hns_roce_qp.c+4−4
@@ -506,7 +506,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, · 505 unmodified lines
506506 {
507507 struct device *dev = hr_dev->dev;
508508 struct hns_roce_ib_create_qp ucmd;
509− struct hns_roce_ib_create_qp_resp resp;
509+ struct hns_roce_ib_create_qp_resp resp = {};
510510 unsigned long qpn = 0;
511511 int ret = 0;
512512 u32 page_shift;
@@ -614,7 +614,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, · 101 unmodified lines
614614 }
615615
616616 if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
617− (udata->outlen == sizeof(resp)) &&
617+ (udata->outlen >= sizeof(resp)) &&
618618 hns_roce_qp_has_rq(init_attr)) {
619619 ret = hns_roce_db_map_user(
620620 to_hr_ucontext(ib_pd->uobject->context),
@@ -730,7 +730,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, · 109 unmodified lines
730730 else
731731 hr_qp->doorbell_qpn = cpu_to_le64(hr_qp->qpn);
732732
733− if (ib_pd->uobject && (udata->outlen == sizeof(resp)) &&
733+ if (ib_pd->uobject && (udata->outlen >= sizeof(resp)) &&
734734 (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)) {
735735
736736 /* indicate kernel supports record db */
@@ -759,7 +759,7 @@ err_qpn: · 22 unmodified lines
759759 err_wrid:
760760 if (ib_pd->uobject) {
761761 if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
762− (udata->outlen == sizeof(resp)) &&
762+ (udata->outlen >= sizeof(resp)) &&
763763 hns_roce_qp_has_rq(init_attr))
764764 hns_roce_db_unmap_user(
765765 to_hr_ucontext(ib_pd->uobject->context),
include/uapi/rdma/hns-abi.h+1−2
@@ -42,8 +42,7 @@ struct hns_roce_ib_create_cq { · 41 unmodified lines
4242 };
4343
4444 struct hns_roce_ib_create_cq_resp {
45− __u32 cqn;
46− __u32 reserved;
45+ __u64 cqn; /* Only 32 bits used, 64 for compat */
4746 __u64 cap_flags;
4847 };
4948

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t