Skip to contentSkip to conversation

ACPI: SPCR: Support Precise Baud Rate filed

PATCH Superseded [email protected] 3 participants 5 messages Sep 12, 2025 – Sep 13, 2025 ACPI

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ACPI: SPCR: Support Precise Baud Rate filed

From: Chen Pei <[email protected]>

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.

---
 drivers/acpi/spcr.c | 54 ++++++++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 23 deletions(-)
drivers/acpi/spcr.c +31 -23
index cd36a97b0ea2..a97b02ee5538 100644
@@ -146,29 +146,37 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console)
 		goto done;
 	}
 
-	switch (table->baud_rate) {
-	case 0:
-		/*
-		 * SPCR 1.04 defines 0 as a preconfigured state of UART.
-		 * Assume firmware or bootloader configures console correctly.
-		 */
-		baud_rate = 0;
-		break;
-	case 3:
-		baud_rate = 9600;
-		break;
-	case 4:
-		baud_rate = 19200;
-		break;
-	case 6:
-		baud_rate = 57600;
-		break;
-	case 7:
-		baud_rate = 115200;
-		break;
-	default:
-		err = -ENOENT;
-		goto done;
+	/*
+	 * 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.
+			 * Assume firmware or bootloader configures console correctly.
+			 */
+			baud_rate = 0;
+			break;
+		case 3:
+			baud_rate = 9600;
+			break;
+		case 4:
+			baud_rate = 19200;
+			break;
+		case 6:
+			baud_rate = 57600;
+			break;
+		case 7:
+			baud_rate = 115200;
+			break;
+		default:
+			err = -ENOENT;
+			goto done;
 	}
 
 	/*
Signature · 1 line
2.49.0
#1 lore raw
Quoted 50 lines · On Fri, Sep 12, 2025 at 2:25 PM <[email protected]> wrote:

From: Chen Pei <[email protected]>

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.

---
 drivers/acpi/spcr.c | 54 ++++++++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 23 deletions(-)
drivers/acpi/spcr.c +0 -22
index cd36a97b0ea2..a97b02ee5538 100644
@@ -146,29 +146,37 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console)
                goto done;
        }
 
-       switch (table->baud_rate) {
-       case 0:
-               /*
-                * SPCR 1.04 defines 0 as a preconfigured state of UART.
-                * Assume firmware or bootloader configures console correctly.
-                */
-               baud_rate = 0;
-               break;
-       case 3:
-               baud_rate = 9600;
-               break;
-       case 4:
-               baud_rate = 19200;
-               break;
-       case 6:
-               baud_rate = 57600;
-               break;
-       case 7:
-               baud_rate = 115200;
-               break;
-       default:
-               err = -ENOENT;

drivers/acpi/spcr.c int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console) · line 157

Quoted 10 lines
drivers/acpi/spcr.c +9 -1
-               goto done;
+       /*
+        * 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) {

Please do not change the indentation below.

Quoted 28 lines
drivers/acpi/spcr.c +22 -1
+               case 0:
+                       /*
+                        * SPCR 1.04 defines 0 as a preconfigured state of UART.
+                        * Assume firmware or bootloader configures console correctly.
+                        */
+                       baud_rate = 0;
+                       break;
+               case 3:
+                       baud_rate = 9600;
+                       break;
+               case 4:
+                       baud_rate = 19200;
+                       break;
+               case 6:
+                       baud_rate = 57600;
+                       break;
+               case 7:
+                       baud_rate = 115200;
+                       break;
+               default:
+                       err = -ENOENT;
+                       goto done;
        }
 
        /*
--

2.49.0

#2 lore raw
Quoted 4 lines · On Fri, 12 Sep 2025 16:02:58 +0200, [email protected] wrote:

drivers/acpi/spcr.c int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console)

Quoted 3 lines
drivers/acpi/spcr.c +3 -0
+       if (table->precise_baudrate)
+               baud_rate = table->precise_baudrate;
+       else switch (table->baud_rate) {> 
Quoted 9 lines

Please do not change the indentation below.>

Quoted 7 lines
drivers/acpi/spcr.c +7 -0
+               case 0:
+                       /*
+                        * SPCR 1.04 defines 0 as a preconfigured state of UART.
+                        * Assume firmware or bootloader configures console correctly.
+                        */
+                       baud_rate = 0;
+                       break;

I got it.

#3 lore raw
In reply to [email protected]
Quoted 11 lines · On Fri, Sep 12, 2025 at 8:25 PM <[email protected]> wrote:

From: Chen Pei <[email protected]>

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

The spec states that it would "override" the baud rate. That means it should happen behind the table->baud_rate or firmware still needs to give out a legal Configured Baud Rate for precise_baudrate.

Then, we move these:
+ if (table->precise_baudrate)
+ baud_rate = table->precise_baudrate;
behind the "switch (table->baud_rate) {}".

Right?

Quoted 77 lines

present, Configured Baud Rate is used.

---
 drivers/acpi/spcr.c | 54 ++++++++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 23 deletions(-)
drivers/acpi/spcr.c +31 -24
index cd36a97b0ea2..a97b02ee5538 100644
@@ -146,29 +146,37 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console)
                goto done;
        }
 
-       switch (table->baud_rate) {
-       case 0:
-               /*
-                * SPCR 1.04 defines 0 as a preconfigured state of UART.
-                * Assume firmware or bootloader configures console correctly.
-                */
-               baud_rate = 0;
-               break;
-       case 3:
-               baud_rate = 9600;
-               break;
-       case 4:
-               baud_rate = 19200;
-               break;
-       case 6:
-               baud_rate = 57600;
-               break;
-       case 7:
-               baud_rate = 115200;
-               break;
-       default:
-               err = -ENOENT;
-               goto done;
+       /*
+        * 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.
+                        * Assume firmware or bootloader configures console correctly.
+                        */
+                       baud_rate = 0;
+                       break;
+               case 3:
+                       baud_rate = 9600;
+                       break;
+               case 4:
+                       baud_rate = 19200;
+                       break;
+               case 6:
+                       baud_rate = 57600;
+                       break;
+               case 7:
+                       baud_rate = 115200;
+                       break;
+               default:
+                       err = -ENOENT;
+                       goto done;
        }
 
        /*
--

2.49.0

Signature · 2 lines
Best Regards
 Guo Ren
#4 lore raw
Quoted 11 lines · On Sat, 13 Sep 2025 13:24:21 +0800, [email protected] wrote:
Quoted 2 lines

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

The spec states that it would "override" the baud rate. That means it should happen behind the table->baud_rate or firmware still needs to give out a legal Configured Baud Rate for precise_baudrate.>

Then, we move these:

drivers/acpi/spcr.c +2 -0
+       if (table->precise_baudrate)
+               baud_rate = table->precise_baudrate;

behind the "switch (table->baud_rate) {}".>

Quoted 3 lines

Right?>

Quoted 1 line

present, Configured Baud Rate is used.

OK, I think "override" means priority in a sense, there is no need to do an overriding action in the behavior.