x86/boot: Enable earlyprintk for HS UARTs
v2 cover x86/boot: Enable earlyprintk for HS UARTs
Newer Intel platforms sometimes have only HS UART enabled and accessible via MMIO on high addresses.
For now, earlyprintk doesn't handle such cases and always rely on the legacy serial port to be present.
This series fills the gap and enables earlyprintk on HS UARTs.
Since v2:
- rebase on top of v5.1-rc1
- parse 'mmio' keyword instead of port range check (Ingo)
- deduplicate code wherever it's possible (Ingo)
Andy Shevchenko (7):
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: Add MMIO byte accessors
x86/boot: Introduce MMIO accessors and their support in earlyprintk x86/boot: Support nocfg parameter for earlyprintk
arch/x86/boot/boot.h | 16 ++- .../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 | 135 ++++++++++++++---- arch/x86/boot/tty.c | 9 +- 6 files changed, 140 insertions(+), 37 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/7 x86/boot: Convert early_serial_base to unsigned long
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.
--- 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(-)
arch/x86/boot/boot.h +1 -1
@@ -299,7 +299,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 */
arch/x86/boot/compressed/early_serial_console.c +1 -1
@@ -1,5 +1,5 @@#include "misc.h" -int early_serial_base; +unsigned long early_serial_base;#include "../early_serial_console.c"
arch/x86/boot/compressed/misc.h +2 -2
@@ -110,10 +110,10 @@ static inline void finalize_identity_maps(void)#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
arch/x86/boot/early_serial_console.c +3 -3
@@ -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;
@@ -48,7 +48,7 @@ static void parse_earlyprintk(void)int baud =DEFAULT_BAUD ;char arg[32 ];int pos =0 ; -int port =0 ; +unsigned long 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
arch/x86/boot/tty.c +1 -1
@@ -15,7 +15,7 @@#include "boot.h" -int early_serial_base; +unsigned long early_serial_base;#define XMTRDY 0x20
Signature · 1 line
2.20.1
Borislav Petkov
maintainerRe: [PATCH v2 1/7] x86/boot: Convert early_serial_base to unsigned long
Quoted 14 lines · Andy Shevchenko
As a preparatory of adding flexible serial I/O accessors, convert
early_serial_baseto unsigned long to cover all possible bus addresses on the system.No functional change intended.
Signed-off-by Andy Shevchenko <[email protected]>--- 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(-)
...
Quoted 23 lines
arch/x86/boot/early_serial_console.c +2
-2@@ -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;@@ -48,7 +48,7 @@ static void parse_earlyprintk(void)int baud =DEFAULT_BAUD ;char arg[32 ];int pos =0 ; -int port =0 ; +unsigned long port =0 ;if (cmdline_find_option ("earlyprintk" , arg,sizeof (arg)) >0 ) {char *e;
arch/x86/boot/early_serial_console.c static void parse_console_uart8250(void) · line 121
Quoted 5 lines
arch/x86/boot/early_serial_console.c +1
-1@@ -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 ;
Here and above:
Please sort function local variables declaration in a reverse christmas tree order:
<type A> longest_variable_name; <type B> shorter_var_name; <type C> even_shorter; <type D> i;
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2 1/7] x86/boot: Convert early_serial_base to unsigned long
Quoted 12 lines · Borislav Petkov
Quoted 11 lines · Andy Shevchenko
As a preparatory of adding flexible serial I/O accessors, convert
early_serial_baseto unsigned long to cover all possible bus addresses on the system.arch/x86/boot/early_serial_console.c +1
-1@@ -48,7 +48,7 @@ static void parse_earlyprintk(void)int baud =DEFAULT_BAUD ;char arg[32 ];int pos =0 ; -int port =0 ; +unsigned long port =0 ;
Quoted 10 lines
arch/x86/boot/early_serial_console.c static void parse_console_uart8250(void) · line 121
Quoted 8 lines
arch/x86/boot/early_serial_console.c +1
-1if (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 ;Here and above:
Agree on above and will fix, but don't see how this different in the latter?
Quoted 9 lines
Please sort function local variables declaration in a reverse christmas tree order:
<type A> longest_variable_name; <type B> shorter_var_name; <type C> even_shorter; <type D> i;
Signature · 2 lines
With Best Regards, Andy Shevchenko
Borislav Petkov
maintainerRe: [PATCH v2 1/7] x86/boot: Convert early_serial_base to unsigned long
Quoted 1 line · Andy Shevchenko
Agree on above and will fix, but don't see how this different in the latter?
Ok, so only the above.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.PATCH v2 2/7 x86/boot: Introduce helpers for serial I/O
In reply to Andy ShevchenkoAs 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.
--- 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(-)
arch/x86/boot/boot.h +2 -0
@@ -299,6 +299,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 );
arch/x86/boot/compressed/early_serial_console.c +3 -0
@@ -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); +unsigned long early_serial_base;#include "../early_serial_console.c"
arch/x86/boot/compressed/misc.c +2 -2
@@ -98,10 +98,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)
arch/x86/boot/compressed/misc.h +4 -0
@@ -110,9 +110,13 @@ static inline void finalize_identity_maps(void)#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 ) { }
arch/x86/boot/early_serial_console.c +45 -18
101 lines not on this page · raw message
arch/x86/boot/tty.c +5 -2
@@ -15,6 +15,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
@@ -31,10 +34,10 @@ static void __attribute__((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 __attribute__((section (".inittext" )))bios_putchar (int ch)
Signature · 1 line
2.20.1
Borislav Petkov
maintainerRe: [PATCH v2 2/7] x86/boot: Introduce helpers for serial I/O
Quoted 4 lines · Andy Shevchenko
As preparatory to enable earlyprintk on non-standard ports on x86, introduce
serial_in()andserial_out()helpers to perform serial I/O.No functional change intended.
...
arch/x86/boot/early_serial_console.c line 60
Quoted 7 lines
arch/x86/boot/early_serial_console.c +7
-0+/* 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; +}
This and the early_serial_use_mmio_accessors() in a later patch is just silly because you need to export and forward-declare those serial_in and serial_out function pointers in a bunch of places.
Just define exactly *two* simple functions serial_in() and serial_out() which have enough logic to decide whether to do serial IO or MMIO and put all that logic in those functions. No need for all that function pointer assignment "fun".
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2 2/7] x86/boot: Introduce helpers for serial I/O
Quoted 8 lines · Borislav Petkov
Quoted 4 lines · Andy Shevchenko
As preparatory to enable earlyprintk on non-standard ports on x86, introduce
serial_in()andserial_out()helpers to perform serial I/O.No functional change intended.
...
Quoted 11 lines
arch/x86/boot/early_serial_console.c line 60
Quoted 7 lines
arch/x86/boot/early_serial_console.c +7
-0+/* 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; +}This and the
early_serial_use_mmio_accessors()in a later patch is just silly because you need to export and forward-declare thoseserial_inandserial_outfunction pointers in a bunch of places.
This is the same approach as it's done in earlyprintk support in the main part of the kernel. Besides the fact that many drivers do it in the same way.
And I wouldn't call 'few' a 'bunch'...
Quoted 3 lines
Just define exactly *two* simple functions
serial_in()andserial_out()which have enough logic to decide whether to do serial IO or MMIO and put all that logic in those functions.
Any idea how it can be done?
Quoted 2 lines
No need for all that function
pointer assignment "fun".
Signature · 2 lines
With Best Regards, Andy Shevchenko
Borislav Petkov
maintainerRe: [PATCH v2 2/7] x86/boot: Introduce helpers for serial I/O
Quoted 1 line · Andy Shevchenko
Any idea how it can be done?
Like this?
static u8 serial_inb(unsigned long addr, int offset)
{
if (early_serial_do_mmio) {
asm volatile("movb %1,%0" : "=q" (v) : "m" (*(volatile u8 __force *)addr));
return v;
} else {
return inb(addr + offset);
}
}Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2 2/7] x86/boot: Introduce helpers for serial I/O
Quoted 6 lines · Borislav Petkov
Quoted 1 line · Andy Shevchenko
Any idea how it can be done?
Like this?
static u8
serial_inb(unsigned long addr, int offset)
It's not a generic serial_in()...
Quoted 9 lines
{
if (early_serial_do_mmio) {
asm volatile("movb %1,%0" : "=q" (v) : "m" (*(volatile u8 __force *)addr));
return v;
} else {
return inb(addr + offset);
}
}What about mmio32 as next step?
Do we have to "fix" earlyprintk implementation in kernel to do the same?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Borislav Petkov
maintainerRe: [PATCH v2 2/7] x86/boot: Introduce helpers for serial I/O
Quoted 1 line · Andy Shevchenko
It's not a generic
serial_in()...
Why?
Quoted 1 line
What about mmio32 as next step?
Next step where? Is it part of your patches?
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2 2/7] x86/boot: Introduce helpers for serial I/O
Quoted 4 lines · Borislav Petkov
Quoted 1 line · Andy Shevchenko
It's not a generic
serial_in()...Why?
By name and by what it's handling (only byte accesses to I/O or MMIO).
Quoted 3 lines
Quoted 1 line
What about mmio32 as next step?
Next step where? Is it part of your patches?
Not this series, but we have hardware that does MMIO32 accesses and yet using non-standard address.
My point is, that doing branch(es) on each I/O call is not good as simple calling the proper (pre-defined) I/O accessor.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Borislav Petkov
maintainerRe: [PATCH v2 2/7] x86/boot: Introduce helpers for serial I/O
Quoted 1 line · Andy Shevchenko
By name and by what it's handling (only byte accesses to I/O or MMIO).
Your series does only byte accesses so you can use byte variant.
Quoted 2 lines
My point is, that doing branch(es) on each I/O call is not good as simple calling the proper (pre-defined) I/O accessor.
What branches?
You do a branch and *then* you do an IO call.
What does "not good" even mean?
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2 2/7] x86/boot: Introduce helpers for serial I/O
Quoted 9 lines · Borislav Petkov
Quoted 1 line · Andy Shevchenko
By name and by what it's handling (only byte accesses to I/O or MMIO).
Your series does only byte accesses so you can use byte variant.
Quoted 2 lines
My point is, that doing branch(es) on each I/O call is not good as simple calling the proper (pre-defined) I/O accessor.
What branches?
Something like this at the end
if (mmio32)
... else if (mmio) ... else if (whatever) ... else ...
Quoted 1 line
You do a branch and *then* you do an IO call.
Yes.
Quoted 1 line
What does "not good" even mean?
We still export global flag variable, on top of this we need an additional branch which we can avoid for free.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 3/7 x86/boot: Split out parse_serial_port() helper for earlyprintk
In reply to Andy ShevchenkoThe newly introduced helper will be used later on to parse serial port in different type of earlyprintk command line arguments.
No functional change intended.
--- arch/x86/boot/early_serial_console.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
arch/x86/boot/early_serial_console.c +15 -5
@@ -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 };
Signature · 1 line
2.20.1
Borislav Petkov
maintainerRe: [PATCH v2 3/7] x86/boot: Split out parse_serial_port() helper for earlyprintk
Quoted 15 lines · Andy Shevchenko
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 <[email protected]>--- arch/x86/boot/early_serial_console.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)arch/x86/boot/early_serial_console.c +0
-0
arch/x86/boot/early_serial_console.c static void early_serial_init(unsigned long port, int baud) · line 74
Quoted 9 lines
arch/x86/boot/early_serial_console.c +6
-0@@ -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 );
WARNING: simple_strtoull is obsolete, use kstrtoull instead #41: FILE: arch/x86/boot/early_serial_console.c:74:
+ port = simple_strtoull(arg + off, &e, 16);
Please do a conversion patch ontop.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2 3/7] x86/boot: Split out parse_serial_port() helper for earlyprintk
Quoted 19 lines · Borislav Petkov
Quoted 18 lines · Andy Shevchenko
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 <[email protected]>--- arch/x86/boot/early_serial_console.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)arch/x86/boot/early_serial_console.c +0
-0@@ -66,6 +66,20 @@ static void early_serial_init(unsigned long port, int baud) early_serial_base = port; }
Quoted 10 lines
arch/x86/boot/early_serial_console.c static void early_serial_init(unsigned long port, int baud) · line 74
Quoted 6 lines
arch/x86/boot/early_serial_console.c +6
-0+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 );WARNING:
simple_strtoullis obsolete, use kstrtoull instead #41: FILE:arch/x86/boot/early_serial_console.c:74:
+ port =simple_strtoull(arg + off, &e, 16);
kstrtox() simple can't cover _all_ simple_strtox() cases.
Quoted 1 line
Please do a conversion patch ontop.
I don't feel like uglifying code to satisfy a tool producing a silly warning.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Borislav Petkov
maintainerRe: [PATCH v2 3/7] x86/boot: Split out parse_serial_port() helper for earlyprintk
Quoted 1 line · Andy Shevchenko
kstrtox()simple can't cover _all_simple_strtox()cases.
I see only one case here. Are you saying kstrtoull() cannot work here?
Quoted 1 line
I don't feel like uglifying code to satisfy a tool producing a silly
warning.
Uglifying how?
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2 3/7] x86/boot: Split out parse_serial_port() helper for earlyprintk
Quoted 5 lines · Borislav Petkov
Quoted 1 line · Andy Shevchenko
kstrtox()simple can't cover _all_simple_strtox()cases.I see only one case here. Are you saying
kstrtoull()cannot work here?
Can, but with code uglifying to workaround kstrtox() restrictions. simple_strtox() _just works_ as expected.
Quoted 4 lines
Quoted 1 line
I don't feel like uglifying code to satisfy a tool producing a silly
warning.
Uglifying how?
Requires buffer copying, finding digits there, making a proper termination. And basically dropping the error check, because we don't care at this stage about wrong input.
And we didn't start to talk about possible user expectation breakage and basically breakage weird user cases.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Borislav Petkov
maintainerRe: [PATCH v2 3/7] x86/boot: Split out parse_serial_port() helper for earlyprintk
Quoted 2 lines · Andy Shevchenko
Can, but with code uglifying to workaround
kstrtox()restrictions.simple_strtox()_justworks_as expected.
simple_strtox() also has its problems.
Quoted 1 line
Requires buffer copying, finding digits there, making a proper termination. And
It needs a single kstrtoull() call to parse the port. And we have kstrtoull() available in the compressed stage so pls do the conversion ontop.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2 3/7] x86/boot: Split out parse_serial_port() helper for earlyprintk
Quoted 5 lines · Borislav Petkov
Quoted 2 lines · Andy Shevchenko
Can, but with code uglifying to workaround
kstrtox()restrictions.simple_strtox()_justworks_as expected.
simple_strtox()also has its problems.
Yes! And point here: we do not care.
Quoted 3 lines
Quoted 1 line
Requires buffer copying, finding digits there, making a proper termination. And
It needs a single
kstrtoull()call to parse the port.
No, it does not. It needs more as I described. Have you investigated a topic? Have you seen all possible combinations of input here?
Quoted 3 lines
And we have
kstrtoull()available in the compressed stage so pls do the conversion ontop.
If it's strong opinion, I consider this rather as NAK. Thank you for review.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Borislav Petkov
maintainerRe: [PATCH v2 3/7] x86/boot: Split out parse_serial_port() helper for earlyprintk
Quoted 2 lines · Andy Shevchenko
If it's strong opinion, I consider this rather as NAK. Thank you for review.
Your call.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2 3/7] x86/boot: Split out parse_serial_port() helper for earlyprintk
Quoted 5 lines · Borislav Petkov
Quoted 2 lines · Andy Shevchenko
If it's strong opinion, I consider this rather as NAK. Thank you for review.
Your call.
Yes, as I said I won't uglify code to pursue kstrtox() whim. Thanks again!
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 4/7 x86/boot: Allow longer parameter list for earlyprintk
In reply to Andy ShevchenkoAllow 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.
--- arch/x86/boot/early_serial_console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/boot/early_serial_console.c +1 -1
@@ -83,7 +83,7 @@ static unsigned long parse_serial_port(const char *arg, int off, int *pos)static void parse_earlyprintk (void ) {int baud =DEFAULT_BAUD ; -char arg[32 ]; +char arg[64 ];int pos =0 ;unsigned long port =0 ;
Signature · 1 line
2.20.1
PATCH v2 5/7 x86/boot: Add MMIO byte accessors
In reply to Andy Shevchenkoreadb() and writeb() would help to access serial device via MMIO address space.
--- arch/x86/boot/boot.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/x86/boot/boot.h +12 -0
@@ -79,6 +79,18 @@ static inline void io_delay(void) asmvolatile ("outb %%al,%0" : :"dN" (DELAY_PORT )); } +static inline u8 readb (const volatile void __iomem *addr) +{ +u8 v; + asmvolatile ("movb %1,%0" :"=q" (v) :"m" (*(volatile u8 __force *)addr)); +return v; +} + +static inline void writeb (u8 v,volatile void __iomem *addr) +{ + asmvolatile ("movb %0,%1" : :"q" (v),"m" (*(volatile u8 __force *)addr)); +} +/* These functions are used to reference data in other segments. */ static inline u16 ds (void )
Signature · 1 line
2.20.1
PATCH v2 6/7 x86/boot: Introduce MMIO accessors and their support in earlyprintk
In reply to Andy ShevchenkoIf user supplied serial base address via kernel command line and at the same time the word 'mmio' is present, use MMIO accessors.
--- arch/x86/boot/early_serial_console.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
arch/x86/boot/early_serial_console.c +25 -0
@@ -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 ;
Signature · 1 line
2.20.1
PATCH v2 7/7 x86/boot: Support nocfg parameter for earlyprintk
In reply to Andy ShevchenkoIf by BIOS or by other means the serial port is configured user might want to skip reconfiguration in the boot code.
Add support of 'nocfg' parameter to earlyprintk.
--- arch/x86/boot/early_serial_console.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
arch/x86/boot/early_serial_console.c +21 -4
@@ -80,9 +80,10 @@ static void early_serial_use_mmio_accessors(void) serial_out = mem8_serial_out; } -static void early_serial_init (unsigned long port,int baud) +static void early_serial_init (unsigned long port,int baud,bool configure) { -early_serial_configure (port, baud); +if (configure) +early_serial_configure (port, baud); early_serial_base = port; }
@@ -101,12 +102,22 @@ static unsigned long parse_serial_port(const char *arg, int off, int *pos)return port; } +static bool parse_serial_configure (const char *arg,int off,int *pos) +{ +if (strncmp (arg + off,"nocfg" ,5 )) +return true; + + *pos = off +5 ; +return false; +} +static void parse_earlyprintk (void ) {int baud =DEFAULT_BAUD ;char arg[64 ];int pos =0 ;unsigned long port =0 ; +bool configure = true;if (cmdline_find_option ("earlyprintk" , arg,sizeof (arg)) >0 ) {char *e;
@@ -146,6 +157,11 @@ static void parse_earlyprintk(void)early_serial_use_io_accessors (); } +if (arg[pos] ==',' ) + pos++; + + configure =parse_serial_configure (arg, pos, &pos); +if (arg[pos] ==',' ) pos++;
@@ -155,7 +171,7 @@ static void parse_earlyprintk(void) }if (port) -early_serial_init (port, baud); +early_serial_init (port, baud, configure); }#define BASE_BAUD (1843200/16)
@@ -179,6 +195,7 @@ static void parse_console_uart8250(void)char optstr[64 ], *options;int baud =DEFAULT_BAUD ;unsigned long port =0 ; +bool configure = true;/* * console=uart8250,io,0x3f8,115200n8
@@ -204,7 +221,7 @@ static void parse_console_uart8250(void) baud =probe_baud (port);if (port) -early_serial_init (port, baud); +early_serial_init (port, baud, configure); }void console_init (void )
Signature · 1 line
2.20.1
Re: [PATCH v2 7/7] x86/boot: Support nocfg parameter for earlyprintk
Quoted 7 lines · Andy Shevchenko
If by BIOS or by other means the serial port is configured user might want to skip reconfiguration in the boot code.
Add support of 'nocfg' parameter to earlyprintk.
Signed-off-by Andy Shevchenko <[email protected]>---
Hi Andy,
Please add "nocfg" to Documentation/admin-guide/kernel-parameters.txt.
Signature · 1 line
~Randy
Re: [PATCH v2 7/7] x86/boot: Support nocfg parameter for earlyprintk
Quoted 7 lines · Randy Dunlap
Quoted 4 lines · Andy Shevchenko
If by BIOS or by other means the serial port is configured user might want to skip reconfiguration in the boot code.
Add support of 'nocfg' parameter to earlyprintk.
Please add "nocfg" to
Documentation/admin-guide/kernel-parameters.txt.
I think it's not a time right now to do so. This only does it for boot stage.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 7/7] x86/boot: Support nocfg parameter for earlyprintk
Quoted 11 lines · Andy Shevchenko
Quoted 7 lines · Randy Dunlap
Quoted 4 lines · Andy Shevchenko
If by BIOS or by other means the serial port is configured user might want to skip reconfiguration in the boot code.
Add support of 'nocfg' parameter to earlyprintk.
Please add "nocfg" to
Documentation/admin-guide/kernel-parameters.txt.I think it's not a time right now to do so. This only does it for boot stage.
OK. Is there somewhere else that it could be added to Documentation/[x86/]?
thanks.
Signature · 1 line
~Randy
Re: [PATCH v2 7/7] x86/boot: Support nocfg parameter for earlyprintk
Quoted 11 lines · Randy Dunlap
Quoted 8 lines · Andy Shevchenko
Quoted 5 lines · Randy Dunlap
Quoted 1 line · Andy Shevchenko
Add support of 'nocfg' parameter to earlyprintk.
Please add "nocfg" to
Documentation/admin-guide/kernel-parameters.txt.I think it's not a time right now to do so. This only does it for boot stage.
OK. Is there somewhere else that it could be added to Documentation/[x86/]?
I don't see the proper place.
I think this is can be added when it would be recognized by next stage of earlyprintk.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Borislav Petkov
maintainerRe: [PATCH v2 7/7] x86/boot: Support nocfg parameter for earlyprintk
Quoted 1 line · Andy Shevchenko
I don't see the proper place.
I see Documentation/x86/earlyprintk.txt which kinda begs to collect earlyprintk documentation...
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Re: [PATCH v2 7/7] x86/boot: Support nocfg parameter for earlyprintk
Quoted 6 lines · Borislav Petkov
Quoted 1 line · Andy Shevchenko
I don't see the proper place.
I see
Documentation/x86/earlyprintk.txtwhich kinda begs to collect earlyprintk documentation...
It says only about USB, but okay, I may shift it as a chapter.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Borislav Petkov
maintainerRe: [PATCH v2 7/7] x86/boot: Support nocfg parameter for earlyprintk
In reply to Andy ShevchenkoQuoted 2 lines · Andy Shevchenko
If by BIOS or by other means the serial port is configured user might want to skip reconfiguration in the boot code.
That needs more explanation: how can that happen? How is the user supposed to know whether the serial port is configured in order to use this cmdline param?
Why can't the kernel detect whether the serial port is configured and not touch that configuration?
A lot of why's and head scratching...
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2 7/7] x86/boot: Support nocfg parameter for earlyprintk
Quoted 5 lines · Borislav Petkov
Quoted 2 lines · Andy Shevchenko
If by BIOS or by other means the serial port is configured user might want to skip reconfiguration in the boot code.
That needs more explanation: how can that happen?
I didn't get what is 'that' here? You mean that serial interface becomes configured before kernel even starts? See below.
Quoted 3 lines
How is the user
supposed to know whether the serial port is configured in order to use this cmdline param?
If the connection to the target is done via serial interface and firmware and / or bootloader already did necessary configuration.
Quoted 2 lines
Why can't the kernel detect whether the serial port is configured and not touch that configuration?
Because it can't at this stage. We simple can't afford to move all serial drivers (even partially) to the _boot_ part of the kernel.
Quoted 1 line
A lot of why's and head scratching...
What other why's should be answered?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Borislav Petkov
maintainerRe: [PATCH v2 7/7] x86/boot: Support nocfg parameter for earlyprintk
Quoted 2 lines · Andy Shevchenko
If the connection to the target is done via serial interface and firmware and / or bootloader already did necessary configuration.
Again: how is the user supposed to know that? When a user sees "nocfg"'s documentation, how is the user supposed to decide whether she needs to supply nocfg or not?
Which exact setups will need to supply nocfg on the cmdline?
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2 7/7] x86/boot: Support nocfg parameter for earlyprintk
Quoted 5 lines · Borislav Petkov
Quoted 2 lines · Andy Shevchenko
If the connection to the target is done via serial interface and firmware and / or bootloader already did necessary configuration.
Again: how is the user supposed to know that?
How one knows that she is typing on keyboard right now and not on touch screen? I really don't get this. User either knows this beforehand or doesn't care. Maybe she needs to read documentation on hardware at some point?
Quoted 3 lines
When a user sees "nocfg"'s
documentation, how is the user supposed to decide whether she needs to supply nocfg or not?
The problem nocfg tries to solve is a hard coded default baud rate and impossibility to know at this stage all parameters of the serial interface.
Quoted 1 line
Which exact setups will need to supply nocfg on the cmdline?
If it's _non-standard_ serial interface (by meaning of I/O accessors and port addresses), user may consider to use this options in case the interface to communicate with kernel is serial one and its configuration is done by other means (firmware / bootloader / EFI / etc).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Borislav Petkov
maintainerRe: [PATCH v2 7/7] x86/boot: Support nocfg parameter for earlyprintk
Quoted 4 lines · Andy Shevchenko
If it's _non-standard_ serial interface (by meaning of I/O accessors and port addresses), user may consider to use this options in case the interface to communicate with kernel is serial one and its configuration is done by other means (firmware / bootloader / EFI / etc).
And is this non-standard interface out there in the wild or only at Intel's labs?
Are there boxes like that out there?
If I go to the store and buy a box, how do I know whether that box would need "nocfg"? Do I look in the BIOS or how do I find out I need to supply "nocfg"?
Quoted 1 line
If by BIOS or by other means the serial port is configured
How do I find out that the serial port is configured?
And don't give me that "example" about the typing on keyboard or on touch screen again.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Re: [PATCH v2 7/7] x86/boot: Support nocfg parameter for earlyprintk
Quoted 8 lines · Borislav Petkov
Quoted 4 lines · Andy Shevchenko
If it's _non-standard_ serial interface (by meaning of I/O accessors and port addresses), user may consider to use this options in case the interface to communicate with kernel is serial one and its configuration is done by other means (firmware / bootloader / EFI / etc).
And is this non-standard interface out there in the wild or only at Intel's labs?
Of course in the wild.
Quoted 1 line
Are there boxes like that out there?
One at hand now is called Intel Edison.
Quoted 3 lines
If I go to the store and buy a box, how do I know whether that box would need "nocfg"? Do I look in the BIOS or how do I find out I need to supply "nocfg"?
By reading some technical documentation I suppose.
What is your point here? earlyprintk is a mechanism for _debugging_, I suppose the user should have slightly more knowledge than user.
Quoted 3 lines
Quoted 1 line
If by BIOS or by other means the serial port is configured
How do I find out that the serial port is configured?
If you _already_ connected via it and get firmware / bootloader messages.
Signature · 2 lines
With Best Regards, Andy Shevchenko