Fix execution dependency with checkstop monitor
phosphor-gpio-monitor watching for checkstop instance is configured
to start at host-start target and to stop at host-stop target.
On detecting the checkstop condition, it is configured to invoke
obmc-host-crash target, which in turn would invoke host-quiesce
target.
Starting and stopping the gpio monitor was achieved by having 2
target files that had just 'Requires' relation with gpio-monitor.
This commit removes the target and uses '.wants' relationship and
puts a drop-in unit for establishing a `Conflicts` relation with
obmc-host-crash target, which is what is invoked by gpio-monitor
on detecting checkstop.
This will ensure that gpio-monitor is stopped before starting
crash target and not relying on power off to do the same.
Fixes openbmc/openbmc#2022
Change-Id: I4dee93859a533c4d1a5138f4c3dd048160301e03
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor.bb
index d5d8d7f..062f9af 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor.bb
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor.bb
@@ -15,11 +15,16 @@
# via GPIO assertion
SYSTEMD_ENVIRONMENT_FILE_${PN} +="obmc/gpio/checkstop"
-STATES = "start stop"
-CHECKSTOP_SERVICE_FMT = "openpower-host-checkstop-monitor-{0}@.target"
-SYSTEMD_SERVICE_${PN} += "${@compose_list(d, 'CHECKSTOP_SERVICE_FMT', 'STATES')}"
+# This package is not supplying the unit file and also this is not a native
+# recipe since state-mgmt needs this package at runtime. Unsetting this below
+# variable will let the build go through
+SYSTEMD_SERVICE_${PN} ?=""
-CHECKSTOP_TMPL = "openpower-host-checkstop-monitor-{0}@.target"
-CHECKSTOP_TGTFMT = "openpower-host-checkstop-monitor-{0}@{1}.target"
-CHECKSTOP_MONITOR_FMT = "../${CHECKSTOP_TMPL}:obmc-host-{0}@{2}.target.wants/${CHECKSTOP_TGTFMT}"
+# Install the override to set up a Conflicts relation
+SYSTEMD_OVERRIDE_${PN} +="checkstop.conf:phosphor-gpio-monitor@checkstop.service.d/checkstop.conf"
+
+STATES = "start"
+GPIO_MONITOR_TMPL = "phosphor-gpio-monitor@.service"
+GPIO_MONITOR_TGTFMT = "phosphor-gpio-monitor@{1}.service"
+CHECKSTOP_MONITOR_FMT = "../${GPIO_MONITOR_TMPL}:obmc-host-{0}@{2}.target.wants/${GPIO_MONITOR_TGTFMT}"
SYSTEMD_LINK_${PN} += "${@compose_list(d, 'CHECKSTOP_MONITOR_FMT', 'STATES', 'OBMC_HOST_MONITOR_INSTANCES', 'OBMC_HOST_INSTANCES')}"
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/checkstop.conf b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/checkstop.conf
new file mode 100644
index 0000000..f47711f
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/checkstop.conf
@@ -0,0 +1,3 @@
+[Unit]
+Conflicts=obmc-host-crash@0.target
+Conflicts=obmc-host-stop@0.target
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor-start@.target b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor-start@.target
deleted file mode 100644
index 6b07a6c..0000000
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor-start@.target
+++ /dev/null
@@ -1,4 +0,0 @@
-[Unit]
-Description=Start Host %I monitor
-Requires=phosphor-gpio-monitor@%i.service
-RefuseManualStop=yes
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor-stop@.target b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor-stop@.target
deleted file mode 100644
index 242683a..0000000
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/host/checkstop-monitor/openpower-host-checkstop-monitor-stop@.target
+++ /dev/null
@@ -1,4 +0,0 @@
-[Unit]
-Description=Stop Host %I monitor
-Conflicts=phosphor-gpio-monitor@%i.service
-RefuseManualStop=yes