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