meta-facebook: Limit times waiting for MCTP connection

It shouldn't keep waiting for MCTP connection if mctpd somehow
crashed. Limit it to wait for only 1 minutes.

Change-Id: I7b6d70a849c4f2a6be2d7bfcab49ba1b2e152807
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle@.service b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle@.service
index 34fcb2a..eb11752 100644
--- a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle@.service
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-powercycle@.service
@@ -4,8 +4,7 @@
 [Service]
 Type=oneshot
 ExecStart=/usr/libexec/phosphor-state-manager/chassis-powercycle %i
-ExecStartPost=/usr/libexec/phosphor-state-manager/wait-until-mctp-connection-done %i
-ExecStartPost=/bin/systemctl restart phosphor-discover-system-state@%i.service
+ExecStartPost=/bin/bash -c "/usr/libexec/phosphor-state-manager/wait-until-mctp-connection-done %i && systemctl restart phosphor-discover-system-state@%i.service"
 
 [Install]
 WantedBy=obmc-chassis-powercycle@%i.target
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-poweron@.service b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-poweron@.service
index 86f8e7e..2345ecf 100644
--- a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-poweron@.service
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/chassis-poweron@.service
@@ -4,8 +4,7 @@
 [Service]
 Type=oneshot
 ExecStart=/usr/libexec/phosphor-state-manager/chassis-poweron %i
-ExecStartPost=/usr/libexec/phosphor-state-manager/wait-until-mctp-connection-done %i
-ExecStartPost=/bin/systemctl restart phosphor-discover-system-state@%i.service
+ExecStartPost=/bin/bash -c "/usr/libexec/phosphor-state-manager/wait-until-mctp-connection-done %i && systemctl restart phosphor-discover-system-state@%i.service"
 
 [Install]
 WantedBy=obmc-chassis-poweron@%i.target
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/wait-until-mctp-connection-done b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/wait-until-mctp-connection-done
index 9273851..569f47f 100644
--- a/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/wait-until-mctp-connection-done
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/wait-until-mctp-connection-done
@@ -1,13 +1,18 @@
 #!/bin/bash
 
 EID=$(($1*10))
+count=0
 
-while true; do
+while [ $count -lt 12 ]; do
     busctl get-property xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp/1/"$EID" xyz.openbmc_project.MCTP.Endpoint EID
     isMctpConnect=$?;
     echo $isMctpConnect
     if [ $isMctpConnect -eq 0 ]; then
-        break;
+        exit 0;
     fi
     sleep 5;
+    count=$((count + 1))
 done
+
+echo "timeout waiting for MCTP connection"
+exit 1