All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] x86/boot: use BASE_BAUD and DEFAULT_SERIAL_PORT
@ 2026-05-15 11:10 Thorsten Blum
  2026-06-04 15:23 ` Thorsten Blum
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2026-05-15 11:10 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Thorsten Blum
  Cc: linux-kernel

Replace the hard-coded divisor and ttyS0 port with the existing
BASE_BAUD and DEFAULT_SERIAL_PORT macros.

In parse_earlyprintk(), assign port directly and drop the redundant
index variable as well as the bases array to simplify the code.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Changes in v2:
- Drop patch 1/2 from the series after feedback from Dave
- v1: https://lore.kernel.org/lkml/20260411153449.69384-4-thorsten.blum@linux.dev/
---
 arch/x86/boot/early_serial_console.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
index 023bf1c3de8b..caf481cdd415 100644
--- a/arch/x86/boot/early_serial_console.c
+++ b/arch/x86/boot/early_serial_console.c
@@ -22,6 +22,7 @@
 #define DLH             1       /*  Divisor latch High        */
 
 #define DEFAULT_BAUD 9600
+#define BASE_BAUD (1843200/16)
 
 static void early_serial_init(int port, int baud)
 {
@@ -33,7 +34,7 @@ static void early_serial_init(int port, int baud)
 	outb(0, port + FCR);	/* no fifo */
 	outb(0x3, port + MCR);	/* DTR + RTS */
 
-	divisor	= 115200 / baud;
+	divisor	= BASE_BAUD / baud;
 	c = inb(port + LCR);
 	outb(c | DLAB, port + LCR);
 	outb(divisor & 0xff, port + DLL);
@@ -74,16 +75,13 @@ static void parse_earlyprintk(void)
 			else
 				pos = e - arg;
 		} else if (!strncmp(arg + pos, "ttyS", 4)) {
-			static const int bases[] = { 0x3f8, 0x2f8 };
-			int idx = 0;
-
 			/* += strlen("ttyS"); */
 			pos += 4;
 
 			if (arg[pos++] == '1')
-				idx = 1;
-
-			port = bases[idx];
+				port = 0x2f8; /* ttyS1 */
+			else
+				port = DEFAULT_SERIAL_PORT;
 		}
 
 		if (arg[pos] == ',')
@@ -98,7 +96,6 @@ static void parse_earlyprintk(void)
 		early_serial_init(port, baud);
 }
 
-#define BASE_BAUD (1843200/16)
 static unsigned int probe_baud(int port)
 {
 	unsigned char lcr, dll, dlh;

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

* Re: [PATCH v2] x86/boot: use BASE_BAUD and DEFAULT_SERIAL_PORT
  2026-05-15 11:10 [PATCH v2] x86/boot: use BASE_BAUD and DEFAULT_SERIAL_PORT Thorsten Blum
@ 2026-06-04 15:23 ` Thorsten Blum
  2026-06-04 20:22   ` Dave Hansen
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2026-06-04 15:23 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin
  Cc: linux-kernel

Gentle ping?

On Fri, May 15, 2026 at 01:10:40PM +0200, Thorsten Blum wrote:
> Replace the hard-coded divisor and ttyS0 port with the existing
> BASE_BAUD and DEFAULT_SERIAL_PORT macros.
> 
> In parse_earlyprintk(), assign port directly and drop the redundant
> index variable as well as the bases array to simplify the code.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> Changes in v2:
> - Drop patch 1/2 from the series after feedback from Dave
> - v1: https://lore.kernel.org/lkml/20260411153449.69384-4-thorsten.blum@linux.dev/
> ---
>  arch/x86/boot/early_serial_console.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
> index 023bf1c3de8b..caf481cdd415 100644
> --- a/arch/x86/boot/early_serial_console.c
> +++ b/arch/x86/boot/early_serial_console.c
> @@ -22,6 +22,7 @@
>  #define DLH             1       /*  Divisor latch High        */
>  
>  #define DEFAULT_BAUD 9600
> +#define BASE_BAUD (1843200/16)
>  
>  static void early_serial_init(int port, int baud)
>  {
> @@ -33,7 +34,7 @@ static void early_serial_init(int port, int baud)
>  	outb(0, port + FCR);	/* no fifo */
>  	outb(0x3, port + MCR);	/* DTR + RTS */
>  
> -	divisor	= 115200 / baud;
> +	divisor	= BASE_BAUD / baud;
>  	c = inb(port + LCR);
>  	outb(c | DLAB, port + LCR);
>  	outb(divisor & 0xff, port + DLL);
> @@ -74,16 +75,13 @@ static void parse_earlyprintk(void)
>  			else
>  				pos = e - arg;
>  		} else if (!strncmp(arg + pos, "ttyS", 4)) {
> -			static const int bases[] = { 0x3f8, 0x2f8 };
> -			int idx = 0;
> -
>  			/* += strlen("ttyS"); */
>  			pos += 4;
>  
>  			if (arg[pos++] == '1')
> -				idx = 1;
> -
> -			port = bases[idx];
> +				port = 0x2f8; /* ttyS1 */
> +			else
> +				port = DEFAULT_SERIAL_PORT;
>  		}
>  
>  		if (arg[pos] == ',')
> @@ -98,7 +96,6 @@ static void parse_earlyprintk(void)
>  		early_serial_init(port, baud);
>  }
>  
> -#define BASE_BAUD (1843200/16)
>  static unsigned int probe_baud(int port)
>  {
>  	unsigned char lcr, dll, dlh;

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

* Re: [PATCH v2] x86/boot: use BASE_BAUD and DEFAULT_SERIAL_PORT
  2026-06-04 15:23 ` Thorsten Blum
@ 2026-06-04 20:22   ` Dave Hansen
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Hansen @ 2026-06-04 20:22 UTC (permalink / raw)
  To: Thorsten Blum, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin
  Cc: linux-kernel

On 6/4/26 08:23, Thorsten Blum wrote:
> Gentle ping?

I put this in my queue of things to look at after the next -rc1. This is
a very small cleanup, but it's in an utterly critical piece of debugging
code. The last thing I want to do is make a boot bug harder to debug
because the early console code broke.

I was kinda hoping some testing might materialize between now and then.

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

end of thread, other threads:[~2026-06-04 20:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-15 11:10 [PATCH v2] x86/boot: use BASE_BAUD and DEFAULT_SERIAL_PORT Thorsten Blum
2026-06-04 15:23 ` Thorsten Blum
2026-06-04 20:22   ` Dave Hansen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.