Skip to contentSkip to conversation

RDMA/hns: Fix bug during CMDQ initialization

PATCH Applied Weihang Li 2 participants 2 messages Mar 13, 2021 – Mar 22, 2021

Subsystems (2)
lore
Share & tools
lore

Weihang Li

author
#0 lore raw

PATCH v2 1/1 RDMA/hns: Fix bug during CMDQ initialization

From: Lang Cheng <[email protected]>

When reloading driver, the head/tail pointer of CMDQ may be not at position
0. Then during initialization of CMDQ, if head is reset first, the firmware will start to handle CMDQ because the head is not equal to the tail. The driver can reset tail first since the firmware will be triggerred only by head. This bug is introduced by changing macros of head/tail register without changing the order of initialization.

Fixes 292b3352bd5b ("RDMA/hns: Adjust fields and variables about CMDQ tail/head")

---
Changes since v1:
- Only retain the bugfix part for -rc branch.
- Link: https://patchwork.kernel.org/project/linux-rdma/patch/[email protected]/

 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -1
index c3934ab..ce26f97 100644
@@ -1194,8 +1194,10 @@ static void hns_roce_cmq_init_regs(struct hns_roce_dev *hr_dev, bool ring_type)
 			   upper_32_bits(dma));
 		roce_write(hr_dev, ROCEE_TX_CMQ_DEPTH_REG,
 			   (u32)ring->desc_num >> HNS_ROCE_CMQ_DESC_NUM_S);
-		roce_write(hr_dev, ROCEE_TX_CMQ_HEAD_REG, 0);
+
+		/* Make sure to write tail first and then head */
 		roce_write(hr_dev, ROCEE_TX_CMQ_TAIL_REG, 0);
+		roce_write(hr_dev, ROCEE_TX_CMQ_HEAD_REG, 0);
 	} else {
 		roce_write(hr_dev, ROCEE_RX_CMQ_BASEADDR_L_REG, (u32)dma);
 		roce_write(hr_dev, ROCEE_RX_CMQ_BASEADDR_H_REG,
Signature · 1 line
2.8.1
maintainer Applied
#1 lore raw
Quoted 12 lines · Weihang Li

From: Lang Cheng <[email protected]>

When reloading driver, the head/tail pointer of CMDQ may be not at position
0. Then during initialization of CMDQ, if head is reset first, the firmware will start to handle CMDQ because the head is not equal to the tail. The driver can reset tail first since the firmware will be triggerred only by head. This bug is introduced by changing macros of head/tail register without changing the order of initialization.

Fixes 292b3352bd5b ("RDMA/hns: Adjust fields and variables about CMDQ tail/head")
Quoted 7 lines

---
Changes since v1:
- Only retain the bugfix part for -rc branch.
- Link: https://patchwork.kernel.org/project/linux-rdma/patch/[email protected]/

 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied to for-rc, thanks

Jason