Re: [PATCH v2 2/3] serial: 8250_exar: Refactor exar_shutdown()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I'll try to get some firm results in the morning; otherwise I won't be
> able to check until early next week as I will be away from the
> hardware.

After doing more testing, I think that I finally have something that
is working fully at all baud rates.  I've tested this at
115200,9600,and 4800, testing via: echo "the quick brown fox jumps
over the lazy dog" > /dev/ttySx

Removing the check to uart_circ_empty in the while loop makes it more
reliable, however it will occasionally fail and only transmit the
first part of the message(at 4800, it will transmit only "t", at
115200 it will transmit "the quick bro").  I've found that breaking it
into two loops, one checking the uart_circ_empty and the other doing
the LSR check is reliable at all baud rates.  Here's what I have at
the moment:

diff --git a/drivers/tty/serial/8250/8250_exar.c
b/drivers/tty/serial/8250/8250_exar.c
index e7448831af6d..4e415b915e35 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -565,18 +565,21 @@ static void
 exar_shutdown(struct uart_port *port)
 {
     unsigned char lsr;
-    bool tx_complete = 0;
     struct uart_8250_port *up = up_to_u8250p(port);
+    unsigned int times = 1000;
     struct circ_buf *xmit = &port->state->xmit;

+    while (!uart_circ_empty(xmit) && --times > 0) {
+        usleep_range(1000, 1100);
+    }
+
+    times = 1000;
     do{
         lsr = serial_in(up, UART_LSR);
         if (lsr & (UART_LSR_TEMT | UART_LSR_THRE))
-            tx_complete = 1;
-        else
-            tx_complete = 0;
-        msleep(1);
-    }while( !uart_circ_empty(xmit) && !tx_complete );
+            break;
+        usleep_range(1000, 1100);
+    }while( --times > 0 );

     serial8250_do_shutdown(port);
 }

I can do a formal patch later, but I just wanted to see if this made
sense first.  The second loop is now much simpler, and does not do the
buffer check at the same time, which was probably causing some
problems with the previous version.

-Robert Middleton



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux