-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NMI (soft reset) control code enablement
Changes here include: 1) A service that triggers Open BMC App (openpower-proc-nmi) 2) An application that waits for a dbus event (NMI) to occur 3) A reset logic that triggers a NMI/softreset dbus service which will invoke pdbg call to trigger stop followed by sreset on all threads 4) Necessary Makefile.am changes Tested: Verified following 1) openpower-proc-nmi app is automatically started once host is started 2) After killing the app made sure app is restarted successfully 3) Verified NMI is detected on the Host side and crash dump being collected in /var/crash/ and taking a watchdog triggered reboot 4) System coming back to original state once all #3 is completed 5) Powered off the system (obmcutil poweroff) service disabled and enabled after host is powered on Signed-off-by: Lakshminarayana R. Kammath <[email protected]> Change-Id: I16f3bb2a2ed0c0ffcea2a720a2ae39a2b303ef9e
- Loading branch information
Showing
8 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
AM_DEFAULT_SOURCE_EXT = .cpp | ||
|
||
systemdsystemunit_DATA = \ | ||
[email protected] | ||
[email protected] \ | ||
xyz.openbmc_project.Control.Host.NMI.service \ | ||
nmi.service | ||
|
||
bin_PROGRAMS = \ | ||
openpower-proc-control | ||
openpower-proc-control \ | ||
openpower-proc-nmi | ||
|
||
openpower_proc_control_SOURCES = \ | ||
proc_control.cpp \ | ||
|
@@ -15,6 +18,10 @@ openpower_proc_control_SOURCES = \ | |
openpower_procedures.cpp \ | ||
ext_interface.cpp | ||
|
||
openpower_proc_nmi_SOURCES = \ | ||
nmi_main.cpp \ | ||
nmi_interface.cpp | ||
|
||
CLEANFILES = openpower_procedures.cpp | ||
|
||
openpower_proc_control_LDFLAGS = $(PHOSPHOR_LOGGING_LIBS) \ | ||
|
@@ -28,6 +35,14 @@ openpower_proc_control_CXXFLAGS = $(PHOSPHOR_LOGGING_CFLAGS) \ | |
$(OPENPOWER_DBUS_INTERFACES_CFLAGS) \ | ||
$(SDBUSPLUS_CFLAGS) | ||
|
||
openpower_proc_nmi_LDFLAGS = $(PHOSPHOR_LOGGING_LIBS) \ | ||
$(PHOSPHOR_DBUS_INTERFACES_LIBS) \ | ||
$(SDBUSPLUS_LIBS) | ||
|
||
openpower_proc_nmi_CXXFLAGS = $(PHOSPHOR_LOGGING_CFLAGS) \ | ||
$(PHOSPHOR_DBUS_INTERFACES_CFLAGS) \ | ||
$(SDBUSPLUS_CFLAGS) | ||
|
||
SUBDIRS = test | ||
|
||
-include Makefile.generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,4 +67,6 @@ AS_IF([test "x$with_systemdsystemunitdir" != "xno"], | |
|
||
AC_CONFIG_FILES([Makefile test/Makefile]) | ||
AC_CONFIG_FILES([[email protected]]) | ||
AC_CONFIG_FILES([xyz.openbmc_project.Control.Host.NMI.service]) | ||
AC_CONFIG_FILES([nmi.service]) | ||
AC_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Unit] | ||
Description=Enable Open Power NMI service | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=no | ||
ExecStart=@bindir@/pdbg -a stop | ||
ExecStart=@bindir@/pdbg -a sreset | ||
SyslogIdentifier=openpower-proc-nmi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright (C) 2019 IBM Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "nmi_interface.hpp" | ||
|
||
#include <phosphor-logging/elog-errors.hpp> | ||
#include <phosphor-logging/elog.hpp> | ||
#include <xyz/openbmc_project/Common/error.hpp> | ||
|
||
namespace openpower | ||
{ | ||
namespace proc | ||
{ | ||
|
||
NMI::NMI(sdbusplus::bus::bus& bus, const char* path) : | ||
Interface(bus, path), bus(bus), objectPath(path) | ||
{ | ||
} | ||
|
||
void NMI::nMI() | ||
{ | ||
using namespace phosphor::logging; | ||
using sdbusplus::exception::SdBusError; | ||
using InternalFailure = | ||
sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; | ||
|
||
constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1"; | ||
constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1"; | ||
constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager"; | ||
|
||
auto method = bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH, | ||
SYSTEMD_INTERFACE, "StartUnit"); | ||
method.append("nmi.service", "replace"); | ||
try | ||
{ | ||
bus.call_noreply(method); | ||
} | ||
catch (const SdBusError& e) | ||
{ | ||
log<level::ALERT>("Error in starting NMI service. "); | ||
report<InternalFailure>(); | ||
} | ||
} | ||
} // namespace proc | ||
} // namespace openpower |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#include <sdbusplus/bus.hpp> | ||
#include <sdbusplus/server/object.hpp> | ||
#include <xyz/openbmc_project/Control/Host/NMI/server.hpp> | ||
|
||
namespace openpower | ||
{ | ||
namespace proc | ||
{ | ||
|
||
using Base = sdbusplus::xyz::openbmc_project::Control::Host::server::NMI; | ||
using Interface = sdbusplus::server::object::object<Base>; | ||
|
||
/* @class NMI | ||
* @brief Implementation of NMI (Soft Reset) | ||
*/ | ||
class NMI : public Interface | ||
{ | ||
public: | ||
NMI() = delete; | ||
NMI(const NMI&) = delete; | ||
NMI& operator=(const NMI&) = delete; | ||
NMI(NMI&&) = delete; | ||
NMI& operator=(NMI&&) = delete; | ||
virtual ~NMI() = default; | ||
|
||
/* @brief Constructor to put object onto bus at a dbus path. | ||
* @param[in] bus - sdbusplus D-Bus to attach to. | ||
* @param[in] path - Path to attach to. | ||
*/ | ||
NMI(sdbusplus::bus::bus& bus, const char* path); | ||
|
||
/* @brief trigger stop followed by soft reset. | ||
*/ | ||
void nMI() override; | ||
|
||
private: | ||
/** @brief sdbus handle */ | ||
sdbusplus::bus::bus& bus; | ||
|
||
/** @brief object path */ | ||
std::string objectPath; | ||
}; | ||
|
||
} // namespace proc | ||
} // namespace openpower |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright © 2019 IBM Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "nmi_interface.hpp" | ||
|
||
#include <sdbusplus/bus.hpp> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
|
||
constexpr auto BUSPATH_NMI = "/xyz/openbmc_project/control/host0/nmi"; | ||
constexpr auto BUSNAME_NMI = "xyz.openbmc_project.Control.Host.NMI"; | ||
auto bus = sdbusplus::bus::new_default(); | ||
|
||
// Add sdbusplus ObjectManager | ||
sdbusplus::server::manager::manager objManager(bus, BUSPATH_NMI); | ||
openpower::proc::NMI NMI(bus, BUSPATH_NMI); | ||
bus.request_name(BUSNAME_NMI); | ||
|
||
while (true) | ||
{ | ||
bus.process_discard(); | ||
bus.wait(); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Start the Open Power Host Control NMI service | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
|
||
[Service] | ||
ExecStart=@bindir@/openpower-proc-nmi | ||
SyslogIdentifier=openpower-proc-nmi | ||
Restart=always | ||
Type=dbus | ||
BusName=xyz.openbmc_project.Control.Host.NMI | ||
|
||
[Install] | ||
[email protected] |