[coreboot-gerrit] Change in coreboot[master]: elog: Support logging S0ix sleep/wake info in elog

Furquan Shaikh (Code Review) gerrit at coreboot.org
Wed Oct 18 01:11:40 CEST 2017


Furquan Shaikh has uploaded this change for review. ( https://review.coreboot.org/22079


Change subject: elog: Support logging S0ix sleep/wake info in elog
......................................................................

elog: Support logging S0ix sleep/wake info in elog

1. Add support for new GSMI commands to log S0ix entry/exit
information in elog.
2. Skip logging anything if the sleep type is not S0ix i.e. if
suspend/resume are using ACPI sleep.
3. In case of resume, provide callbacks to allow platform and
mainboard to log any wake source information.

BUG=b:67874513
BRANCH=None
TEST=None

Change-Id: I593e8a9e31cad720ac1f77aab447a0dbdbe9a28b
Signed-off-by: Furquan Shaikh <furquan at chromium.org>
---
M src/drivers/elog/gsmi.c
M src/include/elog.h
2 files changed, 65 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/79/22079/1

diff --git a/src/drivers/elog/gsmi.c b/src/drivers/elog/gsmi.c
index cd94cf6..bf27ed3 100644
--- a/src/drivers/elog/gsmi.c
+++ b/src/drivers/elog/gsmi.c
@@ -25,6 +25,8 @@
 
 #define GSMI_CMD_SET_EVENT_LOG		0x08
 #define GSMI_CMD_CLEAR_EVENT_LOG	0x09
+#define GSMI_CMD_LOG_SLEEP_INFO		0x0a
+#define GSMI_CMD_LOG_WAKE_INFO		0x0b
 #define GSMI_CMD_HANDSHAKE_TYPE		0xc1
 
 #define GSMI_HANDSHAKE_NONE		0x7f
@@ -46,12 +48,34 @@
 	u32 data_type;
 } __packed;
 
+/*
+ * Sleep/Wake info flags:
+ * Bit 0     - ACPI sleep or wake(1) / Non-ACPI sleep or wake(0)
+ * Bits 1:15 - Reserved
+ */
+#define GSMI_FLAGS_ACPI_SX		(1 << 0)
+
+struct gsmi_log_sleep_wake_info_param {
+	u16 flags;
+} __packed;
+
+void __attribute__((weak)) elog_gsmi_cb_platform_log_wake_source(void)
+{
+	/* Default weak implementation, does nothing. */
+}
+
+void __attribute__((weak)) elog_gsmi_cb_mainboard_log_wake_source(void)
+{
+	/* Default weak implementation, does nothing. */
+}
+
 /* Param is usually EBX, ret in EAX */
 u32 gsmi_exec(u8 command, u32 *param)
 {
 	struct gsmi_set_eventlog_param *sel;
 	struct gsmi_set_eventlog_type1 *type1;
 	struct gsmi_clear_eventlog_param *cel;
+	struct gsmi_log_sleep_wake_info_param *info;
 	u32 ret = GSMI_RET_UNSUPPORTED;
 
 	switch (command) {
@@ -105,6 +129,31 @@
 			ret = GSMI_RET_SUCCESS;
 		break;
 
+	case GSMI_CMD_LOG_SLEEP_INFO:
+	case GSMI_CMD_LOG_WAKE_INFO:
+		info = (struct gsmi_log_sleep_wake_info_param *)(*param);
+		if (!info)
+			break;
+
+		ret = GSMI_RET_SUCCESS;
+
+		/*
+		 * If suspend/resume happens via firmware, there is no need to
+		 * log anything here. Normal suspend/resume paths will take care
+		 * of handling the logging in that case.
+		 */
+		if (info->flags & GSMI_FLAGS_ACPI_SX)
+			break;
+
+		if (command == GSMI_CMD_LOG_SLEEP_INFO)
+			elog_add_event(ELOG_TYPE_S0IX_ENTER);
+		else {
+			elog_add_event(ELOG_TYPE_S0IX_EXIT);
+			elog_gsmi_cb_platform_log_wake_source();
+			elog_gsmi_cb_mainboard_log_wake_source();
+		}
+		break;
+
 	default:
 		printk(BIOS_DEBUG, "GSMI Unknown: 0x%02x\n", command);
 		break;
diff --git a/src/include/elog.h b/src/include/elog.h
index bab7eb0..0f6a811 100644
--- a/src/include/elog.h
+++ b/src/include/elog.h
@@ -215,6 +215,10 @@
 #define ELOG_EC_DEVICE_EVENT_DSP            0x02
 #define ELOG_EC_DEVICE_EVENT_WIFI           0x03
 
+/* S0ix sleep/wake */
+#define ELOG_TYPE_S0IX_ENTER              0xaf
+#define ELOG_TYPE_S0IX_EXIT               0xb0
+
 #if IS_ENABLED(CONFIG_ELOG)
 /* Eventlog backing storage must be initialized before calling elog_init(). */
 extern int elog_init(void);
@@ -249,4 +253,16 @@
 u32 boot_count_read(void);
 u32 boot_count_increment(void);
 
+/*
+ * Callback from GSMI handler to allow platform to log any wake source
+ * information.
+ */
+void elog_gsmi_cb_platform_log_wake_source(void);
+
+/*
+ * Callback from GSMI handler to allow mainboard to log any wake source
+ * information.
+ */
+void elog_gsmi_cb_mainboard_log_wake_source(void);
+
 #endif /* ELOG_H_ */

-- 
To view, visit https://review.coreboot.org/22079
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I593e8a9e31cad720ac1f77aab447a0dbdbe9a28b
Gerrit-Change-Number: 22079
Gerrit-PatchSet: 1
Gerrit-Owner: Furquan Shaikh <furquan at google.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171017/2785c326/attachment-0001.html>


More information about the coreboot-gerrit mailing list