netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch net-next] net: hns3: fix return value error while hclge_cmd_csq_clean failed
@ 2018-08-01  9:53 Huazhong Tan
  2018-08-01 10:00 ` 答复: " tanhuazhong
  2018-08-01 17:03 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Huazhong Tan @ 2018-08-01  9:53 UTC (permalink / raw)
  To: davem; +Cc: netdev, linuxarm

From: fredalu <fredalu@yeah.net>

While cleaning the command queue, the value of the HEAD register is not
in the range of next_to_clean and next_to_use, meaning that this value
is invalid. This also means that there is a hardware error and the
hardware will trigger a reset soon. At this time we should return an
error code instead of 0, and HCLGE_STATE_CMD_DISABLE needs to be set to
prevent sending command again.

Fixes: 3ff504908f95 ("net: hns3: fix a dead loop in hclge_cmd_csq_clean")
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>wq
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
index 165c3d5..ac13cb2 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
@@ -147,7 +147,12 @@ static int hclge_cmd_csq_clean(struct hclge_hw *hw)
 	if (!is_valid_csq_clean_head(csq, head)) {
 		dev_warn(&hdev->pdev->dev, "wrong cmd head (%d, %d-%d)\n", head,
 			 csq->next_to_use, csq->next_to_clean);
-		return 0;
+		dev_warn(&hdev->pdev->dev,
+			 "Disabling any further commands to IMP firmware\n");
+		set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state);
+		dev_warn(&hdev->pdev->dev,
+			 "IMP firmware watchdog reset soon expected!\n");
+		return -EIO;
 	}
 
 	clean = (head - csq->next_to_clean + csq->desc_num) % csq->desc_num;
@@ -267,10 +272,11 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num)
 
 	/* Clean the command send queue */
 	handle = hclge_cmd_csq_clean(hw);
-	if (handle != num) {
+	if (handle < 0)
+		retval = handle;
+	else if (handle != num)
 		dev_warn(&hdev->pdev->dev,
 			 "cleaned %d, need to clean %d\n", handle, num);
-	}
 
 	spin_unlock_bh(&hw->cmq.csq.lock);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* 答复: [Patch net-next] net: hns3: fix return value error while hclge_cmd_csq_clean failed
  2018-08-01  9:53 [Patch net-next] net: hns3: fix return value error while hclge_cmd_csq_clean failed Huazhong Tan
@ 2018-08-01 10:00 ` tanhuazhong
  2018-08-01 17:03 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: tanhuazhong @ 2018-08-01 10:00 UTC (permalink / raw)
  To: tanhuazhong, davem; +Cc: netdev, Linuxarm

Sorry, please ignore this patch. I will resend it.

-----邮件原件-----
发件人: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org] 代表 Huazhong Tan
发送时间: 2018年8月1日 17:53
收件人: davem@davemloft.net
抄送: netdev@vger.kernel.org; Linuxarm <linuxarm@huawei.com>
主题: [Patch net-next] net: hns3: fix return value error while hclge_cmd_csq_clean failed

From: fredalu <fredalu@yeah.net>

While cleaning the command queue, the value of the HEAD register is not in the range of next_to_clean and next_to_use, meaning that this value is invalid. This also means that there is a hardware error and the hardware will trigger a reset soon. At this time we should return an error code instead of 0, and HCLGE_STATE_CMD_DISABLE needs to be set to prevent sending command again.

Fixes: 3ff504908f95 ("net: hns3: fix a dead loop in hclge_cmd_csq_clean")
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>wq
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
index 165c3d5..ac13cb2 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
@@ -147,7 +147,12 @@ static int hclge_cmd_csq_clean(struct hclge_hw *hw)
 	if (!is_valid_csq_clean_head(csq, head)) {
 		dev_warn(&hdev->pdev->dev, "wrong cmd head (%d, %d-%d)\n", head,
 			 csq->next_to_use, csq->next_to_clean);
-		return 0;
+		dev_warn(&hdev->pdev->dev,
+			 "Disabling any further commands to IMP firmware\n");
+		set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state);
+		dev_warn(&hdev->pdev->dev,
+			 "IMP firmware watchdog reset soon expected!\n");
+		return -EIO;
 	}
 
 	clean = (head - csq->next_to_clean + csq->desc_num) % csq->desc_num; @@ -267,10 +272,11 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num)
 
 	/* Clean the command send queue */
 	handle = hclge_cmd_csq_clean(hw);
-	if (handle != num) {
+	if (handle < 0)
+		retval = handle;
+	else if (handle != num)
 		dev_warn(&hdev->pdev->dev,
 			 "cleaned %d, need to clean %d\n", handle, num);
-	}
 
 	spin_unlock_bh(&hw->cmq.csq.lock);
 
--
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Patch net-next] net: hns3: fix return value error while hclge_cmd_csq_clean failed
  2018-08-01  9:53 [Patch net-next] net: hns3: fix return value error while hclge_cmd_csq_clean failed Huazhong Tan
  2018-08-01 10:00 ` 答复: " tanhuazhong
@ 2018-08-01 17:03 ` David Miller
  2018-08-02  0:59   ` tanhuazhong
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2018-08-01 17:03 UTC (permalink / raw)
  To: tanhuazhong; +Cc: netdev, linuxarm

From: Huazhong Tan <tanhuazhong@huawei.com>
Date: Wed, 1 Aug 2018 17:53:28 +0800

> From: fredalu <fredalu@yeah.net>
> 
> While cleaning the command queue, the value of the HEAD register is not
> in the range of next_to_clean and next_to_use, meaning that this value
> is invalid. This also means that there is a hardware error and the
> hardware will trigger a reset soon. At this time we should return an
> error code instead of 0, and HCLGE_STATE_CMD_DISABLE needs to be set to
> prevent sending command again.
> 
> Fixes: 3ff504908f95 ("net: hns3: fix a dead loop in hclge_cmd_csq_clean")
> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>wq
            --->                                      ^^^

I think I know what text editor you use... :-)

Applied with 'wq' removed from your signoff... Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch net-next] net: hns3: fix return value error while hclge_cmd_csq_clean failed
  2018-08-01 17:03 ` David Miller
@ 2018-08-02  0:59   ` tanhuazhong
  0 siblings, 0 replies; 4+ messages in thread
From: tanhuazhong @ 2018-08-02  0:59 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linuxarm



On 2018/8/2 1:03, David Miller wrote:
> From: Huazhong Tan <tanhuazhong@huawei.com>
> Date: Wed, 1 Aug 2018 17:53:28 +0800
> 
>> From: fredalu <fredalu@yeah.net>
>>
>> While cleaning the command queue, the value of the HEAD register is not
>> in the range of next_to_clean and next_to_use, meaning that this value
>> is invalid. This also means that there is a hardware error and the
>> hardware will trigger a reset soon. At this time we should return an
>> error code instead of 0, and HCLGE_STATE_CMD_DISABLE needs to be set to
>> prevent sending command again.
>>
>> Fixes: 3ff504908f95 ("net: hns3: fix a dead loop in hclge_cmd_csq_clean")
>> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>wq
>              --->                                      ^^^
> 
> I think I know what text editor you use... :-)
> 
> Applied with 'wq' removed from your signoff... Thanks.
> 
> .
> 

Sorry about this, I have sent V2 to fix it.
Thanks.:)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-02  2:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-01  9:53 [Patch net-next] net: hns3: fix return value error while hclge_cmd_csq_clean failed Huazhong Tan
2018-08-01 10:00 ` 答复: " tanhuazhong
2018-08-01 17:03 ` David Miller
2018-08-02  0:59   ` tanhuazhong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).