linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] serial: samsung: Use the passed in "port", fixing kgdb w/ no console
@ 2014-04-21 16:40 Doug Anderson
  2014-04-21 16:40 ` [PATCH 2/3] serial: samsung: don't check config for every character Doug Anderson
  2014-04-21 16:40 ` [PATCH 3/3] serial: samsung: Change barrier() to cpu_relax() in console output Doug Anderson
  0 siblings, 2 replies; 3+ messages in thread
From: Doug Anderson @ 2014-04-21 16:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-samsung-soc
  Cc: olof, Doug Anderson, jslaby, linux-serial, linux-kernel

The two functions in the samsung serial driver used for writing
characters out to the port were inconsistent about whether they used
the passed in "port" or the global "cons_uart".  There was no reason
to use the global and the use of the global in
s3c24xx_serial_put_poll_char() caused a crash in the case where you
used the serial port for kgdboc but not for console.

Fix it so we used the passed in variable.

Note that this doesn't fix all problems with the samsung serial
driver.  Specifically:
* s3c24xx_serial_console_putchar() is still 99% identical to
  s3c24xx_serial_put_poll_char() (the function signature is different,
  but that's about it).  A future patch will make them slightly less
  identical and judging by other serial drivers we may need yet more
  differences eventually.
* The samsung serial driver still doesn't allow you to have more than
  one console port since it still uses the global cons_uart in
  s3c24xx_serial_console_write().

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
 drivers/tty/serial/samsung.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 23f4596..a8e8b79 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -1446,8 +1446,8 @@ static int s3c24xx_serial_get_poll_char(struct uart_port *port)
 static void s3c24xx_serial_put_poll_char(struct uart_port *port,
 		unsigned char c)
 {
-	unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON);
-	unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON);
+	unsigned int ufcon = rd_regl(port, S3C2410_UFCON);
+	unsigned int ucon = rd_regl(port, S3C2410_UCON);
 
 	/* not possible to xmit on unconfigured port */
 	if (!s3c24xx_port_configured(ucon))
@@ -1455,7 +1455,7 @@ static void s3c24xx_serial_put_poll_char(struct uart_port *port,
 
 	while (!s3c24xx_serial_console_txrdy(port, ufcon))
 		cpu_relax();
-	wr_regb(cons_uart, S3C2410_UTXH, c);
+	wr_regb(port, S3C2410_UTXH, c);
 }
 
 #endif /* CONFIG_CONSOLE_POLL */
@@ -1463,8 +1463,8 @@ static void s3c24xx_serial_put_poll_char(struct uart_port *port,
 static void
 s3c24xx_serial_console_putchar(struct uart_port *port, int ch)
 {
-	unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON);
-	unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON);
+	unsigned int ufcon = rd_regl(port, S3C2410_UFCON);
+	unsigned int ucon = rd_regl(port, S3C2410_UCON);
 
 	/* not possible to xmit on unconfigured port */
 	if (!s3c24xx_port_configured(ucon))
@@ -1472,7 +1472,7 @@ s3c24xx_serial_console_putchar(struct uart_port *port, int ch)
 
 	while (!s3c24xx_serial_console_txrdy(port, ufcon))
 		barrier();
-	wr_regb(cons_uart, S3C2410_UTXH, ch);
+	wr_regb(port, S3C2410_UTXH, ch);
 }
 
 static void
-- 
1.9.1.423.g4596e3a


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

* [PATCH 2/3] serial: samsung: don't check config for every character
  2014-04-21 16:40 [PATCH 1/3] serial: samsung: Use the passed in "port", fixing kgdb w/ no console Doug Anderson
@ 2014-04-21 16:40 ` Doug Anderson
  2014-04-21 16:40 ` [PATCH 3/3] serial: samsung: Change barrier() to cpu_relax() in console output Doug Anderson
  1 sibling, 0 replies; 3+ messages in thread
From: Doug Anderson @ 2014-04-21 16:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-samsung-soc
  Cc: olof, Doug Anderson, jslaby, linux-serial, linux-kernel

The s3c24xx_serial_console_putchar() is _only_ ever used by
s3c24xx_serial_console_write() and is called in a loop (indirectly
through uart_console_write()).  There's no reason to call
s3c24xx_port_configured() for every iteration through the loop.  Move
it outside the loop.

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
 drivers/tty/serial/samsung.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index a8e8b79..12442748 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -1464,11 +1464,6 @@ static void
 s3c24xx_serial_console_putchar(struct uart_port *port, int ch)
 {
 	unsigned int ufcon = rd_regl(port, S3C2410_UFCON);
-	unsigned int ucon = rd_regl(port, S3C2410_UCON);
-
-	/* not possible to xmit on unconfigured port */
-	if (!s3c24xx_port_configured(ucon))
-		return;
 
 	while (!s3c24xx_serial_console_txrdy(port, ufcon))
 		barrier();
@@ -1479,6 +1474,12 @@ static void
 s3c24xx_serial_console_write(struct console *co, const char *s,
 			     unsigned int count)
 {
+	unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON);
+
+	/* not possible to xmit on unconfigured port */
+	if (!s3c24xx_port_configured(ucon))
+		return;
+
 	uart_console_write(cons_uart, s, count, s3c24xx_serial_console_putchar);
 }
 
-- 
1.9.1.423.g4596e3a


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

* [PATCH 3/3] serial: samsung: Change barrier() to cpu_relax() in console output
  2014-04-21 16:40 [PATCH 1/3] serial: samsung: Use the passed in "port", fixing kgdb w/ no console Doug Anderson
  2014-04-21 16:40 ` [PATCH 2/3] serial: samsung: don't check config for every character Doug Anderson
@ 2014-04-21 16:40 ` Doug Anderson
  1 sibling, 0 replies; 3+ messages in thread
From: Doug Anderson @ 2014-04-21 16:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-samsung-soc
  Cc: olof, Doug Anderson, jslaby, linux-serial, linux-kernel

The two functions to write out to the console (one used in normal
console mode and one in polling console mode) were slightly different.
One used a barrier() in its loop and the other a cpu_relax().  The
barrier() really doesn't do anything since we're using rd_regl() to
read the port anyway.  Switch it to cpu_relax() to make things
consistent.

No known bugs / issues are fixed by this change--it just makes things
more consistent.

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
 drivers/tty/serial/samsung.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 12442748..1f5505e 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -1466,7 +1466,7 @@ s3c24xx_serial_console_putchar(struct uart_port *port, int ch)
 	unsigned int ufcon = rd_regl(port, S3C2410_UFCON);
 
 	while (!s3c24xx_serial_console_txrdy(port, ufcon))
-		barrier();
+		cpu_relax();
 	wr_regb(port, S3C2410_UTXH, ch);
 }
 
-- 
1.9.1.423.g4596e3a


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

end of thread, other threads:[~2014-04-21 16:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-21 16:40 [PATCH 1/3] serial: samsung: Use the passed in "port", fixing kgdb w/ no console Doug Anderson
2014-04-21 16:40 ` [PATCH 2/3] serial: samsung: don't check config for every character Doug Anderson
2014-04-21 16:40 ` [PATCH 3/3] serial: samsung: Change barrier() to cpu_relax() in console output Doug Anderson

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).