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

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"

Or if with acpi=nospcr:
"Use ACPI SPCR as default console: No"

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 SPCR console message
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]

[1]: https://patchew.org/QEMU/20250528105404.457729-1-me@linux.beauty/

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 | 9 ++++++---
 include/linux/acpi.h     | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

-- 
2.49.0


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

* [PATCH 1/2] ACPI: Return -ENODEV from acpi_parse_spcr() when SPCR support is disabled
  2025-06-06  7:27 [PATCH 0/2] ACPI: Improve SPCR handling and messaging on SPCR-less systems Li Chen
@ 2025-06-06  7:27 ` Li Chen
  2025-06-06  7:27 ` [PATCH 2/2] ACPI: Suppress misleading SPCR console message when SPCR table is absent Li Chen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Li Chen @ 2025-06-06  7:27 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Rafael J. Wysocki, Len Brown,
	Hanjun Guo, Liu Wei, Ryan Roberts, Andrew Morton,
	Jonathan Cameron, Li Chen, 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] 6+ messages in thread

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

From: Li Chen <chenl311@chinatelecom.cn>

The kernel currently 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 message is only printed if
acpi_parse_spcr() succeeds (i.e., if the SPCR table
is present and parsed). This avoids user confusion
on SPCR-less systems.

Signed-off-by: Li Chen <chenl311@chinatelecom.cn>
---
 arch/arm64/kernel/acpi.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index b9a66fc146c9f..bf29e7b668f1d 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,11 @@ 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)
+			pr_info("Use ACPI SPCR as default console: %s\n",
+					param_acpi_nospcr ? "No" : "Yes");
 
 		if (IS_ENABLED(CONFIG_ACPI_BGRT))
 			acpi_table_parse(ACPI_SIG_BGRT, acpi_parse_bgrt);
-- 
2.49.0


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

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

Gentle ping incase of forgotten.

 ---- On Fri, 06 Jun 2025 15:27:43 +0800  Li Chen <me@linux.beauty> 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"
 > 
 > Or if with acpi=nospcr:
 > "Use ACPI SPCR as default console: No"
 > 
 > 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 SPCR console message
 > 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]
 > 
 > [1]: https://patchew.org/QEMU/20250528105404.457729-1-me@linux.beauty/
 > 
 > 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 | 9 ++++++---
 >  include/linux/acpi.h     | 2 +-
 >  2 files changed, 7 insertions(+), 4 deletions(-)
 > 
 > -- 
 > 2.49.0
 > 
 > 

Regards,
Li

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

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

Hi Li Chen,

On 2025/6/6 15:27, 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"

Agreed, this is wrong, we need to fix it.

> 
> Or if with acpi=nospcr:
> "Use ACPI SPCR as default console: No"

I think this is OK, it's just to let you know we are not
using ACPI SPCR console when ACPI is enabled, including
cases with no SPCR table.

> 
> 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 SPCR console message
> if acpi_parse_spcr() succeeds.

I have some detail comments for patch 2.

Thanks
Hanjun

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

* Re: [PATCH 2/2] ACPI: Suppress misleading SPCR console message when SPCR table is absent
  2025-06-06  7:27 ` [PATCH 2/2] ACPI: Suppress misleading SPCR console message when SPCR table is absent Li Chen
@ 2025-06-19 14:54   ` Hanjun Guo
  0 siblings, 0 replies; 6+ messages in thread
From: Hanjun Guo @ 2025-06-19 14:54 UTC (permalink / raw)
  To: Li Chen, Catalin Marinas, Will Deacon, Rafael J. Wysocki,
	Len Brown, Liu Wei, Ryan Roberts, Andrew Morton, Jonathan Cameron,
	Li Chen, Sudeep Holla, linux-arm-kernel, linux-kernel, linux-acpi

Hi Li Chen,

On 2025/6/6 15:27, Li Chen wrote:
> From: Li Chen<chenl311@chinatelecom.cn>
> 
> The kernel currently 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 message is only printed if
> acpi_parse_spcr() succeeds (i.e., if the SPCR table
> is present and parsed). This avoids user confusion
> on SPCR-less systems.
> 
> Signed-off-by: Li Chen<chenl311@chinatelecom.cn>
> ---
>   arch/arm64/kernel/acpi.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index b9a66fc146c9f..bf29e7b668f1d 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,11 @@ 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)
> +			pr_info("Use ACPI SPCR as default console: %s\n",
> +					param_acpi_nospcr ? "No" : "Yes");

Print "No" for:
- CONFIG_ACPI_SPCR_TABLE is disabled
- ret != 0
- param_acpi_nospcr = 1

Only print "Yes" for ret = 0.

Thanks
Hanjun

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

end of thread, other threads:[~2025-06-19 14:54 UTC | newest]

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

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).