summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0053-Fix-keep-looping-issue-when-entering-OS.patch
blob: 0d86a42230263aeb7b1d94877839a27c42bc2eaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
From 58771a22dfcaa1e67bcf4fc0bd2ce0aa28c67e3f Mon Sep 17 00:00:00 2001
From: Cheng C Yang <cheng.c.yang@linux.intel.com>
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<CallBack>(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<level::ERR>("Error in clearing SMS attention");
+        elog<InternalFailure>();
+    }
 }
 
 // Called for alerting the host
@@ -112,9 +128,7 @@ void Manager::checkQueueAndAlertHost()
     {
         log<level::DEBUG>("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<std::chrono::microseconds>(
@@ -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<level::ERR>("Error in setting SMS attention");
             elog<InternalFailure>();
-- 
2.17.1