discover: support 3 options to run APR when BMC is rebooted
As defined in the PDIs [1], the RebootCause can be
Power-On-Reset, Watchdog, Pinhole, Software or Unknown. When BMC is
rebooted due to Power-On-Reset, BMC always runs APR feature. But other
RebootCause values, we don't have a clear specification to indicate the
behavior of BMC in those cases. This commit adds 3 more options to
support running APR when BMC rebooted or not.
- 'run-apr-on-pinhole-reset': Run APR when BMC is rebooted due to
pinhole action.
- 'run-apr-on-watchdog-reset': Run APR when BMC is rebooted due to
watchdog.
- 'run-apr-on-software-reset': Run APR when BMC is rebooted due to
software.
[1] https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/State/BMC.interface.yaml#L72
Tested:
Test case 1:
1. Enable run-apr-on-watchdog-reset option
2. Trigger watchdog to reboot BMC
3. BMC runs APR when booting done
4. Disable run-apr-on-watchdog-reset option
5. Trigger watchdog to reboot BMC
6. BMC does not run APR when booting done
Test case 2:
1. Enable run-apr-on-software-reset option
2. Call "reboot" command to reboot BMC
3. BMC runs APR when booting done
4. Disable run-apr-on-software-reset option
5. Trigger watchdog to reboot BMC
6. BMC does not run APR when booting done
Change-Id: I255f52a4008ae1dbf3db69e33471f9d23e0552a0
Signed-off-by: Thang Tran <thuutran@amperecomputing.com>
diff --git a/discover_system_state.cpp b/discover_system_state.cpp
index f6542ef..2153e7c 100644
--- a/discover_system_state.cpp
+++ b/discover_system_state.cpp
@@ -85,23 +85,40 @@
auto bmcPath = sdbusplus::message::object_path(BMC::namespace_path::value) /
BMC::namespace_path::bmc;
+#if !(RUN_APR_ON_PINHOLE_RESET && RUN_APR_ON_WATCHDOG_RESET && \
+ RUN_APR_ON_SOFTWARE_RESET)
auto bmcRebootCause =
sdbusplus::message::convert_from_string<BMC::RebootCause>(
phosphor::state::manager::utils::getProperty(
bus, bmcPath.str, BMCState::interface, "LastRebootCause"));
+#if !RUN_APR_ON_PINHOLE_RESET
if (bmcRebootCause == BMC::RebootCause::PinholeReset)
{
info(
"BMC was reset due to pinhole reset, no power restore policy will be run");
return 0;
}
- else if (bmcRebootCause == BMC::RebootCause::Watchdog)
+#endif // RUN_APR_ON_PINHOLE_RESET
+
+#if !RUN_APR_ON_WATCHDOG_RESET
+ if (bmcRebootCause == BMC::RebootCause::Watchdog)
+ {
+ info(
+ "BMC was reset due to watchdog, no power restore policy will be run");
+ return 0;
+ }
+#endif // RUN_APR_ON_WATCHDOG_RESET
+
+#if !RUN_APR_ON_SOFTWARE_RESET
+ if (bmcRebootCause == BMC::RebootCause::Software)
{
info(
"BMC was reset due to cold reset, no power restore policy will be run");
return 0;
}
+#endif // RUN_APR_ON_SOFTWARE_RESET
+#endif
/* The logic here is to first check the one-time PowerRestorePolicy setting.
* If this property is not the default then look at the persistent
diff --git a/meson.build b/meson.build
index 02c13dd..fee3005 100644
--- a/meson.build
+++ b/meson.build
@@ -41,6 +41,12 @@
get_option('only-run-apr-on-power-loss'),
)
+conf.set10('RUN_APR_ON_PINHOLE_RESET', get_option('run-apr-on-pinhole-reset'))
+
+conf.set10('RUN_APR_ON_WATCHDOG_RESET', get_option('run-apr-on-watchdog-reset'))
+
+conf.set10('RUN_APR_ON_SOFTWARE_RESET', get_option('run-apr-on-software-reset'))
+
conf.set_quoted('SYSFS_TPM_DEVICE_PATH', get_option('sysfs-tpm-device-path'))
conf.set_quoted(
diff --git a/meson.options b/meson.options
index f0221ea..f7a3efc 100644
--- a/meson.options
+++ b/meson.options
@@ -160,3 +160,24 @@
value: 'enabled',
description: 'Install the obmcutil script',
)
+
+option(
+ 'run-apr-on-pinhole-reset',
+ type: 'boolean',
+ value: true,
+ description: 'run APR when BMC has been rebooted due to pinhole action',
+)
+
+option(
+ 'run-apr-on-watchdog-reset',
+ type: 'boolean',
+ value: true,
+ description: 'run APR when BMC has been rebooted due to watchdog',
+)
+
+option(
+ 'run-apr-on-software-reset',
+ type: 'boolean',
+ value: true,
+ description: 'run APR when BMC has been rebooted due to software request',
+)