Implement de-glitch for input fault
If three consecutive reads in a row, on second apart, show the
INPUT_FAULT_WARN and/or VIN_UV_FAULT on, create and log an error.
Resolves: openbmc/openbmc#2484
Change-Id: I35dedfc6acbb68bd8004c4fd1cc3d6dc799a9a17
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index 38898bd..1dcf462 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -258,40 +258,23 @@
{
using namespace witherspoon::pmbus;
- std::uint8_t statusInput = 0;
-
- if (!inputFault && ((statusWord & status_word::INPUT_FAULT_WARN) ||
- (statusWord & status_word::VIN_UV_FAULT)))
+ if ((inputFault < FAULT_COUNT) &&
+ ((statusWord & status_word::INPUT_FAULT_WARN) ||
+ (statusWord & status_word::VIN_UV_FAULT)))
{
- faultFound = true;
- inputFault = true;
-
- util::NamesValues nv;
- nv.add("STATUS_WORD", statusWord);
- captureCmd(nv, STATUS_INPUT, Type::Debug);
-
- using metadata = org::open_power::Witherspoon::Fault::
- PowerSupplyInputFault;
-
- report<PowerSupplyInputFault>(
- metadata::RAW_STATUS(nv.get().c_str()),
- metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
+ inputFault++;
}
else
{
- if ((inputFault) &&
+ if ((inputFault > 0) &&
!(statusWord & status_word::INPUT_FAULT_WARN) &&
!(statusWord & status_word::VIN_UV_FAULT))
{
- inputFault = false;
+ inputFault = 0;
faultFound = false;
- statusInput = pmbusIntf.read(STATUS_INPUT, Type::Debug);
-
log<level::INFO>("INPUT_FAULT_WARN cleared",
- entry("POWERSUPPLY=%s", inventoryPath.c_str()),
- entry("STATUS_WORD=0x%04X", statusWord),
- entry("STATUS_INPUT=0x%02X", statusInput));
+ entry("POWERSUPPLY=%s", inventoryPath.c_str()));
if (powerOn)
{
@@ -304,6 +287,22 @@
}
}
}
+
+ if (!faultFound && (inputFault >= FAULT_COUNT))
+ {
+ util::NamesValues nv;
+ nv.add("STATUS_WORD", statusWord);
+ captureCmd(nv, STATUS_INPUT, Type::Debug);
+
+ using metadata = org::open_power::Witherspoon::Fault::
+ PowerSupplyInputFault;
+
+ report<PowerSupplyInputFault>(
+ metadata::RAW_STATUS(nv.get().c_str()),
+ metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
+ faultFound = true;
+ }
+
}
void PowerSupply::checkPGOrUnitOffFault(const uint16_t statusWord)
@@ -534,7 +533,7 @@
{
readFail = 0;
readFailLogged = false;
- inputFault = false;
+ inputFault = 0;
powerOnFault = 0;
outputOCFault = 0;
outputOVFault = 0;
diff --git a/power-supply/power_supply.hpp b/power-supply/power_supply.hpp
index b1ac71a..7a5f1b5 100644
--- a/power-supply/power_supply.hpp
+++ b/power-supply/power_supply.hpp
@@ -165,12 +165,14 @@
bool readFailLogged = false;
/**
- * @brief Set to true when an input fault or warning is detected
+ * @brief Indicates an input fault or warning if equal to FAULT_COUNT.
*
- * This is the "INPUT FAULT OR WARNING" bit in the high byte from the
- * STATUS_WORD command response.
+ * @details This is the "INPUT FAULT OR WARNING" bit in the high byte,
+ * or the VIN_UV_FAULT bit in the low byte in the STATUS_WORD
+ * command response. If either of those bits are on, this will
+ * be incremented.
*/
- bool inputFault = false;
+ size_t inputFault = 0;
/**
* @brief Indicates output over current fault if equal to FAULT_COUNT