* [PATCH v2 for-rc] RDMA/hns: Fix bug during CMDQ initialization
@ 2021-03-13 2:30 Weihang Li
2021-03-22 12:27 ` Jason Gunthorpe
0 siblings, 1 reply; 2+ messages in thread
From: Weihang Li @ 2021-03-13 2:30 UTC (permalink / raw)
To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm
From: Lang Cheng <chenglang@huawei.com>
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")
Signed-off-by: Lang Cheng <chenglang@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
Changes since v1:
- Only retain the bugfix part for -rc branch.
- Link: https://patchwork.kernel.org/project/linux-rdma/patch/1615541933-35798-1-git-send-email-liweihang@huawei.com/
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index c3934ab..ce26f97 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -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,
--
2.8.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 for-rc] RDMA/hns: Fix bug during CMDQ initialization
2021-03-13 2:30 [PATCH v2 for-rc] RDMA/hns: Fix bug during CMDQ initialization Weihang Li
@ 2021-03-22 12:27 ` Jason Gunthorpe
0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2021-03-22 12:27 UTC (permalink / raw)
To: Weihang Li; +Cc: dledford, leon, linux-rdma, linuxarm
On Sat, Mar 13, 2021 at 10:30:11AM +0800, Weihang Li wrote:
> From: Lang Cheng <chenglang@huawei.com>
>
> 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")
> Signed-off-by: Lang Cheng <chenglang@huawei.com>
> Signed-off-by: Weihang Li <liweihang@huawei.com>
> ---
> Changes since v1:
> - Only retain the bugfix part for -rc branch.
> - Link: https://patchwork.kernel.org/project/linux-rdma/patch/1615541933-35798-1-git-send-email-liweihang@huawei.com/
>
> drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Applied to for-rc, thanks
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-22 12:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-13 2:30 [PATCH v2 for-rc] RDMA/hns: Fix bug during CMDQ initialization Weihang Li
2021-03-22 12:27 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox