[Skiboot] [PATCH 4/4] IPMI: Introduce attention call
Vasant Hegde
hegdevasant at linux.vnet.ibm.com
Thu Aug 20 17:03:34 AEST 2015
Presently abort() function is not working on BMC based machine. System
hangs after abort/assert call. We have to reboot machine from BMC (IPMI
command or BMC console).
This patch introduces attention functionality for BMC based machine.
It logs eSEL event that contains OPAL version, file info and backtrace.
iAnd calls cec_reboot... which takes care of rebooting machine
Note:
- This patch uses ipmi_queue_msg() instead of ipmi_queue_msg_sync() as
we are having some issues with sync path. This will resolved once we
sort out [1].
- This patch calls cec_reboot to reboot machine after logging eSEL event.
It queues IPMI message and bt_poll() should be working until we pass
reboot IPMI message to BMC. Hence we have while loop with time_wait_ms().
Alternatively we can use xscom_trigger_xstop().. but it will stop
immediately and eSEL logging fails.
[1] https://lists.ozlabs.org/pipermail/skiboot/2015-August/001824.html
Sample eSEL output after assert call:
------------------------------------
[hegdevasant at hegdevasant bin]$ strings fir01bmc.150820.120511.eSel.binary
BB821410
AT8335-GTA000000000000
AT8335-GTA000000000000UD
ATDESC
OPAL version : skiboot-5.1.1-6-g0f53436
File info : core/init.c:463:0
CPU 0458 Backtrace:
S: 0000000032d63a00 R: 0000000030060394 .ipmi_log_terminate_event+0x80
S: 0000000032d63be0 R: 00000000300604b8 .ipmi_terminate+0xac
S: 0000000032d63c60 R: 0000000030017f90 ._abort+0x80
S: 0000000032d63ce0 R: 0000000030017fd8 .assert_fail+0x34
S: 0000000032d63d60 R: 0000000030013dcc .load_and_boot_kernel+0x784
S: 0000000032d63e30 R: 000000003001437c .main_cpu_entry+0x57c
S: 0000000032d63f00 R: 0000000030002544 boot_entry+0x194
Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
hw/ipmi/Makefile.inc | 2 +-
hw/ipmi/ipmi-attn.c | 84 ++++++++++++++++++++++++++++++++++++++++++++
include/ipmi.h | 3 ++
platforms/astbmc/firestone.c | 1 +
platforms/astbmc/garrison.c | 1 +
platforms/astbmc/habanero.c | 1 +
platforms/astbmc/palmetto.c | 1 +
7 files changed, 92 insertions(+), 1 deletion(-)
create mode 100644 hw/ipmi/ipmi-attn.c
diff --git a/hw/ipmi/Makefile.inc b/hw/ipmi/Makefile.inc
index 06cdc96..6325369 100644
--- a/hw/ipmi/Makefile.inc
+++ b/hw/ipmi/Makefile.inc
@@ -1,7 +1,7 @@
SUBDIRS += hw/ipmi
IPMI_OBJS = ipmi-rtc.o ipmi-power.o ipmi-opal.o ipmi-fru.o ipmi-sel.o
-IPMI_OBJS += ipmi-watchdog.o ipmi-sensor.o
+IPMI_OBJS += ipmi-watchdog.o ipmi-sensor.o ipmi-attn.o
IPMI = hw/ipmi/built-in.o
$(IPMI): $(IPMI_OBJS:%=hw/ipmi/%)
diff --git a/hw/ipmi/ipmi-attn.c b/hw/ipmi/ipmi-attn.c
new file mode 100644
index 0000000..a5198e9
--- /dev/null
+++ b/hw/ipmi/ipmi-attn.c
@@ -0,0 +1,84 @@
+/* Copyright 2015 IBM Corp.
+ *
+ * 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 <errorlog.h>
+#include <ipmi.h>
+#include <pel.h>
+#include <platform.h>
+#include <processor.h>
+#include <skiboot.h>
+#include <stack.h>
+#include <timebase.h>
+
+/* Use same attention SRC for BMC based machine */
+DEFINE_LOG_ENTRY(OPAL_RC_ATTN, OPAL_PLATFORM_ERR_EVT,
+ OPAL_ATTN, OPAL_PLATFORM_FIRMWARE,
+ OPAL_ERROR_PANIC, OPAL_ABNORMAL_POWER_OFF);
+
+/* Maximum buffer size to capture backtrace and other useful information */
+#define IPMI_TI_BUFFER_SIZE (IPMI_MAX_PEL_SIZE - PEL_MIN_SIZE)
+static char ti_buffer[IPMI_TI_BUFFER_SIZE];
+
+/* Log eSEL event with OPAL backtrace */
+static void ipmi_log_terminate_event(const char *msg)
+{
+#define STACK_BUF_ENTRIES 20
+ unsigned int bt_entry_cnt = STACK_BUF_ENTRIES;
+ unsigned int ti_len;
+ unsigned int ti_size;
+ struct bt_entry bt_buf[STACK_BUF_ENTRIES];
+ struct errorlog *elog_buf;
+
+ /* Fill OPAL version */
+ ti_len = snprintf(ti_buffer, IPMI_TI_BUFFER_SIZE,
+ "OPAL version : %s\n", version);
+
+ /* File information */
+ ti_len += snprintf(ti_buffer + ti_len, IPMI_TI_BUFFER_SIZE - ti_len,
+ "File info : %s\n", msg);
+ ti_size = IPMI_TI_BUFFER_SIZE - ti_len;
+
+ /* Backtrace */
+ __backtrace(bt_buf, &bt_entry_cnt);
+ __print_backtrace(mfspr(SPR_PIR), bt_buf, bt_entry_cnt,
+ ti_buffer + ti_len, &ti_size, true);
+
+ /* Create eSEL event and commit */
+ elog_buf = opal_elog_create(&e_info(OPAL_RC_ATTN), 0);
+ log_append_data(elog_buf, (char *)&ti_buffer, ti_len + ti_size);
+ log_commit(elog_buf);
+}
+
+void __attribute__((noreturn)) ipmi_terminate(const char *msg)
+{
+ /* Terminate called before initialzing IPMI (early abort) */
+ if (!ipmi_present()) {
+ if (platform.cec_reboot())
+ platform.cec_reboot();
+ goto out;
+ }
+
+ /* Log eSEL event */
+ ipmi_log_terminate_event(msg);
+
+ /* Reboot call */
+ if (platform.cec_reboot())
+ platform.cec_reboot();
+
+out:
+ while (1)
+ time_wait_ms(100);
+}
diff --git a/include/ipmi.h b/include/ipmi.h
index d1532ba..bcc780d 100644
--- a/include/ipmi.h
+++ b/include/ipmi.h
@@ -272,4 +272,7 @@ uint8_t ipmi_get_sensor_number(uint8_t sensor_type);
/* Set the boot count once the OS is up and running */
int ipmi_set_boot_count(void);
+/* Terminate immediate */
+void __attribute__((noreturn)) ipmi_terminate(const char *msg);
+
#endif
diff --git a/platforms/astbmc/firestone.c b/platforms/astbmc/firestone.c
index cda9d06..445a28b 100644
--- a/platforms/astbmc/firestone.c
+++ b/platforms/astbmc/firestone.c
@@ -47,4 +47,5 @@ DECLARE_PLATFORM(firestone) = {
.start_preload_resource = flash_start_preload_resource,
.resource_loaded = flash_resource_loaded,
.exit = ipmi_wdt_final_reset,
+ .terminate = ipmi_terminate,
};
diff --git a/platforms/astbmc/garrison.c b/platforms/astbmc/garrison.c
index 5cd8e2e..edc3522 100644
--- a/platforms/astbmc/garrison.c
+++ b/platforms/astbmc/garrison.c
@@ -56,4 +56,5 @@ DECLARE_PLATFORM(garrison) = {
.start_preload_resource = flash_start_preload_resource,
.resource_loaded = flash_resource_loaded,
.exit = ipmi_wdt_final_reset,
+ .terminate = ipmi_terminate,
};
diff --git a/platforms/astbmc/habanero.c b/platforms/astbmc/habanero.c
index 7ae5dc4..db7f1af 100644
--- a/platforms/astbmc/habanero.c
+++ b/platforms/astbmc/habanero.c
@@ -56,4 +56,5 @@ DECLARE_PLATFORM(habanero) = {
.start_preload_resource = flash_start_preload_resource,
.resource_loaded = flash_resource_loaded,
.exit = ipmi_wdt_final_reset,
+ .terminate = ipmi_terminate,
};
diff --git a/platforms/astbmc/palmetto.c b/platforms/astbmc/palmetto.c
index 7c2a157..ca91908 100644
--- a/platforms/astbmc/palmetto.c
+++ b/platforms/astbmc/palmetto.c
@@ -56,4 +56,5 @@ DECLARE_PLATFORM(palmetto) = {
.start_preload_resource = flash_start_preload_resource,
.resource_loaded = flash_resource_loaded,
.exit = ipmi_wdt_final_reset,
+ .terminate = ipmi_terminate,
};
--
2.1.0
More information about the Skiboot
mailing list