From 58771a22dfcaa1e67bcf4fc0bd2ce0aa28c67e3f Mon Sep 17 00:00:00 2001 From: Cheng C Yang Date: Wed, 23 Jan 2019 17:02:40 +0800 Subject: [PATCH] Fix keep looping issue when entering OS Sometimes when entering OS, OS will keep continuously sending ipmi command "READ EVENT MESSAGE BUFFER" to BMC. This issue is caused by incorrect KCS status. If restart the host immediately while OS is still running, SMS_ATN will be set, after that KCS come into an incorrect status, and then KCS communction between BMC and OS crash. To make KCS go back to correct status and fix the issue, clear SMS_ATN after every time power cycle happen. Unit Test: After entered OS, force reset system, after enter OS again, OS can start normally without keep sending READ EVENT MESSAGE BUFFER command. After power on system, enter EFI SHELL, check IPMI can work correctly through KCS channel. --- host-cmd-manager.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/host-cmd-manager.cpp b/host-cmd-manager.cpp index e52c9bb..b3a5d71 100644 --- a/host-cmd-manager.cpp +++ b/host-cmd-manager.cpp @@ -23,6 +23,8 @@ namespace command constexpr auto HOST_STATE_PATH = "/xyz/openbmc_project/state/host0"; constexpr auto HOST_STATE_INTERFACE = "xyz.openbmc_project.State.Host"; constexpr auto HOST_TRANS_PROP = "RequestedHostTransition"; +constexpr const char* IPMI_PATH = "/xyz/openbmc_project/Ipmi/Channel/ipmi_kcs3"; +constexpr const char* IPMI_INTERFACE = "xyz.openbmc_project.Ipmi.Channel.SMS"; // For throwing exceptions using namespace phosphor::logging; @@ -103,6 +105,20 @@ void Manager::clearQueue() // `false` indicating Failure std::get(command)(ipmiCmdData, false); } + + auto host = ::ipmi::getService(this->bus, IPMI_INTERFACE, IPMI_PATH); + auto method = this->bus.new_method_call(host.c_str(), IPMI_PATH, + IPMI_INTERFACE, "clearAttention"); + + try + { + auto reply = this->bus.call(method); + } + catch (sdbusplus::exception_t&) + { + log("Error in clearing SMS attention"); + elog(); + } } // Called for alerting the host @@ -112,9 +128,7 @@ void Manager::checkQueueAndAlertHost() { log("Asserting SMS Attention"); - std::string HOST_IPMI_SVC("org.openbmc.HostIpmi"); - std::string IPMI_PATH("/org/openbmc/HostIpmi/1"); - std::string IPMI_INTERFACE("org.openbmc.HostIpmi"); + auto host = ::ipmi::getService(this->bus, IPMI_INTERFACE, IPMI_PATH); // Start the timer for this transaction auto time = std::chrono::duration_cast( @@ -127,12 +141,13 @@ void Manager::checkQueueAndAlertHost() return; } - auto method = - this->bus.new_method_call(HOST_IPMI_SVC.c_str(), IPMI_PATH.c_str(), - IPMI_INTERFACE.c_str(), "setAttention"); - auto reply = this->bus.call(method); - - if (reply.is_method_error()) + auto method = this->bus.new_method_call(host.c_str(), IPMI_PATH, + IPMI_INTERFACE, "setAttention"); + try + { + auto reply = this->bus.call(method); + } + catch (const std::exception&) { log("Error in setting SMS attention"); elog(); -- 2.17.1