Skip to content

Commit

Permalink
yet another uart race condition fix (sonic-net#75)
Browse files Browse the repository at this point in the history
Signed-off-by: Guohan Lu <gulv@microsoft.com>
  • Loading branch information
lguohan authored Dec 16, 2018
1 parent 39d0301 commit d631eeb
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ From: Guohan Lu <gulv@microsoft.com>

this is complete the fix in a5ba1d95e46ecaea638ddd7cd144107c783acb5d
---
drivers/tty/serial/serial_core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/serial_core.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 53e6db8..ec1187d 100644
index 53e6db8..c98a5d0 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -530,10 +530,12 @@ static int uart_put_char(struct tty_struct *tty, unsigned char c)
Expand All @@ -26,3 +26,18 @@ index 53e6db8..ec1187d 100644
if (port && uart_circ_chars_free(circ) != 0) {
circ->buf[circ->head] = c;
circ->head = (circ->head + 1) & (UART_XMIT_SIZE - 1);
@@ -567,10 +569,12 @@ static int uart_write(struct tty_struct *tty,
}

circ = &state->xmit;
- if (!circ->buf)
+ port = uart_port_lock(state, flags);
+ if (!circ->buf) {
+ uart_port_unlock(port, flags);
return 0;
+ }

- port = uart_port_lock(state, flags);
while (port) {
c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);
if (count < c)

0 comments on commit d631eeb

Please sign in to comment.