summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/state
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/state')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager/0001-Use-binary-serialization-instead-of-JSON.patch104
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager/0002-Max-post-code-file-size-per-cycle-setting.patch63
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager_git.bbappend8
3 files changed, 175 insertions, 0 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager/0001-Use-binary-serialization-instead-of-JSON.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager/0001-Use-binary-serialization-instead-of-JSON.patch
new file mode 100644
index 000000000..91992e260
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager/0001-Use-binary-serialization-instead-of-JSON.patch
@@ -0,0 +1,104 @@
+From 3f362d5e15dd3c20d1026bd814fe52b9793025e5 Mon Sep 17 00:00:00 2001
+From: Jonathan Doman <jonathan.doman@intel.com>
+Date: Wed, 23 Nov 2022 15:04:17 -0800
+Subject: [PATCH 1/2] Use binary serialization instead of JSON
+
+The binary format is much more efficient than JSON in terms of
+computational speed and disk space consumption. The former is important
+in case the host is sending a constant stream of POST codes.
+post-code-manager can fall behind because it takes too long to store
+each new POST code on disk, causing D-Bus messages to pile up and
+increase memory consumption inside dbus-broker.
+
+Tested:
+Rebooted the host a few times and observed that POST code history is
+populated normally in Redfish. After upgrading to this change, old POST
+code history stored in JSON format is lost, but remains on disk until it
+gets overwritten during subsequent host boots.
+
+Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
+Change-Id: Id55909a55d950e6e62b78b3333df687b4c582c42
+Signed-off-by: Manish Baing <manish.baing@intel.com>
+---
+ inc/post_code.hpp | 6 ------
+ src/post_code.cpp | 17 ++++++++++++-----
+ 2 files changed, 12 insertions(+), 11 deletions(-)
+
+diff --git a/inc/post_code.hpp b/inc/post_code.hpp
+index be800f2..3d790b8 100644
+--- a/inc/post_code.hpp
++++ b/inc/post_code.hpp
+@@ -18,12 +18,6 @@
+ #include <fcntl.h>
+ #include <unistd.h>
+
+-#include <cereal/access.hpp>
+-#include <cereal/archives/json.hpp>
+-#include <cereal/cereal.hpp>
+-#include <cereal/types/map.hpp>
+-#include <cereal/types/tuple.hpp>
+-#include <cereal/types/vector.hpp>
+ #include <chrono>
+ #include <filesystem>
+ #include <fstream>
+diff --git a/src/post_code.cpp b/src/post_code.cpp
+index 1fcbe55..dfe6ce7 100644
+--- a/src/post_code.cpp
++++ b/src/post_code.cpp
+@@ -17,6 +17,13 @@
+
+ #include "iomanip"
+
++#include <cereal/access.hpp>
++#include <cereal/archives/binary.hpp>
++#include <cereal/cereal.hpp>
++#include <cereal/types/map.hpp>
++#include <cereal/types/tuple.hpp>
++#include <cereal/types/vector.hpp>
++
+ PostCodeDataHolder* PostCodeDataHolder::instance = 0;
+
+ void PostCode::deleteAll()
+@@ -129,18 +136,18 @@ fs::path PostCode::serialize(const std::string& path)
+ {
+ fs::path idxPath(path + strCurrentBootCycleIndexName);
+ std::ofstream osIdx(idxPath.c_str(), std::ios::binary);
+- cereal::JSONOutputArchive idxArchive(osIdx);
++ cereal::BinaryOutputArchive idxArchive(osIdx);
+ idxArchive(currentBootCycleIndex);
+
+ uint16_t count = currentBootCycleCount();
+ fs::path cntPath(path + strCurrentBootCycleCountName);
+ std::ofstream osCnt(cntPath.c_str(), std::ios::binary);
+- cereal::JSONOutputArchive cntArchive(osCnt);
++ cereal::BinaryOutputArchive cntArchive(osCnt);
+ cntArchive(count);
+
+ std::ofstream osPostCodes(
+ (path + std::to_string(currentBootCycleIndex)));
+- cereal::JSONOutputArchive oarchivePostCodes(osPostCodes);
++ cereal::BinaryOutputArchive oarchivePostCodes(osPostCodes);
+ oarchivePostCodes(postCodes);
+ }
+ catch (const cereal::Exception& e)
+@@ -163,7 +170,7 @@ bool PostCode::deserialize(const fs::path& path, uint16_t& index)
+ if (fs::exists(path))
+ {
+ std::ifstream is(path.c_str(), std::ios::in | std::ios::binary);
+- cereal::JSONInputArchive iarchive(is);
++ cereal::BinaryInputArchive iarchive(is);
+ iarchive(index);
+ return true;
+ }
+@@ -190,7 +197,7 @@ bool PostCode::deserializePostCodes(const fs::path& path,
+ if (fs::exists(path))
+ {
+ std::ifstream is(path.c_str(), std::ios::in | std::ios::binary);
+- cereal::JSONInputArchive iarchive(is);
++ cereal::BinaryInputArchive iarchive(is);
+ iarchive(codes);
+ return true;
+ }
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager/0002-Max-post-code-file-size-per-cycle-setting.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager/0002-Max-post-code-file-size-per-cycle-setting.patch
new file mode 100644
index 000000000..679712d54
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager/0002-Max-post-code-file-size-per-cycle-setting.patch
@@ -0,0 +1,63 @@
+From 4415432e32ac8cbc6ec59815a9b9893c2d832c07 Mon Sep 17 00:00:00 2001
+From: Bonnie Lo <Bonnie_Lo@wiwynn.com>
+Date: Thu, 27 Oct 2022 17:14:55 +0800
+Subject: [PATCH 2/2] Max post code file size per cycle setting
+
+Let user could set POST code file size per cycle
+
+The default size is 512 counts
+
+Reason:
+BMC may crash caused by nonstop saving POST code when BIOS has
+some unusual behavior like PXE loop
+Thus, BMC should set a limit size to prevent this risk
+
+Test Case:
+Manually send POST code to check the POST code file rotation
+
+Signed-off-by: Bonnie Lo <Bonnie_Lo@wiwynn.com>
+Change-Id: Ic7fbafe532a79123e6ae880a8a3506f9c397d933
+---
+ meson.build | 1 +
+ meson_options.txt | 1 +
+ src/post_code.cpp | 4 ++++
+ 3 files changed, 6 insertions(+)
+
+diff --git a/meson.build b/meson.build
+index 2c44f72..632e07e 100644
+--- a/meson.build
++++ b/meson.build
+@@ -16,6 +16,7 @@ conf_data = configuration_data()
+ conf_data.set_quoted('DBUS_OBJECT_NAME', '/xyz/openbmc_project/State/Boot/PostCode0')
+ conf_data.set_quoted('DBUS_INTF_NAME','xyz.openbmc_project.State.Boot.PostCode')
+ conf_data.set('MAX_BOOT_CYCLE_COUNT',get_option('max-boot-cycle-count'))
++conf_data.set('MAX_POST_CODE_SIZE_PER_CYCLE',get_option('max-post-code-size-per-cycle'))
+
+ if get_option('bios-post-code-log').enabled()
+ add_project_arguments('-DENABLE_BIOS_POST_CODE_LOG',language: 'cpp')
+diff --git a/meson_options.txt b/meson_options.txt
+index c3d63fd..d877b97 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -1,2 +1,3 @@
+ option('max-boot-cycle-count', type:'integer', min:1, max: 100, description: 'Maximum boot cycles for which the post codes should be persisted', value:100)
+ option('bios-post-code-log', type:'feature',description:'bios post code log',value:'disabled')
++option('max-post-code-size-per-cycle', type:'integer', min:64, max: 1024, description: 'Maximum post code file size per cycle', value:512)
+diff --git a/src/post_code.cpp b/src/post_code.cpp
+index dfe6ce7..8411718 100644
+--- a/src/post_code.cpp
++++ b/src/post_code.cpp
+@@ -102,6 +102,10 @@ void PostCode::savePostCodes(postcode_t code)
+ }
+
+ postCodes.insert(std::make_pair(tsUS, code));
++ if (postCodes.size() > MAX_POST_CODE_SIZE_PER_CYCLE)
++ {
++ postCodes.erase(postCodes.begin());
++ }
+ serialize(fs::path(strPostCodeListPath));
+
+ #ifdef ENABLE_BIOS_POST_CODE_LOG
+--
+2.17.1
+
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager_git.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager_git.bbappend
index f17d24806..3e52f6bde 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager_git.bbappend
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/state/phosphor-post-code-manager_git.bbappend
@@ -1,2 +1,10 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+PROJECT_SRC_DIR := "${THISDIR}/${PN}"
+
#SRC_URI = "git://github.com/openbmc/phosphor-post-code-manager.git"
SRCREV = "987f91a6536e0330799cc5f4e54740c4023b5ef0"
+
+SRC_URI += "file://0001-Use-binary-serialization-instead-of-JSON.patch"
+SRC_URI += "file://0002-Max-post-code-file-size-per-cycle-setting.patch"
+
+