From 697da84f55c2bb080eee647bcab3255a6fd818e2 Mon Sep 17 00:00:00 2001 From: Raptor Engineering Development Team Date: Sat, 12 May 2018 21:15:17 -0500 Subject: Recover from BMC reboot by properly setting host and IPL status This assumes that if the ATX power is on, the host was previously IPLed --- pyiplobserver/ipl_status_observer.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/pyiplobserver/ipl_status_observer.py b/pyiplobserver/ipl_status_observer.py index 96678fc..b3bafa7 100755 --- a/pyiplobserver/ipl_status_observer.py +++ b/pyiplobserver/ipl_status_observer.py @@ -80,14 +80,17 @@ class IPLStatus(DbusProperties, DbusObjectManager): host_state_iface = dbus.Interface(host_state_dev, 'org.freedesktop.DBus.Properties') host_state_value = host_state_iface.Get("xyz.openbmc_project.State.Host", "CurrentHostState") if host_state_value is not None: - if (host_state_value == HOST_STATUS_RUNNING): - skiboot_flags = self.getSkibootBootFlags() - if (skiboot_flags != 0): - self.current_istep_major = IPL_COMPLETE_ISTEP_MAJOR - self.current_istep_minor = IPL_COMPLETE_ISTEP_MINOR + power_ctrl_flag = self.getChassisPowerRequestFlag() + skiboot_flags = self.getSkibootBootFlags() + if ((skiboot_flags != 0) and (skiboot_flags != 1)) or ((power_ctrl_flag == 1) and (skiboot_flags == 0)): + self.current_istep_major = KERNEL_COMPLETE_ISTEP_MAJOR + self.current_istep_minor = KERNEL_COMPLETE_ISTEP_MAJOR + if (skiboot_flags != 0) or (power_ctrl_flag == 1): self.activateMonitoringPrev = True self.activateMonitoring = True - + if (host_state_value != HOST_STATUS_RUNNING) and (self.activateMonitoring == True): + host_state_iface.Set("xyz.openbmc_project.State.Host", "CurrentHostState", HOST_STATUS_RUNNING) + self.setSkibootBootFlags(2) self.Set(DBUS_NAME, "current_istep", "") self.Set(DBUS_NAME, "current_status", "UNKNOWN") @@ -101,6 +104,17 @@ class IPLStatus(DbusProperties, DbusObjectManager): print "IPLStatus Init Done" + def getChassisPowerRequestFlag(self): + result = 0 + try: + proc = subprocess.Popen(["i2cget -y 12 0x31 0x7"], stdout=subprocess.PIPE, stderr=open(os.devnull, 'wb'), shell=True) + (out, err) = proc.communicate() + result = (int(out, 16) & 2) >> 1 + except: + pass + + return result + # BMC bits OEM1, OEM2, and OEM3 are the signalling flags # OEM1 is unconditionally set at skiboot completion and is only cleared by the BMC IPL monitor # OEM2 is used as a persistent state indicator, and is only set and cleared by the BMC IPL monitor -- cgit v1.2.1