Implement new hard power off target
This target will allow the user to do an immediate
power off of the system without waiting for the host.
It can also be used to cause an immedate power off
if the host is hung during the normal power off
process.
The chassis poweroff target will now require the
host off target to ensure everything is properly
stopped when the chassis is powered off.
Change-Id: I8430d895ae5498d2e451aaf07480b0cf9550e8f2
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/meta-phosphor/common/recipes-core/systemd/obmc-targets.bb b/meta-phosphor/common/recipes-core/systemd/obmc-targets.bb
index 3e217bc..07c2d67 100644
--- a/meta-phosphor/common/recipes-core/systemd/obmc-targets.bb
+++ b/meta-phosphor/common/recipes-core/systemd/obmc-targets.bb
@@ -19,7 +19,8 @@
# - on: Services to run to power on the chassis
# - off: Services to run to power off the chassis
# - reset: Services to check chassis power state and update chassis "on" target
-CHASSIS_ACTION_TARGETS = "on off reset"
+# - hard-off: Services to force an immediate power off of the chassis
+CHASSIS_ACTION_TARGETS = "poweron poweroff powerreset hard-poweroff"
# Track all host synchronization point targets
# - start-pre: Services to run before we start host boot
@@ -42,12 +43,12 @@
HOST_ACTION_TARGETS = "start stop quiesce reset shutdown crash timeout"
CHASSIS_SYNCH_FMT = "obmc-power-{0}@.target"
-CHASSIS_ACTION_FMT = "obmc-chassis-power{0}@.target"
+CHASSIS_ACTION_FMT = "obmc-chassis-{0}@.target"
HOST_SYNCH_FMT = "obmc-host-{0}@.target"
HOST_ACTION_FMT = "obmc-host-{0}@.target"
CHASSIS_LINK_SYNCH_FMT = "${CHASSIS_SYNCH_FMT}:obmc-power-{0}@{1}.target"
-CHASSIS_LINK_ACTION_FMT = "${CHASSIS_ACTION_FMT}:obmc-chassis-power{0}@{1}.target"
+CHASSIS_LINK_ACTION_FMT = "${CHASSIS_ACTION_FMT}:obmc-chassis-{0}@{1}.target"
HOST_LINK_SYNCH_FMT = "${HOST_SYNCH_FMT}:obmc-host-{0}@{1}.target"
HOST_LINK_ACTION_FMT = "${HOST_ACTION_FMT}:obmc-host-{0}@{1}.target"
FAN_LINK_FMT = "obmc-fan-control-ready@.target:obmc-fan-control-ready@{0}.target"
diff --git a/meta-phosphor/common/recipes-core/systemd/obmc-targets/obmc-chassis-hard-poweroff@.target b/meta-phosphor/common/recipes-core/systemd/obmc-targets/obmc-chassis-hard-poweroff@.target
new file mode 100644
index 0000000..6d72d87
--- /dev/null
+++ b/meta-phosphor/common/recipes-core/systemd/obmc-targets/obmc-chassis-hard-poweroff@.target
@@ -0,0 +1,11 @@
+[Unit]
+Description=Chassis%i (Hard Power Off)
+Wants={SYSTEMD_DEFAULT_TARGET}
+After={SYSTEMD_DEFAULT_TARGET}
+Wants=mapper-wait@-xyz-openbmc_project-state-chassis%i.service
+After=mapper-wait@-xyz-openbmc_project-state-chassis%i.service
+Conflicts=obmc-chassis-poweron@%i.target
+Conflicts=obmc-chassis-reset@%i.target
+Conflicts=obmc-host-shutdown@%i.target
+Conflicts=xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service
+RefuseManualStop=yes
diff --git a/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power.bb b/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power.bb
index f85859c..4388e7a 100644
--- a/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power.bb
+++ b/meta-phosphor/common/recipes-phosphor/chassis/obmc-op-control-power.bb
@@ -66,11 +66,19 @@
START_FMT_CTRL = "../${START_TMPL_CTRL}:${START_TGTFMT_CTRL}.requires/${START_INSTFMT_CTRL}"
SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'START_FMT_CTRL', 'OBMC_POWER_INSTANCES', 'OBMC_CHASSIS_INSTANCES')}"
-STOP_TMPL_CTRL = "obmc-chassis-poweroff@.target"
-STOP_TGTFMT_CTRL = "obmc-host-stop@{1}.target"
-STOP_INSTFMT_CTRL = "obmc-chassis-poweroff@{0}.target"
+# Chassis off requires host off
+STOP_TMPL_CTRL = "obmc-host-stop@.target"
+STOP_TGTFMT_CTRL = "obmc-chassis-poweroff@{0}.target"
+STOP_INSTFMT_CTRL = "obmc-host-stop@{1}.target"
STOP_FMT_CTRL = "../${STOP_TMPL_CTRL}:${STOP_TGTFMT_CTRL}.requires/${STOP_INSTFMT_CTRL}"
-SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'STOP_FMT_CTRL', 'OBMC_POWER_INSTANCES', 'OBMC_CHASSIS_INSTANCES')}"
+SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'STOP_FMT_CTRL', 'OBMC_CHASSIS_INSTANCES', 'OBMC_HOST_INSTANCES')}"
+
+# Hard power off requires chassis off
+HARD_OFF_TMPL_CTRL = "obmc-chassis-poweroff@.target"
+HARD_OFF_TGTFMT_CTRL = "obmc-chassis-hard-poweroff@{0}.target"
+HARD_OFF_INSTFMT_CTRL = "obmc-chassis-poweroff@{0}.target"
+HARD_OFF_FMT_CTRL = "../${HARD_OFF_TMPL_CTRL}:${HARD_OFF_TGTFMT_CTRL}.requires/${HARD_OFF_INSTFMT_CTRL}"
+SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HARD_OFF_FMT_CTRL', 'OBMC_CHASSIS_INSTANCES')}"
# Force the standby target to run the chassis reset check target
RESET_TMPL_CTRL = "obmc-chassis-powerreset@.target"
diff --git a/meta-phosphor/common/recipes-phosphor/state/phosphor-state-manager.bb b/meta-phosphor/common/recipes-phosphor/state/phosphor-state-manager.bb
index af6b79c..3ff00c3 100644
--- a/meta-phosphor/common/recipes-phosphor/state/phosphor-state-manager.bb
+++ b/meta-phosphor/common/recipes-phosphor/state/phosphor-state-manager.bb
@@ -80,12 +80,12 @@
FMT = "../${TMPL}:${SYSTEMD_DEFAULT_TARGET}.wants/${INSTFMT}"
SYSTEMD_LINK_${PN}-discover += "${@compose_list(d, 'FMT', 'OBMC_HOST_INSTANCES')}"
-# Force the shutdown target to run the host-stop target
-HOST_STOP_TMPL = "obmc-host-stop@.target"
+# Force the shutdown target to run the chassis-poweroff target
+CHASSIS_STOP_TMPL = "obmc-chassis-poweroff@.target"
HOST_STOP_TGTFMT = "obmc-host-shutdown@{1}.target"
-HOST_STOP_INSTFMT = "obmc-host-stop@{0}.target"
-HOST_STOP_FMT = "../${HOST_STOP_TMPL}:${HOST_STOP_TGTFMT}.requires/${HOST_STOP_INSTFMT}"
-SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_STOP_FMT', 'OBMC_HOST_INSTANCES', 'OBMC_HOST_INSTANCES')}"
+CHASSIS_STOP_INSTFMT = "obmc-chassis-poweroff@{0}.target"
+HOST_STOP_FMT = "../${CHASSIS_STOP_TMPL}:${HOST_STOP_TGTFMT}.requires/${CHASSIS_STOP_INSTFMT}"
+SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_STOP_FMT', 'OBMC_CHASSIS_INSTANCES', 'OBMC_HOST_INSTANCES')}"
SRC_URI += "git://github.com/openbmc/phosphor-state-manager"
SRCREV = "181f8364f81fc8864e9ae86f28de13f80cd9bbf9"