Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/61306 )
Change subject: console: Add loglevel prefix to interactive consoles
......................................................................
console: Add loglevel prefix to interactive consoles
In an attempt to make loglevels more visible (and therefore useful,
hopefully), this patch adds a prefix indicating the log level to every
line sent to an "interactive" console (such as a UART). If the code
contains a `printk(BIOS_DEBUG, "This is a debug message!\n"), it will
now show up as
[DEBUG] This is a debug message!
on the UART output.
"Stored" consoles (such as in CBMEM) will get a similar but more
space-efficient feature in a later CL.
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Change-Id: Ic83413475400821f8097ef1819a293ee8926bb0b
Reviewed-on: https://review.coreboot.org/c/coreboot/+/61306
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
Reviewed-by: Raul Rangel <rrangel(a)chromium.org>
---
M src/commonlib/include/commonlib/loglevel.h
M src/console/console.c
M src/console/printk.c
M src/include/console/streams.h
4 files changed, 70 insertions(+), 9 deletions(-)
Approvals:
build bot (Jenkins): Verified
Raul Rangel: Looks good to me, approved
diff --git a/src/commonlib/include/commonlib/loglevel.h b/src/commonlib/include/commonlib/loglevel.h
index f268750..68b2285 100644
--- a/src/commonlib/include/commonlib/loglevel.h
+++ b/src/commonlib/include/commonlib/loglevel.h
@@ -157,4 +157,27 @@
#define BIOS_NEVER 9
/** @} */
+#ifndef __ASSEMBLER__
+
+/*
+ * When printing logs, lines should be printed with the following prefixes in
+ * front of them according to the BIOS_LOG_PREFIX_PATTERN printf() pattern.
+ */
+#define BIOS_LOG_PREFIX_PATTERN "[%.5s] "
+#define BIOS_LOG_PREFIX_MAX_LEVEL BIOS_SPEW
+static const char bios_log_prefix[BIOS_LOG_PREFIX_MAX_LEVEL + 1][5] = {
+ /* Note: These strings are *not* null-terminated to save space. */
+ [BIOS_EMERG] = "EMERG",
+ [BIOS_ALERT] = "ALERT",
+ [BIOS_CRIT] = "CRIT ",
+ [BIOS_ERR] = "ERROR",
+ [BIOS_WARNING] = "WARN ",
+ [BIOS_NOTICE] = "NOTE ",
+ [BIOS_INFO] = "INFO ",
+ [BIOS_DEBUG] = "DEBUG",
+ [BIOS_SPEW] = "SPEW ",
+};
+
+#endif /* __ASSEMBLER__ */
+
#endif /* LOGLEVEL_H */
diff --git a/src/console/console.c b/src/console/console.c
index 67da107..5b8a872 100644
--- a/src/console/console.c
+++ b/src/console/console.c
@@ -25,28 +25,35 @@
__system76_ec_init();
}
-void console_tx_byte(unsigned char byte)
+void console_interactive_tx_byte(unsigned char byte, void *data_unused)
{
- __cbmemc_tx_byte(byte);
- __spkmodem_tx_byte(byte);
- __qemu_debugcon_tx_byte(byte);
-
- /* Some consoles want newline conversion
- * to keep terminals happy.
- */
if (byte == '\n') {
+ /* Some consoles want newline conversion to keep terminals happy. */
__uart_tx_byte('\r');
__usb_tx_byte('\r');
}
+ __spkmodem_tx_byte(byte);
+ __qemu_debugcon_tx_byte(byte);
__uart_tx_byte(byte);
__ne2k_tx_byte(byte);
__usb_tx_byte(byte);
__spiconsole_tx_byte(byte);
- __flashconsole_tx_byte(byte);
__system76_ec_tx_byte(byte);
}
+void console_stored_tx_byte(unsigned char byte, void *data_unused)
+{
+ __flashconsole_tx_byte(byte);
+ __cbmemc_tx_byte(byte);
+}
+
+void console_tx_byte(unsigned char byte)
+{
+ console_interactive_tx_byte(byte, NULL);
+ console_stored_tx_byte(byte, NULL);
+}
+
void console_tx_flush(void)
{
__uart_tx_flush();
diff --git a/src/console/printk.c b/src/console/printk.c
index ef3d29f..ddd14c0 100644
--- a/src/console/printk.c
+++ b/src/console/printk.c
@@ -67,9 +67,35 @@
};
};
+static void wrap_interactive_printf(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vtxprintf(console_interactive_tx_byte, fmt, args, NULL);
+}
+
+static void line_start(union log_state state)
+{
+ if (state.level > BIOS_LOG_PREFIX_MAX_LEVEL)
+ return;
+ if (state.speed == CONSOLE_LOG_FAST)
+ return;
+
+ /* Interactive consoles get a `[DEBUG] ` style readable prefix. */
+ wrap_interactive_printf(BIOS_LOG_PREFIX_PATTERN, bios_log_prefix[state.level]);
+}
+
static void wrap_putchar(unsigned char byte, void *data)
{
union log_state state = { .as_ptr = data };
+ static bool line_started = false;
+
+ if (byte == '\n') {
+ line_started = false;
+ } else if (!line_started) {
+ line_start(state);
+ line_started = true;
+ }
if (state.speed == CONSOLE_LOG_FAST)
__cbmemc_tx_byte(byte);
diff --git a/src/include/console/streams.h b/src/include/console/streams.h
index 44d96e2..f8b1216 100644
--- a/src/include/console/streams.h
+++ b/src/include/console/streams.h
@@ -10,6 +10,11 @@
void console_tx_byte(unsigned char byte);
void console_tx_flush(void);
+/* Interactive consoles that are usually displayed in real time on a terminal. */
+void console_interactive_tx_byte(unsigned char byte, void *data_unused);
+/* Consoles that store logs on some medium for later retrieval. */
+void console_stored_tx_byte(unsigned char byte, void *data_unused);
+
/*
* Write number_of_bytes data bytes from buffer to the serial device.
* If number_of_bytes is zero, wait until all serial data is output.
6 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
--
To view, visit https://review.coreboot.org/c/coreboot/+/61306
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ic83413475400821f8097ef1819a293ee8926bb0b
Gerrit-Change-Number: 61306
Gerrit-PatchSet: 8
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Reviewer: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Georgi <patrick(a)coreboot.org>
Gerrit-Reviewer: Raul Rangel <rrangel(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-MessageType: merged
Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/61353 )
Change subject: soc/intel/common/block/pcie/rtd3: Add optional _OFF and _ON skip control
......................................................................
soc/intel/common/block/pcie/rtd3: Add optional _OFF and _ON skip control
- Optional feature to provide mechanism to skip _OFF and _On execution.
- It is used for the device to skip _OFF and _ON during device driver
reload.
- OFSK is used to skip _OFF Method at the end of device driver removal.
- ONSK is used to skip _ON Method at the beginning of driver loading.
- General flow use case:
1. Device driver is removed by 'rmmod' command.
2. Device _RST is called. _RST perform reset.
3. Device increments OFSK in _RST to skip the following _OFF invoked by
OSPM.
4. OSPM invokes _OFF at the end of driver removal.
5. _OFF sees OFSK and skips current execution and decrements OFSK so that
_OFF will be executed normally next time.
6. _OFF increments ONSK to skip the following _ON invoked by OSPM.
7. Device driver is reloaded by 'insmod/modprobe' command.
8. OSPM invokes _ON at the beginning of driver loading.
9. _ON sees ONSK and skip current execution and decrements ONSK so that
_ON will be executed normally next time.
- In normal case:
When suspend, OSPM invokes _OFF. Since OFSK is zero, the device goes
to deeper state as expected.
When resume, OSPM invokes _ON. Sinc ONSK is zero, the device goes
to active state as expected.
- Generated changes:
PowerResource (RTD3, 0x00, 0x0000)
Name (ONSK, Zero)
Name (OFSK, Zero)
...
Method (_ON, 0, Serialized) // _ON_: Power On
{
If ((ONSK == Zero))
{
...
}
Else
{
ONSK--
}
}
Method (_OFF, 0, Serialized) // _OFF: Power Off
{
If ((OFSK == Zero))
{
...
}
Else
{
OFSK--
ONSK++
}
}
Test:
Enable and verify OFSK and ONSK Name objects and the if-condition logic
inside _OFF and _ON methods is added.
Signed-off-by: Cliff Huang <cliff.huang(a)intel.com>
Change-Id: Ic32d151d65107bfc220258c383a575e40a496b6f
Reviewed-on: https://review.coreboot.org/c/coreboot/+/61353
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak(a)chromium.org>
---
M src/soc/intel/common/block/pcie/rtd3/chip.h
M src/soc/intel/common/block/pcie/rtd3/rtd3.c
2 files changed, 62 insertions(+), 0 deletions(-)
Approvals:
build bot (Jenkins): Verified
Tim Wawrzynczak: Looks good to me, approved
diff --git a/src/soc/intel/common/block/pcie/rtd3/chip.h b/src/soc/intel/common/block/pcie/rtd3/chip.h
index 7541bc3..652aaff 100644
--- a/src/soc/intel/common/block/pcie/rtd3/chip.h
+++ b/src/soc/intel/common/block/pcie/rtd3/chip.h
@@ -76,6 +76,12 @@
*-----------------------------------------------------------------------------------*
*/
enum acpi_pcie_rp_pm_emit ext_pm_support;
+
+ /*
+ * Add support to skip _OFF and _ON execution when needed, such as reloading
+ * the device driver.
+ */
+ bool skip_on_off_support;
};
#endif /* __SOC_INTEL_COMMON_BLOCK_PCIE_RTD3_CHIP_H__ */
diff --git a/src/soc/intel/common/block/pcie/rtd3/rtd3.c b/src/soc/intel/common/block/pcie/rtd3/rtd3.c
index 260aa65..8a9b068 100644
--- a/src/soc/intel/common/block/pcie/rtd3/rtd3.c
+++ b/src/soc/intel/common/block/pcie/rtd3/rtd3.c
@@ -147,6 +147,13 @@
{
acpigen_write_method_serialized("_ON", 0);
+ /* When this feature is enabled, ONSK indicates if the previous _OFF was
+ * skipped. If so, since the device was not in Off state, and the current
+ * _ON can be skipped as well.
+ */
+ if (config->skip_on_off_support)
+ acpigen_write_if_lequal_namestr_int("ONSK", 0);
+
/* Disable modPHY power gating for PCH RPs. */
if (rp_type == PCIE_RP_PCH)
pcie_rtd3_enable_modphy_pg(pcie_rp, PG_DISABLE);
@@ -173,6 +180,16 @@
if (!config->disable_l23)
pcie_rtd3_acpi_l23_exit();
+ if (config->skip_on_off_support) {
+ /* If current _ON is skipped, ONSK is decremented so that _ON will be
+ * executed normally until _OFF is skipped again.
+ */
+ acpigen_write_else();
+ acpigen_emit_byte(DECREMENT_OP);
+ acpigen_emit_namestring("ONSK");
+
+ acpigen_pop_len(); /* Else */
+ }
acpigen_pop_len(); /* Method */
}
@@ -183,6 +200,14 @@
{
acpigen_write_method_serialized("_OFF", 0);
+ /* When this feature is enabled, ONSK is checked to see if the device
+ * wants _OFF to be skipped for once. ONSK is normally incremented in the
+ * device method, such as reset _RST, which is invoked during driver reload.
+ * In such case, _OFF needs to be avoided at the end of driver removal.
+ */
+ if (config->skip_on_off_support)
+ acpigen_write_if_lequal_namestr_int("OFSK", 0);
+
/* Trigger L23 ready entry flow unless disabled by config. */
if (!config->disable_l23)
pcie_rtd3_acpi_l23_entry();
@@ -209,6 +234,22 @@
acpigen_write_sleep(config->enable_off_delay_ms);
}
+ if (config->skip_on_off_support) {
+ /* If current _OFF is skipped, ONSK is incremented so that the
+ * following _ON will also be skipped. In addition, OFSK is decremented
+ * so that next _OFF will be executed normally until the device method
+ * increments OFSK again.
+ */
+ acpigen_write_else();
+ /* OFSK-- */
+ acpigen_emit_byte(DECREMENT_OP);
+ acpigen_emit_namestring("OFSK");
+ /* ONSK++ */
+ acpigen_emit_byte(INCREMENT_OP);
+ acpigen_emit_namestring("ONSK");
+
+ acpigen_pop_len(); /* Else */
+ }
acpigen_pop_len(); /* Method */
}
@@ -391,6 +432,21 @@
/* ACPI Power Resource for controlling the attached device power. */
acpigen_write_power_res("RTD3", 0, 0, power_res_states, ARRAY_SIZE(power_res_states));
+
+ if (config->skip_on_off_support) {
+ /* OFSK: 0 = _OFF Method will be executed normally when called;
+ * >1 = _OFF will be skipped.
+ * _OFF Method to decrement OFSK and increment ONSK if the
+ * current execution is skipped.
+ * ONSK: 0 = _ON Method will be executed normally when called;
+ * >1 = _ONF will be skipped.
+ * _ON Method to decrement ONSK if the current execution is
+ * skipped.
+ */
+ acpigen_write_name_integer("ONSK", 0);
+ acpigen_write_name_integer("OFSK", 0);
+ }
+
pcie_rtd3_acpi_method_status(config);
pcie_rtd3_acpi_method_on(pcie_rp, config, rp_type);
pcie_rtd3_acpi_method_off(pcie_rp, config, rp_type);
--
To view, visit https://review.coreboot.org/c/coreboot/+/61353
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ic32d151d65107bfc220258c383a575e40a496b6f
Gerrit-Change-Number: 61353
Gerrit-PatchSet: 9
Gerrit-Owner: Cliff Huang <cliff.huang(a)intel.com>
Gerrit-Reviewer: Anil Kumar K <anil.kumar.k(a)intel.com>
Gerrit-Reviewer: Bora Guvendik <bora.guvendik(a)intel.com>
Gerrit-Reviewer: Felix Held <felix-coreboot(a)felixheld.de>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: Selma Bensaid <selma.bensaid(a)intel.com>
Gerrit-Reviewer: Subrata Banik <subratabanik(a)google.com>
Gerrit-Reviewer: Thejaswani Putta <thejaswani.putta(a)intel.com>
Gerrit-Reviewer: Tim Wawrzynczak <twawrzynczak(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-MessageType: merged