Commit c98c406e authored by David Howells's avatar David Howells

MN10300: ttySM: Use memory barriers correctly in circular buffer logic

Use memory barriers correctly in the circular buffer logic used in the driver,
as documented in Documentation/circular-buffers.txt.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarMark Salter <msalter@redhat.com>
parent 541880d9
...@@ -487,16 +487,17 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port) ...@@ -487,16 +487,17 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port)
try_again: try_again:
/* pull chars out of the hat */ /* pull chars out of the hat */
ix = port->rx_outp; ix = ACCESS_ONCE(port->rx_outp);
if (ix == port->rx_inp) { if (CIRC_CNT(port->rx_inp, ix, MNSC_BUFFER_SIZE) == 0) {
if (push && !tty->low_latency) if (push && !tty->low_latency)
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
return; return;
} }
smp_read_barrier_depends();
ch = port->rx_buffer[ix++]; ch = port->rx_buffer[ix++];
st = port->rx_buffer[ix++]; st = port->rx_buffer[ix++];
smp_rmb(); smp_mb();
port->rx_outp = ix & (MNSC_BUFFER_SIZE - 1); port->rx_outp = ix & (MNSC_BUFFER_SIZE - 1);
port->uart.icount.rx++; port->uart.icount.rx++;
...@@ -1657,13 +1658,14 @@ static int mn10300_serial_poll_get_char(struct uart_port *_port) ...@@ -1657,13 +1658,14 @@ static int mn10300_serial_poll_get_char(struct uart_port *_port)
do { do {
/* pull chars out of the hat */ /* pull chars out of the hat */
ix = port->rx_outp; ix = ACCESS_ONCE(port->rx_outp);
if (ix == port->rx_inp) if (CIRC_CNT(port->rx_inp, ix, MNSC_BUFFER_SIZE) == 0)
return NO_POLL_CHAR; return NO_POLL_CHAR;
smp_read_barrier_depends();
ch = port->rx_buffer[ix++]; ch = port->rx_buffer[ix++];
st = port->rx_buffer[ix++]; st = port->rx_buffer[ix++];
smp_rmb(); smp_mb();
port->rx_outp = ix & (MNSC_BUFFER_SIZE - 1); port->rx_outp = ix & (MNSC_BUFFER_SIZE - 1);
} while (st & (SC01STR_FEF | SC01STR_PEF | SC01STR_OEF)); } while (st & (SC01STR_FEF | SC01STR_PEF | SC01STR_OEF));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment