Skip to contentSkip to conversation

acpi, x86: Add SPCR table support

PATCH Superseded Prarit Bhargava 5 participants 15 messages Dec 7, 2017 – Dec 11, 2017

Subsystems (5)
Documentation x86 ACPI arm64 +1 more subsystems

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover acpi, x86: Add SPCR table support

The SPCR (Serial Port Console Redirection) Table provides information about the configuration of serial port. This information can be used to configure the early console.

SPCR support was added for arm64 and is made available across all arches in this patchset. The first patch adds a weak per-arch configuration function and moves the SPCR code into ACPI. The second patch adds support to x86.

The existing behaviour on arm64 is maintained. If the SPCR exists the earlycon and console are automatically configured.

The existing default behaviour on x86 is also maintained. If no console or earlycon parameter is defined and the SPCR exists , the serial port is not configured. If the earlycon parameter is used both the early console and the console are configured using the data from the SPCR.

Prarit Bhargava (2):
acpi, spcr: Make SPCR avialable to other architectures acpi, x86: Use SPCR table for earlycon on x86

 Documentation/admin-guide/kernel-parameters.txt |   9 +-
 arch/arm64/Kconfig                              |   1 -
 arch/arm64/kernel/acpi.c                        | 128 +++++++++++++++++-
 arch/x86/kernel/acpi/boot.c                     |   3 +
 drivers/acpi/Kconfig                            |  11 +-
 drivers/acpi/spcr.c                             | 171 ++++++------------------
 drivers/tty/serial/earlycon.c                   |  16 +--
 include/linux/acpi.h                            |  14 +-
 include/linux/serial_core.h                     |   2 -
 9 files changed, 195 insertions(+), 160 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/2 acpi, spcr: Make SPCR avialable to other architectures

Other architectures can use SPCR to setup an early console or console but the current code is ARM64 specific.

Change the name of parse_spcr() to acpi_parse_spcr(). Add a weak function acpi_arch_setup_console() that can be used for arch-specific setup. Move SPCR initialization flag into ACPI code. Update the Documention on the use of the SPCR earlycon.

This patch does not change arm64 behaviour.

---
 Documentation/admin-guide/kernel-parameters.txt |   6 +-
 arch/arm64/Kconfig                              |   1 -
 arch/arm64/kernel/acpi.c                        | 128 +++++++++++++++++-
 drivers/acpi/Kconfig                            |  11 +-
 drivers/acpi/spcr.c                             | 168 +++++-------------------
 drivers/tty/serial/earlycon.c                   |  16 +--
 include/linux/acpi.h                            |  11 +-
 include/linux/serial_core.h                     |   2 -
 8 files changed, 184 insertions(+), 159 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +3 -3
index 6571fbfdb2a1..0d173289c67e 100644
@@ -914,9 +914,9 @@
 
 	earlycon=	[KNL] Output early console device and options.
 
-			When used with no options, the early console is
-			determined by the stdout-path property in device
-			tree's chosen node.
+			[ARM64] The early console is determined by the
+			stdout-path property in device tree's chosen node,
+			or determined by the ACPI SPCR table.
 
 		cdns,<addr>[,options]
 			Start an early, polled-mode console on a Cadence
arch/arm64/Kconfig +0 -1
index a93339f5178f..c6f91c85abf6 100644
@@ -6,7 +6,6 @@ config ARM64
 	select ACPI_IORT if ACPI
 	select ACPI_REDUCED_HARDWARE_ONLY if ACPI
 	select ACPI_MCFG if ACPI
-	select ACPI_SPCR_TABLE if ACPI
 	select ARCH_CLOCKSOURCE_DATA
 	select ARCH_HAS_DEBUG_VIRTUAL
 	select ARCH_HAS_DEVMEM_IS_ALLOWED
arch/arm64/kernel/acpi.c +125 -3

148 lines not on this page · raw message

drivers/acpi/Kconfig +8 -3
index 46505396869e..ae25159dd976 100644
@@ -78,9 +78,6 @@ config ACPI_DEBUGGER_USER
 
 endif
 
-config ACPI_SPCR_TABLE
-	bool
-
 config ACPI_LPIT
 	bool
 	depends on X86_64
@@ -563,4 +560,12 @@ config TPS68470_PMIC_OPREGION
 	  region, which must be available before any of the devices
 	  using this, are probed.
 
+config ACPI_SPCR_TABLE
+	bool "ACPI Serial Port Console Redirection Support"
+	default y if ARM64
+	help
+	  Enable support for Serial Port Console Redirection (SPCR) Table.
+	  This table provides information about the configuration of the
+	  earlycon console.
+
 endif	# ACPI
drivers/acpi/spcr.c +36 -132

224 lines not on this page · raw message

drivers/tty/serial/earlycon.c +3 -13
index 4c8b80f1c688..b0a5964dd20f 100644
@@ -196,26 +196,16 @@ int __init setup_earlycon(char *buf)
 	return -ENOENT;
 }
 
-/*
- * When CONFIG_ACPI_SPCR_TABLE is defined, "earlycon" without parameters in
- * command line does not start DT earlycon immediately, instead it defers
- * starting it until DT/ACPI decision is made.  At that time if ACPI is enabled
- * call parse_spcr(), else call early_init_dt_scan_chosen_stdout()
- */
-bool earlycon_init_is_deferred __initdata;
-
 /* early_param wrapper for setup_earlycon() */
 static int __init param_setup_earlycon(char *buf)
 {
 	int err;
 
-	/*
-	 * Just 'earlycon' is a valid param for devicetree earlycons;
-	 * don't generate a warning from parse_early_params() in that case
-	 */
+	/* Just 'earlycon' is a valid param for devicetree and ACPI SPCR. */
 	if (!buf || !buf[0]) {
+		/* Do not start early console until ACPI has been enabled. */
 		if (IS_ENABLED(CONFIG_ACPI_SPCR_TABLE)) {
-			earlycon_init_is_deferred = true;
+			console_acpi_spcr_enable = true;
 			return 0;
 		} else if (!buf) {
 			return early_init_dt_scan_chosen_stdout();
include/linux/acpi.h +9 -2
index dc1ebfeeb5ec..818c1053cc6f 100644
@@ -1242,9 +1242,16 @@ static inline bool acpi_has_watchdog(void) { return false; }
 
 #ifdef CONFIG_ACPI_SPCR_TABLE
 extern bool qdf2400_e44_present;
-int parse_spcr(bool earlycon);
+#define ACPI_SPCR_OPTS_SIZE 64
+#define ACPI_SPCR_BUF_SIZE 32
+extern bool console_acpi_spcr_enable __initdata;
+extern int acpi_arch_setup_console(struct acpi_table_spcr *table,
+				   char *opts, char *uart, char *iotype,
+				   int baud_rate, bool earlycon);
+int acpi_parse_spcr(bool earlycon);
 #else
-static inline int parse_spcr(bool earlycon) { return 0; }
+static const bool console_acpi_spcr_enable;
+static inline int acpi_parse_spcr(bool earlycon) { return 0; }
 #endif
 
 #if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI)
include/linux/serial_core.h +0 -2
index 37b044e78333..abfffb4b1c37 100644
@@ -376,10 +376,8 @@ extern int of_setup_earlycon(const struct earlycon_id *match,
 			     const char *options);
 
 #ifdef CONFIG_SERIAL_EARLYCON
-extern bool earlycon_init_is_deferred __initdata;
 int setup_earlycon(char *buf);
 #else
-static const bool earlycon_init_is_deferred;
 static inline int setup_earlycon(char *buf) { return 0; }
 #endif
 
Signature · 1 line
2.15.0.rc0.39.g2f0e14e64
#6 lore raw

PATCH 2/2 acpi, x86: Use SPCR table for earlycon on x86

In reply to Prarit Bhargava

The ACPI SPCR code has been used to define an earlycon console for arm64 and can be used for x86.

Modify the ACPI SPCR parsing code to account for console behaviour differences between arm64 and x86. Initialize the SPCR code from x86 ACPI initialization code.

Cc Bhupesh Sharma <[email protected]>
Cc Lv Zheng <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 Documentation/admin-guide/kernel-parameters.txt | 3 +++
 arch/arm64/kernel/acpi.c                        | 2 +-
 arch/x86/kernel/acpi/boot.c                     | 3 +++
 drivers/acpi/Kconfig                            | 2 +-
 drivers/acpi/spcr.c                             | 5 +++--
 include/linux/acpi.h                            | 7 +++++--
 6 files changed, 16 insertions(+), 6 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +3 -0
index 0d173289c67e..c7cc890a0e81 100644
@@ -918,6 +918,9 @@
 			stdout-path property in device tree's chosen node,
 			or determined by the ACPI SPCR table.
 
+			[X86] When used with no options the early console is
+			determined by the ACPI SPCR table.
+
 		cdns,<addr>[,options]
 			Start an early, polled-mode console on a Cadence
 			(xuartps) serial port at the specified address. Only
arch/arm64/kernel/acpi.c +1 -1
index ef74e1f3e468..9d7842022d47 100644
@@ -355,7 +355,7 @@ void __init acpi_boot_table_init(void)
 			early_init_dt_scan_chosen_stdout();
 	} else {
 		/* Always enable the ACPI SPCR console */
-		acpi_parse_spcr(console_acpi_spcr_enable);
+		acpi_parse_spcr(console_acpi_spcr_enable, true);
 		if (IS_ENABLED(CONFIG_ACPI_BGRT))
 			acpi_table_parse(ACPI_SIG_BGRT, acpi_parse_bgrt);
 	}
arch/x86/kernel/acpi/boot.c +3 -0
index f4c463df8b08..4527ecbab4cb 100644
@@ -1626,6 +1626,9 @@ int __init acpi_boot_init(void)
 	if (!acpi_noirq)
 		x86_init.pci.init = pci_acpi_init;
 
+	/* Do not enable ACPI SPCR console by default */
+	acpi_parse_spcr(console_acpi_spcr_enable, console_acpi_spcr_enable);
+
 	return 0;
 }
 
drivers/acpi/Kconfig +1 -1
index ae25159dd976..6bcddd149ca7 100644
@@ -562,7 +562,7 @@ config TPS68470_PMIC_OPREGION
 
 config ACPI_SPCR_TABLE
 	bool "ACPI Serial Port Console Redirection Support"
-	default y if ARM64
+	default y if (X86 || ARM64)
 	help
 	  Enable support for Serial Port Console Redirection (SPCR) Table.
 	  This table provides information about the configuration of the
drivers/acpi/spcr.c +3 -2
index d8ad8fa67582..23abb1c207a0 100644
@@ -40,7 +40,7 @@ bool console_acpi_spcr_enable __initdata;
  * from arch initialization code as soon as the DT/ACPI decision is made.
  *
  */
-int __init acpi_parse_spcr(bool earlycon)
+int __init acpi_parse_spcr(bool earlycon, bool enable_console)
 {
 	static char opts[ACPI_SPCR_OPTS_SIZE];
 	static char uart[ACPI_SPCR_BUF_SIZE];
@@ -113,7 +113,8 @@ int __init acpi_parse_spcr(bool earlycon)
 	if (earlycon)
 		setup_earlycon(opts);
 
-	err = add_preferred_console(uart, 0, opts + strlen(uart) + 1);
+	if (enable_console)
+		err = add_preferred_console(uart, 0, opts + strlen(uart) + 1);
 done:
 	acpi_put_table((struct acpi_table_header *)table);
 	return err;
include/linux/acpi.h +5 -2
index 818c1053cc6f..252d692f017f 100644
@@ -1248,10 +1248,13 @@ extern bool console_acpi_spcr_enable __initdata;
 extern int acpi_arch_setup_console(struct acpi_table_spcr *table,
 				   char *opts, char *uart, char *iotype,
 				   int baud_rate, bool earlycon);
-int acpi_parse_spcr(bool earlycon);
+int acpi_parse_spcr(bool earlycon, bool enable_console);
 #else
 static const bool console_acpi_spcr_enable;
-static inline int acpi_parse_spcr(bool earlycon) { return 0; }
+static inline int acpi_parse_spcr(bool earlycon, bool enable_console)
+{
+	return 0;
+}
 #endif
 
 #if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI)
Signature · 1 line
2.15.0.rc0.39.g2f0e14e64
#2 lore raw

Re: [PATCH 1/2] acpi, spcr: Make SPCR avialable to other architectures

In reply to Prarit Bhargava
Quoted 9 lines · Prarit Bhargava

Other architectures can use SPCR to setup an early console or console but the current code is ARM64 specific.

Change the name of parse_spcr() to acpi_parse_spcr(). Add a weak function acpi_arch_setup_console() that can be used for arch-specific setup. Move SPCR initialization flag into ACPI code. Update the Documention on the use of the SPCR earlycon.

This patch does not change arm64 behaviour.

Let's hope so. Our E44 erratum work-around has caused lots of problems in the past, so the code is a bit fragile.

Quoted 4 lines
arch/arm64/kernel/acpi.c +4 -0
+static bool qdf2400_erratum_44_present(struct acpi_table_header *h)
+{
+       if (memcmp(h->oem_id, "QCOM  ", ACPI_OEM_ID_SIZE))
+               return false;

arch/arm64/kernel/acpi.c static int __init acpi_fadt_sanity_check(void) · line 207

Quoted 10 lines
arch/arm64/kernel/acpi.c +10 -0
+
+       if (!memcmp(h->oem_table_id, "QDF2432 ", ACPI_OEM_TABLE_ID_SIZE))
+               return true;
+
+       if (!memcmp(h->oem_table_id, "QDF2400 ", ACPI_OEM_TABLE_ID_SIZE) &&
+                       h->oem_revision == 1)
+               return true;
+
+       return false;
+}

Please give us a chance to test this patch before merging. We've had a lot of problems with our E44 work-around, and we need to make sure that qdf2400_erratum_44_present function is called before the pl011 driver is probed.

Quoted 17 lines
arch/arm64/kernel/acpi.c +17 -0
+
+/*
+ * APM X-Gene v1 and v2 UART hardware is an 16550 like device but has its
+ * register aligned to 32-bit. In addition, the BIOS also encoded the
+ * access width to be 8 bits. This function detects this errata condition.
+ */
+static bool xgene_8250_erratum_present(struct acpi_table_spcr *tb)
+{
+       bool xgene_8250 = false;
+
+       if (tb->interface_type != ACPI_DBG2_16550_COMPATIBLE)
+               return false;
+
+       if (memcmp(tb->header.oem_id, "APMC0D", ACPI_OEM_ID_SIZE) &&
+           memcmp(tb->header.oem_id, "HPE   ", ACPI_OEM_ID_SIZE))
+               return false;
+

arch/arm64/kernel/acpi.c static int __init acpi_fadt_sanity_check(void) · line 234

Quoted 10 lines
arch/arm64/kernel/acpi.c +10 -0
+       if (!memcmp(tb->header.oem_table_id, "XGENESPC",
+           ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 0)
+               xgene_8250 = true;
+
+       if (!memcmp(tb->header.oem_table_id, "ProLiant",
+           ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 1)
+               xgene_8250 = true;
+
+       return xgene_8250;
+}

I suspect that this function has the same issues as qdf2400_erratum_44_present().

drivers/acpi/Kconfig config TPS68470_PMIC_OPREGION · line 570

Quoted 8 lines
drivers/acpi/Kconfig +8 -0
+config ACPI_SPCR_TABLE
+       bool "ACPI Serial Port Console Redirection Support"
+       default y if ARM64
+       help
+         Enable support for Serial Port Console Redirection (SPCR) Table.
+         This table provides information about the configuration of the
+         earlycon console.
+

So ACPI without SPCR has never been tested by us. Making it optional makes me a little nervous. We'll have to evaluate this change.

Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#7 lore raw

Re: [PATCH 2/2] acpi, x86: Use SPCR table for earlycon on x86

In reply to Prarit Bhargava

drivers/acpi/spcr.c int __init acpi_parse_spcr(bool earlycon) · line 117

Quoted 12 lines · Prarit Bhargava
drivers/acpi/spcr.c +3 -2
-int __init acpi_parse_spcr(bool earlycon)
+int __init acpi_parse_spcr(bool earlycon, bool enable_console)
 {
        static char opts[ACPI_SPCR_OPTS_SIZE];
        static char uart[ACPI_SPCR_BUF_SIZE];
@@ -113,7 +113,8 @@ int __init acpi_parse_spcr(bool earlycon)
        if (earlycon)
                setup_earlycon(opts);
 
-       err = add_preferred_console(uart, 0, opts + strlen(uart) + 1);
+       if (enable_console)
+               err = add_preferred_console(uart, 0, opts + strlen(uart) + 1);

So if earlycon==true but enable_console==false, then you parse SPCR and use it for the early console, but not the primary console? I'm not sure what that gives you.

#8 lore raw

Re: [PATCH 2/2] acpi, x86: Use SPCR table for earlycon on x86

Quoted 10 lines · Timur Tabi
Quoted 9 lines · Prarit Bhargava
drivers/acpi/spcr.c +1 -1
-int __init acpi_parse_spcr(bool earlycon)
+int __init acpi_parse_spcr(bool earlycon, bool enable_console)
 {
        static char opts[ACPI_SPCR_OPTS_SIZE];
        static char uart[ACPI_SPCR_BUF_SIZE];
@@ -113,7 +113,8 @@ int __init acpi_parse_spcr(bool earlycon)
        if (earlycon)
                setup_earlycon(opts);
 
Quoted 8 lines

drivers/acpi/spcr.c int __init acpi_parse_spcr(bool earlycon) · line 117

Quoted 3 lines
drivers/acpi/spcr.c +2 -1
-       err = add_preferred_console(uart, 0, opts + strlen(uart) + 1);
+       if (enable_console)
+               err = add_preferred_console(uart, 0, opts + strlen(uart) + 1);

So if earlycon==true but enable_console==false, then you parse SPCR and use it for the early console, but not the primary console? I'm not sure what that gives you.

On arm64 the original SPCR code provides both early and primary consoles (as you've pointed out). IOW, if SPRC exists on arm64 a console will be initialized. That is still the case after my change.

The expected behaviour on x86 is that unless someone specifies 'earlycon' or 'console=' that no console should be initialized. There are users (some IOT boxes, etc.) that do NOT want a console.

The above code keeps the existing x86 behaviour.

P.

#3 lore raw

Re: [PATCH 1/2] acpi, spcr: Make SPCR avialable to other architectures

In reply to Timur Tabi
Quoted 25 lines · Timur Tabi
Quoted 9 lines · Prarit Bhargava

Other architectures can use SPCR to setup an early console or console but the current code is ARM64 specific.

Change the name of parse_spcr() to acpi_parse_spcr(). Add a weak function acpi_arch_setup_console() that can be used for arch-specific setup. Move SPCR initialization flag into ACPI code. Update the Documention on the use of the SPCR earlycon.

This patch does not change arm64 behaviour.

Let's hope so. Our E44 erratum work-around has caused lots of problems in the past, so the code is a bit fragile.

Quoted 11 lines
arch/arm64/kernel/acpi.c +11 -0
+static bool qdf2400_erratum_44_present(struct acpi_table_header *h)
+{
+       if (memcmp(h->oem_id, "QCOM  ", ACPI_OEM_ID_SIZE))
+               return false;
+
+       if (!memcmp(h->oem_table_id, "QDF2432 ", ACPI_OEM_TABLE_ID_SIZE))
+               return true;
+
+       if (!memcmp(h->oem_table_id, "QDF2400 ", ACPI_OEM_TABLE_ID_SIZE) &&
+                       h->oem_revision == 1)
+               return true;
Quoted 8 lines

arch/arm64/kernel/acpi.c static int __init acpi_fadt_sanity_check(void) · line 207

Quoted 3 lines
arch/arm64/kernel/acpi.c +3 -0
+
+       return false;
+}

Please give us a chance to test this patch before merging. We've had a lot of problems with our E44 work-around, and we need to make sure that qdf2400_erratum_44_present function is called before the pl011 driver is probed.

Timor, do you know of a specific system that has this problem? If so, I could see if we have one @ Red Hat and test on it to verify the WAR.

Quoted 23 lines
Quoted 23 lines
arch/arm64/kernel/acpi.c +22 -0
+
+/*
+ * APM X-Gene v1 and v2 UART hardware is an 16550 like device but has its
+ * register aligned to 32-bit. In addition, the BIOS also encoded the
+ * access width to be 8 bits. This function detects this errata condition.
+ */
+static bool xgene_8250_erratum_present(struct acpi_table_spcr *tb)
+{
+       bool xgene_8250 = false;
+
+       if (tb->interface_type != ACPI_DBG2_16550_COMPATIBLE)
+               return false;
+
+       if (memcmp(tb->header.oem_id, "APMC0D", ACPI_OEM_ID_SIZE) &&
+           memcmp(tb->header.oem_id, "HPE   ", ACPI_OEM_ID_SIZE))
+               return false;
+
+       if (!memcmp(tb->header.oem_table_id, "XGENESPC",
+           ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 0)
+               xgene_8250 = true;
+
+       if (!memcmp(tb->header.oem_table_id, "ProLiant",
Quoted 9 lines

arch/arm64/kernel/acpi.c static int __init acpi_fadt_sanity_check(void) · line 234

Quoted 5 lines
arch/arm64/kernel/acpi.c +5 -0
+           ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 1)
+               xgene_8250 = true;
+
+       return xgene_8250;
+}

I suspect that this function has the same issues as qdf2400_erratum_44_present().

Ditto.

Quoted 12 lines

drivers/acpi/Kconfig config TPS68470_PMIC_OPREGION · line 570

Quoted 8 lines
drivers/acpi/Kconfig +8 -0
+config ACPI_SPCR_TABLE
+       bool "ACPI Serial Port Console Redirection Support"
+       default y if ARM64
+       help
+         Enable support for Serial Port Console Redirection (SPCR) Table.
+         This table provides information about the configuration of the
+         earlycon console.
+

So ACPI without SPCR has never been tested by us. Making it optional makes me a little nervous. We'll have to evaluate this change.

It is 'y' for ARM64? Maybe I have that wrong but I thought that would always build it for ARM64.

P.

#4 lore raw

Re: [PATCH 1/2] acpi, spcr: Make SPCR avialable to other architectures

Quoted 7 lines · Prarit Bhargava
Quoted 4 lines

Please give us a chance to test this patch before merging. We've had a lot of problems with our E44 work-around, and we need to make sure that qdf2400_erratum_44_present function is called before the pl011 driver is probed.

Timor, do you know of a specific system that has this problem? If so, I could see if we have one @ Red Hat and test on it to verify the WAR.

Yes, Red Hat has our QDF2400 systems. You need one with 1.x silicon. Contact anyone you know in the ARM server group. Email me offline if you can't find anyone.

Quoted 28 lines
Quoted 19 lines
Quoted 19 lines

+ * APM X-Gene v1 and v2 UART hardware is an 16550 like device but has its
+ * register aligned to 32-bit. In addition, the BIOS also encoded the
+ * access width to be 8 bits. This function detects this errata condition.
+ */

arch/arm64/kernel/acpi.c +15 -0
+static bool xgene_8250_erratum_present(struct acpi_table_spcr *tb)
+{
+       bool xgene_8250 = false;
+
+       if (tb->interface_type != ACPI_DBG2_16550_COMPATIBLE)
+               return false;
+
+       if (memcmp(tb->header.oem_id, "APMC0D", ACPI_OEM_ID_SIZE) &&
+           memcmp(tb->header.oem_id, "HPE   ", ACPI_OEM_ID_SIZE))
+               return false;
+
+       if (!memcmp(tb->header.oem_table_id, "XGENESPC",
+           ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 0)
+               xgene_8250 = true;
+
Quoted 9 lines

arch/arm64/kernel/acpi.c static int __init acpi_fadt_sanity_check(void) · line 234

Quoted 6 lines
arch/arm64/kernel/acpi.c +6 -0
+       if (!memcmp(tb->header.oem_table_id, "ProLiant",
+           ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 1)
+               xgene_8250 = true;
+
+       return xgene_8250;
+}

I suspect that this function has the same issues as qdf2400_erratum_44_present().

Quoted 1 line

Ditto.

I don't know if Red Hat has any XGene systems.

Quoted 12 lines
Quoted 12 lines

drivers/acpi/Kconfig config TPS68470_PMIC_OPREGION · line 570

Quoted 9 lines
drivers/acpi/Kconfig +8 -0
+config ACPI_SPCR_TABLE
+       bool "ACPI Serial Port Console Redirection Support"
+       default y if ARM64
+       help
+         Enable support for Serial Port Console Redirection (SPCR) Table.
+         This table provides information about the configuration of the
+         earlycon console.
+

So ACPI without SPCR has never been tested by us. Making it optional makes me a little nervous. We'll have to evaluate this change.

Quoted 2 lines

It is 'y' for ARM64? Maybe I have that wrong but I thought that would always build it for ARM64.

It was forced 't' for ARM64. That is, if ACPI is enabled, SPCR is always enabled and always used. With your patch, we would need to test our kernel with console=ttyAMA0,0xfeblabla,etc to make sure that it still works.

'default y' means that some can turn SPCR off, but keep ACPI still on.

Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#9 lore raw
In reply to Prarit Bhargava
Quoted 3 lines · Prarit Bhargava

The SPCR (Serial Port Console Redirection) Table provides information about the configuration of serial port. This information can be used to configure the early console.

s/about the configuration of serial port
/about the configuration of the serial port

Quoted 6 lines

SPCR support was added for arm64 and is made available across all arches in this patchset. The first patch adds a weak per-arch configuration function and moves the SPCR code into ACPI. The second patch adds support to x86.

The existing behaviour on arm64 is maintained. If the SPCR exists the earlycon and console are automatically configured.

s/arm64
/ARM64

which is easier to read and it's also the prevalent spelling:

triton:~/tip> for N in $(git grep -ih arm64 arch/arm64/ | sed 's/[[:punct:]]/ /g'); do echo $N | grep -iw arm64; done | sort | uniq -c

     412 arm64
       1 Arm64
     854 ARM64
Quoted 4 lines

The existing default behaviour on x86 is also maintained. If no console or earlycon parameter is defined and the SPCR exists , the serial port is not configured. If the earlycon parameter is used both the early console and the console are configured using the data from the SPCR.

s/exists , the
/exists, the

But, the logic to not use the SPCR looks confusing to me.

The SPCR is only present if the user has explicitly configured a serial console for that machine, either in the firmware, or remotely via IPMI, correct? I.e. SPCR will not be spuriously present by default on systems that have a serial console but the user never expressed any interest for them, right?

If so then we should pick up that serial console configuration and activate it, regardless of any kernel boot options!

Thanks,

Ingo

#10 lore raw
Quoted 35 lines · Ingo Molnar
Quoted 3 lines · Prarit Bhargava

The SPCR (Serial Port Console Redirection) Table provides information about the configuration of serial port. This information can be used to configure the early console.

s/about the configuration of serial port
/about the configuration of the serial port

Quoted 6 lines

SPCR support was added for arm64 and is made available across all arches in this patchset. The first patch adds a weak per-arch configuration function and moves the SPCR code into ACPI. The second patch adds support to x86.

The existing behaviour on arm64 is maintained. If the SPCR exists the earlycon and console are automatically configured.

s/arm64
/ARM64

which is easier to read and it's also the prevalent spelling:

triton:~/tip> for N in $(git grep -ih arm64 arch/arm64/ | sed 's/[[:punct:]]/ /g'); do echo $N | grep -iw arm64; done | sort | uniq -c

     412 arm64
       1 Arm64
     854 ARM64
Quoted 4 lines

The existing default behaviour on x86 is also maintained. If no console or earlycon parameter is defined and the SPCR exists , the serial port is not configured. If the earlycon parameter is used both the early console and the console are configured using the data from the SPCR.

s/exists , the
/exists, the

Quoted 6 lines

But, the logic to not use the SPCR looks confusing to me.

The SPCR is only present if the user has explicitly configured a serial console for that machine, either in the firmware, or remotely via IPMI, correct? I.e. SPCR will not be spuriously present by default on systems that have a serial console but the user never expressed any interest for them, right?

If I disable "Serial Port Console Debug" in my BIOS I still see the SPCR configured:

[root@prarit-lab ~]# dmesg | grep SPCR

[    0.000000] ACPI: SPCR 0x0000000069031000 000050 (v01

00000000 00000000)

AFAICT the SPCR is always enabled on some systems.

Quoted 3 lines

If so then we should pick up that serial console configuration and activate it, regardless of any kernel boot options!

I'm worried about someone who doesn't want a console on ttyS0 suddenly ending up with one. The SPCR could contain incorrect data, etc.

I originally wanted this on by default, but the chances of breaking someone's setup seems significant doesn't it? Maybe I'm being too cautious. Anyone else want to weigh in? I'm not ignoring your idea Ingo, I'm just worried about being yelled at by a user :) because I broke their default console setup.

P.

#11 lore raw
Quoted 45 lines · Prarit Bhargava
Quoted 35 lines · Ingo Molnar
Quoted 3 lines · Prarit Bhargava

The SPCR (Serial Port Console Redirection) Table provides information about the configuration of serial port. This information can be used to configure the early console.

s/about the configuration of serial port
/about the configuration of the serial port

Quoted 6 lines

SPCR support was added for arm64 and is made available across all arches in this patchset. The first patch adds a weak per-arch configuration function and moves the SPCR code into ACPI. The second patch adds support to x86.

The existing behaviour on arm64 is maintained. If the SPCR exists the earlycon and console are automatically configured.

s/arm64
/ARM64

which is easier to read and it's also the prevalent spelling:

  triton:~/tip> for N in $(git grep -ih arm64 arch/arm64/ | sed 's/[[:punct:]]/ /g'); do echo $N | grep -iw arm64; done | sort | uniq -c
      412 arm64
        1 Arm64
      854 ARM64
Quoted 4 lines

The existing default behaviour on x86 is also maintained. If no console or earlycon parameter is defined and the SPCR exists , the serial port is not configured. If the earlycon parameter is used both the early console and the console are configured using the data from the SPCR.

s/exists , the
/exists, the

Quoted 6 lines

But, the logic to not use the SPCR looks confusing to me.

The SPCR is only present if the user has explicitly configured a serial console for that machine, either in the firmware, or remotely via IPMI, correct? I.e. SPCR will not be spuriously present by default on systems that have a serial console but the user never expressed any interest for them, right?

Quoted 7 lines

If I disable "Serial Port Console Debug" in my BIOS I still see the SPCR configured:

[root at prarit-lab ~]# dmesg | grep SPCR

[    0.000000] ACPI: SPCR 0x0000000069031000 000050 (v01

00000000 00000000)

AFAICT the SPCR is always enabled on some systems.

"Serial Port Console Debug" sounds like DBG2 to me, although I am unsure of the specific platform you are referencing.

Quoted 5 lines
Quoted 4 lines

If so then we should pick up that serial console configuration and activate it, regardless of any kernel boot options!

Quoted 8 lines

I'm worried about someone who doesn't want a console on ttyS0 suddenly ending up with one. The SPCR could contain incorrect data, etc.

I originally wanted this on by default, but the chances of breaking someone's setup seems significant doesn't it? Maybe I'm being too cautious. Anyone else want to weigh in? I'm not ignoring your idea Ingo, I'm just worried about being yelled at by a user :) because I broke their default console setup.

SPCR is always present on QDF2400 (ARM64 platform). Firmware will automatically update the SPCR table to point to the correct console (IE Serial-over-LAN or SOL if configured via IPMI). Unless a user specifically chooses to override the SPCR via "console=", we expect that a console will be present based on the data in SPCR.

Signature · 5 lines
Jeffrey Hugo
Qualcomm Datacenter Technologies as an affiliate of Qualcomm 
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#12 lore raw
Quoted 74 lines · Jeffrey Hugo
Quoted 47 lines · Prarit Bhargava
Quoted 36 lines · Ingo Molnar
Quoted 3 lines · Prarit Bhargava

The SPCR (Serial Port Console Redirection) Table provides information about the configuration of serial port. This information can be used to configure the early console.

s/about the configuration of serial port
/about the configuration of the serial port

Quoted 6 lines

SPCR support was added for arm64 and is made available across all arches in this patchset. The first patch adds a weak per-arch configuration function and moves the SPCR code into ACPI. The second patch adds support to x86.

The existing behaviour on arm64 is maintained. If the SPCR exists the earlycon and console are automatically configured.

s/arm64
/ARM64

which is easier to read and it's also the prevalent spelling:

triton:~/tip> for N in $(git grep -ih arm64 arch/arm64/ | sed
's/[[:punct:]]/ /g'); do echo $N | grep -iw arm64; done | sort | uniq -c

      412 arm64
        1 Arm64
      854 ARM64
Quoted 4 lines

The existing default behaviour on x86 is also maintained. If no console or earlycon parameter is defined and the SPCR exists , the serial port is not configured. If the earlycon parameter is used both the early console and the console are configured using the data from the SPCR.

s/exists , the
/exists, the

Quoted 7 lines

But, the logic to not use the SPCR looks confusing to me.

The SPCR is only present if the user has explicitly configured a serial console for that machine, either in the firmware, or remotely via IPMI, correct? I.e. SPCR
will not be spuriously present by default on systems that have a serial console but the user never expressed any interest for them, right?

Quoted 8 lines

If I disable "Serial Port Console Debug" in my BIOS I still see the SPCR configured:

[root at prarit-lab ~]# dmesg | grep SPCR

[    0.000000] ACPI: SPCR 0x0000000069031000 000050 (v01

00000000 00000000)

AFAICT the SPCR is always enabled on some systems.

"Serial Port Console Debug" sounds like DBG2 to me, although I am unsure of the specific platform you are referencing.

Quoted 5 lines
Quoted 4 lines

If so then we should pick up that serial console configuration and activate it, regardless of any kernel boot options!

Quoted 8 lines

I'm worried about someone who doesn't want a console on ttyS0 suddenly ending up with one. The SPCR could contain incorrect data, etc.

I originally wanted this on by default, but the chances of breaking someone's setup seems significant doesn't it? Maybe I'm being too cautious. Anyone else want to weigh in? I'm not ignoring your idea Ingo, I'm just worried about being yelled at by a user :) because I broke their default console setup.

Quoted 5 lines

SPCR is always present on QDF2400 (ARM64 platform). Firmware will automatically update the SPCR table to point to the correct console (IE Serial-over-LAN or SOL if configured via IPMI). Unless a user specifically chooses to override the SPCR via "console=", we expect that a console will be present based on the data in SPCR.

Hey Jeffrey -- I think Ingo's & my conversation is x86-specific. I am *NOT* changing the behaviour on ARM64.

P.

Quoted 1 line
#5 lore raw

Re: [PATCH 1/2] acpi, spcr: Make SPCR avialable to other architectures

In reply to Timur Tabi
Quoted 9 lines · Timur Tabi
Quoted 8 lines · Prarit Bhargava

Other architectures can use SPCR to setup an early console or console but the current code is ARM64 specific.

Change the name of parse_spcr() to acpi_parse_spcr(). Add a weak function acpi_arch_setup_console() that can be used for arch-specific setup. Move SPCR initialization flag into ACPI code. Update the Documention on the use of the SPCR earlycon.

Quoted 4 lines
Quoted 1 line

This patch does not change arm64 behaviour.

Let's hope so. Our E44 erratum work-around has caused lots of problems in the past, so the code is a bit fragile.

So it does look like I broke something :( I'll fix this and do more testing. One thing that I just learned (relative to x86) is that you have to test much further and wider than on x86.

P.

Quoted 64 lines
Quoted 5 lines
arch/arm64/kernel/acpi.c +4 -0
+static bool qdf2400_erratum_44_present(struct acpi_table_header *h)
+{
+       if (memcmp(h->oem_id, "QCOM  ", ACPI_OEM_ID_SIZE))
+               return false;

arch/arm64/kernel/acpi.c static int __init acpi_fadt_sanity_check(void) · line 207

Quoted 10 lines
arch/arm64/kernel/acpi.c +10 -0
+
+       if (!memcmp(h->oem_table_id, "QDF2432 ", ACPI_OEM_TABLE_ID_SIZE))
+               return true;
+
+       if (!memcmp(h->oem_table_id, "QDF2400 ", ACPI_OEM_TABLE_ID_SIZE) &&
+                       h->oem_revision == 1)
+               return true;
+
+       return false;
+}

Please give us a chance to test this patch before merging. We've had a lot of problems with our E44 work-around, and we need to make sure that qdf2400_erratum_44_present function is called before the pl011 driver is probed.

Quoted 17 lines
arch/arm64/kernel/acpi.c +17 -0
+
+/*
+ * APM X-Gene v1 and v2 UART hardware is an 16550 like device but has its
+ * register aligned to 32-bit. In addition, the BIOS also encoded the
+ * access width to be 8 bits. This function detects this errata condition.
+ */
+static bool xgene_8250_erratum_present(struct acpi_table_spcr *tb)
+{
+       bool xgene_8250 = false;
+
+       if (tb->interface_type != ACPI_DBG2_16550_COMPATIBLE)
+               return false;
+
+       if (memcmp(tb->header.oem_id, "APMC0D", ACPI_OEM_ID_SIZE) &&
+           memcmp(tb->header.oem_id, "HPE   ", ACPI_OEM_ID_SIZE))
+               return false;
+

arch/arm64/kernel/acpi.c static int __init acpi_fadt_sanity_check(void) · line 234

Quoted 10 lines
arch/arm64/kernel/acpi.c +10 -0
+       if (!memcmp(tb->header.oem_table_id, "XGENESPC",
+           ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 0)
+               xgene_8250 = true;
+
+       if (!memcmp(tb->header.oem_table_id, "ProLiant",
+           ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 1)
+               xgene_8250 = true;
+
+       return xgene_8250;
+}

I suspect that this function has the same issues as qdf2400_erratum_44_present().

drivers/acpi/Kconfig config TPS68470_PMIC_OPREGION · line 570

Quoted 8 lines
drivers/acpi/Kconfig +8 -0
+config ACPI_SPCR_TABLE
+       bool "ACPI Serial Port Console Redirection Support"
+       default y if ARM64
+       help
+         Enable support for Serial Port Console Redirection (SPCR) Table.
+         This table provides information about the configuration of the
+         earlycon console.
+

So ACPI without SPCR has never been tested by us. Making it optional makes me a little nervous. We'll have to evaluate this change.

#13 lore raw
In reply to Prarit Bhargava
Quoted 7 lines · Prarit Bhargava

If I disable "Serial Port Console Debug" in my BIOS I still see the SPCR configured:

[root@prarit-lab ~]# dmesg | grep SPCR

[    0.000000] ACPI: SPCR 0x0000000069031000 000050 (v01

00000000 00000000)

AFAICT the SPCR is always enabled on some systems.

It's part of some of the Windows design flows that it gets incorporated, and it should always be present.

Jon (not talking about AArch64/ARM/arm/ARMv8-A/64-bit ARM/Go ARM Go).

#14 lore raw
In reply to Prarit Bhargava
Quoted 7 lines · Prarit Bhargava

If I disable "Serial Port Console Debug" in my BIOS I still see the SPCR configured:

[root at prarit-lab ~]# dmesg | grep SPCR

[    0.000000] ACPI: SPCR 0x0000000069031000 000050 (v01

00000000 00000000)

AFAICT the SPCR is always enabled on some systems.

Fair enough.

Quoted 5 lines
Quoted 2 lines

If so then we should pick up that serial console configuration and activate it, regardless of any kernel boot options!

I'm worried about someone who doesn't want a console on ttyS0 suddenly ending up with one. The SPCR could contain incorrect data, etc.

Yeah, that's not good.

Thanks,

Ingo