Skip to contentSkip to conversation

ACPI: Improve SPCR handling and messaging on SPCR-less systems

PATCH Applied Li Chen 4 participants 7 messages Jun 20, 2025 – Jul 1, 2025

Subsystems (2)
lore
Share & tools
lore

Li Chen

author
#0 lore raw

v2 cover ACPI: Improve SPCR handling and messaging on SPCR-less systems

From: Li Chen <[email protected]>

From: Li Chen <[email protected]>

This small series improves the kernel behavior and output when the ACPI SPCR table is not present or not supported.

Currently, even on systems that completely lack an SPCR table, the kernel prints:
"Use ACPI SPCR as default console: Yes"

This may mislead users into thinking an SPCR table exists
when in fact there is no such table at all. This series addresses this in two steps:

Patch 1 ensures that acpi_parse_spcr() returns -ENODEV if CONFIG_ACPI_SPCR_TABLE is disabled.

Patch 2 updates arm64 acpi_boot_table_init() to only print the Yes if acpi_parse_spcr() succeeds.

This results in cleaner and more accurate boot logs on ARM64.

Tested on both SPCR-enabled and SPCR-less qemu-system arm64 virt platform. [1]

Changelog:
v2: refine the printk message logic as suggested by Hanjun Guo. [2]

[1]: https://patchew.org/QEMU/[email protected]/
[2]: https://www.spinics.net/lists/kernel/msg5730585.html

Li Chen (2):
ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is
disabled
ACPI: Suppress misleading SPCR console message when SPCR table is
absent

 arch/arm64/kernel/acpi.c | 10 +++++++---
 include/linux/acpi.h     |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.49.0
author
#1 lore raw

PATCH v2 1/2 ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled

From: Li Chen <[email protected]>

If CONFIG_ACPI_SPCR_TABLE is disabled, acpi_parse_spcr() currently returns 0, which may incorrectly suggest that SPCR parsing was successful. This patch changes the behavior to return -ENODEV to clearly indicate that SPCR support is not available.

This prepares the codebase for future changes that depend on acpi_parse_spcr() failure detection, such as suppressing misleading console messages.

---
 include/linux/acpi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/acpi.h +1 -1
index f102c0fe34318..71e692f952905 100644
@@ -1503,7 +1503,7 @@ int acpi_parse_spcr(bool enable_earlycon, bool enable_console);
 #else
 static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console)
 {
-	return 0;
+	return -ENODEV;
 }
 #endif
 
Signature · 1 line
2.49.0
maintainer
#2 lore raw

Re: [PATCH v2 1/2] ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled

Quoted 22 lines · Li Chen

From: Li Chen <[email protected]>

If CONFIG_ACPI_SPCR_TABLE is disabled, acpi_parse_spcr() currently returns 0, which may incorrectly suggest that SPCR parsing was successful. This patch changes the behavior to return -ENODEV to clearly indicate that SPCR support is not available.

This prepares the codebase for future changes that depend on acpi_parse_spcr() failure detection, such as suppressing misleading console messages.

---
 include/linux/acpi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/acpi.h +0 -0
index f102c0fe34318..71e692f952905 100644

include/linux/acpi.h int acpi_parse_spcr(bool enable_earlycon, bool enable_console); · line 1508

Quoted 7 lines
include/linux/acpi.h +1 -1
@@ -1503,7 +1503,7 @@ int acpi_parse_spcr(bool enable_earlycon, bool enable_console);
 #else
 static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console)
 {
-	return 0;
+	return -ENODEV;
 }
 #endif

Rafael, are you ok with this patch going via the arm64 tree?

Thanks.

Signature · 1 line
Catalin
#3 lore raw

Re: [PATCH v2 1/2] ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled

Quoted 19 lines · Catalin Marinas
Quoted 17 lines · Li Chen

From: Li Chen <[email protected]>

If CONFIG_ACPI_SPCR_TABLE is disabled, acpi_parse_spcr() currently returns 0, which may incorrectly suggest that SPCR parsing was successful. This patch changes the behavior to return -ENODEV to clearly indicate that SPCR support is not available.

This prepares the codebase for future changes that depend on acpi_parse_spcr() failure detection, such as suppressing misleading console messages.

---
 include/linux/acpi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

include/linux/acpi.h int acpi_parse_spcr(bool enable_earlycon, bool enable_console); · line 1508

Quoted 12 lines
include/linux/acpi.h +1 -1
index f102c0fe34318..71e692f952905 100644
@@ -1503,7 +1503,7 @@ int acpi_parse_spcr(bool enable_earlycon, bool enable_console);
 #else
 static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console)
 {
-     return 0;
+     return -ENODEV;
 }
 #endif

Rafael, are you ok with this patch going via the arm64 tree?

Yes, I am, thanks!

author
#4 lore raw

PATCH v2 2/2 ACPI: Suppress misleading SPCR console message when SPCR table is absent

In reply to Li Chen

From: Li Chen <[email protected]>

The kernel currently alway prints:
"Use ACPI SPCR as default console: No/Yes "

even on systems that lack an SPCR table. This can mislead users into thinking the SPCR table exists on the machines without SPCR.

With this change, the "Yes" is only printed if the SPCR table is present, parsed and !param_acpi_nospcr. This avoids user confusion on SPCR-less systems.

---
changelog:
v2: refine the printk message logic as suggested by Hanjun Guo.

 arch/arm64/kernel/acpi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
arch/arm64/kernel/acpi.c +7 -3
index b9a66fc146c9f..4d529ff7ba513 100644
@@ -197,6 +197,8 @@ static int __init acpi_fadt_sanity_check(void)
  */
 void __init acpi_boot_table_init(void)
 {
+	int ret;
+
 	/*
 	 * Enable ACPI instead of device tree unless
 	 * - ACPI has been disabled explicitly (acpi=off), or
@@ -250,10 +252,12 @@ void __init acpi_boot_table_init(void)
 		 * behaviour, use acpi=nospcr to disable console in ACPI SPCR
 		 * table as default serial console.
 		 */
-		acpi_parse_spcr(earlycon_acpi_spcr_enable,
+		ret = acpi_parse_spcr(earlycon_acpi_spcr_enable,
 			!param_acpi_nospcr);
-		pr_info("Use ACPI SPCR as default console: %s\n",
-				param_acpi_nospcr ? "No" : "Yes");
+		if (!ret || param_acpi_nospcr || !IS_ENABLED(CONFIG_ACPI_SPCR_TABLE))
+			pr_info("Use ACPI SPCR as default console: No\n");
+		else
+			pr_info("Use ACPI SPCR as default console: Yes\n");
 
 		if (IS_ENABLED(CONFIG_ACPI_BGRT))
 			acpi_table_parse(ACPI_SIG_BGRT, acpi_parse_bgrt);
Signature · 1 line
2.49.0
Acked-by on the v2 series
#5 lore raw
In reply to Li Chen
Quoted 31 lines · Li Chen

From: Li Chen <[email protected]>
This small series improves the kernel behavior and output when the ACPI SPCR table is not present or not supported.

Currently, even on systems that completely lack an SPCR table, the kernel prints:
"Use ACPI SPCR as default console: Yes"

This may mislead users into thinking an SPCR table exists
when in fact there is no such table at all. This series addresses this in two steps:

Patch 1 ensures that acpi_parse_spcr() returns -ENODEV if CONFIG_ACPI_SPCR_TABLE is disabled.

Patch 2 updates arm64 acpi_boot_table_init() to only print the Yes if acpi_parse_spcr() succeeds.

This results in cleaner and more accurate boot logs on ARM64.

Tested on both SPCR-enabled and SPCR-less qemu-system arm64 virt platform. [1]

Changelog:
v2: refine the printk message logic as suggested by Hanjun Guo. [2]

[1]: https://patchew.org/QEMU/[email protected]/
[2]: https://www.spinics.net/lists/kernel/msg5730585.html

Li Chen (2):
ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is
disabled
ACPI: Suppress misleading SPCR console message when SPCR table is
absent

Quoted 3 lines
  arch/arm64/kernel/acpi.c | 10 +++++++---
  include/linux/acpi.h     |  2 +-
  2 files changed, 8 insertions(+), 4 deletions(-)

This version looks good to me,

Thanks
Hanjun

maintainer Applied
#6 lore raw
In reply to Li Chen
Quoted 9 lines · Li Chen

From: Li Chen <[email protected]>

This small series improves the kernel behavior and output when the ACPI SPCR table is not present or not supported.

Currently, even on systems that completely lack an SPCR table, the kernel prints:
"Use ACPI SPCR as default console: Yes"

[...]

Applied to arm64 (for-next/acpi), thanks!

[1/2] ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled

      https://git.kernel.org/arm64/c/b9f58d3572a8
[2/2] ACPI: Suppress misleading SPCR console message when SPCR table is absent
      https://git.kernel.org/arm64/c/bad3fa2fb920
Signature · 1 line
Catalin