Skip to contentSkip to conversation

ntb_hw_switchtec: Force down the peer's link before initializing

PATCH Superseded Logan Gunthorpe 3 participants 7 messages Nov 28, 2017 – Nov 29, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Logan Gunthorpe

author maintainer
#0 lore raw

PATCH 1/1 ntb_hw_switchtec: Force down the peer's link before initializing

If one host crashes and soft reboots, the other host may not see a link down event. Then when the crashed host comes back up, the surviving host may not know the link was reset and the ntb clients may not work without being reset.

To solve this, we send a LINK_FORCE_DOWN message to each peer every time we come up, before we register the ntb device. If a surving host still thinks the link is up it will take it down immediately. In this way, once the crashed host comes up fully, it will send a regular link up event as per usual and the link will be properly restarted.

While we are in the area, this also fixes the MSG_LINK_UP message that was in the link down function that was reported by Doug Meyers.

---
 drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +26 -7
index d71744904b19..5cfcd4deadaf 100644
@@ -463,18 +463,30 @@ static void switchtec_ntb_set_link_speed(struct switchtec_ntb *sndev)
 	sndev->link_width = min(self_width, peer_width);
 }
 
-enum {
+enum switchtec_msg {
 	LINK_MESSAGE = 0,
 	MSG_LINK_UP = 1,
 	MSG_LINK_DOWN = 2,
 	MSG_CHECK_LINK = 3,
+	MSG_LINK_FORCE_DOWN = 4,
 };
 
-static void switchtec_ntb_check_link(struct switchtec_ntb *sndev)
+static void switchtec_ntb_check_link(struct switchtec_ntb *sndev,
+				     enum switchtec_msg msg)
 {
 	int link_sta;
 	int old = sndev->link_is_up;
 
+	if (msg == MSG_LINK_FORCE_DOWN) {
+		if (sndev->link_is_up) {
+			sndev->link_is_up = 0;
+			ntb_link_event(&sndev->ntb);
+			dev_info(&sndev->stdev->dev, "ntb link forced down\n");
+		}
+
+		return;
+	}
+
 	link_sta = sndev->self_shared->link_sta;
 	if (link_sta) {
 		u64 peer = ioread64(&sndev->peer_shared->magic);
@@ -500,7 +512,7 @@ static void switchtec_ntb_link_notification(struct switchtec_dev *stdev)
 {
 	struct switchtec_ntb *sndev = stdev->sndev;
 
-	switchtec_ntb_check_link(sndev);
+	switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
 }
 
 static u64 switchtec_ntb_link_is_up(struct ntb_dev *ntb,
@@ -528,7 +540,7 @@ static int switchtec_ntb_link_enable(struct ntb_dev *ntb,
 	sndev->self_shared->link_sta = 1;
 	switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
 
-	switchtec_ntb_check_link(sndev);
+	switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
 
 	return 0;
 }
@@ -540,9 +552,9 @@ static int switchtec_ntb_link_disable(struct ntb_dev *ntb)
 	dev_dbg(&sndev->stdev->dev, "disabling link\n");
 
 	sndev->self_shared->link_sta = 0;
-	switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
+	switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_DOWN);
 
-	switchtec_ntb_check_link(sndev);
+	switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
 
 	return 0;
 }
@@ -1061,7 +1073,7 @@ static irqreturn_t switchtec_ntb_message_isr(int irq, void *dev)
 			iowrite8(1, &sndev->mmio_self_dbmsg->imsg[i].status);
 
 			if (i == LINK_MESSAGE)
-				switchtec_ntb_check_link(sndev);
+				switchtec_ntb_check_link(sndev, msg);
 		}
 	}
 
@@ -1159,6 +1171,13 @@ static int switchtec_ntb_add(struct device *dev,
 	if (rc)
 		goto deinit_shared_and_exit;
 
+	/*
+	 * If this host crashed, the other host may think the link is
+	 * still up. Tell them to force it down (it will go back up
+	 * once we register the ntb device).
+	 */
+	switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_FORCE_DOWN);
+
 	rc = ntb_register_device(&sndev->ntb);
 	if (rc)
 		goto deinit_and_exit;

--
2.11.0

author maintainer
#1 lore raw

Hey Thai Thu,

Please test with this patch and report back if it fixes your issue.

If it doesn't, can you please send the dmesg output of the two hosts?

Thanks,

Logan

Quoted 114 lines · Logan Gunthorpe

If one host crashes and soft reboots, the other host may not see a link down event. Then when the crashed host comes back up, the surviving host may not know the link was reset and the ntb clients may not work without being reset.

To solve this, we send a LINK_FORCE_DOWN message to each peer every time we come up, before we register the ntb device. If a surving host still thinks the link is up it will take it down immediately. In this way, once the crashed host comes up fully, it will send a regular link up event as per usual and the link will be properly restarted.

While we are in the area, this also fixes the MSG_LINK_UP message that was in the link down function that was reported by Doug Meyers.

---
  drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 33 ++++++++++++++++++++++++++-------
  1 file changed, 26 insertions(+), 7 deletions(-)
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +26 -8
index d71744904b19..5cfcd4deadaf 100644
@@ -463,18 +463,30 @@ static void switchtec_ntb_set_link_speed(struct switchtec_ntb *sndev)
  	sndev->link_width = min(self_width, peer_width);
  }
 
-enum {
+enum switchtec_msg {
  	LINK_MESSAGE = 0,
  	MSG_LINK_UP = 1,
  	MSG_LINK_DOWN = 2,
  	MSG_CHECK_LINK = 3,
+	MSG_LINK_FORCE_DOWN = 4,
  };
 
-static void switchtec_ntb_check_link(struct switchtec_ntb *sndev)
+static void switchtec_ntb_check_link(struct switchtec_ntb *sndev,
+				     enum switchtec_msg msg)
  {
  	int link_sta;
  	int old = sndev->link_is_up;
 
+	if (msg == MSG_LINK_FORCE_DOWN) {
+		if (sndev->link_is_up) {
+			sndev->link_is_up = 0;
+			ntb_link_event(&sndev->ntb);
+			dev_info(&sndev->stdev->dev, "ntb link forced down\n");
+		}
+
+		return;
+	}
+
  	link_sta = sndev->self_shared->link_sta;
  	if (link_sta) {
  		u64 peer = ioread64(&sndev->peer_shared->magic);
@@ -500,7 +512,7 @@ static void switchtec_ntb_link_notification(struct switchtec_dev *stdev)
  {
  	struct switchtec_ntb *sndev = stdev->sndev;
 
-	switchtec_ntb_check_link(sndev);
+	switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
  }
 
  static u64 switchtec_ntb_link_is_up(struct ntb_dev *ntb,
@@ -528,7 +540,7 @@ static int switchtec_ntb_link_enable(struct ntb_dev *ntb,
  	sndev->self_shared->link_sta = 1;
  	switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
 
-	switchtec_ntb_check_link(sndev);
+	switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
 
  	return 0;
  }
@@ -540,9 +552,9 @@ static int switchtec_ntb_link_disable(struct ntb_dev *ntb)
  	dev_dbg(&sndev->stdev->dev, "disabling link\n");
 
  	sndev->self_shared->link_sta = 0;
-	switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
+	switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_DOWN);
 
-	switchtec_ntb_check_link(sndev);
+	switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
 
  	return 0;
  }
@@ -1061,7 +1073,7 @@ static irqreturn_t switchtec_ntb_message_isr(int irq, void *dev)
  			iowrite8(1, &sndev->mmio_self_dbmsg->imsg[i].status);
 
  			if (i == LINK_MESSAGE)
-				switchtec_ntb_check_link(sndev);
+				switchtec_ntb_check_link(sndev, msg);
  		}
  	}
 
@@ -1159,6 +1171,13 @@ static int switchtec_ntb_add(struct device *dev,
  	if (rc)
  		goto deinit_shared_and_exit;
 
+	/*
+	 * If this host crashed, the other host may think the link is
+	 * still up. Tell them to force it down (it will go back up
+	 * once we register the ntb device).
+	 */
+	switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_FORCE_DOWN);
+
  	rc = ntb_register_device(&sndev->ntb);
  	if (rc)
  		goto deinit_and_exit;
--

2.11.0

maintainer
#2 lore raw
Quoted 3 lines · Logan Gunthorpe

Hey Thai Thu,

Please test with this patch and report back if it fixes your issue.

I'll wait on the ack before applying this patch and I'll add the "tested-by" line (assuming it works).

Thanks,
Jon

Quoted 134 lines

If it doesn't, can you please send the dmesg output of the two hosts?

Thanks,

Logan

Quoted 124 lines · Logan Gunthorpe

If one host crashes and soft reboots, the other host may not see a link down event. Then when the crashed host comes back up, the surviving host may not know the link was reset and the ntb clients may not work without being reset.

To solve this, we send a LINK_FORCE_DOWN message to each peer every time we come up, before we register the ntb device. If a surving host still thinks the link is up it will take it down immediately. In this way, once the crashed host comes up fully, it will send a regular link up event as per usual and the link will be properly restarted.

While we are in the area, this also fixes the MSG_LINK_UP message that was in the link down function that was reported by Doug Meyers.

---
  drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 33
++++++++++++++++++++++++++-------
  1 file changed, 26 insertions(+), 7 deletions(-)
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +14 -2
index d71744904b19..5cfcd4deadaf 100644
@@ -463,18 +463,30 @@ static void switchtec_ntb_set_link_speed(struct
 switchtec_ntb *sndev)
        sndev->link_width = min(self_width, peer_width);
  }
 
-enum {
+enum switchtec_msg {
        LINK_MESSAGE = 0,
        MSG_LINK_UP = 1,
        MSG_LINK_DOWN = 2,
        MSG_CHECK_LINK = 3,
+       MSG_LINK_FORCE_DOWN = 4,
  };
 
-static void switchtec_ntb_check_link(struct switchtec_ntb *sndev)
+static void switchtec_ntb_check_link(struct switchtec_ntb *sndev,
+                                    enum switchtec_msg msg)
  {
        int link_sta;
        int old = sndev->link_is_up;
 
+       if (msg == MSG_LINK_FORCE_DOWN) {
+               if (sndev->link_is_up) {
+                       sndev->link_is_up = 0;
+                       ntb_link_event(&sndev->ntb);
+                       dev_info(&sndev->stdev->dev, "ntb link forced
 down\n");
+               }
+
+               return;
+       }
+
        link_sta = sndev->self_shared->link_sta;
        if (link_sta) {
                u64 peer = ioread64(&sndev->peer_shared->magic);
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
@@ -500,7 +512,7 @@ static void switchtec_ntb_link_notification(struct
 switchtec_dev *stdev)
  {
        struct switchtec_ntb *sndev = stdev->sndev;
 
-       switchtec_ntb_check_link(sndev);
+       switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
  }
 

static u64 switchtec_ntb_link_is_up(struct ntb_dev *ntb,

drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
@@ -528,7 +540,7 @@ static int switchtec_ntb_link_enable(struct ntb_dev
 *ntb,
        sndev->self_shared->link_sta = 1;
        switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
 
-       switchtec_ntb_check_link(sndev);
+       switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
 
        return 0;
  }
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +2 -2
@@ -540,9 +552,9 @@ static int switchtec_ntb_link_disable(struct ntb_dev
 *ntb)
        dev_dbg(&sndev->stdev->dev, "disabling link\n");
 
        sndev->self_shared->link_sta = 0;
-       switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
+       switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_DOWN);
 
-       switchtec_ntb_check_link(sndev);
+       switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
 
        return 0;
  }
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
@@ -1061,7 +1073,7 @@ static irqreturn_t switchtec_ntb_message_isr(int
 irq, void *dev)
                        iowrite8(1,
 &sndev->mmio_self_dbmsg->imsg[i].status);
 
                        if (i == LINK_MESSAGE)
-                               switchtec_ntb_check_link(sndev);
+                               switchtec_ntb_check_link(sndev, msg);
                }
        }
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +7 -1
@@ -1159,6 +1171,13 @@ static int switchtec_ntb_add(struct device *dev,
        if (rc)
                goto deinit_shared_and_exit;
 
+       /*
+        * If this host crashed, the other host may think the link is
+        * still up. Tell them to force it down (it will go back up
+        * once we register the ntb device).
+        */
+       switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_FORCE_DOWN);
+
        rc = ntb_register_device(&sndev->ntb);
        if (rc)
                goto deinit_and_exit;
--

2.11.0

#3 lore raw

Dear Logan,

It works only for soft-reboot, but for power-on reset, it doesn't. I saw the problem is: with the power-on reset, the good peer didn't receive any message from the crashed peer even the crashed peer already sent out the message.

Do you think that after power-in reset, the memory-window is modified ? So it cannot translate the message from the crashed peer to the good peer.

Thanks !

Quoted 149 lines · Jon Mason
Quoted 3 lines · Logan Gunthorpe

Hey Thai Thu,

Please test with this patch and report back if it fixes your issue.

I'll wait on the ack before applying this patch and I'll add the "tested-by" line (assuming it works).

Thanks,
Jon

Quoted 87 lines

If it doesn't, can you please send the dmesg output of the two hosts?

Thanks,

Logan

Quoted 78 lines · Logan Gunthorpe

If one host crashes and soft reboots, the other host may not see a link down event. Then when the crashed host comes back up, the surviving host may not know the link was reset and the ntb clients may not work without being reset.

To solve this, we send a LINK_FORCE_DOWN message to each peer every time we come up, before we register the ntb device. If a surving host still thinks the link is up it will take it down immediately. In this way, once the crashed host comes up fully, it will send a regular link up event as per usual and the link will be properly restarted.

While we are in the area, this also fixes the MSG_LINK_UP message that was in the link down function that was reported by Doug Meyers.

---
  drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 33
++++++++++++++++++++++++++-------
  1 file changed, 26 insertions(+), 7 deletions(-)
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +14 -2
index d71744904b19..5cfcd4deadaf 100644
@@ -463,18 +463,30 @@ static void switchtec_ntb_set_link_speed(struct
 switchtec_ntb *sndev)
        sndev->link_width = min(self_width, peer_width);
  }
 
-enum {
+enum switchtec_msg {
        LINK_MESSAGE = 0,
        MSG_LINK_UP = 1,
        MSG_LINK_DOWN = 2,
        MSG_CHECK_LINK = 3,
+       MSG_LINK_FORCE_DOWN = 4,
  };
 
-static void switchtec_ntb_check_link(struct switchtec_ntb *sndev)
+static void switchtec_ntb_check_link(struct switchtec_ntb *sndev,
+                                    enum switchtec_msg msg)
  {
        int link_sta;
        int old = sndev->link_is_up;
 
+       if (msg == MSG_LINK_FORCE_DOWN) {
+               if (sndev->link_is_up) {
+                       sndev->link_is_up = 0;
+                       ntb_link_event(&sndev->ntb);
+                       dev_info(&sndev->stdev->dev, "ntb link forced
 down\n");
+               }
+
+               return;
+       }
+
        link_sta = sndev->self_shared->link_sta;
        if (link_sta) {
                u64 peer = ioread64(&sndev->peer_shared->magic);
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
@@ -500,7 +512,7 @@ static void switchtec_ntb_link_notification(struct
 switchtec_dev *stdev)
  {
        struct switchtec_ntb *sndev = stdev->sndev;
 
-       switchtec_ntb_check_link(sndev);
+       switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
  }
 

static u64 switchtec_ntb_link_is_up(struct ntb_dev *ntb,

drivers/ntb/hw/mscc/ntb_hw_switchtec.c +0 -0
@@ -528,7 +540,7 @@ static int switchtec_ntb_link_enable(struct ntb_dev
 *ntb,
        sndev->self_shared->link_sta = 1;
        switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
 
Quoted 6 lines

drivers/ntb/hw/mscc/ntb_hw_switchtec.c static int switchtec_ntb_link_disable(struct

Quoted 6 lines
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
-       switchtec_ntb_check_link(sndev);
+       switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
 
        return 0;
  }
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +0 -0
@@ -540,9 +552,9 @@ static int switchtec_ntb_link_disable(struct

ntb_dev

Quoted 27 lines
Quoted 27 lines
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +2 -2
 *ntb)
        dev_dbg(&sndev->stdev->dev, "disabling link\n");
 
        sndev->self_shared->link_sta = 0;
-       switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
+       switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_DOWN);
 
-       switchtec_ntb_check_link(sndev);
+       switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
 
        return 0;
  }
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
@@ -1061,7 +1073,7 @@ static irqreturn_t switchtec_ntb_message_isr(int
 irq, void *dev)
                        iowrite8(1,
 &sndev->mmio_self_dbmsg->imsg[i].status);
 
                        if (i == LINK_MESSAGE)
-                               switchtec_ntb_check_link(sndev);
+                               switchtec_ntb_check_link(sndev, msg);
                }
        }
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +0 -0
@@ -1159,6 +1171,13 @@ static int switchtec_ntb_add(struct device *dev,
        if (rc)
                goto deinit_shared_and_exit;
 
Quoted 6 lines

drivers/ntb/hw/mscc/ntb_hw_switchtec.c static int switchtec_ntb_add(struct device *dev,

Quoted 6 lines
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +6 -0
+       /*
+        * If this host crashed, the other host may think the link is
+        * still up. Tell them to force it down (it will go back up
+        * once we register the ntb device).
+        */
+       switchtec_ntb_send_msg(sndev, LINK_MESSAGE,

MSG_LINK_FORCE_DOWN);

Quoted 8 lines
Quoted 7 lines
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
+
        rc = ntb_register_device(&sndev->ntb);
        if (rc)
                goto deinit_and_exit;
--

2.11.0

#4 lore raw

The good peer didn't receive any message, the interrupt routine is not asserted.

Thanks !

Quoted 167 lines · ThanhTuThai

Dear Logan,

It works only for soft-reboot, but for power-on reset, it doesn't. I saw the problem is: with the power-on reset, the good peer didn't receive any message from the crashed peer even the crashed peer already sent out the message.

Do you think that after power-in reset, the memory-window is modified ? So it cannot translate the message from the crashed peer to the good peer.

Thanks !

Quoted 150 lines · Jon Mason
Quoted 3 lines · Logan Gunthorpe

Hey Thai Thu,

Please test with this patch and report back if it fixes your issue.

I'll wait on the ack before applying this patch and I'll add the "tested-by" line (assuming it works).

Thanks,
Jon

Quoted 77 lines

If it doesn't, can you please send the dmesg output of the two hosts?

Thanks,

Logan

Quoted 68 lines · Logan Gunthorpe

If one host crashes and soft reboots, the other host may not see a link down event. Then when the crashed host comes back up, the surviving host may not know the link was reset and the ntb clients may not work without being reset.

To solve this, we send a LINK_FORCE_DOWN message to each peer every time we come up, before we register the ntb device. If a surving host still thinks the link is up it will take it down immediately. In this way, once the crashed host comes up fully, it will send a regular link up event as per usual and the link will be properly restarted.

While we are in the area, this also fixes the MSG_LINK_UP message that was in the link down function that was reported by Doug Meyers.

---
  drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 33
++++++++++++++++++++++++++-------
  1 file changed, 26 insertions(+), 7 deletions(-)
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +14 -2
index d71744904b19..5cfcd4deadaf 100644
@@ -463,18 +463,30 @@ static void switchtec_ntb_set_link_speed(struct
 switchtec_ntb *sndev)
        sndev->link_width = min(self_width, peer_width);
  }
 
-enum {
+enum switchtec_msg {
        LINK_MESSAGE = 0,
        MSG_LINK_UP = 1,
        MSG_LINK_DOWN = 2,
        MSG_CHECK_LINK = 3,
+       MSG_LINK_FORCE_DOWN = 4,
  };
 
-static void switchtec_ntb_check_link(struct switchtec_ntb *sndev)
+static void switchtec_ntb_check_link(struct switchtec_ntb *sndev,
+                                    enum switchtec_msg msg)
  {
        int link_sta;
        int old = sndev->link_is_up;
 
+       if (msg == MSG_LINK_FORCE_DOWN) {
+               if (sndev->link_is_up) {
+                       sndev->link_is_up = 0;
+                       ntb_link_event(&sndev->ntb);
+                       dev_info(&sndev->stdev->dev, "ntb link forced
 down\n");
+               }
+
+               return;
+       }
+
        link_sta = sndev->self_shared->link_sta;
        if (link_sta) {
                u64 peer = ioread64(&sndev->peer_shared->magic);
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +0 -0
@@ -500,7 +512,7 @@ static void switchtec_ntb_link_notification(struct
 switchtec_dev *stdev)
  {
        struct switchtec_ntb *sndev = stdev->sndev;
 
Quoted 6 lines

drivers/ntb/hw/mscc/ntb_hw_switchtec.c static int switchtec_ntb_link_enable(struct

Quoted 6 lines
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
-       switchtec_ntb_check_link(sndev);
+       switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
  }
 

static u64 switchtec_ntb_link_is_up(struct ntb_dev *ntb,

drivers/ntb/hw/mscc/ntb_hw_switchtec.c +0 -0
@@ -528,7 +540,7 @@ static int switchtec_ntb_link_enable(struct

ntb_dev

Quoted 10 lines

drivers/ntb/hw/mscc/ntb_hw_switchtec.c static int switchtec_ntb_link_disable(struct

Quoted 10 lines
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
 *ntb,
        sndev->self_shared->link_sta = 1;
        switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
 
-       switchtec_ntb_check_link(sndev);
+       switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
 
        return 0;
  }
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +0 -0
@@ -540,9 +552,9 @@ static int switchtec_ntb_link_disable(struct

ntb_dev

Quoted 27 lines
Quoted 27 lines
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +2 -2
 *ntb)
        dev_dbg(&sndev->stdev->dev, "disabling link\n");
 
        sndev->self_shared->link_sta = 0;
-       switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
+       switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_DOWN);
 
-       switchtec_ntb_check_link(sndev);
+       switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
 
        return 0;
  }
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
@@ -1061,7 +1073,7 @@ static irqreturn_t switchtec_ntb_message_isr(int
 irq, void *dev)
                        iowrite8(1,
 &sndev->mmio_self_dbmsg->imsg[i].status);
 
                        if (i == LINK_MESSAGE)
-                               switchtec_ntb_check_link(sndev);
+                               switchtec_ntb_check_link(sndev, msg);
                }
        }
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +0 -0
@@ -1159,6 +1171,13 @@ static int switchtec_ntb_add(struct device *dev,
        if (rc)
                goto deinit_shared_and_exit;
 
Quoted 6 lines

drivers/ntb/hw/mscc/ntb_hw_switchtec.c static int switchtec_ntb_add(struct device *dev,

Quoted 6 lines
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +6 -0
+       /*
+        * If this host crashed, the other host may think the link is
+        * still up. Tell them to force it down (it will go back up
+        * once we register the ntb device).
+        */
+       switchtec_ntb_send_msg(sndev, LINK_MESSAGE,

MSG_LINK_FORCE_DOWN);

Quoted 8 lines
Quoted 7 lines
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
+
        rc = ntb_register_device(&sndev->ntb);
        if (rc)
                goto deinit_and_exit;
--

2.11.0

author maintainer
#5 lore raw
In reply to ThanhTuThai

Hey,

Quoted 2 lines

It works only for soft-reboot, but for power-on reset, it doesn't.
I saw the problem is: with the power-on reset, the good peer didn't receive any message from the crashed peer even the crashed peer already sent out the message.

Hmm, that's unexpected. If the link state changed on one of the ports the good host should have gotten an interrupt.

Can you send me the dmesg output on both hosts? Preferably with debugging[1] turned on.

Thanks,

Logan

[1] https://www.kernel.org/doc/html/latest/admin-guide/dynamic-debug-howto.html

author maintainer
#6 lore raw

Also,

Can you grab the switchtec management utility[1] and send me the output of:

sudo switchtec gas dump > gas_dump.dat

On the good host after the bad host came back up?

Thanks,

Logan