]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.27.46/serial-8250-add-serial-transmitter-fully-empty-test.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.27.46 / serial-8250-add-serial-transmitter-fully-empty-test.patch
1 From bca476139d2ded86be146dae09b06e22548b67f3 Mon Sep 17 00:00:00 2001
2 From: Dick Hollenbeck <dick@softplc.com>
3 Date: Wed, 9 Dec 2009 12:31:34 -0800
4 Subject: serial: 8250: add serial transmitter fully empty test
5
6 From: Dick Hollenbeck <dick@softplc.com>
7
8 commit bca476139d2ded86be146dae09b06e22548b67f3 upstream.
9
10 When controlling an industrial radio modem it can be necessary to
11 manipulate the handshake lines in order to control the radio modem's
12 transmitter, from userspace.
13
14 The transmitter should not be turned off before all characters have been
15 transmitted. serial8250_tx_empty() was reporting that all characters were
16 transmitted before they actually were.
17
18 ===
19
20 Discovered in parallel with more testing and analysis by Kees Schoenmakers
21 as follows:
22
23 I ran into an NetMos 9835 serial pci board which behaves a little
24 different than the standard. This type of expansion board is very common.
25
26 "Standard" 8250 compatible devices clear the 'UART_LST_TEMT" bit together
27 with the "UART_LSR_THRE" bit when writing data to the device.
28
29 The NetMos device does it slightly different
30
31 I believe that the TEMT bit is coupled to the shift register. The problem
32 is that after writing data to the device and very quickly after that one
33 does call serial8250_tx_empty, it returns the wrong information.
34
35 My patch makes the test more robust (and solves the problem) and it does
36 not affect the already correct devices.
37
38 Alan:
39
40 We may yet need to quirk this but now we know which chips we have a
41 way to do that should we find this breaks some other 8250 clone with
42 dodgy THRE.
43
44 Signed-off-by: Dick Hollenbeck <dick@softplc.com>
45 Signed-off-by: Alan Cox <alan@linux.intel.com>
46 Cc: Kees Schoenmakers <k.schoenmakers@sigmae.nl>
47 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
48 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
49
50 ---
51 drivers/serial/8250.c | 7 ++++---
52 1 file changed, 4 insertions(+), 3 deletions(-)
53
54 --- a/drivers/serial/8250.c
55 +++ b/drivers/serial/8250.c
56 @@ -70,6 +70,9 @@ static unsigned int nr_uarts = CONFIG_SE
57
58 #define PASS_LIMIT 256
59
60 +#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
61 +
62 +
63 /*
64 * We default to IRQ0 for the "no irq" hack. Some
65 * machine types want others as well - they're free
66 @@ -1656,7 +1659,7 @@ static unsigned int serial8250_tx_empty(
67 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
68 spin_unlock_irqrestore(&up->port.lock, flags);
69
70 - return lsr & UART_LSR_TEMT ? TIOCSER_TEMT : 0;
71 + return (lsr & BOTH_EMPTY) == BOTH_EMPTY ? TIOCSER_TEMT : 0;
72 }
73
74 static unsigned int serial8250_get_mctrl(struct uart_port *port)
75 @@ -1714,8 +1717,6 @@ static void serial8250_break_ctl(struct
76 spin_unlock_irqrestore(&up->port.lock, flags);
77 }
78
79 -#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
80 -
81 /*
82 * Wait for transmitter & holding register to empty
83 */