From: Chen Pei cp0613@linux.alibaba.com
[ Upstream commit 4d330fe54145ecfbb657ac01a554fdedf3c1927e ]
The Microsoft Serial Port Console Redirection (SPCR) specification revision 1.09 comprises additional field: Precise Baud Rate [1].
It is used to describe non-traditional baud rates (such as those used by high-speed UARTs).
It contains a specific non-zero baud rate which overrides the value of the Configured Baud Rate field. If this field is zero or not present, Configured Baud Rate is used.
Link: https://learn.microsoft.com/en-us/windows-hardware/drivers/serports/serial-p... [1] Signed-off-by: Chen Pei cp0613@linux.alibaba.com Link: https://patch.msgid.link/20250913070815.16758-1-cp0613@linux.alibaba.com [ rjw: Corrected typo in the subject ] Signed-off-by: Rafael J. Wysocki rafael.j.wysocki@intel.com Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
- What it changes and why it matters: - Adds support for the SPCR “Precise Baud Rate” field so the kernel honors non‑standard/high‑speed UART baud rates from firmware. The new logic checks `table->precise_baudrate` and, if non‑zero, uses it; otherwise it falls back to the existing enumerated “Configured Baud Rate” mapping. - Code reference: drivers/acpi/spcr.c:153 adds the explanatory comment and the override logic; drivers/acpi/spcr.c:158 uses `if (table->precise_baudrate) baud_rate = table->precise_baudrate; else switch (table->baud_rate) { ... }`. - Without this, systems that publish a precise baud in SPCR (e.g., 1.5M, 3M, etc.) end up with an incorrect console configuration (typically 115200), breaking or garbling the serial console. This is a user-visible bug in environments that follow SPCR 1.09+.
- Scope and risk: - Minimal, self‑contained change in one file (drivers/acpi/spcr.c). It does not alter console selection logic, I/O type decisions, or errata handling; it only sets `baud_rate` earlier when the field is present, leaving the long‑standing switch on `table->baud_rate` unchanged. - No architectural or behavioral changes beyond honoring an existing spec field. No new features; this is a spec‑compliance fix.
- Dependencies and compatibility: - Requires the ACPICA header update that introduced the field in `struct acpi_table_spcr`: - Code reference: include/acpi/actbl3.h:124 defines `u32 precise_baudrate;` (added by “ACPICA: SPCR: Update the SPCR table to version 4”, present from v6.12 and newer). - For stable trees older than v6.12, this commit will not compile unless that ACPICA update (and its related SPCR struct changes) is backported first. Backporting both together is straightforward and low‑risk, as the header change is additive and this code only reads the new field.
- Subtlety to be aware of: - The SPCR spec says the precise field “overrides” when non‑zero; if zero or not present, use the configured enumerated value. The code implements this correctly by falling back to the existing switch when the field is zero (drivers/acpi/spcr.c:158). - As upstream implemented, there is no explicit table-length check before reading `precise_baudrate`. This matches mainline, but when backporting to very old kernels and encountering very old SPCR revisions, maintainers may optionally add a guard using `table->header.length` to be extra defensive. Not required for v6.12+ where the header and field are in place.
- Stable backport criteria: - Fixes a real, user‑visible issue (misconfigured or non‑functional serial console on systems using SPCR precise baud). - Small and localized change with minimal regression risk. - No architectural churn or new feature exposure. - Touches the ACPI SPCR parsing path only; console setup remains unchanged aside from using the correct baud.
Conclusion: This is a good candidate for stable backport, provided the target stable series already contains (or is backported with) the SPCR v4 ACPICA header update that defines `precise_baudrate`.
drivers/acpi/spcr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c index cd36a97b0ea2c..fa12e740386de 100644 --- a/drivers/acpi/spcr.c +++ b/drivers/acpi/spcr.c @@ -146,7 +146,15 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console) goto done; }
- switch (table->baud_rate) { + /* + * SPCR 1.09 defines Precise Baud Rate Filed contains a specific + * non-zero baud rate which overrides the value of the Configured + * Baud Rate field. If this field is zero or not present, Configured + * Baud Rate is used. + */ + if (table->precise_baudrate) + baud_rate = table->precise_baudrate; + else switch (table->baud_rate) { case 0: /* * SPCR 1.04 defines 0 as a preconfigured state of UART.