Skip to content

Commit 52c5e9e

Browse files
larrchjgunthorpe
authored andcommitted
RDMA/hns: Initialize all fields of doorbells to zero
Prevent uninitialized fields when new fields are added, and make code look simpler. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lang Cheng <[email protected]> Signed-off-by: Weihang Li <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 8d8d2b7 commit 52c5e9e

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

drivers/infiniband/hw/hns/hns_roce_hw_v1.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
6969
struct hns_roce_wqe_data_seg *dseg = NULL;
7070
struct hns_roce_qp *qp = to_hr_qp(ibqp);
7171
struct device *dev = &hr_dev->pdev->dev;
72-
struct hns_roce_sq_db sq_db;
72+
struct hns_roce_sq_db sq_db = {};
7373
int ps_opcode = 0, i = 0;
7474
unsigned long flags = 0;
7575
void *wqe = NULL;
@@ -318,8 +318,6 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
318318
/* Memory barrier */
319319
wmb();
320320

321-
sq_db.u32_4 = 0;
322-
sq_db.u32_8 = 0;
323321
roce_set_field(sq_db.u32_4, SQ_DOORBELL_U32_4_SQ_HEAD_M,
324322
SQ_DOORBELL_U32_4_SQ_HEAD_S,
325323
(qp->sq.head & ((qp->sq.wqe_cnt << 1) - 1)));
@@ -351,7 +349,7 @@ static int hns_roce_v1_post_recv(struct ib_qp *ibqp,
351349
struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
352350
struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
353351
struct device *dev = &hr_dev->pdev->dev;
354-
struct hns_roce_rq_db rq_db;
352+
struct hns_roce_rq_db rq_db = {};
355353
__le32 doorbell[2] = {0};
356354
unsigned long flags = 0;
357355
unsigned int wqe_idx;
@@ -418,9 +416,6 @@ static int hns_roce_v1_post_recv(struct ib_qp *ibqp,
418416
ROCEE_QP1C_CFG3_0_REG +
419417
QP1C_CFGN_OFFSET * hr_qp->phy_port, reg_val);
420418
} else {
421-
rq_db.u32_4 = 0;
422-
rq_db.u32_8 = 0;
423-
424419
roce_set_field(rq_db.u32_4, RQ_DOORBELL_U32_4_RQ_HEAD_M,
425420
RQ_DOORBELL_U32_4_RQ_HEAD_S,
426421
hr_qp->rq.head);

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp,
255255
struct hns_roce_qp *qp = to_hr_qp(ibqp);
256256
struct hns_roce_wqe_frmr_seg *fseg;
257257
struct device *dev = hr_dev->dev;
258-
struct hns_roce_v2_db sq_db;
258+
struct hns_roce_v2_db sq_db = {};
259259
unsigned int owner_bit;
260260
unsigned int sge_idx;
261261
unsigned int wqe_idx;
@@ -583,9 +583,6 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp,
583583
/* Memory barrier */
584584
wmb();
585585

586-
sq_db.byte_4 = 0;
587-
sq_db.parameter = 0;
588-
589586
roce_set_field(sq_db.byte_4, V2_DB_BYTE_4_TAG_M,
590587
V2_DB_BYTE_4_TAG_S, qp->doorbell_qpn);
591588
roce_set_field(sq_db.byte_4, V2_DB_BYTE_4_CMD_M,

0 commit comments

Comments
 (0)