psu-ng: Limit tracing to STATUS_WORD changes
Add in a statusWordOld to compare with new statusWord value. Use that to
limit tracing to only when the value changes.
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: I40d9d8c08b5e60f7c11f753c0bf88c78304ecb1d
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index ba3eb2e..4771183 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -199,11 +199,13 @@
{
if (cmlFault < DEGLITCH_LIMIT)
{
- log<level::ERR>(fmt::format("CML fault: STATUS_WORD = {:#06x}, "
- "STATUS_CML = {:#04x}",
- statusWord, statusCML)
- .c_str());
-
+ if (statusWord != statusWordOld)
+ {
+ log<level::ERR>(fmt::format("CML fault: STATUS_WORD = {:#06x}, "
+ "STATUS_CML = {:#02x}",
+ statusWord, statusCML)
+ .c_str());
+ }
cmlFault++;
}
}
@@ -219,12 +221,15 @@
{
if (inputFault < DEGLITCH_LIMIT)
{
- log<level::ERR>(fmt::format("INPUT fault: STATUS_WORD = {:#06x}, "
- "STATUS_MFR_SPECIFIC = {:#04x}, "
- "STATUS_INPUT = {:#04x}",
- statusWord, statusMFR, statusInput)
- .c_str());
-
+ if (statusWord != statusWordOld)
+ {
+ log<level::ERR>(
+ fmt::format("INPUT fault: STATUS_WORD = {:#06x}, "
+ "STATUS_MFR_SPECIFIC = {:#04x}, "
+ "STATUS_INPUT = {:#04x}",
+ statusWord, statusMFR, statusInput)
+ .c_str());
+ }
inputFault++;
}
}
@@ -250,12 +255,15 @@
{
if (voutOVFault < DEGLITCH_LIMIT)
{
- log<level::ERR>(
- fmt::format("VOUT_OV_FAULT fault: STATUS_WORD = {:#06x}, "
- "STATUS_MFR_SPECIFIC = {:#04x}, "
- "STATUS_VOUT = {:#04x}",
- statusWord, statusMFR, statusVout)
- .c_str());
+ if (statusWord != statusWordOld)
+ {
+ log<level::ERR>(
+ fmt::format("VOUT_OV_FAULT fault: STATUS_WORD = {:#06x}, "
+ "STATUS_MFR_SPECIFIC = {:#04x}, "
+ "STATUS_VOUT = {:#02x}",
+ statusWord, statusMFR, statusVout)
+ .c_str());
+ }
voutOVFault++;
}
@@ -272,11 +280,15 @@
{
if (ioutOCFault < DEGLITCH_LIMIT)
{
- log<level::ERR>(fmt::format("IOUT fault: STATUS_WORD = {:#06x}, "
- "STATUS_MFR_SPECIFIC = {:#04x}, "
- "STATUS_IOUT = {:#04x}",
- statusWord, statusMFR, statusIout)
- .c_str());
+ if (statusWord != statusWordOld)
+ {
+ log<level::ERR>(
+ fmt::format("IOUT fault: STATUS_WORD = {:#06x}, "
+ "STATUS_MFR_SPECIFIC = {:#04x}, "
+ "STATUS_IOUT = {:#04x}",
+ statusWord, statusMFR, statusIout)
+ .c_str());
+ }
ioutOCFault++;
}
@@ -294,13 +306,15 @@
{
if (voutUVFault < DEGLITCH_LIMIT)
{
- log<level::ERR>(
- fmt::format("VOUT_UV_FAULT fault: STATUS_WORD = {:#06x}, "
- "STATUS_MFR_SPECIFIC = {:#04x}, "
- "STATUS_VOUT = {:#04x}",
- statusWord, statusMFR, statusVout)
- .c_str());
-
+ if (statusWord != statusWordOld)
+ {
+ log<level::ERR>(
+ fmt::format("VOUT_UV_FAULT fault: STATUS_WORD = {:#06x}, "
+ "STATUS_MFR_SPECIFIC = {:#04x}, "
+ "STATUS_VOUT = {:#04x}",
+ statusWord, statusMFR, statusVout)
+ .c_str());
+ }
voutUVFault++;
}
}
@@ -316,13 +330,15 @@
{
if (fanFault < DEGLITCH_LIMIT)
{
- log<level::ERR>(fmt::format("FANS fault/warning: "
- "STATUS_WORD = {:#06x}, "
- "STATUS_MFR_SPECIFIC = {:#04x}, "
- "STATUS_FANS_1_2 = {:#04x}",
- statusWord, statusMFR, statusFans12)
- .c_str());
-
+ if (statusWord != statusWordOld)
+ {
+ log<level::ERR>(fmt::format("FANS fault/warning: "
+ "STATUS_WORD = {:#06x}, "
+ "STATUS_MFR_SPECIFIC = {:#04x}, "
+ "STATUS_FANS_1_2 = {:#04x}",
+ statusWord, statusMFR, statusFans12)
+ .c_str());
+ }
fanFault++;
}
}
@@ -338,14 +354,16 @@
{
if (tempFault < DEGLITCH_LIMIT)
{
- log<level::ERR>(fmt::format("TEMPERATURE fault/warning: "
- "STATUS_WORD = {:#06x}, "
- "STATUS_MFR_SPECIFIC = {:#04x}, "
- "STATUS_TEMPERATURE = {:#04x}",
- statusWord, statusMFR,
- statusTemperature)
- .c_str());
-
+ if (statusWord != statusWordOld)
+ {
+ log<level::ERR>(fmt::format("TEMPERATURE fault/warning: "
+ "STATUS_WORD = {:#06x}, "
+ "STATUS_MFR_SPECIFIC = {:#04x}, "
+ "STATUS_TEMPERATURE = {:#04x}",
+ statusWord, statusMFR,
+ statusTemperature)
+ .c_str());
+ }
tempFault++;
}
}
@@ -362,12 +380,14 @@
{
if (pgoodFault < DEGLITCH_LIMIT)
{
- log<level::ERR>(fmt::format("PGOOD fault: "
- "STATUS_WORD = {:#06x}, "
- "STATUS_MFR_SPECIFIC = {:#04x}",
- statusWord, statusMFR)
- .c_str());
-
+ if (statusWord != statusWordOld)
+ {
+ log<level::ERR>(fmt::format("PGOOD fault: "
+ "STATUS_WORD = {:#06x}, "
+ "STATUS_MFR_SPECIFIC = {:#04x}",
+ statusWord, statusMFR)
+ .c_str());
+ }
pgoodFault++;
}
}
@@ -426,11 +446,14 @@
{
if (mfrFault < DEGLITCH_LIMIT)
{
- log<level::ERR>(fmt::format("MFR fault: "
- "STATUS_WORD = {:#06x} "
- "STATUS_MFR_SPECIFIC = {:#04x}",
- statusWord, statusMFR)
- .c_str());
+ if (statusWord != statusWordOld)
+ {
+ log<level::ERR>(fmt::format("MFR fault: "
+ "STATUS_WORD = {:#06x} "
+ "STATUS_MFR_SPECIFIC = {:#04x}",
+ statusWord, statusMFR)
+ .c_str());
+ }
mfrFault++;
}
@@ -448,11 +471,15 @@
{
if (vinUVFault < DEGLITCH_LIMIT)
{
- log<level::ERR>(fmt::format("VIN_UV fault: STATUS_WORD = {:#06x}, "
- "STATUS_MFR_SPECIFIC = {:#04x}, "
- "STATUS_INPUT = {:#04x}",
- statusWord, statusMFR, statusInput)
- .c_str());
+ if (statusWord != statusWordOld)
+ {
+ log<level::ERR>(
+ fmt::format("VIN_UV fault: STATUS_WORD = {:#06x}, "
+ "STATUS_MFR_SPECIFIC = {:#04x}, "
+ "STATUS_INPUT = {:#04x}",
+ statusWord, statusMFR, statusInput)
+ .c_str());
+ }
vinUVFault++;
}
}
@@ -483,6 +510,7 @@
{
try
{
+ statusWordOld = statusWord;
statusWord = pmbusIntf->read(STATUS_WORD, Type::Debug,
(readFail < LOG_LIMIT));
// Read worked, reset the fail count.
@@ -522,6 +550,13 @@
}
else
{
+ if (statusWord != statusWordOld)
+ {
+ log<level::INFO>(fmt::format("STATUS_WORD = {:#06x} {}",
+ statusWord, inventoryPath)
+ .c_str());
+ }
+
// if INPUT/VIN_UV fault was on, it cleared, trace it.
if (inputFault)
{
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index c49039a..7ef32f4 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -431,6 +431,9 @@
/** @brief Will be updated to the latest/lastvalue read from STATUS_WORD.*/
uint64_t statusWord = 0;
+ /** @brief Will be set to the last read value of STATUS_WORD. */
+ uint64_t statusWordOld = 0;
+
/** @brief Will be updated to the latest/lastvalue read from STATUS_INPUT.*/
uint64_t statusInput = 0;