* [PATCH 1/5] serial: arc: Remove __init marking from early write
2017-07-18 6:02 [PATCH 0/5] earlycon hang under some conditions Jeffy Chen
@ 2017-07-18 6:02 ` Jeffy Chen
2017-07-18 6:02 ` [PATCH 2/5] serial: omap: " Jeffy Chen
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Jeffy Chen @ 2017-07-18 6:02 UTC (permalink / raw)
To: linux-kernel
Cc: gregkh, briannorris, dianders, peter, Jeffy Chen, Jiri Slaby,
Vineet Gupta, linux-serial, linux-snps-arc
The earlycon would be alive outside the init code in these cases:
1/ we have keep_bootcon in cmdline.
2/ we don't have a real console to switch to.
So remove the __init marking to avoid invalid memory access.
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
drivers/tty/serial/arc_uart.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index 5ac06fc..77fe306 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -549,8 +549,8 @@ static struct console arc_console = {
.data = &arc_uart_driver
};
-static __init void arc_early_serial_write(struct console *con, const char *s,
- unsigned int n)
+static void arc_early_serial_write(struct console *con, const char *s,
+ unsigned int n)
{
struct earlycon_device *dev = con->data;
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 2/5] serial: omap: Remove __init marking from early write
2017-07-18 6:02 [PATCH 0/5] earlycon hang under some conditions Jeffy Chen
2017-07-18 6:02 ` [PATCH 1/5] serial: arc: Remove __init marking from early write Jeffy Chen
@ 2017-07-18 6:02 ` Jeffy Chen
2017-07-18 6:02 ` [PATCH 3/5] serial: xuartps: " Jeffy Chen
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Jeffy Chen @ 2017-07-18 6:02 UTC (permalink / raw)
To: linux-kernel
Cc: gregkh, briannorris, dianders, peter, Jeffy Chen, linux-serial,
Jiri Slaby
The earlycon would be alive outside the init code in these cases:
1/ we have keep_bootcon in cmdline.
2/ we don't have a real console to switch to.
So remove the __init marking to avoid invalid memory access.
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
drivers/tty/serial/omap-serial.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 1ea05ac..7754053 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1235,21 +1235,20 @@ static int serial_omap_poll_get_char(struct uart_port *port)
#ifdef CONFIG_SERIAL_OMAP_CONSOLE
#ifdef CONFIG_SERIAL_EARLYCON
-static unsigned int __init omap_serial_early_in(struct uart_port *port,
- int offset)
+static unsigned int omap_serial_early_in(struct uart_port *port, int offset)
{
offset <<= port->regshift;
return readw(port->membase + offset);
}
-static void __init omap_serial_early_out(struct uart_port *port, int offset,
- int value)
+static void omap_serial_early_out(struct uart_port *port, int offset,
+ int value)
{
offset <<= port->regshift;
writew(value, port->membase + offset);
}
-static void __init omap_serial_early_putc(struct uart_port *port, int c)
+static void omap_serial_early_putc(struct uart_port *port, int c)
{
unsigned int status;
@@ -1262,8 +1261,8 @@ static void __init omap_serial_early_putc(struct uart_port *port, int c)
omap_serial_early_out(port, UART_TX, c);
}
-static void __init early_omap_serial_write(struct console *console,
- const char *s, unsigned int count)
+static void early_omap_serial_write(struct console *console, const char *s,
+ unsigned int count)
{
struct earlycon_device *device = console->data;
struct uart_port *port = &device->port;
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 3/5] serial: xuartps: Remove __init marking from early write
2017-07-18 6:02 [PATCH 0/5] earlycon hang under some conditions Jeffy Chen
2017-07-18 6:02 ` [PATCH 1/5] serial: arc: Remove __init marking from early write Jeffy Chen
2017-07-18 6:02 ` [PATCH 2/5] serial: omap: " Jeffy Chen
@ 2017-07-18 6:02 ` Jeffy Chen
2017-07-18 6:02 ` [PATCH 4/5] serial: 8250_ingenic: " Jeffy Chen
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Jeffy Chen @ 2017-07-18 6:02 UTC (permalink / raw)
To: linux-kernel
Cc: gregkh, briannorris, dianders, peter, Jeffy Chen,
Sören Brinkmann, Michal Simek, Jiri Slaby, linux-serial,
linux-arm-kernel
The earlycon would be alive outside the init code in these cases:
1/ we have keep_bootcon in cmdline.
2/ we don't have a real console to switch to.
So remove the __init marking to avoid invalid memory access.
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
drivers/tty/serial/xilinx_uartps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index fde55dc..31a630a 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1163,7 +1163,7 @@ static void cdns_uart_console_putchar(struct uart_port *port, int ch)
writel(ch, port->membase + CDNS_UART_FIFO);
}
-static void __init cdns_early_write(struct console *con, const char *s,
+static void cdns_early_write(struct console *con, const char *s,
unsigned n)
{
struct earlycon_device *dev = con->data;
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 4/5] serial: 8250_ingenic: Remove __init marking from early write
2017-07-18 6:02 [PATCH 0/5] earlycon hang under some conditions Jeffy Chen
` (2 preceding siblings ...)
2017-07-18 6:02 ` [PATCH 3/5] serial: xuartps: " Jeffy Chen
@ 2017-07-18 6:02 ` Jeffy Chen
2017-07-18 6:02 ` [PATCH 5/5] serial: 8250_early: " Jeffy Chen
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Jeffy Chen @ 2017-07-18 6:02 UTC (permalink / raw)
To: linux-kernel
Cc: gregkh, briannorris, dianders, peter, Jeffy Chen, linux-serial,
Jiri Slaby
The earlycon would be alive outside the init code in these cases:
1/ we have keep_bootcon in cmdline.
2/ we don't have a real console to switch to.
So remove the __init marking to avoid invalid memory access.
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
drivers/tty/serial/8250/8250_ingenic.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_ingenic.c b/drivers/tty/serial/8250/8250_ingenic.c
index 4d9dc10..464389b 100644
--- a/drivers/tty/serial/8250/8250_ingenic.c
+++ b/drivers/tty/serial/8250/8250_ingenic.c
@@ -50,17 +50,17 @@ static const struct of_device_id of_match[];
static struct earlycon_device *early_device;
-static uint8_t __init early_in(struct uart_port *port, int offset)
+static uint8_t early_in(struct uart_port *port, int offset)
{
return readl(port->membase + (offset << 2));
}
-static void __init early_out(struct uart_port *port, int offset, uint8_t value)
+static void early_out(struct uart_port *port, int offset, uint8_t value)
{
writel(value, port->membase + (offset << 2));
}
-static void __init ingenic_early_console_putc(struct uart_port *port, int c)
+static void ingenic_early_console_putc(struct uart_port *port, int c)
{
uint8_t lsr;
@@ -71,7 +71,7 @@ static void __init ingenic_early_console_putc(struct uart_port *port, int c)
early_out(port, UART_TX, c);
}
-static void __init ingenic_early_console_write(struct console *console,
+static void ingenic_early_console_write(struct console *console,
const char *s, unsigned int count)
{
uart_console_write(&early_device->port, s, count,
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 5/5] serial: 8250_early: Remove __init marking from early write
2017-07-18 6:02 [PATCH 0/5] earlycon hang under some conditions Jeffy Chen
` (3 preceding siblings ...)
2017-07-18 6:02 ` [PATCH 4/5] serial: 8250_ingenic: " Jeffy Chen
@ 2017-07-18 6:02 ` Jeffy Chen
2017-07-18 17:51 ` [PATCH 0/5] earlycon hang under some conditions Brian Norris
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Jeffy Chen @ 2017-07-18 6:02 UTC (permalink / raw)
To: linux-kernel
Cc: gregkh, briannorris, dianders, peter, Jeffy Chen, Marc Gonzalez,
Jiri Slaby, linux-serial
The earlycon would be alive outside the init code in these cases:
1/ we have keep_bootcon in cmdline.
2/ we don't have a real console to switch to.
So remove the __init marking to avoid invalid memory access.
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
drivers/tty/serial/8250/8250_early.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 82fc48e..af72ec3 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -37,7 +37,7 @@
#include <asm/io.h>
#include <asm/serial.h>
-static unsigned int __init serial8250_early_in(struct uart_port *port, int offset)
+static unsigned int serial8250_early_in(struct uart_port *port, int offset)
{
int reg_offset = offset;
offset <<= port->regshift;
@@ -60,7 +60,7 @@ static unsigned int __init serial8250_early_in(struct uart_port *port, int offse
}
}
-static void __init serial8250_early_out(struct uart_port *port, int offset, int value)
+static void serial8250_early_out(struct uart_port *port, int offset, int value)
{
int reg_offset = offset;
offset <<= port->regshift;
@@ -89,7 +89,7 @@ static void __init serial8250_early_out(struct uart_port *port, int offset, int
#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
-static void __init serial_putc(struct uart_port *port, int c)
+static void serial_putc(struct uart_port *port, int c)
{
unsigned int status;
@@ -103,7 +103,7 @@ static void __init serial_putc(struct uart_port *port, int c)
}
}
-static void __init early_serial8250_write(struct console *console,
+static void early_serial8250_write(struct console *console,
const char *s, unsigned int count)
{
struct earlycon_device *device = console->data;
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 0/5] earlycon hang under some conditions
2017-07-18 6:02 [PATCH 0/5] earlycon hang under some conditions Jeffy Chen
` (4 preceding siblings ...)
2017-07-18 6:02 ` [PATCH 5/5] serial: 8250_early: " Jeffy Chen
@ 2017-07-18 17:51 ` Brian Norris
2017-07-18 21:17 ` Doug Anderson
2017-07-24 23:50 ` Doug Anderson
2017-07-30 14:31 ` Andy Shevchenko
7 siblings, 1 reply; 10+ messages in thread
From: Brian Norris @ 2017-07-18 17:51 UTC (permalink / raw)
To: Jeffy Chen
Cc: linux-kernel, gregkh, dianders, peter, Sören Brinkmann,
Michal Simek, Marc Gonzalez, Jiri Slaby, Vineet Gupta,
linux-serial, linux-snps-arc, linux-arm-kernel
Hi Jeffy,
On Tue, Jul 18, 2017 at 02:02:53PM +0800, Jeffy Chen wrote:
> I was testing earlycon with 8250 dw serial console. And it hangs in
> these cases:
> 1/ kernel hang when calling early write function after free_initmem:
> a) the earlycon not disabled after the init code(due to keep_bootcon or
> not specify a real console to switch to)
> b) the early write func is marked as __init, for example 8250_early.
FWIW, I tested 8250_early with "keep_bootcon", and this fixes that:
Tested-by: Brian Norris <briannorris@chromium.org>
But then I get double console, if I have both a "real" and "early"
console.
If I were to *only* have the early console, then I might hit the
problems you mention:
> 2/ kernel hang when calling early write function after disable unused
> clks/pm domain:
> a) the earlycon not disabled after the init code
> b) the disable unused clks/pm domain kill the requiered clks/pm
> domain, since they are not referenced by the earlycon.
>
> 3/ kernel hang when calling early write function after the serial
> console driver runtime suspended:
> a) the earlycon not disabled after the init code
> b) the serial console driver's runtime suspend kills the requiered
> clks/pm domain, since they are not referenced by the earlycon.
>
> This serial fix 1/ case only.
Problems 2 and 3 look like something that's not really in scope for
early consoles. There's a reason they are mainly supported for early
boot, and we try to switch off of them. There isn't really a good way to
handle all the clock and PM infrastructure without...switching off the
earlycon and using the real one :)
So, I guess this patchset has value for systems where the clock/PM
requirements are simple enough, and the earlycon can actually be useful
beyond early init.
Brian
>
>
> Jeffy Chen (5):
> serial: arc: Remove __init marking from early write
> serial: omap: Remove __init marking from early write
> serial: xuartps: Remove __init marking from early write
> serial: 8250_ingenic: Remove __init marking from early write
> serial: 8250_early: Remove __init marking from early write
>
> drivers/tty/serial/8250/8250_early.c | 8 ++++----
> drivers/tty/serial/8250/8250_ingenic.c | 8 ++++----
> drivers/tty/serial/arc_uart.c | 4 ++--
> drivers/tty/serial/omap-serial.c | 13 ++++++-------
> drivers/tty/serial/xilinx_uartps.c | 2 +-
> 5 files changed, 17 insertions(+), 18 deletions(-)
>
> --
> 2.1.4
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 0/5] earlycon hang under some conditions
2017-07-18 17:51 ` [PATCH 0/5] earlycon hang under some conditions Brian Norris
@ 2017-07-18 21:17 ` Doug Anderson
0 siblings, 0 replies; 10+ messages in thread
From: Doug Anderson @ 2017-07-18 21:17 UTC (permalink / raw)
To: Brian Norris
Cc: Jeffy Chen, linux-kernel@vger.kernel.org, Greg Kroah-Hartman,
Peter Hurley, Sören Brinkmann, Michal Simek, Marc Gonzalez,
Jiri Slaby, Vineet Gupta, linux-serial, linux-snps-arc,
linux-arm-kernel@lists.infradead.org
Hi,
On Tue, Jul 18, 2017 at 10:51 AM, Brian Norris <briannorris@chromium.org> wrote:
> Hi Jeffy,
>
> On Tue, Jul 18, 2017 at 02:02:53PM +0800, Jeffy Chen wrote:
>> I was testing earlycon with 8250 dw serial console. And it hangs in
>> these cases:
>> 1/ kernel hang when calling early write function after free_initmem:
>> a) the earlycon not disabled after the init code(due to keep_bootcon or
>> not specify a real console to switch to)
>> b) the early write func is marked as __init, for example 8250_early.
>
> FWIW, I tested 8250_early with "keep_bootcon", and this fixes that:
>
> Tested-by: Brian Norris <briannorris@chromium.org>
>
> But then I get double console, if I have both a "real" and "early"
> console.
>
> If I were to *only* have the early console, then I might hit the
> problems you mention:
>
>> 2/ kernel hang when calling early write function after disable unused
>> clks/pm domain:
>> a) the earlycon not disabled after the init code
>> b) the disable unused clks/pm domain kill the requiered clks/pm
>> domain, since they are not referenced by the earlycon.
>>
>> 3/ kernel hang when calling early write function after the serial
>> console driver runtime suspended:
>> a) the earlycon not disabled after the init code
>> b) the serial console driver's runtime suspend kills the requiered
>> clks/pm domain, since they are not referenced by the earlycon.
>>
>> This serial fix 1/ case only.
>
> Problems 2 and 3 look like something that's not really in scope for
> early consoles. There's a reason they are mainly supported for early
> boot, and we try to switch off of them. There isn't really a good way to
> handle all the clock and PM infrastructure without...switching off the
> earlycon and using the real one :)
>
> So, I guess this patchset has value for systems where the clock/PM
> requirements are simple enough, and the earlycon can actually be useful
> beyond early init.
Presumably someone using this would just use the "clk_ignore_unused"
and "pd_ignore_unused" kernel parameters to help them... In this case
that seems fine to me. The "early" boot console is early because it
can't rely on all of the generic OS mechanisms to do things super
cleanly, so requiring the user to know that they should add the extra
command line arguments seems sane.
-Doug
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/5] earlycon hang under some conditions
2017-07-18 6:02 [PATCH 0/5] earlycon hang under some conditions Jeffy Chen
` (5 preceding siblings ...)
2017-07-18 17:51 ` [PATCH 0/5] earlycon hang under some conditions Brian Norris
@ 2017-07-24 23:50 ` Doug Anderson
2017-07-30 14:31 ` Andy Shevchenko
7 siblings, 0 replies; 10+ messages in thread
From: Doug Anderson @ 2017-07-24 23:50 UTC (permalink / raw)
To: Jeffy Chen
Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman, Brian Norris,
Peter Hurley, Sören Brinkmann, Michal Simek, Marc Gonzalez,
Jiri Slaby, Vineet Gupta, linux-serial, linux-snps-arc,
linux-arm-kernel@lists.infradead.org
Hi,
On Mon, Jul 17, 2017 at 11:02 PM, Jeffy Chen <jeffy.chen@rock-chips.com> wrote:
> I was testing earlycon with 8250 dw serial console. And it hangs in
> these cases:
> 1/ kernel hang when calling early write function after free_initmem:
> a) the earlycon not disabled after the init code(due to keep_bootcon or
> not specify a real console to switch to)
> b) the early write func is marked as __init, for example 8250_early.
>
> 2/ kernel hang when calling early write function after disable unused
> clks/pm domain:
> a) the earlycon not disabled after the init code
> b) the disable unused clks/pm domain kill the requiered clks/pm
> domain, since they are not referenced by the earlycon.
>
> 3/ kernel hang when calling early write function after the serial
> console driver runtime suspended:
> a) the earlycon not disabled after the init code
> b) the serial console driver's runtime suspend kills the requiered
> clks/pm domain, since they are not referenced by the earlycon.
>
> This serial fix 1/ case only.
>
>
>
> Jeffy Chen (5):
> serial: arc: Remove __init marking from early write
> serial: omap: Remove __init marking from early write
> serial: xuartps: Remove __init marking from early write
> serial: 8250_ingenic: Remove __init marking from early write
> serial: 8250_early: Remove __init marking from early write
>
> drivers/tty/serial/8250/8250_early.c | 8 ++++----
> drivers/tty/serial/8250/8250_ingenic.c | 8 ++++----
> drivers/tty/serial/arc_uart.c | 4 ++--
> drivers/tty/serial/omap-serial.c | 13 ++++++-------
> drivers/tty/serial/xilinx_uartps.c | 2 +-
> 5 files changed, 17 insertions(+), 18 deletions(-)
I looked through all 5 patches and they seem sane to me. I didn't go
through and test them since Brian already tested the patches for the
one UART driver I'd have access to anyway.
As per my previous email, I don't see any need to solve all the
world'd problems with this patch series, plus the keep_bootcon seems
to be an experts / debugging type option and it seems sane if you need
to take care in using it.
So officially for the series (FWIW since I'm just an interested 3rd party):
Reviewed-by: Douglas Anderson <dianders@chromium.org>
-Doug
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 0/5] earlycon hang under some conditions
2017-07-18 6:02 [PATCH 0/5] earlycon hang under some conditions Jeffy Chen
` (6 preceding siblings ...)
2017-07-24 23:50 ` Doug Anderson
@ 2017-07-30 14:31 ` Andy Shevchenko
7 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2017-07-30 14:31 UTC (permalink / raw)
To: Jeffy Chen
Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman, Brian Norris,
Douglas Anderson, Peter Hurley, Sören Brinkmann,
Michal Simek, Marc Gonzalez, Jiri Slaby, Vineet Gupta,
linux-serial@vger.kernel.org, linux-snps-arc,
linux-arm Mailing List
On Tue, Jul 18, 2017 at 9:02 AM, Jeffy Chen <jeffy.chen@rock-chips.com> wrote:
> I was testing earlycon with 8250 dw serial console. And it hangs in
> these cases:
> 1/ kernel hang when calling early write function after free_initmem:
> a) the earlycon not disabled after the init code(due to keep_bootcon or
> not specify a real console to switch to)
> b) the early write func is marked as __init, for example 8250_early.
> This serial fix 1/ case only.
Here is another opinion.
I can tell that conditions to get into the trouble are quite unusual or rare.
Any rationale behind why one needs such a combination of parameters?
P.S. For doulble output ask Sergey and Petr (they are quite concerned
about it). Actually strange I didn't see their names in Cc list for
console related stuff,
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread