Skip to contentSkip to conversation

arm: io: Set is_pl011_uart flag in ACPI initialization

PATCH In review Colton Lewis 2 participants 3 messages Jun 19 – Jun 26

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 arm: io: Set is_pl011_uart flag in ACPI initialization

When booting via ACPI on ARM64, the SPCR table is parsed to initialize the console UART. However, the code was neglecting to set the is_pl011_uart flag. This caused __getchar() to fall back to treating the UART as a 16550A device, which fails on systems with a PL011.

Tests that wait for serial input (like its-migration) would hang indefinitely because __getchar() would always return -1.

Update uart0_init_acpi() to inspect the SPCR interface_type and set is_pl011_uart accordingly. Also define DBG2 macros for SPCR interface types in lib/acpi.h.

---
v2:
- Align macro names with Linux kernel DBG2 definitions (Alexandru Elisei).

v1:
https://lore.kernel.org/r/[email protected]

 lib/acpi.h   | 6 ++++++
 lib/arm/io.c | 3 +++
 2 files changed, 9 insertions(+)
lib/acpi.h +6 -0
index 66e3062d..a62cd3a9 100644
@@ -251,6 +251,12 @@ enum acpi_madt_type {
 /* MADT Local APIC flags */
 #define ACPI_MADT_ENABLED		(1)	/* 00: Processor is usable if set */
 
+/* Values for interface_type field in struct spcr_descriptor */
+#define ACPI_DBG2_16550_COMPATIBLE	0x0000
+#define ACPI_DBG2_16550_SUBSET		0x0001
+#define ACPI_DBG2_MAX311XE_SPI		0x0002
+#define ACPI_DBG2_ARM_PL011		0x0003
+
 struct spcr_descriptor {
 	ACPI_TABLE_HEADER_DEF	/* ACPI common table header */
 	u8 interface_type;	/* 0=full 16550, 1=subset of 16550 */
lib/arm/io.c +3 -0
index 836fa854..9c07fa3d 100644
@@ -81,6 +81,9 @@ static void uart0_init_acpi(void)
 
 	assert_msg(spcr, "Unable to find ACPI SPCR");
 	uart0_base = ioremap(spcr->serial_port.address, spcr->serial_port.bit_width);
+
+	if (spcr->interface_type == ACPI_DBG2_ARM_PL011)
+		is_pl011_uart = true;
 }
 #else
 
Signature · 1 line
2.55.0.rc0.738.g0c8ab3ebcc-goog
#1 lore raw
Quoted 20 lines · Colton Lewis

When booting via ACPI on ARM64, the SPCR table is parsed to initialize the console UART. However, the code was neglecting to set the is_pl011_uart flag. This caused __getchar() to fall back to treating the UART as a 16550A device, which fails on systems with a PL011.

Tests that wait for serial input (like its-migration) would hang indefinitely because __getchar() would always return -1.

Update uart0_init_acpi() to inspect the SPCR interface_type and set is_pl011_uart accordingly. Also define DBG2 macros for SPCR interface types in lib/acpi.h.

---
v2:
- Align macro names with Linux kernel DBG2 definitions (Alexandru Elisei).

Quoted 7 lines

v1:
https://lore.kernel.org/r/[email protected]

 lib/acpi.h   | 6 ++++++
 lib/arm/io.c | 3 +++
 2 files changed, 9 insertions(+)

Added

Fixes 8c065edf33c0 ("lib/arm/io: Fix calling getchar() multiple times")

and queued, https://gitlab.com/jones-drew/kvm-unit-tests/-/commits/arm/queue

Thanks,
drew

#2 lore raw
Quoted 29 lines · Andrew Jones
Quoted 20 lines · Colton Lewis

When booting via ACPI on ARM64, the SPCR table is parsed to initialize the console UART. However, the code was neglecting to set the is_pl011_uart flag. This caused __getchar() to fall back to treating the UART as a 16550A device, which fails on systems with a PL011.

Tests that wait for serial input (like its-migration) would hang indefinitely because __getchar() would always return -1.

Update uart0_init_acpi() to inspect the SPCR interface_type and set is_pl011_uart accordingly. Also define DBG2 macros for SPCR interface types in lib/acpi.h.

---
v2:
- Align macro names with Linux kernel DBG2 definitions (Alexandru Elisei).

Quoted 7 lines

v1:
https://lore.kernel.org/r/[email protected]

 lib/acpi.h   | 6 ++++++
 lib/arm/io.c | 3 +++
 2 files changed, 9 insertions(+)
Quoted 6 lines

Added

Fixes 8c065edf33c0 ("lib/arm/io: Fix calling getchar() multiple times")

and queued, https://gitlab.com/jones-drew/kvm-unit-tests/-/commits/arm/queue

Merged.

Thanks,
drew