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
315 struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev);315 struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev);
316 struct device *dev = hr_dev->dev;316 struct device *dev = hr_dev->dev;
317 struct hns_roce_ib_create_cq ucmd;317 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 = {};
319 struct hns_roce_cq *hr_cq = NULL;319 struct hns_roce_cq *hr_cq = NULL;
320 struct hns_roce_uar *uar = NULL;320 struct hns_roce_uar *uar = NULL;
321 int vector = attr->comp_vector;321 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
389 }389 }
390 390
391 if (context && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&391 if (context && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
392 (udata->outlen == sizeof(resp))) {392 (udata->outlen >= sizeof(resp))) {
393 ret = hns_roce_db_map_user(to_hr_ucontext(context),393 ret = hns_roce_db_map_user(to_hr_ucontext(context),
394 ucmd.db_addr, &hr_cq->db);394 ucmd.db_addr, &hr_cq->db);
395 if (ret) {395 if (ret) {
@@ -413,15 +413,14 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev, · 17 unmodified lines
413 hr_cq->cq_depth = cq_entries;413 hr_cq->cq_depth = cq_entries;
414 414
415 if (context) {415 if (context) {
416 resp.cqn = hr_cq->cqn;
416 if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&417 if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
417 (udata->outlen == sizeof(resp))) {418 (udata->outlen >= sizeof(resp))) {
418 hr_cq->db_en = 1;419 hr_cq->db_en = 1;
419 resp.cqn = hr_cq->cqn;
420 resp.cap_flags |= HNS_ROCE_SUPPORT_CQ_RECORD_DB;420 resp.cap_flags |= HNS_ROCE_SUPPORT_CQ_RECORD_DB;
421 ret = ib_copy_to_udata(udata, &resp, sizeof(resp));421 }
422 } else
423 ret = ib_copy_to_udata(udata, &hr_cq->cqn, sizeof(u64));
424 422
423 ret = ib_copy_to_udata(udata, &resp, sizeof(resp));
425 if (ret)424 if (ret)
426 goto err_dbmap;425 goto err_dbmap;
427 }426 }
@@ -430,7 +429,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev, · 2 unmodified lines
430 429
431err_dbmap:430err_dbmap:
432 if (context && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&431 if (context && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
433 (udata->outlen == sizeof(resp)))432 (udata->outlen >= sizeof(resp)))
434 hns_roce_db_unmap_user(to_hr_ucontext(context),433 hns_roce_db_unmap_user(to_hr_ucontext(context),
435 &hr_cq->db);434 &hr_cq->db);
436 435
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
506{506{
507 struct device *dev = hr_dev->dev;507 struct device *dev = hr_dev->dev;
508 struct hns_roce_ib_create_qp ucmd;508 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 = {};
510 unsigned long qpn = 0;510 unsigned long qpn = 0;
511 int ret = 0;511 int ret = 0;
512 u32 page_shift;512 u32 page_shift;
@@ -614,7 +614,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, · 101 unmodified lines
614 }614 }
615 615
616 if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&616 if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
617 (udata->outlen == sizeof(resp)) &&617 (udata->outlen >= sizeof(resp)) &&
618 hns_roce_qp_has_rq(init_attr)) {618 hns_roce_qp_has_rq(init_attr)) {
619 ret = hns_roce_db_map_user(619 ret = hns_roce_db_map_user(
620 to_hr_ucontext(ib_pd->uobject->context),620 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
730 else730 else
731 hr_qp->doorbell_qpn = cpu_to_le64(hr_qp->qpn);731 hr_qp->doorbell_qpn = cpu_to_le64(hr_qp->qpn);
732 732
733 if (ib_pd->uobject && (udata->outlen == sizeof(resp)) &&733 if (ib_pd->uobject && (udata->outlen >= sizeof(resp)) &&
734 (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)) {734 (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB)) {
735 735
736 /* indicate kernel supports record db */736 /* indicate kernel supports record db */
@@ -759,7 +759,7 @@ err_qpn: · 22 unmodified lines
759err_wrid:759err_wrid:
760 if (ib_pd->uobject) {760 if (ib_pd->uobject) {
761 if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&761 if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
762 (udata->outlen == sizeof(resp)) &&762 (udata->outlen >= sizeof(resp)) &&
763 hns_roce_qp_has_rq(init_attr))763 hns_roce_qp_has_rq(init_attr))
764 hns_roce_db_unmap_user(764 hns_roce_db_unmap_user(
765 to_hr_ucontext(ib_pd->uobject->context),765 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
42};42};
43 43
44struct hns_roce_ib_create_cq_resp {44struct hns_roce_ib_create_cq_resp {
45 __u32 cqn;45 __u64 cqn; /* Only 32 bits used, 64 for compat */
46 __u32 reserved;
47 __u64 cap_flags;46 __u64 cap_flags;
48};47};
49 48

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