Patch to shutdown when deconfig happens outside reconfig loop
diff --git a/openpower/package/hostboot/hostboot-0006-shutdown-deconfig-outside-reconfig-loop.patch b/openpower/package/hostboot/hostboot-0006-shutdown-deconfig-outside-reconfig-loop.patch
new file mode 100644
index 0000000..773a9db
--- /dev/null
+++ b/openpower/package/hostboot/hostboot-0006-shutdown-deconfig-outside-reconfig-loop.patch
@@ -0,0 +1,187 @@
+From 7c592db2c42b8dbef0f31a8daebb97ff0ed6a3ac Mon Sep 17 00:00:00 2001
+From: Stephen Cprek <smcprek@us.ibm.com>
+Date: Tue, 30 Jun 2015 16:49:22 -0500
+Subject: [PATCH] Shutdown when deconfig outside of reconfig loop on BMC
+ systems
+
+Change-Id: I1faf0ab0d831a41c332993f555231a8dbecf53ef
+CQ:SW312075
+---
+ src/include/usr/initservice/initsvcreasoncodes.H | 4 +-
+ .../initservice/istepdispatcher/istepdispatcher.C | 120 ++++++++++++++++-----
+ 2 files changed, 98 insertions(+), 26 deletions(-)
+
+diff --git a/src/include/usr/initservice/initsvcreasoncodes.H b/src/include/usr/initservice/initsvcreasoncodes.H
+index d11824e..e174564 100644
+--- a/src/include/usr/initservice/initsvcreasoncodes.H
++++ b/src/include/usr/initservice/initsvcreasoncodes.H
+@@ -5,7 +5,7 @@
+ /* */
+ /* OpenPOWER HostBoot Project */
+ /* */
+-/* Contributors Listed Below - COPYRIGHT 2011,2014 */
++/* Contributors Listed Below - COPYRIGHT 2011,2015 */
+ /* [+] International Business Machines Corp. */
+ /* */
+ /* */
+@@ -74,6 +74,8 @@ enum InitServiceReasonCode
+ //termination_rc
+ SBE_EXTRACT_RC_REQUEST_REIPL = INITSVC_COMP_ID | 0x0e,
+ RECONFIG_LOOP_TEST_RC = INITSVC_COMP_ID | 0x0f,
++ //termination_rc
++ SHUTDOWN_NOT_RECONFIG_LOOP = INITSVC_COMP_ID | 0x10,
+ };
+
+ enum InitServiceUserDetailDataSubSection
+diff --git a/src/usr/initservice/istepdispatcher/istepdispatcher.C b/src/usr/initservice/istepdispatcher/istepdispatcher.C
+index d3581e9..7f3c0b7 100644
+--- a/src/usr/initservice/istepdispatcher/istepdispatcher.C
++++ b/src/usr/initservice/istepdispatcher/istepdispatcher.C
+@@ -96,6 +96,10 @@ const uint8_t OUTER_STOP_STEP = 14;
+ const uint8_t OUTER_STOP_SUBSTEP = 5;
+ const uint8_t HB_START_ISTEP = 6;
+
++// @todo RTC 124679 - Remove Once BMC Monitors Shutdown Attention
++// Set Watchdog Timer To 15 seconds before calling doShutdown()
++const uint16_t SET_WD_TIMER_IN_SECS = 15;
++
+ /**
+ * _start() task entry procedure using the macro in taskargs.H
+ */
+@@ -506,14 +510,58 @@ errlHndl_t IStepDispatcher::executeAllISteps()
+ }
+ else
+ {
+- // Reconfig loop required, but the istep is either outside
+- // of the reconfig loop, too many reconfigs have been
+- // attempted, in manufacturing mode, or in MPIPL.
+- // Return an error to cause termination
++
+ if (!err)
+ {
+- err = failedDueToDeconfig(istep, substep,
+- newIstep, newSubstep);
++ // Reconfig loop required, but the istep is either outside
++ // of the reconfig loop, too many reconfigs have been
++ // attempted, in manufacturing mode, or in MPIPL.
++ // Return an error to cause termination on FSP systems
++ if (iv_spBaseServicesEnabled)
++ {
++ err = failedDueToDeconfig(istep, substep,
++ newIstep, newSubstep);
++ }
++ // Otherwise increment the reboot count and shutdown
++ #ifdef CONFIG_BMC_IPMI
++ else
++ {
++ uint16_t l_count = 0;
++ SENSOR::RebootCountSensor l_sensor;
++
++ // Read reboot count sensor
++ err = l_sensor.getRebootCount(l_count);
++ if (err)
++ {
++ TRACFCOMP(g_trac_initsvc, ERR_MRK"executeAllISteps: getRebootCount failed");
++ break;
++ }
++ // Increment reboot count
++ l_count++;
++ err = l_sensor.setRebootCount(l_count);
++ if (err)
++ {
++ TRACFCOMP(g_trac_initsvc, ERR_MRK"executeAllISteps: setRebootCount to %d failed", l_count);
++ break;
++ }
++
++ // @TODO RTC:124679 - Remove Once BMC Monitors
++ // Shutdown Attention
++ // Set Watchdog Timer before calling doShutdown()
++ TRACFCOMP( g_trac_initsvc,"executeAllISteps: "
++ "Set Watch Dog Timer To %d Seconds",
++ SET_WD_TIMER_IN_SECS);
++
++ err = IPMIWATCHDOG::setWatchDogTimer(
++ SET_WD_TIMER_IN_SECS, // new time
++ static_cast<uint8_t>
++ (IPMIWATCHDOG::DO_NOT_STOP |
++ IPMIWATCHDOG::BIOS_FRB2), // default
++ IPMIWATCHDOG::TIMEOUT_HARD_RESET);
++
++ shutdownDuringIpl();
++ }
++ #endif
+ }
+ // else return the error from doIstep
+ }
+@@ -1260,27 +1308,49 @@ void IStepDispatcher::shutdownDuringIpl()
+ {
+ TRACFCOMP(g_trac_initsvc, ENTER_MRK"IStepDispatcher::shutdownDuringIpl");
+
+- // Create and commit error log for FFDC
+-
+- /*@
+- * @errortype
+- * @reasoncode SHUTDOWN_REQUESTED_BY_FSP
+- * @severity ERRORLOG::ERRL_SEV_INFORMATIONAL
+- * @moduleid ISTEP_INITSVC_MOD_ID
+- * @userdata1 Current IStep
+- * @userdata2 Current SubStep
+- * @devdesc Received shutdown request from FSP
+- */
+- errlHndl_t err = new ERRORLOG::ErrlEntry(
+- ERRORLOG::ERRL_SEV_INFORMATIONAL,
+- ISTEP_INITSVC_MOD_ID,
+- SHUTDOWN_REQUESTED_BY_FSP,
+- this->iv_curIStep, this->iv_curSubStep);
++ // Create and commit error log for FFDC and call doShutdown with the RC
++ // to initiate a TI
++ if (iv_spBaseServicesEnabled)
++ {
++ /*@
++ * @errortype
++ * @reasoncode SHUTDOWN_REQUESTED_BY_FSP
++ * @severity ERRORLOG::ERRL_SEV_INFORMATIONAL
++ * @moduleid ISTEP_INITSVC_MOD_ID
++ * @userdata1 Current IStep
++ * @userdata2 Current SubStep
++ * @devdesc Received shutdown request from FSP
++ */
++ errlHndl_t err = new ERRORLOG::ErrlEntry(
++ ERRORLOG::ERRL_SEV_INFORMATIONAL,
++ ISTEP_INITSVC_MOD_ID,
++ SHUTDOWN_REQUESTED_BY_FSP,
++ this->iv_curIStep, this->iv_curSubStep);
+
+- errlCommit(err, INITSVC_COMP_ID);
++ errlCommit(err, INITSVC_COMP_ID);
++ INITSERVICE::doShutdown(SHUTDOWN_REQUESTED_BY_FSP);
++ }
++ else
++ {
++ /*@
++ * @errortype
++ * @reasoncode SHUTDOWN_NOT_RECONFIG_LOOP
++ * @severity ERRORLOG::ERRL_SEV_INFORMATIONAL
++ * @moduleid ISTEP_INITSVC_MOD_ID
++ * @userdata1 Current IStep
++ * @userdata2 Current SubStep
++ * @devdesc Received shutdown request due to deconfigure
++ * outside of reconfig loop
++ */
++ errlHndl_t err = new ERRORLOG::ErrlEntry(
++ ERRORLOG::ERRL_SEV_INFORMATIONAL,
++ ISTEP_INITSVC_MOD_ID,
++ SHUTDOWN_NOT_RECONFIG_LOOP,
++ this->iv_curIStep, this->iv_curSubStep);
+
+- // Call doShutdown with the RC to initiate a TI
+- INITSERVICE::doShutdown(SHUTDOWN_REQUESTED_BY_FSP);
++ errlCommit(err, INITSVC_COMP_ID);
++ INITSERVICE::doShutdown(SHUTDOWN_NOT_RECONFIG_LOOP);
++ }
+
+ }
+
+--
+1.8.2.2
+