Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2019 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 16 | #include <peci.h> |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 17 | #include <systemd/sd-journal.h> |
| 18 | |
Jason M. Bills | 08b2c7a | 2020-08-28 15:39:14 -0700 | [diff] [blame] | 19 | #include <boost/asio/io_service.hpp> |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 20 | #include <boost/asio/posix/stream_descriptor.hpp> |
Jason M. Bills | 08b2c7a | 2020-08-28 15:39:14 -0700 | [diff] [blame] | 21 | #include <boost/asio/steady_timer.hpp> |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 22 | #include <gpiod.hpp> |
Jason M. Bills | d711cc8 | 2020-12-04 16:46:39 -0800 | [diff] [blame^] | 23 | #include <host_error_monitor.hpp> |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 24 | #include <sdbusplus/asio/object_server.hpp> |
Jason M. Bills | 48e5dff | 2020-06-10 13:47:47 -0700 | [diff] [blame] | 25 | |
| 26 | #include <bitset> |
| 27 | #include <iostream> |
Jason M. Bills | d1a19f6 | 2019-08-06 11:52:58 -0700 | [diff] [blame] | 28 | #include <variant> |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 29 | |
| 30 | namespace host_error_monitor |
| 31 | { |
| 32 | static boost::asio::io_service io; |
| 33 | static std::shared_ptr<sdbusplus::asio::connection> conn; |
Jason M. Bills | c4b91f2 | 2019-11-26 17:04:50 -0800 | [diff] [blame] | 34 | static std::shared_ptr<sdbusplus::asio::dbus_interface> hostErrorTimeoutIface; |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 35 | |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 36 | using Association = std::tuple<std::string, std::string, std::string>; |
| 37 | static std::shared_ptr<sdbusplus::asio::dbus_interface> associationSSBThermTrip; |
| 38 | static std::shared_ptr<sdbusplus::asio::dbus_interface> associationCATAssert; |
| 39 | |
| 40 | static const constexpr char* rootPath = "/xyz/openbmc_project/CallbackManager"; |
| 41 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 42 | static bool hostOff = true; |
Jason M. Bills | d711cc8 | 2020-12-04 16:46:39 -0800 | [diff] [blame^] | 43 | bool hostIsOff() |
| 44 | { |
| 45 | return hostOff; |
| 46 | } |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 47 | |
Jason M. Bills | c4b91f2 | 2019-11-26 17:04:50 -0800 | [diff] [blame] | 48 | static size_t caterrTimeoutMs = 2000; |
| 49 | const static constexpr size_t caterrTimeoutMsMax = 600000; // 10 minutes maximum |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 50 | const static constexpr size_t errTimeoutMs = 90000; |
Jason M. Bills | 89922f8 | 2019-08-06 11:10:02 -0700 | [diff] [blame] | 51 | const static constexpr size_t smiTimeoutMs = 90000; |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 52 | |
| 53 | // Timers |
| 54 | // Timer for CATERR asserted |
| 55 | static boost::asio::steady_timer caterrAssertTimer(io); |
Jason M. Bills | 8c58439 | 2019-08-19 11:05:51 -0700 | [diff] [blame] | 56 | // Timer for ERR0 asserted |
| 57 | static boost::asio::steady_timer err0AssertTimer(io); |
Jason M. Bills | 75af396 | 2019-08-19 11:07:17 -0700 | [diff] [blame] | 58 | // Timer for ERR1 asserted |
| 59 | static boost::asio::steady_timer err1AssertTimer(io); |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 60 | // Timer for ERR2 asserted |
| 61 | static boost::asio::steady_timer err2AssertTimer(io); |
Jason M. Bills | 89922f8 | 2019-08-06 11:10:02 -0700 | [diff] [blame] | 62 | // Timer for SMI asserted |
| 63 | static boost::asio::steady_timer smiAssertTimer(io); |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 64 | |
| 65 | // GPIO Lines and Event Descriptors |
| 66 | static gpiod::line caterrLine; |
| 67 | static boost::asio::posix::stream_descriptor caterrEvent(io); |
Jason M. Bills | 8c58439 | 2019-08-19 11:05:51 -0700 | [diff] [blame] | 68 | static gpiod::line err0Line; |
| 69 | static boost::asio::posix::stream_descriptor err0Event(io); |
Jason M. Bills | 75af396 | 2019-08-19 11:07:17 -0700 | [diff] [blame] | 70 | static gpiod::line err1Line; |
| 71 | static boost::asio::posix::stream_descriptor err1Event(io); |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 72 | static gpiod::line err2Line; |
| 73 | static boost::asio::posix::stream_descriptor err2Event(io); |
Jason M. Bills | 89922f8 | 2019-08-06 11:10:02 -0700 | [diff] [blame] | 74 | static gpiod::line smiLine; |
| 75 | static boost::asio::posix::stream_descriptor smiEvent(io); |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 76 | static gpiod::line cpu1FIVRFaultLine; |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 77 | static gpiod::line cpu1ThermtripLine; |
| 78 | static boost::asio::posix::stream_descriptor cpu1ThermtripEvent(io); |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 79 | static gpiod::line cpu2FIVRFaultLine; |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 80 | static gpiod::line cpu2ThermtripLine; |
| 81 | static boost::asio::posix::stream_descriptor cpu2ThermtripEvent(io); |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 82 | static gpiod::line cpu1VRHotLine; |
| 83 | static boost::asio::posix::stream_descriptor cpu1VRHotEvent(io); |
| 84 | static gpiod::line cpu2VRHotLine; |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 85 | static boost::asio::posix::stream_descriptor cpu1MemABCDVRHotEvent(io); |
| 86 | static gpiod::line cpu1MemEFGHVRHotLine; |
| 87 | static boost::asio::posix::stream_descriptor cpu1MemEFGHVRHotEvent(io); |
| 88 | static gpiod::line cpu2MemABCDVRHotLine; |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 89 | static boost::asio::posix::stream_descriptor cpu2VRHotEvent(io); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 90 | static gpiod::line cpu1MemABCDVRHotLine; |
| 91 | static boost::asio::posix::stream_descriptor cpu2MemABCDVRHotEvent(io); |
| 92 | static gpiod::line cpu2MemEFGHVRHotLine; |
| 93 | static boost::asio::posix::stream_descriptor cpu2MemEFGHVRHotEvent(io); |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 94 | //---------------------------------- |
| 95 | // PCH_BMC_THERMTRIP function related definition |
| 96 | //---------------------------------- |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 97 | static gpiod::line pchThermtripLine; |
| 98 | static boost::asio::posix::stream_descriptor pchThermtripEvent(io); |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 99 | //---------------------------------- |
| 100 | // CPU_MEM_THERM_EVENT function related definition |
| 101 | //---------------------------------- |
| 102 | static gpiod::line cpu1MemtripLine; |
| 103 | static boost::asio::posix::stream_descriptor cpu1MemtripEvent(io); |
| 104 | static gpiod::line cpu2MemtripLine; |
| 105 | static boost::asio::posix::stream_descriptor cpu2MemtripEvent(io); |
jayaprakash Mutyala | 53099c4 | 2020-03-15 00:16:26 +0000 | [diff] [blame] | 106 | //--------------------------------- |
| 107 | // CPU_MISMATCH function related definition |
| 108 | //--------------------------------- |
| 109 | static gpiod::line cpu1MismatchLine; |
| 110 | static gpiod::line cpu2MismatchLine; |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 111 | |
Yong Li | 061eb03 | 2020-02-26 15:06:18 +0800 | [diff] [blame] | 112 | // beep function for CPU error |
Yong Li | 8c798c7 | 2020-04-22 15:29:07 +0800 | [diff] [blame] | 113 | const static constexpr uint8_t beepCPUIERR = 4; |
Yong Li | 061eb03 | 2020-02-26 15:06:18 +0800 | [diff] [blame] | 114 | const static constexpr uint8_t beepCPUErr2 = 5; |
| 115 | |
| 116 | static void beep(const uint8_t& beepPriority) |
| 117 | { |
| 118 | conn->async_method_call( |
| 119 | [](boost::system::error_code ec) { |
| 120 | if (ec) |
| 121 | { |
| 122 | std::cerr << "beep returned error with " |
| 123 | "async_method_call (ec = " |
| 124 | << ec << ")\n"; |
| 125 | return; |
| 126 | } |
| 127 | }, |
| 128 | "xyz.openbmc_project.BeepCode", "/xyz/openbmc_project/BeepCode", |
| 129 | "xyz.openbmc_project.BeepCode", "Beep", uint8_t(beepPriority)); |
| 130 | } |
| 131 | |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 132 | static void cpuIERRLog() |
| 133 | { |
| 134 | sd_journal_send("MESSAGE=HostError: IERR", "PRIORITY=%i", LOG_INFO, |
| 135 | "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.CPUError", |
| 136 | "REDFISH_MESSAGE_ARGS=%s", "IERR", NULL); |
| 137 | } |
| 138 | |
| 139 | static void cpuIERRLog(const int cpuNum) |
| 140 | { |
| 141 | std::string msg = "IERR on CPU " + std::to_string(cpuNum + 1); |
| 142 | |
| 143 | sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", |
| 144 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.CPUError", |
| 145 | "REDFISH_MESSAGE_ARGS=%s", msg.c_str(), NULL); |
| 146 | } |
| 147 | |
| 148 | static void cpuIERRLog(const int cpuNum, const std::string& type) |
| 149 | { |
| 150 | std::string msg = type + " IERR on CPU " + std::to_string(cpuNum + 1); |
| 151 | |
| 152 | sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", |
| 153 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.CPUError", |
| 154 | "REDFISH_MESSAGE_ARGS=%s", msg.c_str(), NULL); |
| 155 | } |
| 156 | |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 157 | static void cpuERRXLog(const int errPin) |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 158 | { |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 159 | std::string msg = "ERR" + std::to_string(errPin) + " Timeout"; |
| 160 | |
| 161 | sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", |
| 162 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.CPUError", |
| 163 | "REDFISH_MESSAGE_ARGS=%s", msg.c_str(), NULL); |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 164 | } |
| 165 | |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 166 | static void cpuERRXLog(const int errPin, const int cpuNum) |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 167 | { |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 168 | std::string msg = "ERR" + std::to_string(errPin) + " Timeout on CPU " + |
| 169 | std::to_string(cpuNum + 1); |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 170 | |
| 171 | sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", |
| 172 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.CPUError", |
| 173 | "REDFISH_MESSAGE_ARGS=%s", msg.c_str(), NULL); |
| 174 | } |
| 175 | |
Jason M. Bills | 89922f8 | 2019-08-06 11:10:02 -0700 | [diff] [blame] | 176 | static void smiTimeoutLog() |
| 177 | { |
| 178 | sd_journal_send("MESSAGE=HostError: SMI Timeout", "PRIORITY=%i", LOG_INFO, |
| 179 | "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.CPUError", |
| 180 | "REDFISH_MESSAGE_ARGS=%s", "SMI Timeout", NULL); |
| 181 | } |
| 182 | |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 183 | static void cpuBootFIVRFaultLog(const int cpuNum) |
| 184 | { |
| 185 | std::string msg = "Boot FIVR Fault on CPU " + std::to_string(cpuNum); |
| 186 | |
| 187 | sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", |
| 188 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.CPUError", |
| 189 | "REDFISH_MESSAGE_ARGS=%s", msg.c_str(), NULL); |
| 190 | } |
| 191 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 192 | static void cpuThermTripLog(const int cpuNum) |
| 193 | { |
| 194 | std::string msg = "CPU " + std::to_string(cpuNum) + " thermal trip"; |
| 195 | |
| 196 | sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", |
| 197 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", |
| 198 | "OpenBMC.0.1.CPUThermalTrip", "REDFISH_MESSAGE_ARGS=%d", |
| 199 | cpuNum, NULL); |
| 200 | } |
| 201 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 202 | static void memThermTripLog(const int cpuNum) |
| 203 | { |
| 204 | std::string cpuNumber = "CPU " + std::to_string(cpuNum); |
| 205 | std::string msg = cpuNumber + " Memory Thermal trip."; |
| 206 | |
| 207 | sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", |
| 208 | LOG_ERR, "REDFISH_MESSAGE_ID=%s", |
| 209 | "OpenBMC.0.1.MemoryThermTrip", "REDFISH_MESSAGE_ARGS=%s", |
| 210 | cpuNumber.c_str(), NULL); |
| 211 | } |
| 212 | |
jayaprakash Mutyala | 53099c4 | 2020-03-15 00:16:26 +0000 | [diff] [blame] | 213 | static void cpuMismatchLog(const int cpuNum) |
| 214 | { |
| 215 | std::string msg = "CPU " + std::to_string(cpuNum) + " mismatch"; |
| 216 | |
| 217 | sd_journal_send("MESSAGE= %s", msg.c_str(), "PRIORITY=%i", LOG_ERR, |
| 218 | "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.CPUMismatch", |
| 219 | "REDFISH_MESSAGE_ARGS=%d", cpuNum, NULL); |
| 220 | } |
| 221 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 222 | static void cpuVRHotLog(const std::string& vr) |
| 223 | { |
| 224 | std::string msg = vr + " Voltage Regulator Overheated."; |
| 225 | |
| 226 | sd_journal_send("MESSAGE=HostError: %s", msg.c_str(), "PRIORITY=%i", |
| 227 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", |
| 228 | "OpenBMC.0.1.VoltageRegulatorOverheated", |
| 229 | "REDFISH_MESSAGE_ARGS=%s", vr.c_str(), NULL); |
| 230 | } |
| 231 | |
Jason M. Bills | 0886654 | 2019-08-16 12:04:19 -0700 | [diff] [blame] | 232 | static void ssbThermTripLog() |
| 233 | { |
| 234 | sd_journal_send("MESSAGE=HostError: SSB thermal trip", "PRIORITY=%i", |
| 235 | LOG_INFO, "REDFISH_MESSAGE_ID=%s", |
| 236 | "OpenBMC.0.1.SsbThermalTrip", NULL); |
| 237 | } |
| 238 | |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 239 | static inline bool peciError(EPECIStatus peciStatus, uint8_t cc) |
| 240 | { |
| 241 | return ( |
| 242 | peciStatus != PECI_CC_SUCCESS || |
| 243 | (cc != PECI_DEV_CC_SUCCESS && cc != PECI_DEV_CC_FATAL_MCA_DETECTED)); |
| 244 | } |
| 245 | |
| 246 | static void printPECIError(const std::string& reg, const size_t addr, |
| 247 | const EPECIStatus peciStatus, const size_t cc) |
| 248 | { |
| 249 | std::cerr << "Failed to read " << reg << " on CPU address " << addr |
| 250 | << ". Error: " << peciStatus << ": cc: 0x" << std::hex << cc |
| 251 | << "\n"; |
| 252 | } |
| 253 | |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 254 | static void initializeErrorState(); |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 255 | static void initializeHostState() |
| 256 | { |
| 257 | conn->async_method_call( |
| 258 | [](boost::system::error_code ec, |
| 259 | const std::variant<std::string>& property) { |
| 260 | if (ec) |
| 261 | { |
| 262 | return; |
| 263 | } |
| 264 | const std::string* state = std::get_if<std::string>(&property); |
| 265 | if (state == nullptr) |
| 266 | { |
| 267 | std::cerr << "Unable to read host state value\n"; |
| 268 | return; |
| 269 | } |
| 270 | hostOff = *state == "xyz.openbmc_project.State.Host.HostState.Off"; |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 271 | // If the system is on, initialize the error state |
| 272 | if (!hostOff) |
| 273 | { |
| 274 | initializeErrorState(); |
| 275 | } |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 276 | }, |
| 277 | "xyz.openbmc_project.State.Host", "/xyz/openbmc_project/state/host0", |
| 278 | "org.freedesktop.DBus.Properties", "Get", |
| 279 | "xyz.openbmc_project.State.Host", "CurrentHostState"); |
| 280 | } |
| 281 | |
| 282 | static std::shared_ptr<sdbusplus::bus::match::match> startHostStateMonitor() |
| 283 | { |
| 284 | return std::make_shared<sdbusplus::bus::match::match>( |
| 285 | *conn, |
| 286 | "type='signal',interface='org.freedesktop.DBus.Properties'," |
Jason M. Bills | 2fbb9ea | 2020-06-19 14:46:54 -0700 | [diff] [blame] | 287 | "member='PropertiesChanged',arg0='xyz.openbmc_project.State.Host'", |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 288 | [](sdbusplus::message::message& msg) { |
| 289 | std::string interfaceName; |
| 290 | boost::container::flat_map<std::string, std::variant<std::string>> |
| 291 | propertiesChanged; |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 292 | try |
| 293 | { |
| 294 | msg.read(interfaceName, propertiesChanged); |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 295 | } |
| 296 | catch (std::exception& e) |
| 297 | { |
| 298 | std::cerr << "Unable to read host state\n"; |
| 299 | return; |
| 300 | } |
Jason M. Bills | 566ccc4 | 2020-06-18 16:38:26 -0700 | [diff] [blame] | 301 | // We only want to check for CurrentHostState |
| 302 | if (propertiesChanged.begin()->first != "CurrentHostState") |
| 303 | { |
| 304 | return; |
| 305 | } |
| 306 | std::string* state = |
| 307 | std::get_if<std::string>(&(propertiesChanged.begin()->second)); |
| 308 | if (state == nullptr) |
| 309 | { |
| 310 | std::cerr << propertiesChanged.begin()->first |
| 311 | << " property invalid\n"; |
| 312 | return; |
| 313 | } |
| 314 | |
| 315 | hostOff = *state == "xyz.openbmc_project.State.Host.HostState.Off"; |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 316 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 317 | if (hostOff) |
| 318 | { |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 319 | // No host events should fire while off, so cancel any pending |
| 320 | // timers |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 321 | caterrAssertTimer.cancel(); |
Jason M. Bills | 8c58439 | 2019-08-19 11:05:51 -0700 | [diff] [blame] | 322 | err0AssertTimer.cancel(); |
Jason M. Bills | 75af396 | 2019-08-19 11:07:17 -0700 | [diff] [blame] | 323 | err1AssertTimer.cancel(); |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 324 | err2AssertTimer.cancel(); |
Jason M. Bills | 89922f8 | 2019-08-06 11:10:02 -0700 | [diff] [blame] | 325 | smiAssertTimer.cancel(); |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 326 | } |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 327 | else |
| 328 | { |
| 329 | // Handle any initial errors when the host turns on |
| 330 | initializeErrorState(); |
| 331 | } |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 332 | }); |
| 333 | } |
| 334 | |
| 335 | static bool requestGPIOEvents( |
| 336 | const std::string& name, const std::function<void()>& handler, |
| 337 | gpiod::line& gpioLine, |
| 338 | boost::asio::posix::stream_descriptor& gpioEventDescriptor) |
| 339 | { |
| 340 | // Find the GPIO line |
| 341 | gpioLine = gpiod::find_line(name); |
| 342 | if (!gpioLine) |
| 343 | { |
| 344 | std::cerr << "Failed to find the " << name << " line\n"; |
| 345 | return false; |
| 346 | } |
| 347 | |
| 348 | try |
| 349 | { |
| 350 | gpioLine.request( |
| 351 | {"host-error-monitor", gpiod::line_request::EVENT_BOTH_EDGES}); |
| 352 | } |
| 353 | catch (std::exception&) |
| 354 | { |
| 355 | std::cerr << "Failed to request events for " << name << "\n"; |
| 356 | return false; |
| 357 | } |
| 358 | |
| 359 | int gpioLineFd = gpioLine.event_get_fd(); |
| 360 | if (gpioLineFd < 0) |
| 361 | { |
| 362 | std::cerr << "Failed to get " << name << " fd\n"; |
| 363 | return false; |
| 364 | } |
| 365 | |
| 366 | gpioEventDescriptor.assign(gpioLineFd); |
| 367 | |
| 368 | gpioEventDescriptor.async_wait( |
| 369 | boost::asio::posix::stream_descriptor::wait_read, |
| 370 | [&name, handler](const boost::system::error_code ec) { |
| 371 | if (ec) |
| 372 | { |
| 373 | std::cerr << name << " fd handler error: " << ec.message() |
| 374 | << "\n"; |
| 375 | return; |
| 376 | } |
| 377 | handler(); |
| 378 | }); |
| 379 | return true; |
| 380 | } |
| 381 | |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 382 | static bool requestGPIOInput(const std::string& name, gpiod::line& gpioLine) |
| 383 | { |
| 384 | // Find the GPIO line |
| 385 | gpioLine = gpiod::find_line(name); |
| 386 | if (!gpioLine) |
| 387 | { |
| 388 | std::cerr << "Failed to find the " << name << " line.\n"; |
| 389 | return false; |
| 390 | } |
| 391 | |
| 392 | // Request GPIO input |
| 393 | try |
| 394 | { |
| 395 | gpioLine.request({__FUNCTION__, gpiod::line_request::DIRECTION_INPUT}); |
| 396 | } |
| 397 | catch (std::exception&) |
| 398 | { |
| 399 | std::cerr << "Failed to request " << name << " input\n"; |
| 400 | return false; |
| 401 | } |
| 402 | |
| 403 | return true; |
| 404 | } |
| 405 | |
Jason M. Bills | d1a19f6 | 2019-08-06 11:52:58 -0700 | [diff] [blame] | 406 | static void incrementCPUErrorCount(int cpuNum) |
| 407 | { |
| 408 | std::string propertyName = "ErrorCountCPU" + std::to_string(cpuNum + 1); |
| 409 | |
| 410 | // Get the current count |
| 411 | conn->async_method_call( |
| 412 | [propertyName](boost::system::error_code ec, |
| 413 | const std::variant<uint8_t>& property) { |
| 414 | if (ec) |
| 415 | { |
| 416 | std::cerr << "Failed to read " << propertyName << ": " |
| 417 | << ec.message() << "\n"; |
| 418 | return; |
| 419 | } |
| 420 | const uint8_t* errorCountVariant = std::get_if<uint8_t>(&property); |
| 421 | if (errorCountVariant == nullptr) |
| 422 | { |
| 423 | std::cerr << propertyName << " invalid\n"; |
| 424 | return; |
| 425 | } |
| 426 | uint8_t errorCount = *errorCountVariant; |
| 427 | if (errorCount == std::numeric_limits<uint8_t>::max()) |
| 428 | { |
| 429 | std::cerr << "Maximum error count reached\n"; |
| 430 | return; |
| 431 | } |
| 432 | // Increment the count |
| 433 | errorCount++; |
| 434 | conn->async_method_call( |
| 435 | [propertyName](boost::system::error_code ec) { |
| 436 | if (ec) |
| 437 | { |
| 438 | std::cerr << "Failed to set " << propertyName << ": " |
| 439 | << ec.message() << "\n"; |
| 440 | } |
| 441 | }, |
| 442 | "xyz.openbmc_project.Settings", |
| 443 | "/xyz/openbmc_project/control/processor_error_config", |
| 444 | "org.freedesktop.DBus.Properties", "Set", |
| 445 | "xyz.openbmc_project.Control.Processor.ErrConfig", propertyName, |
| 446 | std::variant<uint8_t>{errorCount}); |
| 447 | }, |
| 448 | "xyz.openbmc_project.Settings", |
| 449 | "/xyz/openbmc_project/control/processor_error_config", |
| 450 | "org.freedesktop.DBus.Properties", "Get", |
| 451 | "xyz.openbmc_project.Control.Processor.ErrConfig", propertyName); |
| 452 | } |
| 453 | |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 454 | static bool checkIERRCPUs() |
| 455 | { |
| 456 | bool cpuIERRFound = false; |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 457 | for (size_t cpu = 0, addr = MIN_CLIENT_ADDR; addr <= MAX_CLIENT_ADDR; |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 458 | cpu++, addr++) |
| 459 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 460 | EPECIStatus peciStatus = PECI_CC_SUCCESS; |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 461 | uint8_t cc = 0; |
| 462 | CPUModel model{}; |
| 463 | uint8_t stepping = 0; |
| 464 | if (peci_GetCPUID(addr, &model, &stepping, &cc) != PECI_CC_SUCCESS) |
| 465 | { |
| 466 | std::cerr << "Cannot get CPUID!\n"; |
| 467 | continue; |
| 468 | } |
| 469 | |
| 470 | switch (model) |
| 471 | { |
| 472 | case skx: |
| 473 | { |
| 474 | // First check the MCA_ERR_SRC_LOG to see if this is the CPU |
| 475 | // that caused the IERR |
| 476 | uint32_t mcaErrSrcLog = 0; |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 477 | peciStatus = peci_RdPkgConfig(addr, 0, 5, 4, |
| 478 | (uint8_t*)&mcaErrSrcLog, &cc); |
| 479 | if (peciError(peciStatus, cc)) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 480 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 481 | printPECIError("MCA_ERR_SRC_LOG", addr, peciStatus, cc); |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 482 | continue; |
| 483 | } |
| 484 | // Check MSMI_INTERNAL (20) and IERR_INTERNAL (27) |
| 485 | if ((mcaErrSrcLog & (1 << 20)) || (mcaErrSrcLog & (1 << 27))) |
| 486 | { |
| 487 | // TODO: Light the CPU fault LED? |
| 488 | cpuIERRFound = true; |
Jason M. Bills | d1a19f6 | 2019-08-06 11:52:58 -0700 | [diff] [blame] | 489 | incrementCPUErrorCount(cpu); |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 490 | // Next check if it's a CPU/VR mismatch by reading the |
| 491 | // IA32_MC4_STATUS MSR (0x411) |
| 492 | uint64_t mc4Status = 0; |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 493 | peciStatus = peci_RdIAMSR(addr, 0, 0x411, &mc4Status, &cc); |
| 494 | if (peciError(peciStatus, cc)) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 495 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 496 | printPECIError("IA32_MC4_STATUS", addr, peciStatus, cc); |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 497 | continue; |
| 498 | } |
| 499 | // Check MSEC bits 31:24 for |
| 500 | // MCA_SVID_VCCIN_VR_ICC_MAX_FAILURE (0x40), |
| 501 | // MCA_SVID_VCCIN_VR_VOUT_FAILURE (0x42), or |
| 502 | // MCA_SVID_CPU_VR_CAPABILITY_ERROR (0x43) |
Jason M. Bills | c90570a | 2020-09-22 15:24:58 -0700 | [diff] [blame] | 503 | uint64_t msec = (mc4Status >> 24) & 0xFF; |
| 504 | if (msec == 0x40 || msec == 0x42 || msec == 0x43) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 505 | { |
| 506 | cpuIERRLog(cpu, "CPU/VR Mismatch"); |
| 507 | continue; |
| 508 | } |
| 509 | |
| 510 | // Next check if it's a Core FIVR fault by looking for a |
| 511 | // non-zero value of CORE_FIVR_ERR_LOG (B(1) D30 F2 offset |
| 512 | // 80h) |
| 513 | uint32_t coreFIVRErrLog = 0; |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 514 | peciStatus = peci_RdPCIConfigLocal( |
| 515 | addr, 1, 30, 2, 0x80, sizeof(uint32_t), |
| 516 | (uint8_t*)&coreFIVRErrLog, &cc); |
| 517 | if (peciError(peciStatus, cc)) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 518 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 519 | printPECIError("CORE_FIVR_ERR_LOG", addr, peciStatus, |
| 520 | cc); |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 521 | continue; |
| 522 | } |
| 523 | if (coreFIVRErrLog) |
| 524 | { |
| 525 | cpuIERRLog(cpu, "Core FIVR Fault"); |
| 526 | continue; |
| 527 | } |
| 528 | |
| 529 | // Next check if it's an Uncore FIVR fault by looking for a |
| 530 | // non-zero value of UNCORE_FIVR_ERR_LOG (B(1) D30 F2 offset |
| 531 | // 84h) |
| 532 | uint32_t uncoreFIVRErrLog = 0; |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 533 | peciStatus = peci_RdPCIConfigLocal( |
| 534 | addr, 1, 30, 2, 0x84, sizeof(uint32_t), |
| 535 | (uint8_t*)&uncoreFIVRErrLog, &cc); |
| 536 | if (peciError(peciStatus, cc)) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 537 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 538 | printPECIError("UNCORE_FIVR_ERR_LOG", addr, peciStatus, |
| 539 | cc); |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 540 | continue; |
| 541 | } |
| 542 | if (uncoreFIVRErrLog) |
| 543 | { |
| 544 | cpuIERRLog(cpu, "Uncore FIVR Fault"); |
| 545 | continue; |
| 546 | } |
| 547 | |
| 548 | // Last if CORE_FIVR_ERR_LOG and UNCORE_FIVR_ERR_LOG are |
| 549 | // both zero, but MSEC bits 31:24 have either |
| 550 | // MCA_FIVR_CATAS_OVERVOL_FAULT (0x51) or |
| 551 | // MCA_FIVR_CATAS_OVERCUR_FAULT (0x52), then log it as an |
| 552 | // uncore FIVR fault |
| 553 | if (!coreFIVRErrLog && !uncoreFIVRErrLog && |
Jason M. Bills | c90570a | 2020-09-22 15:24:58 -0700 | [diff] [blame] | 554 | (msec == 0x51 || msec == 0x52)) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 555 | { |
| 556 | cpuIERRLog(cpu, "Uncore FIVR Fault"); |
| 557 | continue; |
| 558 | } |
| 559 | cpuIERRLog(cpu); |
| 560 | } |
| 561 | break; |
| 562 | } |
| 563 | case icx: |
| 564 | { |
| 565 | // First check the MCA_ERR_SRC_LOG to see if this is the CPU |
| 566 | // that caused the IERR |
| 567 | uint32_t mcaErrSrcLog = 0; |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 568 | peciStatus = peci_RdPkgConfig(addr, 0, 5, 4, |
| 569 | (uint8_t*)&mcaErrSrcLog, &cc); |
| 570 | if (peciError(peciStatus, cc)) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 571 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 572 | printPECIError("MCA_ERR_SRC_LOG", addr, peciStatus, cc); |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 573 | continue; |
| 574 | } |
| 575 | // Check MSMI_INTERNAL (20) and IERR_INTERNAL (27) |
| 576 | if ((mcaErrSrcLog & (1 << 20)) || (mcaErrSrcLog & (1 << 27))) |
| 577 | { |
| 578 | // TODO: Light the CPU fault LED? |
| 579 | cpuIERRFound = true; |
Jason M. Bills | d1a19f6 | 2019-08-06 11:52:58 -0700 | [diff] [blame] | 580 | incrementCPUErrorCount(cpu); |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 581 | // Next check if it's a CPU/VR mismatch by reading the |
| 582 | // IA32_MC4_STATUS MSR (0x411) |
| 583 | uint64_t mc4Status = 0; |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 584 | peciStatus = peci_RdIAMSR(addr, 0, 0x411, &mc4Status, &cc); |
| 585 | if (peciError(peciStatus, cc)) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 586 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 587 | printPECIError("IA32_MC4_STATUS", addr, peciStatus, cc); |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 588 | continue; |
| 589 | } |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 590 | // Check MSEC bits 31:24 for |
| 591 | // MCA_SVID_VCCIN_VR_ICC_MAX_FAILURE (0x40), |
| 592 | // MCA_SVID_VCCIN_VR_VOUT_FAILURE (0x42), or |
| 593 | // MCA_SVID_CPU_VR_CAPABILITY_ERROR (0x43) |
Jason M. Bills | c90570a | 2020-09-22 15:24:58 -0700 | [diff] [blame] | 594 | uint64_t msec = (mc4Status >> 24) & 0xFF; |
| 595 | if (msec == 0x40 || msec == 0x42 || msec == 0x43) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 596 | { |
| 597 | cpuIERRLog(cpu, "CPU/VR Mismatch"); |
| 598 | continue; |
| 599 | } |
| 600 | |
| 601 | // Next check if it's a Core FIVR fault by looking for a |
| 602 | // non-zero value of CORE_FIVR_ERR_LOG (B(31) D30 F2 offsets |
| 603 | // C0h and C4h) (Note: Bus 31 is accessed on PECI as bus 14) |
| 604 | uint32_t coreFIVRErrLog0 = 0; |
| 605 | uint32_t coreFIVRErrLog1 = 0; |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 606 | peciStatus = peci_RdEndPointConfigPciLocal( |
| 607 | addr, 0, 14, 30, 2, 0xC0, sizeof(uint32_t), |
| 608 | (uint8_t*)&coreFIVRErrLog0, &cc); |
| 609 | if (peciError(peciStatus, cc)) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 610 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 611 | printPECIError("CORE_FIVR_ERR_LOG_0", addr, peciStatus, |
| 612 | cc); |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 613 | continue; |
| 614 | } |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 615 | peciStatus = peci_RdEndPointConfigPciLocal( |
| 616 | addr, 0, 14, 30, 2, 0xC4, sizeof(uint32_t), |
| 617 | (uint8_t*)&coreFIVRErrLog1, &cc); |
| 618 | if (peciError(peciStatus, cc)) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 619 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 620 | printPECIError("CORE_FIVR_ERR_LOG_1", addr, peciStatus, |
| 621 | cc); |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 622 | continue; |
| 623 | } |
| 624 | if (coreFIVRErrLog0 || coreFIVRErrLog1) |
| 625 | { |
| 626 | cpuIERRLog(cpu, "Core FIVR Fault"); |
| 627 | continue; |
| 628 | } |
| 629 | |
| 630 | // Next check if it's an Uncore FIVR fault by looking for a |
| 631 | // non-zero value of UNCORE_FIVR_ERR_LOG (B(31) D30 F2 |
| 632 | // offset 84h) (Note: Bus 31 is accessed on PECI as bus 14) |
| 633 | uint32_t uncoreFIVRErrLog = 0; |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 634 | peciStatus = peci_RdEndPointConfigPciLocal( |
| 635 | addr, 0, 14, 30, 2, 0x84, sizeof(uint32_t), |
| 636 | (uint8_t*)&uncoreFIVRErrLog, &cc); |
| 637 | if (peciError(peciStatus, cc)) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 638 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 639 | printPECIError("UNCORE_FIVR_ERR_LOG", addr, peciStatus, |
| 640 | cc); |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 641 | continue; |
| 642 | } |
| 643 | if (uncoreFIVRErrLog) |
| 644 | { |
| 645 | cpuIERRLog(cpu, "Uncore FIVR Fault"); |
| 646 | continue; |
| 647 | } |
| 648 | |
| 649 | // TODO: Update MSEC/MSCOD_31_24 check |
| 650 | // Last if CORE_FIVR_ERR_LOG and UNCORE_FIVR_ERR_LOG are |
| 651 | // both zero, but MSEC bits 31:24 have either |
| 652 | // MCA_FIVR_CATAS_OVERVOL_FAULT (0x51) or |
| 653 | // MCA_FIVR_CATAS_OVERCUR_FAULT (0x52), then log it as an |
| 654 | // uncore FIVR fault |
| 655 | if (!coreFIVRErrLog0 && !coreFIVRErrLog1 && |
Jason M. Bills | c90570a | 2020-09-22 15:24:58 -0700 | [diff] [blame] | 656 | !uncoreFIVRErrLog && (msec == 0x51 || msec == 0x52)) |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 657 | { |
| 658 | cpuIERRLog(cpu, "Uncore FIVR Fault"); |
| 659 | continue; |
| 660 | } |
| 661 | cpuIERRLog(cpu); |
| 662 | } |
| 663 | break; |
| 664 | } |
| 665 | } |
| 666 | } |
| 667 | return cpuIERRFound; |
| 668 | } |
| 669 | |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 670 | static void caterrAssertHandler() |
| 671 | { |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 672 | caterrAssertTimer.expires_after(std::chrono::milliseconds(caterrTimeoutMs)); |
| 673 | caterrAssertTimer.async_wait([](const boost::system::error_code ec) { |
| 674 | if (ec) |
| 675 | { |
| 676 | // operation_aborted is expected if timer is canceled |
| 677 | // before completion. |
| 678 | if (ec != boost::asio::error::operation_aborted) |
| 679 | { |
| 680 | std::cerr << "caterr timeout async_wait failed: " |
| 681 | << ec.message() << "\n"; |
| 682 | } |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 683 | return; |
| 684 | } |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 685 | std::cerr << "CATERR asserted for " << std::to_string(caterrTimeoutMs) |
| 686 | << " ms\n"; |
Yong Li | 8c798c7 | 2020-04-22 15:29:07 +0800 | [diff] [blame] | 687 | beep(beepCPUIERR); |
Jason M. Bills | a339793 | 2019-08-06 11:07:21 -0700 | [diff] [blame] | 688 | if (!checkIERRCPUs()) |
| 689 | { |
| 690 | cpuIERRLog(); |
| 691 | } |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 692 | conn->async_method_call( |
| 693 | [](boost::system::error_code ec, |
| 694 | const std::variant<bool>& property) { |
| 695 | if (ec) |
| 696 | { |
| 697 | return; |
| 698 | } |
| 699 | const bool* reset = std::get_if<bool>(&property); |
| 700 | if (reset == nullptr) |
| 701 | { |
| 702 | std::cerr << "Unable to read reset on CATERR value\n"; |
| 703 | return; |
| 704 | } |
Jason M. Bills | d711cc8 | 2020-12-04 16:46:39 -0800 | [diff] [blame^] | 705 | startCrashdumpAndRecovery(conn, *reset, "IERR"); |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 706 | }, |
| 707 | "xyz.openbmc_project.Settings", |
| 708 | "/xyz/openbmc_project/control/processor_error_config", |
| 709 | "org.freedesktop.DBus.Properties", "Get", |
| 710 | "xyz.openbmc_project.Control.Processor.ErrConfig", "ResetOnCATERR"); |
| 711 | }); |
| 712 | } |
| 713 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 714 | static void caterrHandler() |
| 715 | { |
| 716 | if (!hostOff) |
| 717 | { |
| 718 | gpiod::line_event gpioLineEvent = caterrLine.event_read(); |
| 719 | |
| 720 | bool caterr = |
| 721 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 722 | |
| 723 | std::vector<Association> associations; |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 724 | if (caterr) |
| 725 | { |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 726 | caterrAssertHandler(); |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 727 | associations.emplace_back( |
| 728 | "", "critical", |
| 729 | "/xyz/openbmc_project/host_error_monitor/cat_error"); |
| 730 | associations.emplace_back("", "critical", |
| 731 | host_error_monitor::rootPath); |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 732 | } |
| 733 | else |
| 734 | { |
| 735 | caterrAssertTimer.cancel(); |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 736 | associations.emplace_back("", "", ""); |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 737 | } |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 738 | host_error_monitor::associationCATAssert->set_property("Associations", |
| 739 | associations); |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 740 | } |
| 741 | caterrEvent.async_wait(boost::asio::posix::stream_descriptor::wait_read, |
| 742 | [](const boost::system::error_code ec) { |
| 743 | if (ec) |
| 744 | { |
| 745 | std::cerr << "caterr handler error: " |
| 746 | << ec.message() << "\n"; |
| 747 | return; |
| 748 | } |
| 749 | caterrHandler(); |
| 750 | }); |
| 751 | } |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 752 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 753 | static void cpu1ThermtripAssertHandler() |
| 754 | { |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 755 | if (cpu1FIVRFaultLine.get_value() == 0) |
| 756 | { |
| 757 | cpuBootFIVRFaultLog(1); |
| 758 | } |
| 759 | else |
| 760 | { |
| 761 | cpuThermTripLog(1); |
| 762 | } |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 763 | } |
| 764 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 765 | static void cpu1ThermtripHandler() |
| 766 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 767 | gpiod::line_event gpioLineEvent = cpu1ThermtripLine.event_read(); |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 768 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 769 | bool cpu1Thermtrip = |
| 770 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 771 | if (cpu1Thermtrip) |
| 772 | { |
| 773 | cpu1ThermtripAssertHandler(); |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 774 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 775 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 776 | cpu1ThermtripEvent.async_wait( |
| 777 | boost::asio::posix::stream_descriptor::wait_read, |
| 778 | [](const boost::system::error_code ec) { |
| 779 | if (ec) |
| 780 | { |
| 781 | std::cerr << "CPU 1 Thermtrip handler error: " << ec.message() |
| 782 | << "\n"; |
| 783 | return; |
| 784 | } |
| 785 | cpu1ThermtripHandler(); |
| 786 | }); |
| 787 | } |
| 788 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 789 | static void cpu1MemtripHandler() |
| 790 | { |
Jason M. Bills | 5287c02 | 2020-05-19 11:16:09 -0700 | [diff] [blame] | 791 | gpiod::line_event gpioLineEvent = cpu1MemtripLine.event_read(); |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 792 | |
Jason M. Bills | 5287c02 | 2020-05-19 11:16:09 -0700 | [diff] [blame] | 793 | bool cpu1Memtrip = |
| 794 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 795 | if (cpu1Memtrip) |
| 796 | { |
| 797 | memThermTripLog(1); |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 798 | } |
Jason M. Bills | 5287c02 | 2020-05-19 11:16:09 -0700 | [diff] [blame] | 799 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 800 | cpu1MemtripEvent.async_wait( |
| 801 | boost::asio::posix::stream_descriptor::wait_read, |
| 802 | [](const boost::system::error_code ec) { |
| 803 | if (ec) |
| 804 | { |
| 805 | std::cerr << "CPU 1 Memory Thermaltrip handler error: " |
| 806 | << ec.message() << "\n"; |
| 807 | return; |
| 808 | } |
| 809 | cpu1MemtripHandler(); |
| 810 | }); |
| 811 | } |
| 812 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 813 | static void cpu2ThermtripAssertHandler() |
| 814 | { |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 815 | if (cpu2FIVRFaultLine.get_value() == 0) |
| 816 | { |
| 817 | cpuBootFIVRFaultLog(2); |
| 818 | } |
| 819 | else |
| 820 | { |
| 821 | cpuThermTripLog(2); |
| 822 | } |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 823 | } |
| 824 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 825 | static void cpu2ThermtripHandler() |
| 826 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 827 | gpiod::line_event gpioLineEvent = cpu2ThermtripLine.event_read(); |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 828 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 829 | bool cpu2Thermtrip = |
| 830 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 831 | if (cpu2Thermtrip) |
| 832 | { |
| 833 | cpu2ThermtripAssertHandler(); |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 834 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 835 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 836 | cpu2ThermtripEvent.async_wait( |
| 837 | boost::asio::posix::stream_descriptor::wait_read, |
| 838 | [](const boost::system::error_code ec) { |
| 839 | if (ec) |
| 840 | { |
| 841 | std::cerr << "CPU 2 Thermtrip handler error: " << ec.message() |
| 842 | << "\n"; |
| 843 | return; |
| 844 | } |
| 845 | cpu2ThermtripHandler(); |
| 846 | }); |
| 847 | } |
| 848 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 849 | static void cpu2MemtripHandler() |
| 850 | { |
Jason M. Bills | 5287c02 | 2020-05-19 11:16:09 -0700 | [diff] [blame] | 851 | gpiod::line_event gpioLineEvent = cpu2MemtripLine.event_read(); |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 852 | |
Jason M. Bills | 5287c02 | 2020-05-19 11:16:09 -0700 | [diff] [blame] | 853 | bool cpu2Memtrip = |
| 854 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 855 | if (cpu2Memtrip) |
| 856 | { |
| 857 | memThermTripLog(2); |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 858 | } |
Jason M. Bills | 5287c02 | 2020-05-19 11:16:09 -0700 | [diff] [blame] | 859 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 860 | cpu2MemtripEvent.async_wait( |
| 861 | boost::asio::posix::stream_descriptor::wait_read, |
| 862 | [](const boost::system::error_code ec) { |
| 863 | if (ec) |
| 864 | { |
| 865 | std::cerr << "CPU 2 Memory Thermaltrip handler error: " |
| 866 | << ec.message() << "\n"; |
| 867 | return; |
| 868 | } |
| 869 | cpu2MemtripHandler(); |
| 870 | }); |
| 871 | } |
| 872 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 873 | static void cpu1VRHotAssertHandler() |
| 874 | { |
| 875 | cpuVRHotLog("CPU 1"); |
| 876 | } |
| 877 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 878 | static void cpu1VRHotHandler() |
| 879 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 880 | gpiod::line_event gpioLineEvent = cpu1VRHotLine.event_read(); |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 881 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 882 | bool cpu1VRHot = |
| 883 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 884 | if (cpu1VRHot) |
| 885 | { |
| 886 | cpu1VRHotAssertHandler(); |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 887 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 888 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 889 | cpu1VRHotEvent.async_wait(boost::asio::posix::stream_descriptor::wait_read, |
| 890 | [](const boost::system::error_code ec) { |
| 891 | if (ec) |
| 892 | { |
| 893 | std::cerr << "CPU 1 VRHot handler error: " |
| 894 | << ec.message() << "\n"; |
| 895 | return; |
| 896 | } |
| 897 | cpu1VRHotHandler(); |
| 898 | }); |
| 899 | } |
| 900 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 901 | static void cpu1MemABCDVRHotAssertHandler() |
| 902 | { |
| 903 | cpuVRHotLog("CPU 1 Memory ABCD"); |
| 904 | } |
| 905 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 906 | static void cpu1MemABCDVRHotHandler() |
| 907 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 908 | gpiod::line_event gpioLineEvent = cpu1MemABCDVRHotLine.event_read(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 909 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 910 | bool cpu1MemABCDVRHot = |
| 911 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 912 | if (cpu1MemABCDVRHot) |
| 913 | { |
| 914 | cpu1MemABCDVRHotAssertHandler(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 915 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 916 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 917 | cpu1MemABCDVRHotEvent.async_wait( |
| 918 | boost::asio::posix::stream_descriptor::wait_read, |
| 919 | [](const boost::system::error_code ec) { |
| 920 | if (ec) |
| 921 | { |
| 922 | std::cerr << "CPU 1 Memory ABCD VRHot handler error: " |
| 923 | << ec.message() << "\n"; |
| 924 | return; |
| 925 | } |
| 926 | cpu1MemABCDVRHotHandler(); |
| 927 | }); |
| 928 | } |
| 929 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 930 | static void cpu1MemEFGHVRHotAssertHandler() |
| 931 | { |
| 932 | cpuVRHotLog("CPU 1 Memory EFGH"); |
| 933 | } |
| 934 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 935 | static void cpu1MemEFGHVRHotHandler() |
| 936 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 937 | gpiod::line_event gpioLineEvent = cpu1MemEFGHVRHotLine.event_read(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 938 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 939 | bool cpu1MemEFGHVRHot = |
| 940 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 941 | if (cpu1MemEFGHVRHot) |
| 942 | { |
| 943 | cpu1MemEFGHVRHotAssertHandler(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 944 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 945 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 946 | cpu1MemEFGHVRHotEvent.async_wait( |
| 947 | boost::asio::posix::stream_descriptor::wait_read, |
| 948 | [](const boost::system::error_code ec) { |
| 949 | if (ec) |
| 950 | { |
| 951 | std::cerr << "CPU 1 Memory EFGH VRHot handler error: " |
| 952 | << ec.message() << "\n"; |
| 953 | return; |
| 954 | } |
| 955 | cpu1MemEFGHVRHotHandler(); |
| 956 | }); |
| 957 | } |
| 958 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 959 | static void cpu2VRHotAssertHandler() |
| 960 | { |
| 961 | cpuVRHotLog("CPU 2"); |
| 962 | } |
| 963 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 964 | static void cpu2VRHotHandler() |
| 965 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 966 | gpiod::line_event gpioLineEvent = cpu2VRHotLine.event_read(); |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 967 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 968 | bool cpu2VRHot = |
| 969 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 970 | if (cpu2VRHot) |
| 971 | { |
| 972 | cpu2VRHotAssertHandler(); |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 973 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 974 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 975 | cpu2VRHotEvent.async_wait(boost::asio::posix::stream_descriptor::wait_read, |
| 976 | [](const boost::system::error_code ec) { |
| 977 | if (ec) |
| 978 | { |
| 979 | std::cerr << "CPU 2 VRHot handler error: " |
| 980 | << ec.message() << "\n"; |
| 981 | return; |
| 982 | } |
| 983 | cpu2VRHotHandler(); |
| 984 | }); |
| 985 | } |
| 986 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 987 | static void cpu2MemABCDVRHotAssertHandler() |
| 988 | { |
| 989 | cpuVRHotLog("CPU 2 Memory ABCD"); |
| 990 | } |
| 991 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 992 | static void cpu2MemABCDVRHotHandler() |
| 993 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 994 | gpiod::line_event gpioLineEvent = cpu2MemABCDVRHotLine.event_read(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 995 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 996 | bool cpu2MemABCDVRHot = |
| 997 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 998 | if (cpu2MemABCDVRHot) |
| 999 | { |
| 1000 | cpu2MemABCDVRHotAssertHandler(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 1001 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 1002 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 1003 | cpu2MemABCDVRHotEvent.async_wait( |
| 1004 | boost::asio::posix::stream_descriptor::wait_read, |
| 1005 | [](const boost::system::error_code ec) { |
| 1006 | if (ec) |
| 1007 | { |
| 1008 | std::cerr << "CPU 2 Memory ABCD VRHot handler error: " |
| 1009 | << ec.message() << "\n"; |
| 1010 | return; |
| 1011 | } |
| 1012 | cpu2MemABCDVRHotHandler(); |
| 1013 | }); |
| 1014 | } |
| 1015 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 1016 | static void cpu2MemEFGHVRHotAssertHandler() |
| 1017 | { |
| 1018 | cpuVRHotLog("CPU 2 Memory EFGH"); |
| 1019 | } |
| 1020 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 1021 | static void cpu2MemEFGHVRHotHandler() |
| 1022 | { |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 1023 | gpiod::line_event gpioLineEvent = cpu2MemEFGHVRHotLine.event_read(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 1024 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 1025 | bool cpu2MemEFGHVRHot = |
| 1026 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 1027 | if (cpu2MemEFGHVRHot) |
| 1028 | { |
| 1029 | cpu2MemEFGHVRHotAssertHandler(); |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 1030 | } |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 1031 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 1032 | cpu2MemEFGHVRHotEvent.async_wait( |
| 1033 | boost::asio::posix::stream_descriptor::wait_read, |
| 1034 | [](const boost::system::error_code ec) { |
| 1035 | if (ec) |
| 1036 | { |
| 1037 | std::cerr << "CPU 2 Memory EFGH VRHot handler error: " |
| 1038 | << ec.message() << "\n"; |
| 1039 | return; |
| 1040 | } |
| 1041 | cpu2MemEFGHVRHotHandler(); |
| 1042 | }); |
| 1043 | } |
| 1044 | |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 1045 | static void pchThermtripHandler() |
| 1046 | { |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 1047 | std::vector<Association> associations; |
| 1048 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 1049 | gpiod::line_event gpioLineEvent = pchThermtripLine.event_read(); |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 1050 | |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 1051 | bool pchThermtrip = |
| 1052 | gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 1053 | if (pchThermtrip) |
| 1054 | { |
| 1055 | ssbThermTripLog(); |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 1056 | associations.emplace_back( |
| 1057 | "", "critical", |
| 1058 | "/xyz/openbmc_project/host_error_monitor/ssb_thermal_trip"); |
| 1059 | associations.emplace_back("", "critical", host_error_monitor::rootPath); |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 1060 | } |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 1061 | else |
| 1062 | { |
| 1063 | associations.emplace_back("", "", ""); |
| 1064 | } |
| 1065 | host_error_monitor::associationSSBThermTrip->set_property("Associations", |
| 1066 | associations); |
Jason M. Bills | 8495114 | 2020-04-17 15:57:11 -0700 | [diff] [blame] | 1067 | |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 1068 | pchThermtripEvent.async_wait( |
| 1069 | boost::asio::posix::stream_descriptor::wait_read, |
| 1070 | [](const boost::system::error_code ec) { |
| 1071 | if (ec) |
| 1072 | { |
| 1073 | std::cerr << "PCH Thermal trip handler error: " << ec.message() |
| 1074 | << "\n"; |
| 1075 | return; |
| 1076 | } |
| 1077 | pchThermtripHandler(); |
| 1078 | }); |
| 1079 | } |
| 1080 | |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1081 | static std::bitset<MAX_CPUS> checkERRPinCPUs(const int errPin) |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1082 | { |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1083 | int errPinSts = (1 << errPin); |
| 1084 | std::bitset<MAX_CPUS> errPinCPUs = 0; |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 1085 | for (size_t cpu = 0, addr = MIN_CLIENT_ADDR; addr <= MAX_CLIENT_ADDR; |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1086 | cpu++, addr++) |
| 1087 | { |
| 1088 | if (peci_Ping(addr) == PECI_CC_SUCCESS) |
| 1089 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 1090 | EPECIStatus peciStatus = PECI_CC_SUCCESS; |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1091 | uint8_t cc = 0; |
| 1092 | CPUModel model{}; |
| 1093 | uint8_t stepping = 0; |
| 1094 | if (peci_GetCPUID(addr, &model, &stepping, &cc) != PECI_CC_SUCCESS) |
| 1095 | { |
| 1096 | std::cerr << "Cannot get CPUID!\n"; |
| 1097 | continue; |
| 1098 | } |
| 1099 | |
| 1100 | switch (model) |
| 1101 | { |
| 1102 | case skx: |
| 1103 | { |
| 1104 | // Check the ERRPINSTS to see if this is the CPU that caused |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1105 | // the ERRx (B(0) D8 F0 offset 210h) |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1106 | uint32_t errpinsts = 0; |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 1107 | peciStatus = peci_RdPCIConfigLocal( |
| 1108 | addr, 0, 8, 0, 0x210, sizeof(uint32_t), |
| 1109 | (uint8_t*)&errpinsts, &cc); |
| 1110 | if (peciError(peciStatus, cc)) |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1111 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 1112 | printPECIError("ERRPINSTS", addr, peciStatus, cc); |
| 1113 | continue; |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1114 | } |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 1115 | |
| 1116 | errPinCPUs[cpu] = (errpinsts & errPinSts) != 0; |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1117 | break; |
| 1118 | } |
| 1119 | case icx: |
| 1120 | { |
| 1121 | // Check the ERRPINSTS to see if this is the CPU that caused |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1122 | // the ERRx (B(30) D0 F3 offset 274h) (Note: Bus 30 is |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1123 | // accessed on PECI as bus 13) |
| 1124 | uint32_t errpinsts = 0; |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 1125 | peciStatus = peci_RdEndPointConfigPciLocal( |
| 1126 | addr, 0, 13, 0, 3, 0x274, sizeof(uint32_t), |
| 1127 | (uint8_t*)&errpinsts, &cc); |
| 1128 | if (peciError(peciStatus, cc)) |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1129 | { |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 1130 | printPECIError("ERRPINSTS", addr, peciStatus, cc); |
| 1131 | continue; |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1132 | } |
Jason M. Bills | 8064f8b | 2020-09-22 15:09:49 -0700 | [diff] [blame] | 1133 | |
| 1134 | errPinCPUs[cpu] = (errpinsts & errPinSts) != 0; |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1135 | break; |
| 1136 | } |
| 1137 | } |
| 1138 | } |
| 1139 | } |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1140 | return errPinCPUs; |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1141 | } |
| 1142 | |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1143 | static void errXAssertHandler(const int errPin, |
| 1144 | boost::asio::steady_timer& errXAssertTimer) |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1145 | { |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1146 | // ERRx status is not guaranteed through the timeout, so save which |
| 1147 | // CPUs have it asserted |
| 1148 | std::bitset<MAX_CPUS> errPinCPUs = checkERRPinCPUs(errPin); |
| 1149 | errXAssertTimer.expires_after(std::chrono::milliseconds(errTimeoutMs)); |
| 1150 | errXAssertTimer.async_wait([errPin, errPinCPUs]( |
| 1151 | const boost::system::error_code ec) { |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1152 | if (ec) |
| 1153 | { |
| 1154 | // operation_aborted is expected if timer is canceled before |
| 1155 | // completion. |
| 1156 | if (ec != boost::asio::error::operation_aborted) |
| 1157 | { |
| 1158 | std::cerr << "err2 timeout async_wait failed: " << ec.message() |
| 1159 | << "\n"; |
| 1160 | } |
| 1161 | return; |
| 1162 | } |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1163 | std::cerr << "ERR" << std::to_string(errPin) << " asserted for " |
| 1164 | << std::to_string(errTimeoutMs) << " ms\n"; |
| 1165 | if (errPinCPUs.count()) |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1166 | { |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1167 | for (int i = 0; i < errPinCPUs.size(); i++) |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1168 | { |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1169 | if (errPinCPUs[i]) |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1170 | { |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1171 | cpuERRXLog(errPin, i); |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1172 | } |
| 1173 | } |
| 1174 | } |
| 1175 | else |
| 1176 | { |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1177 | cpuERRXLog(errPin); |
| 1178 | } |
| 1179 | }); |
| 1180 | } |
| 1181 | |
Jason M. Bills | 8c58439 | 2019-08-19 11:05:51 -0700 | [diff] [blame] | 1182 | static void err0AssertHandler() |
| 1183 | { |
| 1184 | // Handle the standard ERR0 detection and logging |
| 1185 | const static constexpr int err0 = 0; |
| 1186 | errXAssertHandler(err0, err0AssertTimer); |
| 1187 | } |
| 1188 | |
| 1189 | static void err0Handler() |
| 1190 | { |
| 1191 | if (!hostOff) |
| 1192 | { |
| 1193 | gpiod::line_event gpioLineEvent = err0Line.event_read(); |
| 1194 | |
| 1195 | bool err0 = gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 1196 | if (err0) |
| 1197 | { |
| 1198 | err0AssertHandler(); |
| 1199 | } |
| 1200 | else |
| 1201 | { |
| 1202 | err0AssertTimer.cancel(); |
| 1203 | } |
| 1204 | } |
| 1205 | err0Event.async_wait(boost::asio::posix::stream_descriptor::wait_read, |
| 1206 | [](const boost::system::error_code ec) { |
| 1207 | if (ec) |
| 1208 | { |
| 1209 | std::cerr |
| 1210 | << "err0 handler error: " << ec.message() |
| 1211 | << "\n"; |
| 1212 | return; |
| 1213 | } |
| 1214 | err0Handler(); |
| 1215 | }); |
| 1216 | } |
| 1217 | |
Jason M. Bills | 75af396 | 2019-08-19 11:07:17 -0700 | [diff] [blame] | 1218 | static void err1AssertHandler() |
| 1219 | { |
| 1220 | // Handle the standard ERR1 detection and logging |
| 1221 | const static constexpr int err1 = 1; |
| 1222 | errXAssertHandler(err1, err1AssertTimer); |
| 1223 | } |
| 1224 | |
| 1225 | static void err1Handler() |
| 1226 | { |
| 1227 | if (!hostOff) |
| 1228 | { |
| 1229 | gpiod::line_event gpioLineEvent = err1Line.event_read(); |
| 1230 | |
| 1231 | bool err1 = gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 1232 | if (err1) |
| 1233 | { |
| 1234 | err1AssertHandler(); |
| 1235 | } |
| 1236 | else |
| 1237 | { |
| 1238 | err1AssertTimer.cancel(); |
| 1239 | } |
| 1240 | } |
| 1241 | err1Event.async_wait(boost::asio::posix::stream_descriptor::wait_read, |
| 1242 | [](const boost::system::error_code ec) { |
| 1243 | if (ec) |
| 1244 | { |
| 1245 | std::cerr |
| 1246 | << "err1 handler error: " << ec.message() |
| 1247 | << "\n"; |
| 1248 | return; |
| 1249 | } |
| 1250 | err1Handler(); |
| 1251 | }); |
| 1252 | } |
| 1253 | |
Jason M. Bills | cbf7853 | 2019-08-16 15:32:11 -0700 | [diff] [blame] | 1254 | static void err2AssertHandler() |
| 1255 | { |
| 1256 | // Handle the standard ERR2 detection and logging |
| 1257 | const static constexpr int err2 = 2; |
| 1258 | errXAssertHandler(err2, err2AssertTimer); |
| 1259 | // Also handle reset for ERR2 |
| 1260 | err2AssertTimer.async_wait([](const boost::system::error_code ec) { |
| 1261 | if (ec) |
| 1262 | { |
| 1263 | // operation_aborted is expected if timer is canceled before |
| 1264 | // completion. |
| 1265 | if (ec != boost::asio::error::operation_aborted) |
| 1266 | { |
| 1267 | std::cerr << "err2 timeout async_wait failed: " << ec.message() |
| 1268 | << "\n"; |
| 1269 | } |
| 1270 | return; |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1271 | } |
| 1272 | conn->async_method_call( |
| 1273 | [](boost::system::error_code ec, |
| 1274 | const std::variant<bool>& property) { |
| 1275 | if (ec) |
| 1276 | { |
| 1277 | return; |
| 1278 | } |
| 1279 | const bool* reset = std::get_if<bool>(&property); |
| 1280 | if (reset == nullptr) |
| 1281 | { |
| 1282 | std::cerr << "Unable to read reset on ERR2 value\n"; |
| 1283 | return; |
| 1284 | } |
Jason M. Bills | d711cc8 | 2020-12-04 16:46:39 -0800 | [diff] [blame^] | 1285 | startCrashdumpAndRecovery(conn, *reset, "ERR2 Timeout"); |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1286 | }, |
| 1287 | "xyz.openbmc_project.Settings", |
| 1288 | "/xyz/openbmc_project/control/processor_error_config", |
| 1289 | "org.freedesktop.DBus.Properties", "Get", |
| 1290 | "xyz.openbmc_project.Control.Processor.ErrConfig", "ResetOnERR2"); |
Yong Li | 061eb03 | 2020-02-26 15:06:18 +0800 | [diff] [blame] | 1291 | |
| 1292 | beep(beepCPUErr2); |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1293 | }); |
| 1294 | } |
| 1295 | |
| 1296 | static void err2Handler() |
| 1297 | { |
| 1298 | if (!hostOff) |
| 1299 | { |
| 1300 | gpiod::line_event gpioLineEvent = err2Line.event_read(); |
| 1301 | |
| 1302 | bool err2 = gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 1303 | if (err2) |
| 1304 | { |
| 1305 | err2AssertHandler(); |
| 1306 | } |
| 1307 | else |
| 1308 | { |
| 1309 | err2AssertTimer.cancel(); |
| 1310 | } |
| 1311 | } |
| 1312 | err2Event.async_wait(boost::asio::posix::stream_descriptor::wait_read, |
| 1313 | [](const boost::system::error_code ec) { |
| 1314 | if (ec) |
| 1315 | { |
| 1316 | std::cerr |
| 1317 | << "err2 handler error: " << ec.message() |
| 1318 | << "\n"; |
| 1319 | return; |
| 1320 | } |
| 1321 | err2Handler(); |
| 1322 | }); |
| 1323 | } |
| 1324 | |
Jason M. Bills | 89922f8 | 2019-08-06 11:10:02 -0700 | [diff] [blame] | 1325 | static void smiAssertHandler() |
| 1326 | { |
| 1327 | smiAssertTimer.expires_after(std::chrono::milliseconds(smiTimeoutMs)); |
| 1328 | smiAssertTimer.async_wait([](const boost::system::error_code ec) { |
| 1329 | if (ec) |
| 1330 | { |
| 1331 | // operation_aborted is expected if timer is canceled before |
| 1332 | // completion. |
| 1333 | if (ec != boost::asio::error::operation_aborted) |
| 1334 | { |
| 1335 | std::cerr << "smi timeout async_wait failed: " << ec.message() |
| 1336 | << "\n"; |
| 1337 | } |
| 1338 | return; |
| 1339 | } |
| 1340 | std::cerr << "SMI asserted for " << std::to_string(smiTimeoutMs) |
| 1341 | << " ms\n"; |
| 1342 | smiTimeoutLog(); |
| 1343 | conn->async_method_call( |
| 1344 | [](boost::system::error_code ec, |
| 1345 | const std::variant<bool>& property) { |
| 1346 | if (ec) |
| 1347 | { |
| 1348 | return; |
| 1349 | } |
| 1350 | const bool* reset = std::get_if<bool>(&property); |
| 1351 | if (reset == nullptr) |
| 1352 | { |
| 1353 | std::cerr << "Unable to read reset on SMI value\n"; |
| 1354 | return; |
| 1355 | } |
Jason M. Bills | 9478544 | 2020-01-07 15:22:09 -0800 | [diff] [blame] | 1356 | #ifdef HOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT |
Jason M. Bills | b61766b | 2019-11-26 17:02:44 -0800 | [diff] [blame] | 1357 | startCrashdumpAndRecovery(*reset, "SMI Timeout"); |
Jason M. Bills | 9478544 | 2020-01-07 15:22:09 -0800 | [diff] [blame] | 1358 | #else |
| 1359 | if (*reset) |
| 1360 | { |
Jason M. Bills | d69549b | 2020-08-27 11:42:43 -0700 | [diff] [blame] | 1361 | std::cerr << "Recovering the system\n"; |
Jason M. Bills | d711cc8 | 2020-12-04 16:46:39 -0800 | [diff] [blame^] | 1362 | startWarmReset(conn); |
Jason M. Bills | 9478544 | 2020-01-07 15:22:09 -0800 | [diff] [blame] | 1363 | } |
| 1364 | #endif |
Jason M. Bills | 89922f8 | 2019-08-06 11:10:02 -0700 | [diff] [blame] | 1365 | }, |
| 1366 | "xyz.openbmc_project.Settings", |
| 1367 | "/xyz/openbmc_project/control/bmc_reset_disables", |
| 1368 | "org.freedesktop.DBus.Properties", "Get", |
| 1369 | "xyz.openbmc_project.Control.ResetDisables", "ResetOnSMI"); |
| 1370 | }); |
| 1371 | } |
| 1372 | |
| 1373 | static void smiHandler() |
| 1374 | { |
| 1375 | if (!hostOff) |
| 1376 | { |
| 1377 | gpiod::line_event gpioLineEvent = smiLine.event_read(); |
| 1378 | |
| 1379 | bool smi = gpioLineEvent.event_type == gpiod::line_event::FALLING_EDGE; |
| 1380 | if (smi) |
| 1381 | { |
| 1382 | smiAssertHandler(); |
| 1383 | } |
| 1384 | else |
| 1385 | { |
| 1386 | smiAssertTimer.cancel(); |
| 1387 | } |
| 1388 | } |
| 1389 | smiEvent.async_wait(boost::asio::posix::stream_descriptor::wait_read, |
| 1390 | [](const boost::system::error_code ec) { |
| 1391 | if (ec) |
| 1392 | { |
| 1393 | std::cerr |
| 1394 | << "smi handler error: " << ec.message() |
| 1395 | << "\n"; |
| 1396 | return; |
| 1397 | } |
| 1398 | smiHandler(); |
| 1399 | }); |
| 1400 | } |
| 1401 | |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 1402 | static void initializeErrorState() |
| 1403 | { |
jayaprakash Mutyala | 53099c4 | 2020-03-15 00:16:26 +0000 | [diff] [blame] | 1404 | // Handle CPU1_MISMATCH if it's asserted now |
| 1405 | if (cpu1MismatchLine.get_value() == 1) |
| 1406 | { |
| 1407 | cpuMismatchLog(1); |
| 1408 | } |
| 1409 | |
| 1410 | // Handle CPU2_MISMATCH if it's asserted now |
| 1411 | if (cpu2MismatchLine.get_value() == 1) |
| 1412 | { |
| 1413 | cpuMismatchLog(2); |
| 1414 | } |
| 1415 | |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 1416 | // Handle CPU_CATERR if it's asserted now |
| 1417 | if (caterrLine.get_value() == 0) |
| 1418 | { |
| 1419 | caterrAssertHandler(); |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 1420 | std::vector<Association> associations; |
| 1421 | associations.emplace_back( |
| 1422 | "", "critical", "/xyz/openbmc_project/host_error_monitor/cat_err"); |
| 1423 | associations.emplace_back("", "critical", host_error_monitor::rootPath); |
| 1424 | host_error_monitor::associationCATAssert->set_property("Associations", |
| 1425 | associations); |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 1426 | } |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1427 | |
Jason M. Bills | 8c58439 | 2019-08-19 11:05:51 -0700 | [diff] [blame] | 1428 | // Handle CPU_ERR0 if it's asserted now |
| 1429 | if (err0Line.get_value() == 0) |
| 1430 | { |
| 1431 | err0AssertHandler(); |
| 1432 | } |
| 1433 | |
Jason M. Bills | 75af396 | 2019-08-19 11:07:17 -0700 | [diff] [blame] | 1434 | // Handle CPU_ERR1 if it's asserted now |
| 1435 | if (err1Line.get_value() == 0) |
| 1436 | { |
| 1437 | err1AssertHandler(); |
| 1438 | } |
| 1439 | |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1440 | // Handle CPU_ERR2 if it's asserted now |
| 1441 | if (err2Line.get_value() == 0) |
| 1442 | { |
| 1443 | err2AssertHandler(); |
| 1444 | } |
Jason M. Bills | 89922f8 | 2019-08-06 11:10:02 -0700 | [diff] [blame] | 1445 | |
| 1446 | // Handle SMI if it's asserted now |
| 1447 | if (smiLine.get_value() == 0) |
| 1448 | { |
| 1449 | smiAssertHandler(); |
| 1450 | } |
Jason M. Bills | 0886654 | 2019-08-16 12:04:19 -0700 | [diff] [blame] | 1451 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 1452 | // Handle CPU1_THERMTRIP if it's asserted now |
| 1453 | if (cpu1ThermtripLine.get_value() == 0) |
| 1454 | { |
| 1455 | cpu1ThermtripAssertHandler(); |
| 1456 | } |
| 1457 | |
| 1458 | // Handle CPU2_THERMTRIP if it's asserted now |
| 1459 | if (cpu2ThermtripLine.get_value() == 0) |
| 1460 | { |
| 1461 | cpu2ThermtripAssertHandler(); |
| 1462 | } |
| 1463 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 1464 | // Handle CPU1_MEM_THERM_EVENT (CPU1 DIMM Thermal trip) if it's asserted now |
| 1465 | if (cpu1MemtripLine.get_value() == 0) |
| 1466 | { |
| 1467 | memThermTripLog(1); |
| 1468 | } |
| 1469 | |
| 1470 | // Handle CPU2_MEM_THERM_EVENT (CPU2 DIMM Thermal trip) if it's asserted now |
| 1471 | if (cpu2MemtripLine.get_value() == 0) |
| 1472 | { |
| 1473 | memThermTripLog(2); |
| 1474 | } |
| 1475 | |
Jason M. Bills | e94f5e1 | 2019-09-13 11:11:34 -0700 | [diff] [blame] | 1476 | // Handle CPU1_VRHOT if it's asserted now |
| 1477 | if (cpu1VRHotLine.get_value() == 0) |
| 1478 | { |
| 1479 | cpu1VRHotAssertHandler(); |
| 1480 | } |
| 1481 | |
| 1482 | // Handle CPU1_MEM_ABCD_VRHOT if it's asserted now |
| 1483 | if (cpu1MemABCDVRHotLine.get_value() == 0) |
| 1484 | { |
| 1485 | cpu1MemABCDVRHotAssertHandler(); |
| 1486 | } |
| 1487 | |
| 1488 | // Handle CPU1_MEM_EFGH_VRHOT if it's asserted now |
| 1489 | if (cpu1MemEFGHVRHotLine.get_value() == 0) |
| 1490 | { |
| 1491 | cpu1MemEFGHVRHotAssertHandler(); |
| 1492 | } |
| 1493 | |
| 1494 | // Handle CPU2_VRHOT if it's asserted now |
| 1495 | if (cpu2VRHotLine.get_value() == 0) |
| 1496 | { |
| 1497 | cpu2VRHotAssertHandler(); |
| 1498 | } |
| 1499 | |
| 1500 | // Handle CPU2_MEM_ABCD_VRHOT if it's asserted now |
| 1501 | if (cpu2MemABCDVRHotLine.get_value() == 0) |
| 1502 | { |
| 1503 | cpu2MemABCDVRHotAssertHandler(); |
| 1504 | } |
| 1505 | |
| 1506 | // Handle CPU2_MEM_EFGH_VRHOT if it's asserted now |
| 1507 | if (cpu2MemEFGHVRHotLine.get_value() == 0) |
| 1508 | { |
| 1509 | cpu2MemEFGHVRHotAssertHandler(); |
| 1510 | } |
| 1511 | |
Jason M. Bills | 0886654 | 2019-08-16 12:04:19 -0700 | [diff] [blame] | 1512 | // Handle PCH_BMC_THERMTRIP if it's asserted now |
| 1513 | if (pchThermtripLine.get_value() == 0) |
| 1514 | { |
| 1515 | ssbThermTripLog(); |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 1516 | std::vector<Association> associations; |
| 1517 | associations.emplace_back( |
| 1518 | "", "critical", |
| 1519 | "/xyz/openbmc_project/host_error_monitor/ssb_thermal_trip"); |
| 1520 | associations.emplace_back("", "critical", host_error_monitor::rootPath); |
| 1521 | host_error_monitor::associationSSBThermTrip->set_property( |
| 1522 | "Associations", associations); |
Jason M. Bills | 0886654 | 2019-08-16 12:04:19 -0700 | [diff] [blame] | 1523 | } |
Jason M. Bills | a15c252 | 2019-08-16 10:01:44 -0700 | [diff] [blame] | 1524 | } |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 1525 | } // namespace host_error_monitor |
| 1526 | |
| 1527 | int main(int argc, char* argv[]) |
| 1528 | { |
| 1529 | // setup connection to dbus |
| 1530 | host_error_monitor::conn = |
| 1531 | std::make_shared<sdbusplus::asio::connection>(host_error_monitor::io); |
| 1532 | |
Jason M. Bills | c4b91f2 | 2019-11-26 17:04:50 -0800 | [diff] [blame] | 1533 | // Host Error Monitor Service |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 1534 | host_error_monitor::conn->request_name( |
| 1535 | "xyz.openbmc_project.HostErrorMonitor"); |
| 1536 | sdbusplus::asio::object_server server = |
| 1537 | sdbusplus::asio::object_server(host_error_monitor::conn); |
| 1538 | |
Yong Li | 1429ca8 | 2020-04-27 16:49:45 +0800 | [diff] [blame] | 1539 | // Associations interface for led status |
| 1540 | std::vector<host_error_monitor::Association> associations; |
| 1541 | associations.emplace_back("", "", ""); |
| 1542 | host_error_monitor::associationSSBThermTrip = server.add_interface( |
| 1543 | "/xyz/openbmc_project/host_error_monitor/ssb_thermal_trip", |
| 1544 | "xyz.openbmc_project.Association.Definitions"); |
| 1545 | host_error_monitor::associationSSBThermTrip->register_property( |
| 1546 | "Associations", associations); |
| 1547 | host_error_monitor::associationSSBThermTrip->initialize(); |
| 1548 | |
| 1549 | host_error_monitor::associationCATAssert = server.add_interface( |
| 1550 | "/xyz/openbmc_project/host_error_monitor/cat_assert", |
| 1551 | "xyz.openbmc_project.Association.Definitions"); |
| 1552 | host_error_monitor::associationCATAssert->register_property("Associations", |
| 1553 | associations); |
| 1554 | host_error_monitor::associationCATAssert->initialize(); |
| 1555 | |
Jason M. Bills | c4b91f2 | 2019-11-26 17:04:50 -0800 | [diff] [blame] | 1556 | // Restart Cause Interface |
| 1557 | host_error_monitor::hostErrorTimeoutIface = |
| 1558 | server.add_interface("/xyz/openbmc_project/host_error_monitor", |
| 1559 | "xyz.openbmc_project.HostErrorMonitor.Timeout"); |
| 1560 | |
| 1561 | host_error_monitor::hostErrorTimeoutIface->register_property( |
| 1562 | "IERRTimeoutMs", host_error_monitor::caterrTimeoutMs, |
| 1563 | [](const std::size_t& requested, std::size_t& resp) { |
| 1564 | if (requested > host_error_monitor::caterrTimeoutMsMax) |
| 1565 | { |
| 1566 | std::cerr << "IERRTimeoutMs update to " << requested |
| 1567 | << "ms rejected. Cannot be greater than " |
| 1568 | << host_error_monitor::caterrTimeoutMsMax << "ms.\n"; |
| 1569 | return 0; |
| 1570 | } |
| 1571 | std::cerr << "IERRTimeoutMs updated to " << requested << "ms\n"; |
| 1572 | host_error_monitor::caterrTimeoutMs = requested; |
| 1573 | resp = requested; |
| 1574 | return 1; |
| 1575 | }, |
| 1576 | [](std::size_t& resp) { return host_error_monitor::caterrTimeoutMs; }); |
| 1577 | host_error_monitor::hostErrorTimeoutIface->initialize(); |
| 1578 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 1579 | // Start tracking host state |
| 1580 | std::shared_ptr<sdbusplus::bus::match::match> hostStateMonitor = |
| 1581 | host_error_monitor::startHostStateMonitor(); |
| 1582 | |
jayaprakash Mutyala | 53099c4 | 2020-03-15 00:16:26 +0000 | [diff] [blame] | 1583 | // Request CPU1_MISMATCH GPIO events |
| 1584 | if (!host_error_monitor::requestGPIOInput( |
| 1585 | "CPU1_MISMATCH", host_error_monitor::cpu1MismatchLine)) |
| 1586 | { |
| 1587 | return -1; |
| 1588 | } |
| 1589 | |
| 1590 | // Request CPU2_MISMATCH GPIO events |
| 1591 | if (!host_error_monitor::requestGPIOInput( |
| 1592 | "CPU2_MISMATCH", host_error_monitor::cpu2MismatchLine)) |
| 1593 | { |
| 1594 | return -1; |
| 1595 | } |
| 1596 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 1597 | // Initialize the host state |
| 1598 | host_error_monitor::initializeHostState(); |
| 1599 | |
| 1600 | // Request CPU_CATERR GPIO events |
| 1601 | if (!host_error_monitor::requestGPIOEvents( |
| 1602 | "CPU_CATERR", host_error_monitor::caterrHandler, |
| 1603 | host_error_monitor::caterrLine, host_error_monitor::caterrEvent)) |
| 1604 | { |
| 1605 | return -1; |
| 1606 | } |
| 1607 | |
Jason M. Bills | 8c58439 | 2019-08-19 11:05:51 -0700 | [diff] [blame] | 1608 | // Request CPU_ERR0 GPIO events |
| 1609 | if (!host_error_monitor::requestGPIOEvents( |
| 1610 | "CPU_ERR0", host_error_monitor::err0Handler, |
| 1611 | host_error_monitor::err0Line, host_error_monitor::err0Event)) |
| 1612 | { |
| 1613 | return -1; |
| 1614 | } |
| 1615 | |
Jason M. Bills | 75af396 | 2019-08-19 11:07:17 -0700 | [diff] [blame] | 1616 | // Request CPU_ERR1 GPIO events |
| 1617 | if (!host_error_monitor::requestGPIOEvents( |
| 1618 | "CPU_ERR1", host_error_monitor::err1Handler, |
| 1619 | host_error_monitor::err1Line, host_error_monitor::err1Event)) |
| 1620 | { |
| 1621 | return -1; |
| 1622 | } |
| 1623 | |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 1624 | // Request CPU_ERR2 GPIO events |
| 1625 | if (!host_error_monitor::requestGPIOEvents( |
| 1626 | "CPU_ERR2", host_error_monitor::err2Handler, |
| 1627 | host_error_monitor::err2Line, host_error_monitor::err2Event)) |
| 1628 | { |
| 1629 | return -1; |
| 1630 | } |
| 1631 | |
Jason M. Bills | 89922f8 | 2019-08-06 11:10:02 -0700 | [diff] [blame] | 1632 | // Request SMI GPIO events |
| 1633 | if (!host_error_monitor::requestGPIOEvents( |
| 1634 | "SMI", host_error_monitor::smiHandler, host_error_monitor::smiLine, |
| 1635 | host_error_monitor::smiEvent)) |
| 1636 | { |
| 1637 | return -1; |
| 1638 | } |
| 1639 | |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 1640 | // Request CPU1_FIVR_FAULT GPIO input |
| 1641 | if (!host_error_monitor::requestGPIOInput( |
| 1642 | "CPU1_FIVR_FAULT", host_error_monitor::cpu1FIVRFaultLine)) |
| 1643 | { |
| 1644 | return -1; |
| 1645 | } |
| 1646 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 1647 | // Request CPU1_THERMTRIP GPIO events |
| 1648 | if (!host_error_monitor::requestGPIOEvents( |
| 1649 | "CPU1_THERMTRIP", host_error_monitor::cpu1ThermtripHandler, |
| 1650 | host_error_monitor::cpu1ThermtripLine, |
| 1651 | host_error_monitor::cpu1ThermtripEvent)) |
| 1652 | { |
| 1653 | return -1; |
| 1654 | } |
| 1655 | |
Jason M. Bills | 45e87e0 | 2019-09-09 14:45:38 -0700 | [diff] [blame] | 1656 | // Request CPU2_FIVR_FAULT GPIO input |
| 1657 | if (!host_error_monitor::requestGPIOInput( |
| 1658 | "CPU2_FIVR_FAULT", host_error_monitor::cpu2FIVRFaultLine)) |
| 1659 | { |
| 1660 | return -1; |
| 1661 | } |
| 1662 | |
Jason M. Bills | 78c5eed | 2019-08-28 14:00:40 -0700 | [diff] [blame] | 1663 | // Request CPU2_THERMTRIP GPIO events |
| 1664 | if (!host_error_monitor::requestGPIOEvents( |
| 1665 | "CPU2_THERMTRIP", host_error_monitor::cpu2ThermtripHandler, |
| 1666 | host_error_monitor::cpu2ThermtripLine, |
| 1667 | host_error_monitor::cpu2ThermtripEvent)) |
| 1668 | { |
| 1669 | return -1; |
| 1670 | } |
| 1671 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 1672 | // Request CPU1_VRHOT GPIO events |
| 1673 | if (!host_error_monitor::requestGPIOEvents( |
| 1674 | "CPU1_VRHOT", host_error_monitor::cpu1VRHotHandler, |
| 1675 | host_error_monitor::cpu1VRHotLine, |
| 1676 | host_error_monitor::cpu1VRHotEvent)) |
| 1677 | { |
| 1678 | return -1; |
| 1679 | } |
| 1680 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 1681 | // Request CPU1_MEM_ABCD_VRHOT GPIO events |
| 1682 | if (!host_error_monitor::requestGPIOEvents( |
| 1683 | "CPU1_MEM_ABCD_VRHOT", host_error_monitor::cpu1MemABCDVRHotHandler, |
| 1684 | host_error_monitor::cpu1MemABCDVRHotLine, |
| 1685 | host_error_monitor::cpu1MemABCDVRHotEvent)) |
| 1686 | { |
| 1687 | return -1; |
| 1688 | } |
| 1689 | |
| 1690 | // Request CPU1_MEM_EFGH_VRHOT GPIO events |
| 1691 | if (!host_error_monitor::requestGPIOEvents( |
| 1692 | "CPU1_MEM_EFGH_VRHOT", host_error_monitor::cpu1MemEFGHVRHotHandler, |
| 1693 | host_error_monitor::cpu1MemEFGHVRHotLine, |
| 1694 | host_error_monitor::cpu1MemEFGHVRHotEvent)) |
| 1695 | { |
| 1696 | return -1; |
| 1697 | } |
| 1698 | |
Jason M. Bills | 250fa63 | 2019-08-28 15:58:25 -0700 | [diff] [blame] | 1699 | // Request CPU2_VRHOT GPIO events |
| 1700 | if (!host_error_monitor::requestGPIOEvents( |
| 1701 | "CPU2_VRHOT", host_error_monitor::cpu2VRHotHandler, |
| 1702 | host_error_monitor::cpu2VRHotLine, |
| 1703 | host_error_monitor::cpu2VRHotEvent)) |
| 1704 | { |
| 1705 | return -1; |
| 1706 | } |
| 1707 | |
Jason M. Bills | 9647ba7 | 2019-08-29 14:19:19 -0700 | [diff] [blame] | 1708 | // Request CPU2_MEM_ABCD_VRHOT GPIO events |
| 1709 | if (!host_error_monitor::requestGPIOEvents( |
| 1710 | "CPU2_MEM_ABCD_VRHOT", host_error_monitor::cpu2MemABCDVRHotHandler, |
| 1711 | host_error_monitor::cpu2MemABCDVRHotLine, |
| 1712 | host_error_monitor::cpu2MemABCDVRHotEvent)) |
| 1713 | { |
| 1714 | return -1; |
| 1715 | } |
| 1716 | |
| 1717 | // Request CPU2_MEM_EFGH_VRHOT GPIO events |
| 1718 | if (!host_error_monitor::requestGPIOEvents( |
| 1719 | "CPU2_MEM_EFGH_VRHOT", host_error_monitor::cpu2MemEFGHVRHotHandler, |
| 1720 | host_error_monitor::cpu2MemEFGHVRHotLine, |
| 1721 | host_error_monitor::cpu2MemEFGHVRHotEvent)) |
| 1722 | { |
| 1723 | return -1; |
| 1724 | } |
| 1725 | |
Chen Yugang | e6c0f1c | 2019-08-02 20:36:42 +0800 | [diff] [blame] | 1726 | // Request PCH_BMC_THERMTRIP GPIO events |
| 1727 | if (!host_error_monitor::requestGPIOEvents( |
| 1728 | "PCH_BMC_THERMTRIP", host_error_monitor::pchThermtripHandler, |
| 1729 | host_error_monitor::pchThermtripLine, |
| 1730 | host_error_monitor::pchThermtripEvent)) |
| 1731 | { |
| 1732 | return -1; |
| 1733 | } |
| 1734 | |
jayaprakash Mutyala | 009adbc | 2019-12-24 22:08:07 +0000 | [diff] [blame] | 1735 | // Request CPU1_MEM_THERM_EVENT GPIO events |
| 1736 | if (!host_error_monitor::requestGPIOEvents( |
| 1737 | "CPU1_MEM_THERM_EVENT", host_error_monitor::cpu1MemtripHandler, |
| 1738 | host_error_monitor::cpu1MemtripLine, |
| 1739 | host_error_monitor::cpu1MemtripEvent)) |
| 1740 | { |
| 1741 | return -1; |
| 1742 | } |
| 1743 | |
| 1744 | // Request CPU2_MEM_THERM_EVENT GPIO events |
| 1745 | if (!host_error_monitor::requestGPIOEvents( |
| 1746 | "CPU2_MEM_THERM_EVENT", host_error_monitor::cpu2MemtripHandler, |
| 1747 | host_error_monitor::cpu2MemtripLine, |
| 1748 | host_error_monitor::cpu2MemtripEvent)) |
| 1749 | { |
| 1750 | return -1; |
| 1751 | } |
| 1752 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 1753 | host_error_monitor::io.run(); |
| 1754 | |
| 1755 | return 0; |
| 1756 | } |