summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason M. Bills <jason.m.bills@linux.intel.com>2019-08-29 00:00:40 +0300
committerJason M. Bills <jason.m.bills@linux.intel.com>2019-09-06 03:12:31 +0300
commitd468f6945552d31484a8b62c3a06b07bd8af2ee5 (patch)
treede844f8dff59b9a67e7597d9129fdc08867cbaf1
parent7046c58ecbbaf0e2f466cafbb9fb91dfe7b6a29d (diff)
downloadprovingground-d468f6945552d31484a8b62c3a06b07bd8af2ee5.tar.xz
Add CPU Thermtrip monitoring and logging
This adds a monitor for the CPU Thermtrip signals. Tested: Heated each CPU with a heat gun until the system shut down and verfied that the CPU Thermal Trip event was logged. Change-Id: I6a13c22f1cce917130c2716934b474ea8f5e51f8 Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
-rw-r--r--host_error_monitor/src/host_error_monitor.cpp86
1 files changed, 85 insertions, 1 deletions
diff --git a/host_error_monitor/src/host_error_monitor.cpp b/host_error_monitor/src/host_error_monitor.cpp
index 7522e9b..7ec0a37 100644
--- a/host_error_monitor/src/host_error_monitor.cpp
+++ b/host_error_monitor/src/host_error_monitor.cpp
@@ -59,10 +59,13 @@ static gpiod::line err2Line;
static boost::asio::posix::stream_descriptor err2Event(io);
static gpiod::line smiLine;
static boost::asio::posix::stream_descriptor smiEvent(io);
+static gpiod::line cpu1ThermtripLine;
+static boost::asio::posix::stream_descriptor cpu1ThermtripEvent(io);
+static gpiod::line cpu2ThermtripLine;
+static boost::asio::posix::stream_descriptor cpu2ThermtripEvent(io);
//----------------------------------
// PCH_BMC_THERMTRIP function related definition
//----------------------------------
-// GPIO Lines and Event Descriptors
static gpiod::line pchThermtripLine;
static boost::asio::posix::stream_descriptor pchThermtripEvent(io);
@@ -117,6 +120,16 @@ static void smiTimeoutLog()
"REDFISH_MESSAGE_ARGS=%s", "SMI Timeout", NULL);
}
+static void cpuThermTripLog(const int cpuNum)
+{
+ std::string msg = "CPU " + std::to_string(cpuNum) + " thermal trip";
+
+ sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i",
+ LOG_INFO, "REDFISH_MESSAGE_ID=%s",
+ "OpenBMC.0.1.CPUThermalTrip", "REDFISH_MESSAGE_ARGS=%d",
+ cpuNum, NULL);
+}
+
static void ssbThermTripLog()
{
sd_journal_send("MESSAGE=HostError: SSB thermal trip", "PRIORITY=%i",
@@ -650,6 +663,59 @@ static void caterrHandler()
caterrHandler();
});
}
+
+static void cpu1ThermtripHandler()
+{
+ if (!hostOff)
+ {
+ gpiod::line_event gpioLineEvent = cpu1ThermtripLine.event_read();
+
+ bool cpu1Thermtrip =
+ gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE;
+ if (cpu1Thermtrip)
+ {
+ cpuThermTripLog(1);
+ }
+ }
+ cpu1ThermtripEvent.async_wait(
+ boost::asio::posix::stream_descriptor::wait_read,
+ [](const boost::system::error_code ec) {
+ if (ec)
+ {
+ std::cerr << "CPU 1 Thermtrip handler error: " << ec.message()
+ << "\n";
+ return;
+ }
+ cpu1ThermtripHandler();
+ });
+}
+
+static void cpu2ThermtripHandler()
+{
+ if (!hostOff)
+ {
+ gpiod::line_event gpioLineEvent = cpu2ThermtripLine.event_read();
+
+ bool cpu2Thermtrip =
+ gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE;
+ if (cpu2Thermtrip)
+ {
+ cpuThermTripLog(2);
+ }
+ }
+ cpu2ThermtripEvent.async_wait(
+ boost::asio::posix::stream_descriptor::wait_read,
+ [](const boost::system::error_code ec) {
+ if (ec)
+ {
+ std::cerr << "CPU 2 Thermtrip handler error: " << ec.message()
+ << "\n";
+ return;
+ }
+ cpu2ThermtripHandler();
+ });
+}
+
static void pchThermtripHandler()
{
if (!hostOff)
@@ -1097,6 +1163,24 @@ int main(int argc, char* argv[])
return -1;
}
+ // Request CPU1_THERMTRIP GPIO events
+ if (!host_error_monitor::requestGPIOEvents(
+ "CPU1_THERMTRIP", host_error_monitor::cpu1ThermtripHandler,
+ host_error_monitor::cpu1ThermtripLine,
+ host_error_monitor::cpu1ThermtripEvent))
+ {
+ return -1;
+ }
+
+ // Request CPU2_THERMTRIP GPIO events
+ if (!host_error_monitor::requestGPIOEvents(
+ "CPU2_THERMTRIP", host_error_monitor::cpu2ThermtripHandler,
+ host_error_monitor::cpu2ThermtripLine,
+ host_error_monitor::cpu2ThermtripEvent))
+ {
+ return -1;
+ }
+
// Request PCH_BMC_THERMTRIP GPIO events
if (!host_error_monitor::requestGPIOEvents(
"PCH_BMC_THERMTRIP", host_error_monitor::pchThermtripHandler,