From 7b4674daebc997c7cc509c81f9465c78cac14c53 Mon Sep 17 00:00:00 2001 From: wjiang Date: Mon, 28 Apr 2025 16:03:48 +0800 Subject: [PATCH] fix ras-mc-ctl --summary failed and Add some improvements and add new modules to HiSilicon common section --- ...me-compilation-alarms-in-ras-record..patch | 38 ++++ ...w-compilation-warnings-in-non-standa.patch | 46 ++++ ...daemon-Fix-some-static-check-warning.patch | 198 ++++++++++++++++++ ...w-modules-supported-by-HiSilicon-com.patch | 40 ++++ fix-ras-mc-ctl-summary-failed.patch | 25 +++ rasdaemon.spec | 14 +- 6 files changed, 360 insertions(+), 1 deletion(-) create mode 100644 0001-rasdaemon-Fix-some-compilation-alarms-in-ras-record..patch create mode 100644 0002-rasdaemon-Fix-few-compilation-warnings-in-non-standa.patch create mode 100644 0003-rasdaemon-Fix-some-static-check-warning.patch create mode 100644 0004-rasdaemon-Add-new-modules-supported-by-HiSilicon-com.patch create mode 100644 fix-ras-mc-ctl-summary-failed.patch diff --git a/0001-rasdaemon-Fix-some-compilation-alarms-in-ras-record..patch b/0001-rasdaemon-Fix-some-compilation-alarms-in-ras-record..patch new file mode 100644 index 0000000..7d892ea --- /dev/null +++ b/0001-rasdaemon-Fix-some-compilation-alarms-in-ras-record..patch @@ -0,0 +1,38 @@ +From a0cf58e6c96bb5e2646da9fd43e1ddd285a6e8da Mon Sep 17 00:00:00 2001 +From: Bing Xia +Date: Sun, 19 Jan 2025 11:08:26 +0000 +Subject: [PATCH 1/4] rasdaemon: Fix some compilation alarms in ras-record.h. + +Fix the problem that the type of a constant string does not match +when it is assigned to a character pointer. + +Signed-off-by: Bing Xia +Signed-off-by: Shiju Jose +Signed-off-by: Mauro Carvalho Chehab +--- + ras-record.h | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/ras-record.h b/ras-record.h +index 5eab62c..eec0702 100644 +--- a/ras-record.h ++++ b/ras-record.h +@@ -318,12 +318,12 @@ struct sqlite3_priv { + }; + + struct db_fields { +- char *name; +- char *type; ++ const char *name; ++ const char *type; + }; + + struct db_table_descriptor { +- char *name; ++ const char *name; + const struct db_fields *fields; + size_t num_fields; + }; +-- +2.25.1 + diff --git a/0002-rasdaemon-Fix-few-compilation-warnings-in-non-standa.patch b/0002-rasdaemon-Fix-few-compilation-warnings-in-non-standa.patch new file mode 100644 index 0000000..642fcb2 --- /dev/null +++ b/0002-rasdaemon-Fix-few-compilation-warnings-in-non-standa.patch @@ -0,0 +1,46 @@ +From 1d83921b5ad4dc03a411abf759c1025e548ce3e0 Mon Sep 17 00:00:00 2001 +From: Bing Xia +Date: Sun, 19 Jan 2025 11:26:43 +0000 +Subject: [PATCH 2/4] rasdaemon: Fix few compilation warnings in non standard + hisilicon code + +Fix the problem that the type of a constant string does not match +when it is assigned to a character pointer. + +Signed-off-by: Bing Xia +Signed-off-by: Shiju Jose +Signed-off-by: Mauro Carvalho Chehab +--- + non-standard-hisi_hip08.c | 2 +- + non-standard-hisilicon.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/non-standard-hisi_hip08.c b/non-standard-hisi_hip08.c +index de5b5e9..3b8d93c 100644 +--- a/non-standard-hisi_hip08.c ++++ b/non-standard-hisi_hip08.c +@@ -462,7 +462,7 @@ static const char * const oem_submodule_name(const struct hisi_module_info *info + return "unknown"; + } + +-static char *pcie_local_sub_module_name(uint8_t id) ++static const char *pcie_local_sub_module_name(uint8_t id) + { + switch (id) { + case HISI_PCIE_SUB_MODULE_ID_AP: return "AP_Layer"; +diff --git a/non-standard-hisilicon.h b/non-standard-hisilicon.h +index 44da9e7..afd5e83 100644 +--- a/non-standard-hisilicon.h ++++ b/non-standard-hisilicon.h +@@ -24,7 +24,7 @@ enum hisi_oem_data_type { + }; + + /* helper functions */ +-static inline char *err_severity(uint8_t err_sev) ++static inline const char *err_severity(uint8_t err_sev) + { + switch (err_sev) { + case HISI_ERR_SEVERITY_NFE: return "recoverable"; +-- +2.25.1 + diff --git a/0003-rasdaemon-Fix-some-static-check-warning.patch b/0003-rasdaemon-Fix-some-static-check-warning.patch new file mode 100644 index 0000000..dcd486a --- /dev/null +++ b/0003-rasdaemon-Fix-some-static-check-warning.patch @@ -0,0 +1,198 @@ +From f717326ae7ffb30d6da09840c7e4613793d0113e Mon Sep 17 00:00:00 2001 +From: Qizhi Zhang +Date: Tue, 8 Apr 2025 10:55:06 +0800 +Subject: [PATCH] rasdaemon: Fix some static check warning + +The decode_int_fields() and decode_text_fields() functions are used +to replace the original if judgment branch, reducing the cyclomatic +complexity. + +Signed-off-by: Xiaofei Tan +Signed-off-by: Shiju Jose +Signed-off-by: Mauro Carvalho Chehab +--- + non-standard-hisilicon.c | 135 ++++++++++++++++++--------------------- + 1 file changed, 61 insertions(+), 74 deletions(-) + +diff --git a/non-standard-hisilicon.c b/non-standard-hisilicon.c +index 2b00ed6..53b36ed 100644 +--- a/non-standard-hisilicon.c ++++ b/non-standard-hisilicon.c +@@ -144,7 +144,6 @@ int step_vendor_data_tab(struct ras_ns_ev_decoder *ev_decoder, const char *name) + } + #endif + +-#ifdef HAVE_SQLITE3 + static const struct db_fields hisi_common_section_fields[] = { + { .name = "id", .type = "INTEGER PRIMARY KEY" }, + { .name = "timestamp", .type = "TEXT" }, +@@ -164,6 +163,7 @@ static const struct db_fields hisi_common_section_fields[] = { + { .name = "regs_dump", .type = "TEXT" }, + }; + ++#ifdef HAVE_SQLITE3 + static const struct db_table_descriptor hisi_common_section_tab = { + .name = "hisi_common_section_v2", + .fields = hisi_common_section_fields, +@@ -245,81 +245,33 @@ static void decode_module(struct ras_ns_ev_decoder *ev_decoder, + } + } + +-static void decode_hisi_common_section_hdr(struct ras_ns_ev_decoder *ev_decoder, +- const struct hisi_common_error_section *err, +- struct hisi_event *event) ++static void decode_int_fields(struct ras_ns_ev_decoder *ev_decoder, int id, ++ uint16_t data, struct hisi_event *event, bool valid) + { +- HISI_SNPRINTF(event->error_msg, "[ table_version=%hhu", err->version); +- record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_INT, +- HISI_COMMON_FIELD_VERSION, +- err->version, NULL); +- if (err->val_bits & BIT(HISI_COMMON_VALID_SOC_ID)) { +- HISI_SNPRINTF(event->error_msg, "soc=%s", get_soc_desc(err->soc_id)); +- record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_INT, +- HISI_COMMON_FIELD_SOC_ID, +- err->soc_id, NULL); +- } +- +- if (err->val_bits & BIT(HISI_COMMON_VALID_SOCKET_ID)) { +- HISI_SNPRINTF(event->error_msg, "socket_id=%hhu", err->socket_id); +- record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_INT, +- HISI_COMMON_FIELD_SOCKET_ID, +- err->socket_id, NULL); +- } ++ if (!valid) ++ return; + +- if (err->val_bits & BIT(HISI_COMMON_VALID_TOTEM_ID)) { +- HISI_SNPRINTF(event->error_msg, "totem_id=%hhu", err->totem_id); +- record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_INT, +- HISI_COMMON_FIELD_TOTEM_ID, +- err->totem_id, NULL); ++ if (id == HISI_COMMON_FIELD_SOC_ID) { ++ HISI_SNPRINTF(event->error_msg, "soc=%s", get_soc_desc(data)); ++ } else { ++ HISI_SNPRINTF(event->error_msg, "%s=%hu", ++ hisi_common_section_fields[id].name, data); + } + +- if (err->val_bits & BIT(HISI_COMMON_VALID_NIMBUS_ID)) { +- HISI_SNPRINTF(event->error_msg, "nimbus_id=%hhu", err->nimbus_id); +- record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_INT, +- HISI_COMMON_FIELD_NIMBUS_ID, +- err->nimbus_id, NULL); +- } ++ record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_INT, id, data, NULL); ++} + +- if (err->val_bits & BIT(HISI_COMMON_VALID_SUBSYSTEM_ID)) { +- HISI_SNPRINTF(event->error_msg, "subsystem_id=%hhu", err->subsystem_id); +- record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_INT, +- HISI_COMMON_FIELD_SUB_SYSTEM_ID, +- err->subsystem_id, NULL); +- } ++static void decode_text_fields(struct ras_ns_ev_decoder *ev_decoder, int id, ++ const struct hisi_common_error_section *err, ++ struct hisi_event *event, bool valid) ++{ ++ if (!valid) ++ return; + +- if (err->val_bits & BIT(HISI_COMMON_VALID_MODULE_ID)) ++ if (id == HISI_COMMON_FIELD_MODULE_ID) + decode_module(ev_decoder, event, err->module_id); + +- if (err->val_bits & BIT(HISI_COMMON_VALID_SUBMODULE_ID)) { +- HISI_SNPRINTF(event->error_msg, "submodule_id=%hhu", err->submodule_id); +- record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_INT, +- HISI_COMMON_FIELD_SUB_MODULE_ID, +- err->submodule_id, NULL); +- } +- +- if (err->val_bits & BIT(HISI_COMMON_VALID_CORE_ID)) { +- HISI_SNPRINTF(event->error_msg, "core_id=%hhu", err->core_id); +- record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_INT, +- HISI_COMMON_FIELD_CORE_ID, +- err->core_id, NULL); +- } +- +- if (err->val_bits & BIT(HISI_COMMON_VALID_PORT_ID)) { +- HISI_SNPRINTF(event->error_msg, "port_id=%hhu", err->port_id); +- record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_INT, +- HISI_COMMON_FIELD_PORT_ID, +- err->port_id, NULL); +- } +- +- if (err->val_bits & BIT(HISI_COMMON_VALID_ERR_TYPE)) { +- HISI_SNPRINTF(event->error_msg, "err_type=%hu", err->err_type); +- record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_INT, +- HISI_COMMON_FIELD_ERR_TYPE, +- err->err_type, NULL); +- } +- +- if (err->val_bits & BIT(HISI_COMMON_VALID_PCIE_INFO)) { ++ if (id == HISI_COMMON_FIELD_PCIE_INFO) { + HISI_SNPRINTF(event->error_msg, "pcie_device_id=%04x:%02x:%02x.%x", + err->pcie_info.segment, err->pcie_info.bus, + err->pcie_info.device, err->pcie_info.function); +@@ -327,16 +279,51 @@ static void decode_hisi_common_section_hdr(struct ras_ns_ev_decoder *ev_decoder, + err->pcie_info.segment, err->pcie_info.bus, + err->pcie_info.device, err->pcie_info.function); + record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_TEXT, +- HISI_COMMON_FIELD_PCIE_INFO, +- 0, event->pcie_info); ++ id, 0, event->pcie_info); + } + +- if (err->val_bits & BIT(HISI_COMMON_VALID_ERR_SEVERITY)) { +- HISI_SNPRINTF(event->error_msg, "err_severity=%s", err_severity(err->err_severity)); ++ if (id == HISI_COMMON_FIELD_ERR_SEVERITY) { ++ HISI_SNPRINTF(event->error_msg, "err_severity=%s", ++ err_severity(err->err_severity)); + record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_TEXT, +- HISI_COMMON_FIELD_ERR_SEVERITY, +- 0, err_severity(err->err_severity)); ++ id, 0, err_severity(err->err_severity)); + } ++} ++ ++static void decode_hisi_common_section_hdr(struct ras_ns_ev_decoder *ev_decoder, ++ const struct hisi_common_error_section *err, ++ struct hisi_event *event) ++{ ++ HISI_SNPRINTF(event->error_msg, "["); ++ ++ decode_int_fields(ev_decoder, HISI_COMMON_FIELD_VERSION, err->version, event, 1); ++ decode_int_fields(ev_decoder, HISI_COMMON_FIELD_SOC_ID, err->soc_id, event, ++ err->val_bits & BIT(HISI_COMMON_VALID_SOC_ID)); ++ decode_int_fields(ev_decoder, HISI_COMMON_FIELD_SOCKET_ID, err->socket_id, event, ++ err->val_bits & BIT(HISI_COMMON_VALID_SOCKET_ID)); ++ decode_int_fields(ev_decoder, HISI_COMMON_FIELD_TOTEM_ID, err->totem_id, event, ++ err->val_bits & BIT(HISI_COMMON_VALID_TOTEM_ID)); ++ decode_int_fields(ev_decoder, HISI_COMMON_FIELD_NIMBUS_ID, err->nimbus_id, event, ++ err->val_bits & BIT(HISI_COMMON_VALID_NIMBUS_ID)); ++ decode_int_fields(ev_decoder, HISI_COMMON_FIELD_SUB_SYSTEM_ID, err->subsystem_id, event, ++ err->val_bits & BIT(HISI_COMMON_VALID_SUBSYSTEM_ID)); ++ ++ decode_text_fields(ev_decoder, HISI_COMMON_FIELD_MODULE_ID, err, event, ++ err->val_bits & BIT(HISI_COMMON_VALID_MODULE_ID)); ++ ++ decode_int_fields(ev_decoder, HISI_COMMON_FIELD_SUB_MODULE_ID, err->submodule_id, event, ++ err->val_bits & BIT(HISI_COMMON_VALID_SUBMODULE_ID)); ++ decode_int_fields(ev_decoder, HISI_COMMON_FIELD_CORE_ID, err->core_id, event, ++ err->val_bits & BIT(HISI_COMMON_VALID_CORE_ID)); ++ decode_int_fields(ev_decoder, HISI_COMMON_FIELD_PORT_ID, err->port_id, event, ++ err->val_bits & BIT(HISI_COMMON_VALID_PORT_ID)); ++ decode_int_fields(ev_decoder, HISI_COMMON_FIELD_ERR_TYPE, err->err_type, event, ++ err->val_bits & BIT(HISI_COMMON_VALID_ERR_TYPE)); ++ ++ decode_text_fields(ev_decoder, HISI_COMMON_FIELD_PCIE_INFO, err, event, ++ err->val_bits & BIT(HISI_COMMON_VALID_PCIE_INFO)); ++ decode_text_fields(ev_decoder, HISI_COMMON_FIELD_ERR_SEVERITY, err, event, ++ err->val_bits & BIT(HISI_COMMON_VALID_ERR_SEVERITY)); + + HISI_SNPRINTF(event->error_msg, "]"); + } +-- +2.25.1 + diff --git a/0004-rasdaemon-Add-new-modules-supported-by-HiSilicon-com.patch b/0004-rasdaemon-Add-new-modules-supported-by-HiSilicon-com.patch new file mode 100644 index 0000000..2e8cc23 --- /dev/null +++ b/0004-rasdaemon-Add-new-modules-supported-by-HiSilicon-com.patch @@ -0,0 +1,40 @@ +From 34e16f737fdcc90ed396a4b6074c6f2e3573e1d1 Mon Sep 17 00:00:00 2001 +From: Qizhi Zhang +Date: Tue, 8 Apr 2025 11:15:55 +0800 +Subject: [PATCH] rasdaemon: Add new modules supported by HiSilicon common + section + +Add new modules supported by HiSilicon common error section. + +Signed-off-by: Bing Xia +Signed-off-by: Shiju Jose +Signed-off-by: Mauro Carvalho Chehab +--- + non-standard-hisilicon.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/non-standard-hisilicon.c b/non-standard-hisilicon.c +index 2b00ed6..d294442 100644 +--- a/non-standard-hisilicon.c ++++ b/non-standard-hisilicon.c +@@ -219,6 +219,17 @@ static const char* module_name[] = { + "SDMA", + "UC", + "HBMC", ++ "PMC", ++ "SCHE", ++ "ASMB_DFS", ++ "ASMB_NTU", ++ "UB", ++ "UMMU", ++ "PCU", ++ "UCMI", ++ "DJTAGM", ++ "CFGBUS", ++ "MPU", + }; + + static const char* get_soc_desc(uint8_t soc_id) +-- +2.25.1 + diff --git a/fix-ras-mc-ctl-summary-failed.patch b/fix-ras-mc-ctl-summary-failed.patch new file mode 100644 index 0000000..8ea9263 --- /dev/null +++ b/fix-ras-mc-ctl-summary-failed.patch @@ -0,0 +1,25 @@ +From 8f9b6aeb13884696fbf17da7ac28111a672c1301 Mon Sep 17 00:00:00 2001 +From: root +Date: Sat, 19 Apr 2025 10:04:20 +0800 +Subject: [PATCH] fix ras-mc-ctl --summary failed + +--- + misc/rasdaemon.service.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/misc/rasdaemon.service.in b/misc/rasdaemon.service.in +index 508aa3c..4ef3d2c 100644 +--- a/misc/rasdaemon.service.in ++++ b/misc/rasdaemon.service.in +@@ -4,7 +4,7 @@ After=syslog.target + + [Service] + EnvironmentFile=@SYSCONFDEFDIR@/rasdaemon +-ExecStart=@sbindir@/rasdaemon -f ++ExecStart=@sbindir@/rasdaemon -f -r + ExecStartPost=@sbindir@/rasdaemon --enable + ExecStop=@sbindir@/rasdaemon --disable + Restart=on-abort +-- +2.27.0 + diff --git a/rasdaemon.spec b/rasdaemon.spec index d6fbb10..7a6a384 100644 --- a/rasdaemon.spec +++ b/rasdaemon.spec @@ -1,6 +1,6 @@ Name: rasdaemon Version: 0.8.0 -Release: 10 +Release: 11 License: GPLv2 Summary: Utility to get Platform Reliability, Availability and Serviceability (RAS) reports via the Kernel tracing events URL: https://github.com/mchehab/rasdaemon.git @@ -39,6 +39,11 @@ Patch9012: backport-Rasdaemon-Fix-autoreconf-build-error.patch Patch9013: backport-mce-amd-smca-update-smca_hwid-to-use-smca_bank_types.patch Patch9014: backport-Fix-the-bug-that-config-env-is-greater-than-ulong_ma.patch Patch9015: fix-parse-param-bug-and-set-default-when-overflow.patch +Patch9016: fix-ras-mc-ctl-summary-failed.patch +Patch9017: 0001-rasdaemon-Fix-some-compilation-alarms-in-ras-record..patch +Patch9018: 0002-rasdaemon-Fix-few-compilation-warnings-in-non-standa.patch +Patch9019: 0003-rasdaemon-Fix-some-static-check-warning.patch +Patch9020: 0004-rasdaemon-Add-new-modules-supported-by-HiSilicon-com.patch %description The rasdaemon program is a daemon which monitors the platform @@ -90,6 +95,13 @@ fi /usr/bin/systemctl disable rasdaemon.service >/dev/null 2>&1 || : %changelog +* Mon Apr 28 2025 wangjiang - 0.8.0-11 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:fix ras-mc-ctl --summary failed + Add some improvements and add new modules to HiSilicon common section + * Tue Mar 25 2025 zhangjinqiang - 0.8.0-10 - Type:bugfix - CVE:NA -- Gitee