serial: sh-sci: Fix setting SCSCR_TIE while transferring data [Linux 3.16.72]

This Linux kernel change "serial: sh-sci: Fix setting SCSCR_TIE while transferring data" is included in the Linux 3.16.72 release. This change is authored by Hoan Nguyen An <na-hoan [at] jinso.co.jp> on Mon Mar 18 18:26:32 2019 +0900. The commit for this change in Linux stable tree is fe9f6d5 (patch) which is from upstream commit 93bcefd. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 93bcefd.

serial: sh-sci: Fix setting SCSCR_TIE while transferring data

commit 93bcefd4c6bad4c69dbc4edcd3fbf774b24d930d upstream.

We disable transmission interrupt (clear SCSCR_TIE) after all data has been transmitted
(if uart_circ_empty(xmit)). While transmitting, if the data is still in the tty buffer,
re-enable the SCSCR_TIE bit, which was done at sci_start_tx().
This is unnecessary processing, wasting CPU operation if the data transmission length is large.
And further, transmit end, FIFO empty bits disabling have also been performed in the step above.

Signed-off-by: Hoan Nguyen An <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <[email protected]>

There are 12 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/tty/serial/sh-sci.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index e222421..0dc1d1a 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -633,19 +633,9 @@ static void sci_transmit_chars(struct uart_port *port)

    if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
        uart_write_wakeup(port);
-   if (uart_circ_empty(xmit)) {
+   if (uart_circ_empty(xmit))
        sci_stop_tx(port);
-   } else {
-       ctrl = serial_port_in(port, SCSCR);
-
-       if (port->type != PORT_SCI) {
-           serial_port_in(port, SCxSR); /* Dummy read */
-           serial_port_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
-       }

-       ctrl |= SCSCR_TIE;
-       serial_port_out(port, SCSCR, ctrl);
-   }
 }

 /* On SH3, SCIF may read end-of-break as a space->mark char */

Leave a Reply

Your email address will not be published. Required fields are marked *