linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] ACPI: Improve SPCR handling and messaging on SPCR-less systems
@ 2025-06-20 13:13 Li Chen
  2025-06-20 13:13 ` [PATCH v2 1/2] ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled Li Chen
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Li Chen @ 2025-06-20 13:13 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Will Deacon, Rafael J . Wysocki,
	Len Brown, Liu Wei, Ryan Roberts, Andrew Morton, Jonathan Cameron,
	Sudeep Holla, linux-arm-kernel, linux-kernel, linux-acpi

From: Li Chen <chenl311@chinatelecom.cn>

From: Li Chen <chenl311@chinatelecom.cn>

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/20250528105404.457729-1-me@linux.beauty/
[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(-)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled
  2025-06-20 13:13 [PATCH v2 0/2] ACPI: Improve SPCR handling and messaging on SPCR-less systems Li Chen
@ 2025-06-20 13:13 ` Li Chen
  2025-07-01 11:53   ` Catalin Marinas
  2025-06-20 13:13 ` [PATCH v2 2/2] ACPI: Suppress misleading SPCR console message when SPCR table is absent Li Chen
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Li Chen @ 2025-06-20 13:13 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Will Deacon, Rafael J . Wysocki,
	Len Brown, Liu Wei, Ryan Roberts, Andrew Morton, Jonathan Cameron,
	Sudeep Holla, linux-arm-kernel, linux-kernel, linux-acpi

From: Li Chen <chenl311@chinatelecom.cn>

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.

Signed-off-by: Li Chen <chenl311@chinatelecom.cn>
---
 include/linux/acpi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index f102c0fe34318..71e692f952905 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -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
 
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] ACPI: Suppress misleading SPCR console message when SPCR table is absent
  2025-06-20 13:13 [PATCH v2 0/2] ACPI: Improve SPCR handling and messaging on SPCR-less systems Li Chen
  2025-06-20 13:13 ` [PATCH v2 1/2] ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled Li Chen
@ 2025-06-20 13:13 ` Li Chen
  2025-06-28  7:42 ` [PATCH v2 0/2] ACPI: Improve SPCR handling and messaging on SPCR-less systems Hanjun Guo
  2025-07-01 14:28 ` Catalin Marinas
  3 siblings, 0 replies; 7+ messages in thread
From: Li Chen @ 2025-06-20 13:13 UTC (permalink / raw)
  To: Hanjun Guo, Catalin Marinas, Will Deacon, Rafael J . Wysocki,
	Len Brown, Liu Wei, Ryan Roberts, Andrew Morton, Jonathan Cameron,
	Sudeep Holla, linux-arm-kernel, linux-kernel, linux-acpi,
	Anshuman Khandual, Li Chen

From: Li Chen <chenl311@chinatelecom.cn>

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.

Signed-off-by: Li Chen <chenl311@chinatelecom.cn>
---
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(-)

diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index b9a66fc146c9f..4d529ff7ba513 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -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);
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] ACPI: Improve SPCR handling and messaging on SPCR-less systems
  2025-06-20 13:13 [PATCH v2 0/2] ACPI: Improve SPCR handling and messaging on SPCR-less systems Li Chen
  2025-06-20 13:13 ` [PATCH v2 1/2] ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled Li Chen
  2025-06-20 13:13 ` [PATCH v2 2/2] ACPI: Suppress misleading SPCR console message when SPCR table is absent Li Chen
@ 2025-06-28  7:42 ` Hanjun Guo
  2025-07-01 14:28 ` Catalin Marinas
  3 siblings, 0 replies; 7+ messages in thread
From: Hanjun Guo @ 2025-06-28  7:42 UTC (permalink / raw)
  To: Li Chen, Catalin Marinas, Will Deacon, Rafael J . Wysocki,
	Len Brown, Liu Wei, Ryan Roberts, Andrew Morton, Jonathan Cameron,
	Sudeep Holla, linux-arm-kernel, linux-kernel, linux-acpi

On 2025/6/20 21:13, Li Chen wrote:
> From: Li Chen <chenl311@chinatelecom.cn>
> 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/20250528105404.457729-1-me@linux.beauty/
> [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(-)

This version looks good to me,

Acked-by: Hanjun Guo <guohanjun@huawei.com>

Thanks
Hanjun

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled
  2025-06-20 13:13 ` [PATCH v2 1/2] ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled Li Chen
@ 2025-07-01 11:53   ` Catalin Marinas
  2025-07-01 13:54     ` Rafael J. Wysocki
  0 siblings, 1 reply; 7+ messages in thread
From: Catalin Marinas @ 2025-07-01 11:53 UTC (permalink / raw)
  To: Li Chen, Rafael J . Wysocki
  Cc: Hanjun Guo, Will Deacon, Len Brown, Liu Wei, Ryan Roberts,
	Andrew Morton, Jonathan Cameron, Sudeep Holla, linux-arm-kernel,
	linux-kernel, linux-acpi

On Fri, Jun 20, 2025 at 09:13:07PM +0800, Li Chen wrote:
> From: Li Chen <chenl311@chinatelecom.cn>
> 
> 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.
> 
> Signed-off-by: Li Chen <chenl311@chinatelecom.cn>
> ---
>  include/linux/acpi.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index f102c0fe34318..71e692f952905 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -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.

-- 
Catalin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled
  2025-07-01 11:53   ` Catalin Marinas
@ 2025-07-01 13:54     ` Rafael J. Wysocki
  0 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2025-07-01 13:54 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Li Chen, Rafael J . Wysocki, Hanjun Guo, Will Deacon, Len Brown,
	Liu Wei, Ryan Roberts, Andrew Morton, Jonathan Cameron,
	Sudeep Holla, linux-arm-kernel, linux-kernel, linux-acpi

On Tue, Jul 1, 2025 at 1:53 PM Catalin Marinas <catalin.marinas@arm.com> wrote:
>
> On Fri, Jun 20, 2025 at 09:13:07PM +0800, Li Chen wrote:
> > From: Li Chen <chenl311@chinatelecom.cn>
> >
> > 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.
> >
> > Signed-off-by: Li Chen <chenl311@chinatelecom.cn>
> > ---
> >  include/linux/acpi.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> > index f102c0fe34318..71e692f952905 100644
> > --- a/include/linux/acpi.h
> > +++ b/include/linux/acpi.h
> > @@ -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!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] ACPI: Improve SPCR handling and messaging on SPCR-less systems
  2025-06-20 13:13 [PATCH v2 0/2] ACPI: Improve SPCR handling and messaging on SPCR-less systems Li Chen
                   ` (2 preceding siblings ...)
  2025-06-28  7:42 ` [PATCH v2 0/2] ACPI: Improve SPCR handling and messaging on SPCR-less systems Hanjun Guo
@ 2025-07-01 14:28 ` Catalin Marinas
  3 siblings, 0 replies; 7+ messages in thread
From: Catalin Marinas @ 2025-07-01 14:28 UTC (permalink / raw)
  To: Hanjun Guo, Will Deacon, Rafael J . Wysocki, Len Brown, Liu Wei,
	Ryan Roberts, Andrew Morton, Jonathan Cameron, Sudeep Holla,
	linux-arm-kernel, linux-kernel, linux-acpi, Li Chen

On Fri, 20 Jun 2025 21:13:06 +0800, Li Chen wrote:
> From: Li Chen <chenl311@chinatelecom.cn>
> 
> 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

-- 
Catalin


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-07-01 14:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-20 13:13 [PATCH v2 0/2] ACPI: Improve SPCR handling and messaging on SPCR-less systems Li Chen
2025-06-20 13:13 ` [PATCH v2 1/2] ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled Li Chen
2025-07-01 11:53   ` Catalin Marinas
2025-07-01 13:54     ` Rafael J. Wysocki
2025-06-20 13:13 ` [PATCH v2 2/2] ACPI: Suppress misleading SPCR console message when SPCR table is absent Li Chen
2025-06-28  7:42 ` [PATCH v2 0/2] ACPI: Improve SPCR handling and messaging on SPCR-less systems Hanjun Guo
2025-07-01 14:28 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).