aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/hns/hns_roce_cq.c
diff options
context:
space:
mode:
authorYixian Liu <liuyixian@huawei.com>2018-03-15 15:23:14 +0800
committerJason Gunthorpe <jgg@mellanox.com>2018-03-15 15:34:26 -0600
commit7b48221cf41a90cf4bfc36e6d699b7fa4169c970 (patch)
tree1389bc25e0ed6f4a9e34a1f05f3e0df07d356119 /drivers/infiniband/hw/hns/hns_roce_cq.c
parentIB/core: Move rdma_addr_find_l2_eth_by_grh to core_priv.h (diff)
downloadlinux-dev-7b48221cf41a90cf4bfc36e6d699b7fa4169c970.tar.xz
linux-dev-7b48221cf41a90cf4bfc36e6d699b7fa4169c970.zip
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. Suggested-by: Jason Gunthorpe <jgg@mellanox.com> Fixes: e088a685eae9 (hns: Support rq record doorbell for the user space) Fixes: 9b44703d0a21 (hns: Support cq record doorbell for the user space) Signed-off-by: Yixian Liu <liuyixian@huawei.com> Signed-off-by: Lijun Ou <oulijun@huawei.com> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com> Signed-off-by: Shaobo Xu <xushaobo2@huawei.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/hw/hns/hns_roce_cq.c')
-rw-r--r--drivers/infiniband/hw/hns/hns_roce_cq.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/infiniband/hw/hns/hns_roce_cq.c b/drivers/infiniband/hw/hns/hns_roce_cq.c
index 462b644bbbd7..095a9100717d 100644
--- a/drivers/infiniband/hw/hns/hns_roce_cq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_cq.c
@@ -315,7 +315,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev);
struct device *dev = hr_dev->dev;
struct hns_roce_ib_create_cq ucmd;
- struct hns_roce_ib_create_cq_resp resp;
+ struct hns_roce_ib_create_cq_resp resp = {};
struct hns_roce_cq *hr_cq = NULL;
struct hns_roce_uar *uar = NULL;
int vector = attr->comp_vector;
@@ -389,7 +389,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
}
if (context && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
- (udata->outlen == sizeof(resp))) {
+ (udata->outlen >= sizeof(resp))) {
ret = hns_roce_db_map_user(to_hr_ucontext(context),
ucmd.db_addr, &hr_cq->db);
if (ret) {
@@ -413,15 +413,14 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
hr_cq->cq_depth = cq_entries;
if (context) {
+ resp.cqn = hr_cq->cqn;
if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
- (udata->outlen == sizeof(resp))) {
+ (udata->outlen >= sizeof(resp))) {
hr_cq->db_en = 1;
- resp.cqn = hr_cq->cqn;
resp.cap_flags |= HNS_ROCE_SUPPORT_CQ_RECORD_DB;
- ret = ib_copy_to_udata(udata, &resp, sizeof(resp));
- } else
- ret = ib_copy_to_udata(udata, &hr_cq->cqn, sizeof(u64));
+ }
+ ret = ib_copy_to_udata(udata, &resp, sizeof(resp));
if (ret)
goto err_dbmap;
}
@@ -430,7 +429,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
err_dbmap:
if (context && (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) &&
- (udata->outlen == sizeof(resp)))
+ (udata->outlen >= sizeof(resp)))
hns_roce_db_unmap_user(to_hr_ucontext(context),
&hr_cq->db);