* [PATCH v3 0/3] serial: 8250_early: simplify serial_putc()
@ 2015-10-30 2:39 Masahiro Yamada
2015-10-30 2:39 ` [PATCH v3 1/3] serial: 8250_early: do not save and restore IER in write callback Masahiro Yamada
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Masahiro Yamada @ 2015-10-30 2:39 UTC (permalink / raw)
To: linux-serial
Cc: Peter Hurley, Masahiro Yamada, Greg Kroah-Hartman, linux-kernel,
Jiri Slaby
Changes in v3:
- Split into three patches.
- Confirm the empty TX only after sending each character.
Changes in v2:
- split into two patches
Masahiro Yamada (3):
serial: 8250_early: do not save and restore IER in write callback
serial: 8250_early: confirm empty transmitter after sending characters
serial: 8250_early: squash wait_for_xmitr() into serial_putc()
drivers/tty/serial/8250/8250_early.c | 24 ++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/3] serial: 8250_early: do not save and restore IER in write callback
2015-10-30 2:39 [PATCH v3 0/3] serial: 8250_early: simplify serial_putc() Masahiro Yamada
@ 2015-10-30 2:39 ` Masahiro Yamada
2015-10-30 2:39 ` [PATCH v3 2/3] serial: 8250_early: confirm empty transmitter after sending characters Masahiro Yamada
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2015-10-30 2:39 UTC (permalink / raw)
To: linux-serial
Cc: Peter Hurley, Masahiro Yamada, Greg Kroah-Hartman, linux-kernel,
Jiri Slaby
The IER has already been masked in early_serial8250_setup(), there is
no reason to save and restore it every time early_serial8250_write()
is called.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
drivers/tty/serial/8250/8250_early.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 7aff3d8..23c322f 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -99,20 +99,11 @@ static void __init early_serial8250_write(struct console *console,
{
struct earlycon_device *device = console->data;
struct uart_port *port = &device->port;
- unsigned int ier;
-
- /* Save the IER and disable interrupts preserving the UUE bit */
- ier = serial8250_early_in(port, UART_IER);
- if (ier)
- serial8250_early_out(port, UART_IER, ier & UART_IER_UUE);
uart_console_write(port, s, count, serial_putc);
- /* Wait for transmitter to become empty and restore the IER */
+ /* Wait for transmitter to become empty */
wait_for_xmitr(port);
-
- if (ier)
- serial8250_early_out(port, UART_IER, ier);
}
static void __init init_port(struct earlycon_device *device)
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/3] serial: 8250_early: confirm empty transmitter after sending characters
2015-10-30 2:39 [PATCH v3 0/3] serial: 8250_early: simplify serial_putc() Masahiro Yamada
2015-10-30 2:39 ` [PATCH v3 1/3] serial: 8250_early: do not save and restore IER in write callback Masahiro Yamada
@ 2015-10-30 2:39 ` Masahiro Yamada
2015-10-30 2:39 ` [PATCH v3 3/3] serial: 8250_early: squash wait_for_xmitr() into serial_putc() Masahiro Yamada
2015-10-30 13:41 ` [PATCH v3 0/3] serial: 8250_early: simplify serial_putc() Peter Hurley
3 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2015-10-30 2:39 UTC (permalink / raw)
To: linux-serial
Cc: Peter Hurley, Masahiro Yamada, Greg Kroah-Hartman, linux-kernel,
Jiri Slaby
The current code waits until the transmitter becomes empty,
before sending each character, and after finishing the whole string.
This seems a bit redundant.
It can be more efficient by checking the transmitter only after sending
each character. This should be safe because the transmitter is already
empty at the first entry of serial_putc().
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
drivers/tty/serial/8250/8250_early.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 23c322f..0b65a26 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -90,8 +90,8 @@ static void __init wait_for_xmitr(struct uart_port *port)
static void __init serial_putc(struct uart_port *port, int c)
{
- wait_for_xmitr(port);
serial8250_early_out(port, UART_TX, c);
+ wait_for_xmitr(port);
}
static void __init early_serial8250_write(struct console *console,
@@ -101,9 +101,6 @@ static void __init early_serial8250_write(struct console *console,
struct uart_port *port = &device->port;
uart_console_write(port, s, count, serial_putc);
-
- /* Wait for transmitter to become empty */
- wait_for_xmitr(port);
}
static void __init init_port(struct earlycon_device *device)
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 3/3] serial: 8250_early: squash wait_for_xmitr() into serial_putc()
2015-10-30 2:39 [PATCH v3 0/3] serial: 8250_early: simplify serial_putc() Masahiro Yamada
2015-10-30 2:39 ` [PATCH v3 1/3] serial: 8250_early: do not save and restore IER in write callback Masahiro Yamada
2015-10-30 2:39 ` [PATCH v3 2/3] serial: 8250_early: confirm empty transmitter after sending characters Masahiro Yamada
@ 2015-10-30 2:39 ` Masahiro Yamada
2015-10-30 13:41 ` [PATCH v3 0/3] serial: 8250_early: simplify serial_putc() Peter Hurley
3 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2015-10-30 2:39 UTC (permalink / raw)
To: linux-serial
Cc: Peter Hurley, Masahiro Yamada, Greg Kroah-Hartman, linux-kernel,
Jiri Slaby
Now, wait_for_xmitr() is only called from serial_putc(), and both
are short enough. They can be merged into a single function.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
drivers/tty/serial/8250/8250_early.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 0b65a26..f9e25ed 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -76,24 +76,20 @@ 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 wait_for_xmitr(struct uart_port *port)
+static void __init serial_putc(struct uart_port *port, int c)
{
unsigned int status;
+ serial8250_early_out(port, UART_TX, c);
+
for (;;) {
status = serial8250_early_in(port, UART_LSR);
if ((status & BOTH_EMPTY) == BOTH_EMPTY)
- return;
+ break;
cpu_relax();
}
}
-static void __init serial_putc(struct uart_port *port, int c)
-{
- serial8250_early_out(port, UART_TX, c);
- wait_for_xmitr(port);
-}
-
static void __init early_serial8250_write(struct console *console,
const char *s, unsigned int count)
{
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 0/3] serial: 8250_early: simplify serial_putc()
2015-10-30 2:39 [PATCH v3 0/3] serial: 8250_early: simplify serial_putc() Masahiro Yamada
` (2 preceding siblings ...)
2015-10-30 2:39 ` [PATCH v3 3/3] serial: 8250_early: squash wait_for_xmitr() into serial_putc() Masahiro Yamada
@ 2015-10-30 13:41 ` Peter Hurley
3 siblings, 0 replies; 5+ messages in thread
From: Peter Hurley @ 2015-10-30 13:41 UTC (permalink / raw)
To: Masahiro Yamada, linux-serial
Cc: Greg Kroah-Hartman, linux-kernel, Jiri Slaby
On 10/29/2015 10:39 PM, Masahiro Yamada wrote:
> Changes in v3:
> - Split into three patches.
> - Confirm the empty TX only after sending each character.
>
> Changes in v2:
> - split into two patches
>
> Masahiro Yamada (3):
> serial: 8250_early: do not save and restore IER in write callback
> serial: 8250_early: confirm empty transmitter after sending characters
> serial: 8250_early: squash wait_for_xmitr() into serial_putc()
>
> drivers/tty/serial/8250/8250_early.c | 24 ++++--------------------
> 1 file changed, 4 insertions(+), 20 deletions(-)
For series
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-10-30 13:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-30 2:39 [PATCH v3 0/3] serial: 8250_early: simplify serial_putc() Masahiro Yamada
2015-10-30 2:39 ` [PATCH v3 1/3] serial: 8250_early: do not save and restore IER in write callback Masahiro Yamada
2015-10-30 2:39 ` [PATCH v3 2/3] serial: 8250_early: confirm empty transmitter after sending characters Masahiro Yamada
2015-10-30 2:39 ` [PATCH v3 3/3] serial: 8250_early: squash wait_for_xmitr() into serial_putc() Masahiro Yamada
2015-10-30 13:41 ` [PATCH v3 0/3] serial: 8250_early: simplify serial_putc() Peter Hurley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).