* [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit)
@ 2025-05-02 12:29 Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 1/6] x86/boot: Convert early_serial_base to unsigned long Andy Shevchenko
` (7 more replies)
0 siblings, 8 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-02 12:29 UTC (permalink / raw)
To: Andy Shevchenko, Ashish Kalra, Kirill A. Shutemov, linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, David Woodhouse, Denis Mukhin
Some of the platforms may have no legacy COM ports and only provide
an MMIO accessible UART. Add support for such to earlyprintk for the
boot phase of the kernel.
Andy Shevchenko (6):
x86/boot: Convert early_serial_base to unsigned long
x86/boot: Introduce helpers for serial I/O
x86/boot: Split out parse_serial_port() helper for earlyprintk
x86/boot: Allow longer parameter list for earlyprintk
x86/boot: Also share MMIO accessors
x86/boot: Introduce MMIO accessors and their support in earlyprintk
arch/x86/boot/boot.h | 4 +-
.../boot/compressed/early_serial_console.c | 5 +-
arch/x86/boot/compressed/misc.c | 4 +-
arch/x86/boot/compressed/misc.h | 8 +-
arch/x86/boot/early_serial_console.c | 114 ++++++++++++++----
arch/x86/boot/tty.c | 9 +-
arch/x86/include/asm/io.h | 65 ----------
arch/x86/include/asm/shared/io.h | 68 +++++++++++
8 files changed, 177 insertions(+), 100 deletions(-)
--
2.47.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v1 1/6] x86/boot: Convert early_serial_base to unsigned long
2025-05-02 12:29 [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) Andy Shevchenko
@ 2025-05-02 12:29 ` Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 2/6] x86/boot: Introduce helpers for serial I/O Andy Shevchenko
` (6 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-02 12:29 UTC (permalink / raw)
To: Andy Shevchenko, Ashish Kalra, Kirill A. Shutemov, linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, David Woodhouse, Denis Mukhin
As a preparatory of adding flexible serial I/O accessors, convert
early_serial_base to unsigned long to cover all possible bus addresses
on the system.
No functional change intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/x86/boot/boot.h | 2 +-
arch/x86/boot/compressed/early_serial_console.c | 2 +-
arch/x86/boot/compressed/misc.h | 4 ++--
arch/x86/boot/early_serial_console.c | 6 +++---
arch/x86/boot/tty.c | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
index 38f17a1e1e36..753f429b28cb 100644
--- a/arch/x86/boot/boot.h
+++ b/arch/x86/boot/boot.h
@@ -274,7 +274,7 @@ int check_knl_erratum(void);
int validate_cpu(void);
/* early_serial_console.c */
-extern int early_serial_base;
+extern unsigned long early_serial_base;
void console_init(void);
/* edd.c */
diff --git a/arch/x86/boot/compressed/early_serial_console.c b/arch/x86/boot/compressed/early_serial_console.c
index 70a8d1706d0f..5b8db03f40ad 100644
--- a/arch/x86/boot/compressed/early_serial_console.c
+++ b/arch/x86/boot/compressed/early_serial_console.c
@@ -1,6 +1,6 @@
#include "misc.h"
/* This might be accessed before .bss is cleared, so use .data instead. */
-int early_serial_base __section(".data");
+unsigned long early_serial_base __section(".data");
#include "../early_serial_console.c"
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index dd8d1a85f671..f083360c84c1 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -127,10 +127,10 @@ extern unsigned char _pgtable[];
#ifdef CONFIG_EARLY_PRINTK
/* early_serial_console.c */
-extern int early_serial_base;
+extern unsigned long early_serial_base;
void console_init(void);
#else
-static const int early_serial_base;
+static const unsigned long early_serial_base;
static inline void console_init(void)
{ }
#endif
diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
index 023bf1c3de8b..7a7766fa16e5 100644
--- a/arch/x86/boot/early_serial_console.c
+++ b/arch/x86/boot/early_serial_console.c
@@ -23,7 +23,7 @@
#define DEFAULT_BAUD 9600
-static void early_serial_init(int port, int baud)
+static void early_serial_init(unsigned long port, int baud)
{
unsigned char c;
unsigned divisor;
@@ -46,9 +46,9 @@ static void early_serial_init(int port, int baud)
static void parse_earlyprintk(void)
{
int baud = DEFAULT_BAUD;
+ unsigned long port = 0;
char arg[32];
int pos = 0;
- int port = 0;
if (cmdline_find_option("earlyprintk", arg, sizeof(arg)) > 0) {
char *e;
@@ -118,7 +118,7 @@ static void parse_console_uart8250(void)
{
char optstr[64], *options;
int baud = DEFAULT_BAUD;
- int port = 0;
+ unsigned long port = 0;
/*
* console=uart8250,io,0x3f8,115200n8
diff --git a/arch/x86/boot/tty.c b/arch/x86/boot/tty.c
index f7eb976b0a4b..e2ab8b8076ef 100644
--- a/arch/x86/boot/tty.c
+++ b/arch/x86/boot/tty.c
@@ -13,7 +13,7 @@
#include "boot.h"
-int early_serial_base;
+unsigned long early_serial_base;
#define XMTRDY 0x20
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 2/6] x86/boot: Introduce helpers for serial I/O
2025-05-02 12:29 [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 1/6] x86/boot: Convert early_serial_base to unsigned long Andy Shevchenko
@ 2025-05-02 12:29 ` Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 3/6] x86/boot: Split out parse_serial_port() helper for earlyprintk Andy Shevchenko
` (5 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-02 12:29 UTC (permalink / raw)
To: Andy Shevchenko, Ashish Kalra, Kirill A. Shutemov, linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, David Woodhouse, Denis Mukhin
As preparatory to enable earlyprintk on non-standard ports on x86,
introduce serial_in() and serial_out() helpers to perform serial I/O.
No functional change intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/x86/boot/boot.h | 2 +
.../boot/compressed/early_serial_console.c | 3 +
arch/x86/boot/compressed/misc.c | 4 +-
arch/x86/boot/compressed/misc.h | 4 ++
arch/x86/boot/early_serial_console.c | 63 +++++++++++++------
arch/x86/boot/tty.c | 7 ++-
6 files changed, 61 insertions(+), 22 deletions(-)
diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
index 753f429b28cb..6688c2053707 100644
--- a/arch/x86/boot/boot.h
+++ b/arch/x86/boot/boot.h
@@ -274,6 +274,8 @@ int check_knl_erratum(void);
int validate_cpu(void);
/* early_serial_console.c */
+extern unsigned int (*serial_in)(unsigned long addr, int offset);
+extern void (*serial_out)(unsigned long addr, int offset, int value);
extern unsigned long early_serial_base;
void console_init(void);
diff --git a/arch/x86/boot/compressed/early_serial_console.c b/arch/x86/boot/compressed/early_serial_console.c
index 5b8db03f40ad..a5e0459c3d2f 100644
--- a/arch/x86/boot/compressed/early_serial_console.c
+++ b/arch/x86/boot/compressed/early_serial_console.c
@@ -1,5 +1,8 @@
#include "misc.h"
+unsigned int (*serial_in)(unsigned long addr, int offset);
+void (*serial_out)(unsigned long addr, int offset, int value);
+
/* This might be accessed before .bss is cleared, so use .data instead. */
unsigned long early_serial_base __section(".data");
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 94b5991da001..056fa5f01598 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -109,10 +109,10 @@ static void serial_putchar(int ch)
{
unsigned timeout = 0xffff;
- while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
+ while ((serial_in(early_serial_base, LSR) & XMTRDY) == 0 && --timeout)
cpu_relax();
- outb(ch, early_serial_base + TXR);
+ serial_out(early_serial_base, TXR, ch);
}
void __putstr(const char *s)
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index f083360c84c1..a70e5f31765b 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -127,9 +127,13 @@ extern unsigned char _pgtable[];
#ifdef CONFIG_EARLY_PRINTK
/* early_serial_console.c */
+extern unsigned int (*serial_in)(unsigned long addr, int offset);
+extern void (*serial_out)(unsigned long addr, int offset, int value);
extern unsigned long early_serial_base;
void console_init(void);
#else
+static unsigned int (*serial_in)(unsigned long addr, int offset);
+static void (*serial_out)(unsigned long addr, int offset, int value);
static const unsigned long early_serial_base;
static inline void console_init(void)
{ }
diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
index 7a7766fa16e5..f52a14284854 100644
--- a/arch/x86/boot/early_serial_console.c
+++ b/arch/x86/boot/early_serial_console.c
@@ -23,22 +23,45 @@
#define DEFAULT_BAUD 9600
-static void early_serial_init(unsigned long port, int baud)
+static unsigned int io_serial_in(unsigned long addr, int offset)
+{
+ return inb(addr + offset);
+}
+
+static void io_serial_out(unsigned long addr, int offset, int value)
+{
+ outb(value, addr + offset);
+}
+
+static void early_serial_configure(unsigned long port, int baud)
{
unsigned char c;
unsigned divisor;
- outb(0x3, port + LCR); /* 8n1 */
- outb(0, port + IER); /* no interrupt */
- outb(0, port + FCR); /* no fifo */
- outb(0x3, port + MCR); /* DTR + RTS */
+ serial_out(port, LCR, 0x3); /* 8n1 */
+ serial_out(port, IER, 0); /* no interrupt */
+ serial_out(port, FCR, 0); /* no fifo */
+ serial_out(port, MCR, 0x3); /* DTR + RTS */
divisor = 115200 / baud;
- c = inb(port + LCR);
- outb(c | DLAB, port + LCR);
- outb(divisor & 0xff, port + DLL);
- outb((divisor >> 8) & 0xff, port + DLH);
- outb(c & ~DLAB, port + LCR);
+ c = serial_in(port, LCR);
+ serial_out(port, LCR, c | DLAB);
+ serial_out(port, DLL, divisor & 0xff);
+ serial_out(port, DLH, (divisor >> 8) & 0xff);
+ serial_out(port, LCR, c & ~DLAB);
+}
+
+/* Assign serial I/O accessors */
+static void early_serial_use_io_accessors(void)
+{
+ /* These will always be IO based ports */
+ serial_in = io_serial_in;
+ serial_out = io_serial_out;
+}
+
+static void early_serial_init(unsigned long port, int baud)
+{
+ early_serial_configure(port, baud);
early_serial_base = port;
}
@@ -73,6 +96,7 @@ static void parse_earlyprintk(void)
port = DEFAULT_SERIAL_PORT;
else
pos = e - arg;
+ early_serial_use_io_accessors();
} else if (!strncmp(arg + pos, "ttyS", 4)) {
static const int bases[] = { 0x3f8, 0x2f8 };
int idx = 0;
@@ -84,6 +108,7 @@ static void parse_earlyprintk(void)
idx = 1;
port = bases[idx];
+ early_serial_use_io_accessors();
}
if (arg[pos] == ',')
@@ -104,11 +129,11 @@ static unsigned int probe_baud(int port)
unsigned char lcr, dll, dlh;
unsigned int quot;
- lcr = inb(port + LCR);
- outb(lcr | DLAB, port + LCR);
- dll = inb(port + DLL);
- dlh = inb(port + DLH);
- outb(lcr, port + LCR);
+ lcr = serial_in(port, LCR);
+ serial_out(port, LCR, lcr | DLAB);
+ dll = serial_in(port, DLL);
+ dlh = serial_in(port, DLH);
+ serial_out(port, LCR, lcr);
quot = (dlh << 8) | dll;
return BASE_BAUD / quot;
@@ -129,11 +154,13 @@ static void parse_console_uart8250(void)
options = optstr;
- if (!strncmp(options, "uart8250,io,", 12))
+ if (!strncmp(options, "uart8250,io,", 12)) {
port = simple_strtoull(options + 12, &options, 0);
- else if (!strncmp(options, "uart,io,", 8))
+ early_serial_use_io_accessors();
+ } else if (!strncmp(options, "uart,io,", 8)) {
port = simple_strtoull(options + 8, &options, 0);
- else
+ early_serial_use_io_accessors();
+ } else
return;
if (options && (options[0] == ','))
diff --git a/arch/x86/boot/tty.c b/arch/x86/boot/tty.c
index e2ab8b8076ef..eb0eacd88db7 100644
--- a/arch/x86/boot/tty.c
+++ b/arch/x86/boot/tty.c
@@ -13,6 +13,9 @@
#include "boot.h"
+unsigned int (*serial_in)(unsigned long addr, int offset);
+void (*serial_out)(unsigned long addr, int offset, int value);
+
unsigned long early_serial_base;
#define XMTRDY 0x20
@@ -29,10 +32,10 @@ static void __section(".inittext") serial_putchar(int ch)
{
unsigned timeout = 0xffff;
- while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
+ while ((serial_in(early_serial_base, LSR) & XMTRDY) == 0 && --timeout)
cpu_relax();
- outb(ch, early_serial_base + TXR);
+ serial_out(early_serial_base, TXR, ch);
}
static void __section(".inittext") bios_putchar(int ch)
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 3/6] x86/boot: Split out parse_serial_port() helper for earlyprintk
2025-05-02 12:29 [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 1/6] x86/boot: Convert early_serial_base to unsigned long Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 2/6] x86/boot: Introduce helpers for serial I/O Andy Shevchenko
@ 2025-05-02 12:29 ` Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 4/6] x86/boot: Allow longer parameter list " Andy Shevchenko
` (4 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-02 12:29 UTC (permalink / raw)
To: Andy Shevchenko, Ashish Kalra, Kirill A. Shutemov, linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, David Woodhouse, Denis Mukhin
The newly introduced helper will be used later on to parse serial port
in different type of earlyprintk command line arguments.
No functional change intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/x86/boot/early_serial_console.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
index f52a14284854..fa6520719a1e 100644
--- a/arch/x86/boot/early_serial_console.c
+++ b/arch/x86/boot/early_serial_console.c
@@ -66,6 +66,20 @@ static void early_serial_init(unsigned long port, int baud)
early_serial_base = port;
}
+static unsigned long parse_serial_port(const char *arg, int off, int *pos)
+{
+ unsigned long port;
+ char *e;
+
+ port = simple_strtoull(arg + off, &e, 16);
+ if (port == 0 || arg + off == e)
+ port = DEFAULT_SERIAL_PORT;
+ else
+ *pos = e - arg;
+
+ return port;
+}
+
static void parse_earlyprintk(void)
{
int baud = DEFAULT_BAUD;
@@ -91,11 +105,7 @@ static void parse_earlyprintk(void)
* "ttyS0,115200"
*/
if (pos == 7 && !strncmp(arg + pos, "0x", 2)) {
- port = simple_strtoull(arg + pos, &e, 16);
- if (port == 0 || arg + pos == e)
- port = DEFAULT_SERIAL_PORT;
- else
- pos = e - arg;
+ port = parse_serial_port(arg, pos + 0, &pos);
early_serial_use_io_accessors();
} else if (!strncmp(arg + pos, "ttyS", 4)) {
static const int bases[] = { 0x3f8, 0x2f8 };
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 4/6] x86/boot: Allow longer parameter list for earlyprintk
2025-05-02 12:29 [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) Andy Shevchenko
` (2 preceding siblings ...)
2025-05-02 12:29 ` [PATCH v1 3/6] x86/boot: Split out parse_serial_port() helper for earlyprintk Andy Shevchenko
@ 2025-05-02 12:29 ` Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 5/6] x86/boot: Also share MMIO accessors Andy Shevchenko
` (3 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-02 12:29 UTC (permalink / raw)
To: Andy Shevchenko, Ashish Kalra, Kirill A. Shutemov, linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, David Woodhouse, Denis Mukhin
Allow longer parameter list, up to 64 characters, for earlyprintk
to support new coming parameters.
If the parsed string is longer than this buffer it will be cut up by
the buffer size.
No functional change intended.
Note, that 'console' case is already covered.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/x86/boot/early_serial_console.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
index fa6520719a1e..6841f14346c2 100644
--- a/arch/x86/boot/early_serial_console.c
+++ b/arch/x86/boot/early_serial_console.c
@@ -84,7 +84,7 @@ static void parse_earlyprintk(void)
{
int baud = DEFAULT_BAUD;
unsigned long port = 0;
- char arg[32];
+ char arg[64];
int pos = 0;
if (cmdline_find_option("earlyprintk", arg, sizeof(arg)) > 0) {
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 5/6] x86/boot: Also share MMIO accessors
2025-05-02 12:29 [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) Andy Shevchenko
` (3 preceding siblings ...)
2025-05-02 12:29 ` [PATCH v1 4/6] x86/boot: Allow longer parameter list " Andy Shevchenko
@ 2025-05-02 12:29 ` Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 6/6] x86/boot: Introduce MMIO accessors and their support in earlyprintk Andy Shevchenko
` (2 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-02 12:29 UTC (permalink / raw)
To: Andy Shevchenko, Ashish Kalra, Kirill A. Shutemov, linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, David Woodhouse, Denis Mukhin
For the enabling an arbitrary MMIO for earlyprintk,
share MMIO accessors with a boot code.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/x86/include/asm/io.h | 65 ------------------------------
arch/x86/include/asm/shared/io.h | 68 ++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 65 deletions(-)
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index e889c3bab5a2..e6ca50fbcbbf 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -44,71 +44,6 @@
#include <asm/shared/io.h>
#include <asm/special_insns.h>
-#define build_mmio_read(name, size, type, reg, barrier) \
-static inline type name(const volatile void __iomem *addr) \
-{ type ret; asm volatile("mov" size " %1,%0":reg (ret) \
-:"m" (*(volatile type __force *)addr) barrier); return ret; }
-
-#define build_mmio_write(name, size, type, reg, barrier) \
-static inline void name(type val, volatile void __iomem *addr) \
-{ asm volatile("mov" size " %0,%1": :reg (val), \
-"m" (*(volatile type __force *)addr) barrier); }
-
-build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
-build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
-build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
-
-build_mmio_read(__readb, "b", unsigned char, "=q", )
-build_mmio_read(__readw, "w", unsigned short, "=r", )
-build_mmio_read(__readl, "l", unsigned int, "=r", )
-
-build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
-build_mmio_write(writew, "w", unsigned short, "r", :"memory")
-build_mmio_write(writel, "l", unsigned int, "r", :"memory")
-
-build_mmio_write(__writeb, "b", unsigned char, "q", )
-build_mmio_write(__writew, "w", unsigned short, "r", )
-build_mmio_write(__writel, "l", unsigned int, "r", )
-
-#define readb readb
-#define readw readw
-#define readl readl
-#define readb_relaxed(a) __readb(a)
-#define readw_relaxed(a) __readw(a)
-#define readl_relaxed(a) __readl(a)
-#define __raw_readb __readb
-#define __raw_readw __readw
-#define __raw_readl __readl
-
-#define writeb writeb
-#define writew writew
-#define writel writel
-#define writeb_relaxed(v, a) __writeb(v, a)
-#define writew_relaxed(v, a) __writew(v, a)
-#define writel_relaxed(v, a) __writel(v, a)
-#define __raw_writeb __writeb
-#define __raw_writew __writew
-#define __raw_writel __writel
-
-#ifdef CONFIG_X86_64
-
-build_mmio_read(readq, "q", u64, "=r", :"memory")
-build_mmio_read(__readq, "q", u64, "=r", )
-build_mmio_write(writeq, "q", u64, "r", :"memory")
-build_mmio_write(__writeq, "q", u64, "r", )
-
-#define readq_relaxed(a) __readq(a)
-#define writeq_relaxed(v, a) __writeq(v, a)
-
-#define __raw_readq __readq
-#define __raw_writeq __writeq
-
-/* Let people know that we have them */
-#define readq readq
-#define writeq writeq
-
-#endif
-
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
extern int valid_phys_addr_range(phys_addr_t addr, size_t size);
extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
diff --git a/arch/x86/include/asm/shared/io.h b/arch/x86/include/asm/shared/io.h
index 8009d781c2f9..35437ee26e21 100644
--- a/arch/x86/include/asm/shared/io.h
+++ b/arch/x86/include/asm/shared/io.h
@@ -31,4 +31,72 @@ BUILDIO(l, , u32)
#define outw __outw
#define outl __outl
+#define build_mmio_read(name, size, type, reg, barrier) \
+static inline type name(const volatile void __iomem *addr) \
+{ type ret; asm volatile("mov" size " %1,%0":reg (ret) \
+:"m" (*(volatile type __force *)addr) barrier); return ret; }
+
+#define build_mmio_write(name, size, type, reg, barrier) \
+static inline void name(type val, volatile void __iomem *addr) \
+{ asm volatile("mov" size " %0,%1": :reg (val), \
+"m" (*(volatile type __force *)addr) barrier); }
+
+build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
+build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
+build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
+
+build_mmio_read(__readb, "b", unsigned char, "=q", )
+build_mmio_read(__readw, "w", unsigned short, "=r", )
+build_mmio_read(__readl, "l", unsigned int, "=r", )
+
+build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
+build_mmio_write(writew, "w", unsigned short, "r", :"memory")
+build_mmio_write(writel, "l", unsigned int, "r", :"memory")
+
+build_mmio_write(__writeb, "b", unsigned char, "q", )
+build_mmio_write(__writew, "w", unsigned short, "r", )
+build_mmio_write(__writel, "l", unsigned int, "r", )
+
+#define readb readb
+#define readw readw
+#define readl readl
+#define readb_relaxed(a) __readb(a)
+#define readw_relaxed(a) __readw(a)
+#define readl_relaxed(a) __readl(a)
+#define __raw_readb __readb
+#define __raw_readw __readw
+#define __raw_readl __readl
+
+#define writeb writeb
+#define writew writew
+#define writel writel
+#define writeb_relaxed(v, a) __writeb(v, a)
+#define writew_relaxed(v, a) __writew(v, a)
+#define writel_relaxed(v, a) __writel(v, a)
+#define __raw_writeb __writeb
+#define __raw_writew __writew
+#define __raw_writel __writel
+
+#ifdef CONFIG_X86_64
+
+build_mmio_read(readq, "q", u64, "=r", :"memory")
+build_mmio_read(__readq, "q", u64, "=r", )
+build_mmio_write(writeq, "q", u64, "r", :"memory")
+build_mmio_write(__writeq, "q", u64, "r", )
+
+#define readq_relaxed(a) __readq(a)
+#define writeq_relaxed(v, a) __writeq(v, a)
+
+#define __raw_readq __readq
+#define __raw_writeq __writeq
+
+/* Let people know that we have them */
+#define readq readq
+#define writeq writeq
+
+#endif
+
+#undef build_mmio_write
+#undef build_mmio_read
+
#endif
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 6/6] x86/boot: Introduce MMIO accessors and their support in earlyprintk
2025-05-02 12:29 [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) Andy Shevchenko
` (4 preceding siblings ...)
2025-05-02 12:29 ` [PATCH v1 5/6] x86/boot: Also share MMIO accessors Andy Shevchenko
@ 2025-05-02 12:29 ` Andy Shevchenko
2025-05-02 17:33 ` [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) David Woodhouse
2025-05-06 19:38 ` David Woodhouse
7 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-02 12:29 UTC (permalink / raw)
To: Andy Shevchenko, Ashish Kalra, Kirill A. Shutemov, linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, David Woodhouse, Denis Mukhin
If user supplied serial base address via kernel command line and
at the same time the word 'mmio' is present, use MMIO accessors.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/x86/boot/early_serial_console.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
index 6841f14346c2..fa8eb0b4542e 100644
--- a/arch/x86/boot/early_serial_console.c
+++ b/arch/x86/boot/early_serial_console.c
@@ -33,6 +33,20 @@ static void io_serial_out(unsigned long addr, int offset, int value)
outb(value, addr + offset);
}
+static void mem8_serial_out(unsigned long addr, int offset, int value)
+{
+ u8 __iomem *vaddr = (u8 __iomem *)addr;
+ /* shift implied by pointer type */
+ writeb(value, vaddr + offset);
+}
+
+static unsigned int mem8_serial_in(unsigned long addr, int offset)
+{
+ u8 __iomem *vaddr = (u8 __iomem *)addr;
+ /* shift implied by pointer type */
+ return readb(vaddr + offset);
+}
+
static void early_serial_configure(unsigned long port, int baud)
{
unsigned char c;
@@ -59,6 +73,13 @@ static void early_serial_use_io_accessors(void)
serial_out = io_serial_out;
}
+static void early_serial_use_mmio_accessors(void)
+{
+ /* It is memory mapped - assume 8-bit alignment */
+ serial_in = mem8_serial_in;
+ serial_out = mem8_serial_out;
+}
+
static void early_serial_init(unsigned long port, int baud)
{
early_serial_configure(port, baud);
@@ -101,12 +122,16 @@ static void parse_earlyprintk(void)
/*
* make sure we have
* "serial,0x3f8,115200"
+ * "serial,mmio,0xff010180,115200"
* "serial,ttyS0,115200"
* "ttyS0,115200"
*/
if (pos == 7 && !strncmp(arg + pos, "0x", 2)) {
port = parse_serial_port(arg, pos + 0, &pos);
early_serial_use_io_accessors();
+ } else if (pos == 7 && !strncmp(arg + pos, "mmio,0x", 7)) {
+ port = parse_serial_port(arg, pos + 5, &pos);
+ early_serial_use_mmio_accessors();
} else if (!strncmp(arg + pos, "ttyS", 4)) {
static const int bases[] = { 0x3f8, 0x2f8 };
int idx = 0;
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit)
2025-05-02 12:29 [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) Andy Shevchenko
` (5 preceding siblings ...)
2025-05-02 12:29 ` [PATCH v1 6/6] x86/boot: Introduce MMIO accessors and their support in earlyprintk Andy Shevchenko
@ 2025-05-02 17:33 ` David Woodhouse
2025-05-05 14:05 ` Andy Shevchenko
2025-05-06 19:38 ` David Woodhouse
7 siblings, 1 reply; 16+ messages in thread
From: David Woodhouse @ 2025-05-02 17:33 UTC (permalink / raw)
To: Andy Shevchenko, Ashish Kalra, Kirill A. Shutemov, linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Denis Mukhin
[-- Attachment #1: Type: text/plain, Size: 742 bytes --]
On Fri, 2025-05-02 at 15:29 +0300, Andy Shevchenko wrote:
> Some of the platforms may have no legacy COM ports and only provide
> an MMIO accessible UART. Add support for such to earlyprintk for the
> boot phase of the kernel.
Shiny. I had to hack QEMU's PCI serial port to do unnatural things, in
order to test the mmio32 variant which was the only thing the
earlyprintk code used to support. But I *did* so, and it works with the
kexec debugging.
Can you add support for this mode to the kexec debugging too, please?
I believe it's currently in tip/asm. This should be a simple example to
work from:
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/asm&id=7516e7216bdfb9e2fab0a0ca3bd23cb2e61e46ed
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit)
2025-05-02 17:33 ` [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) David Woodhouse
@ 2025-05-05 14:05 ` Andy Shevchenko
2025-05-05 14:35 ` David Woodhouse
0 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-05 14:05 UTC (permalink / raw)
To: David Woodhouse
Cc: Ashish Kalra, Kirill A. Shutemov, linux-kernel, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Denis Mukhin
On Fri, May 02, 2025 at 10:33:49AM -0700, David Woodhouse wrote:
> On Fri, 2025-05-02 at 15:29 +0300, Andy Shevchenko wrote:
> > Some of the platforms may have no legacy COM ports and only provide
> > an MMIO accessible UART. Add support for such to earlyprintk for the
> > boot phase of the kernel.
>
> Shiny. I had to hack QEMU's PCI serial port to do unnatural things, in
> order to test the mmio32 variant which was the only thing the
> earlyprintk code used to support. But I *did* so, and it works with the
> kexec debugging.
>
> Can you add support for this mode to the kexec debugging too, please?
Do you mean to add MMIO 8-bit to kexec assembly code and other parts like you
did in the below mentioned change?
I can try it at some point, but have no time right now for this.
I would appreciate if you can give a try for this patch series
functionality to see if it helps for the initial messages (as
far as I understand you also want to have this in the second
kernel, right?).
> I believe it's currently in tip/asm. This should be a simple example to
> work from:
> https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/asm&id=7516e7216bdfb9e2fab0a0ca3bd23cb2e61e46ed
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit)
2025-05-05 14:05 ` Andy Shevchenko
@ 2025-05-05 14:35 ` David Woodhouse
2025-05-05 14:59 ` Andy Shevchenko
0 siblings, 1 reply; 16+ messages in thread
From: David Woodhouse @ 2025-05-05 14:35 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Ashish Kalra, Kirill A. Shutemov, linux-kernel, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Denis Mukhin
[-- Attachment #1: Type: text/plain, Size: 1211 bytes --]
On Mon, 2025-05-05 at 17:05 +0300, Andy Shevchenko wrote:
> On Fri, May 02, 2025 at 10:33:49AM -0700, David Woodhouse wrote:
> > On Fri, 2025-05-02 at 15:29 +0300, Andy Shevchenko wrote:
> > > Some of the platforms may have no legacy COM ports and only provide
> > > an MMIO accessible UART. Add support for such to earlyprintk for the
> > > boot phase of the kernel.
> >
> > Shiny. I had to hack QEMU's PCI serial port to do unnatural things, in
> > order to test the mmio32 variant which was the only thing the
> > earlyprintk code used to support. But I *did* so, and it works with the
> > kexec debugging.
> >
> > Can you add support for this mode to the kexec debugging too, please?
>
> Do you mean to add MMIO 8-bit to kexec assembly code and other parts like you
> did in the below mentioned change?
>
> I can try it at some point, but have no time right now for this.
> I would appreciate if you can give a try for this patch series
> functionality to see if it helps for the initial messages (as
> far as I understand you also want to have this in the second
> kernel, right?).
I'll see if I can find the time to take a look. Got a branch I can pull
your series from?
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit)
2025-05-05 14:35 ` David Woodhouse
@ 2025-05-05 14:59 ` Andy Shevchenko
2025-05-05 15:01 ` Andy Shevchenko
0 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-05 14:59 UTC (permalink / raw)
To: David Woodhouse
Cc: Ashish Kalra, Kirill A. Shutemov, linux-kernel, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Denis Mukhin
On Mon, May 05, 2025 at 07:35:04AM -0700, David Woodhouse wrote:
> On Mon, 2025-05-05 at 17:05 +0300, Andy Shevchenko wrote:
> > On Fri, May 02, 2025 at 10:33:49AM -0700, David Woodhouse wrote:
> > > On Fri, 2025-05-02 at 15:29 +0300, Andy Shevchenko wrote:
> > > > Some of the platforms may have no legacy COM ports and only provide
> > > > an MMIO accessible UART. Add support for such to earlyprintk for the
> > > > boot phase of the kernel.
> > >
> > > Shiny. I had to hack QEMU's PCI serial port to do unnatural things, in
> > > order to test the mmio32 variant which was the only thing the
> > > earlyprintk code used to support. But I *did* so, and it works with the
> > > kexec debugging.
> > >
> > > Can you add support for this mode to the kexec debugging too, please?
> >
> > Do you mean to add MMIO 8-bit to kexec assembly code and other parts like you
> > did in the below mentioned change?
> >
> > I can try it at some point, but have no time right now for this.
> > I would appreciate if you can give a try for this patch series
> > functionality to see if it helps for the initial messages (as
> > far as I understand you also want to have this in the second
> > kernel, right?).
>
> I'll see if I can find the time to take a look. Got a branch I can pull
> your series from?
Yeo, https://bitbucket.org/andy-shev/linux/commits/branch/topic%2Fx86%2Fboot-earlyprintk.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit)
2025-05-05 14:59 ` Andy Shevchenko
@ 2025-05-05 15:01 ` Andy Shevchenko
2025-05-05 23:32 ` David Woodhouse
0 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-05 15:01 UTC (permalink / raw)
To: David Woodhouse
Cc: Ashish Kalra, Kirill A. Shutemov, linux-kernel, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Denis Mukhin
On Mon, May 05, 2025 at 05:59:48PM +0300, Andy Shevchenko wrote:
> On Mon, May 05, 2025 at 07:35:04AM -0700, David Woodhouse wrote:
> > On Mon, 2025-05-05 at 17:05 +0300, Andy Shevchenko wrote:
> > > On Fri, May 02, 2025 at 10:33:49AM -0700, David Woodhouse wrote:
> > > > On Fri, 2025-05-02 at 15:29 +0300, Andy Shevchenko wrote:
> > > > > Some of the platforms may have no legacy COM ports and only provide
> > > > > an MMIO accessible UART. Add support for such to earlyprintk for the
> > > > > boot phase of the kernel.
> > > >
> > > > Shiny. I had to hack QEMU's PCI serial port to do unnatural things, in
> > > > order to test the mmio32 variant which was the only thing the
> > > > earlyprintk code used to support. But I *did* so, and it works with the
> > > > kexec debugging.
> > > >
> > > > Can you add support for this mode to the kexec debugging too, please?
> > >
> > > Do you mean to add MMIO 8-bit to kexec assembly code and other parts like you
> > > did in the below mentioned change?
> > >
> > > I can try it at some point, but have no time right now for this.
> > > I would appreciate if you can give a try for this patch series
> > > functionality to see if it helps for the initial messages (as
> > > far as I understand you also want to have this in the second
> > > kernel, right?).
> >
> > I'll see if I can find the time to take a look. Got a branch I can pull
> > your series from?
>
> Yeo, https://bitbucket.org/andy-shev/linux/commits/branch/topic%2Fx86%2Fboot-earlyprintk.
But just FYI that with `b4` it's as easy to pull from the mailing list as from
a branch:
b4 am 20250502123145.4066635-1-andriy.shevchenko@linux.intel.com
git am -C1 -s ...
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit)
2025-05-05 15:01 ` Andy Shevchenko
@ 2025-05-05 23:32 ` David Woodhouse
2025-05-06 3:19 ` David Woodhouse
0 siblings, 1 reply; 16+ messages in thread
From: David Woodhouse @ 2025-05-05 23:32 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Ashish Kalra, Kirill A. Shutemov, linux-kernel, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Denis Mukhin
[-- Attachment #1: Type: text/plain, Size: 2547 bytes --]
On Mon, 2025-05-05 at 18:01 +0300, Andy Shevchenko wrote:
> On Mon, May 05, 2025 at 05:59:48PM +0300, Andy Shevchenko wrote:
> > On Mon, May 05, 2025 at 07:35:04AM -0700, David Woodhouse wrote:
> > > On Mon, 2025-05-05 at 17:05 +0300, Andy Shevchenko wrote:
> > > > On Fri, May 02, 2025 at 10:33:49AM -0700, David Woodhouse
> > > > wrote:
> > > > > On Fri, 2025-05-02 at 15:29 +0300, Andy Shevchenko wrote:
> > > > > > Some of the platforms may have no legacy COM ports and only
> > > > > > provide
> > > > > > an MMIO accessible UART. Add support for such to
> > > > > > earlyprintk for the
> > > > > > boot phase of the kernel.
> > > > >
> > > > > Shiny. I had to hack QEMU's PCI serial port to do unnatural
> > > > > things, in
> > > > > order to test the mmio32 variant which was the only thing the
> > > > > earlyprintk code used to support. But I *did* so, and it
> > > > > works with the
> > > > > kexec debugging.
> > > > >
> > > > > Can you add support for this mode to the kexec debugging too,
> > > > > please?
> > > >
> > > > Do you mean to add MMIO 8-bit to kexec assembly code and other
> > > > parts like you
> > > > did in the below mentioned change?
> > > >
> > > > I can try it at some point, but have no time right now for
> > > > this.
> > > > I would appreciate if you can give a try for this patch series
> > > > functionality to see if it helps for the initial messages (as
> > > > far as I understand you also want to have this in the second
> > > > kernel, right?).
> > >
> > > I'll see if I can find the time to take a look. Got a branch I
> > > can pull
> > > your series from?
> >
> > Yeo,
> > https://bitbucket.org/andy-shev/linux/commits/branch/topic%2Fx86%2Fboot-earlyprintk
> > .
>
> But just FYI that with `b4` it's as easy to pull from the mailing
> list as from
> a branch:
>
> b4 am
> 20250502123145.4066635-1-andriy.shevchenko@linux.intel.com
> git am -C1 -s ...
Thanks. Should I be expecting this to work...?
qemu-system-x86_64 -display none -vga none -accel kvm,kernel-irqchip=split \
-kernel arch/x86/boot/bzImage \
-append "console=ttyS4 root=/dev/vda1 earlyprintk=pciserial" \
-chardev stdio,mux=on,id=char0,signal=off -mon char0 -device pci-serial,chardev=char0
I get no early output (I think it's still using the mmio32 variant),
and I only see output from when the real driver takes over:
[ 0.894054] printk: legacy console [ttyS4] enabled
[ 0.895498] printk: legacy bootconsole [earlyser0] disabled
...
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit)
2025-05-05 23:32 ` David Woodhouse
@ 2025-05-06 3:19 ` David Woodhouse
0 siblings, 0 replies; 16+ messages in thread
From: David Woodhouse @ 2025-05-06 3:19 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Ashish Kalra, Kirill A. Shutemov, linux-kernel, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Denis Mukhin
[-- Attachment #1: Type: text/plain, Size: 1965 bytes --]
On Mon, 2025-05-05 at 16:32 -0700, David Woodhouse wrote:
>
> Thanks. Should I be expecting this to work...?
>
> qemu-system-x86_64 -display none -vga none -accel kvm,kernel-irqchip=split \
> -kernel arch/x86/boot/bzImage \
> -append "console=ttyS4 root=/dev/vda1 earlyprintk=pciserial" \
> -chardev stdio,mux=on,id=char0,signal=off -mon char0 -device pci-serial,chardev=char0
Hm, no, qemu's pci-serial is PIO. I'd need to do this:
--- a/hw/char/serial-pci.c
+++ b/hw/char/serial-pci.c
@@ -58,7 +58,7 @@ static void serial_pci_realize(PCIDevice *dev, Error **errp)
s->irq = pci_allocate_irq(&pci->dev);
memory_region_init_io(&s->io, OBJECT(pci), &serial_io_ops, s, "serial", 8);
- pci_register_bar(&pci->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io);
+ pci_register_bar(&pci->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->io);
}
static void serial_pci_exit(PCIDevice *dev)
And then the kernel's 'earlyprintk=pciserial' needs to be told the BDF,
e.g. earlyprintk=pciserial,00:03.0,keep
And it's still defaulting to mmio32 unless I do this in the kernel...
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -198,7 +198,7 @@ static __init void early_serial_init(char *s)
static __noendbr void mem32_serial_out(unsigned long addr, int offset, int value)
{
- u32 __iomem *vaddr = (u32 __iomem *)addr;
+ u8 __iomem *vaddr = (u8 __iomem *)addr;
/* shift implied by pointer type */
writel(value, vaddr + offset);
}
@@ -206,7 +206,7 @@ ANNOTATE_NOENDBR_SYM(mem32_serial_out);
static __noendbr unsigned int mem32_serial_in(unsigned long addr, int offset)
{
- u32 __iomem *vaddr = (u32 __iomem *)addr;
+ u8 __iomem *vaddr = (u8 __iomem *)addr;
/* shift implied by pointer type */
return readl(vaddr + offset);
}
If you can get this part working sanely, I'll happily add the kexec debug part.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit)
2025-05-02 12:29 [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) Andy Shevchenko
` (6 preceding siblings ...)
2025-05-02 17:33 ` [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) David Woodhouse
@ 2025-05-06 19:38 ` David Woodhouse
2025-05-07 13:54 ` Andy Shevchenko
7 siblings, 1 reply; 16+ messages in thread
From: David Woodhouse @ 2025-05-06 19:38 UTC (permalink / raw)
To: Andy Shevchenko, Ashish Kalra, Kirill A. Shutemov, linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Denis Mukhin
[-- Attachment #1: Type: text/plain, Size: 859 bytes --]
On Fri, 2025-05-02 at 15:29 +0300, Andy Shevchenko wrote:
> Some of the platforms may have no legacy COM ports and only provide
> an MMIO accessible UART. Add support for such to earlyprintk for the
> boot phase of the kernel.
Aha, I understand now... you've added this *only* for the boot code,
and haven't added the corresponding support to the in-kernel
earlyprintk, in arch/x86/kernel/early_printk.c
The latter does already support MMIO but it only supports a 32-bit
stride, not 8-bit.
Please could you make that consistent, and ensure the earlyprintk=
arguments function the same for both phases? I'm happy to add the
kexec-debug parts on top of *that*.
It would be really helpful if we could test this in QEMU; it shouldn't
be that hard to make it provide a 16550 on MMIO, along the lines of the
one-line hack I posted yesterday.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit)
2025-05-06 19:38 ` David Woodhouse
@ 2025-05-07 13:54 ` Andy Shevchenko
0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-05-07 13:54 UTC (permalink / raw)
To: David Woodhouse
Cc: Ashish Kalra, Kirill A. Shutemov, linux-kernel, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Denis Mukhin
On Tue, May 06, 2025 at 12:38:21PM -0700, David Woodhouse wrote:
> On Fri, 2025-05-02 at 15:29 +0300, Andy Shevchenko wrote:
> > Some of the platforms may have no legacy COM ports and only provide
> > an MMIO accessible UART. Add support for such to earlyprintk for the
> > boot phase of the kernel.
>
> Aha, I understand now... you've added this *only* for the boot code,
> and haven't added the corresponding support to the in-kernel
> earlyprintk, in arch/x86/kernel/early_printk.c
Haven't added yet. This is part 1 only.
> The latter does already support MMIO but it only supports a 32-bit
> stride, not 8-bit.
>
> Please could you make that consistent, and ensure the earlyprintk=
> arguments function the same for both phases? I'm happy to add the
> kexec-debug parts on top of *that*.
It's not as easy as it looks like. I had done in the past the comparison table
of what we have between all early*=... for serial consoles and it all so
inconsistent to begin with. A big work needs to be fulfilled in order to put
this mess in order. Hence this is just the first step.
> It would be really helpful if we could test this in QEMU; it shouldn't
> be that hard to make it provide a 16550 on MMIO, along the lines of the
> one-line hack I posted yesterday.
I understand. But if no go for this series, I don't won't to spend time on
the next part.
In any case, thanks for looking into this.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2025-05-07 13:54 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-02 12:29 [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 1/6] x86/boot: Convert early_serial_base to unsigned long Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 2/6] x86/boot: Introduce helpers for serial I/O Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 3/6] x86/boot: Split out parse_serial_port() helper for earlyprintk Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 4/6] x86/boot: Allow longer parameter list " Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 5/6] x86/boot: Also share MMIO accessors Andy Shevchenko
2025-05-02 12:29 ` [PATCH v1 6/6] x86/boot: Introduce MMIO accessors and their support in earlyprintk Andy Shevchenko
2025-05-02 17:33 ` [PATCH v1 0/6] x86/boot: Enable earlyprintk on MMIO (8-bit) David Woodhouse
2025-05-05 14:05 ` Andy Shevchenko
2025-05-05 14:35 ` David Woodhouse
2025-05-05 14:59 ` Andy Shevchenko
2025-05-05 15:01 ` Andy Shevchenko
2025-05-05 23:32 ` David Woodhouse
2025-05-06 3:19 ` David Woodhouse
2025-05-06 19:38 ` David Woodhouse
2025-05-07 13:54 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox