Skip to content

Commit

Permalink
MN10300: ttySM: Use memory barriers correctly in circular buffer logic
Browse files Browse the repository at this point in the history
Use memory barriers correctly in the circular buffer logic used in the driver,
as documented in Documentation/circular-buffers.txt.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Mark Salter <msalter@redhat.com>
  • Loading branch information
David Howells committed Dec 12, 2012
1 parent 541880d commit c98c406
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions arch/mn10300/kernel/mn10300-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,16 +487,17 @@ static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port)

try_again:
/* pull chars out of the hat */
ix = port->rx_outp;
if (ix == port->rx_inp) {
ix = ACCESS_ONCE(port->rx_outp);
if (CIRC_CNT(port->rx_inp, ix, MNSC_BUFFER_SIZE) == 0) {
if (push && !tty->low_latency)
tty_flip_buffer_push(tty);
return;
}

smp_read_barrier_depends();
ch = port->rx_buffer[ix++];
st = port->rx_buffer[ix++];
smp_rmb();
smp_mb();
port->rx_outp = ix & (MNSC_BUFFER_SIZE - 1);
port->uart.icount.rx++;

Expand Down Expand Up @@ -1657,13 +1658,14 @@ static int mn10300_serial_poll_get_char(struct uart_port *_port)

do {
/* pull chars out of the hat */
ix = port->rx_outp;
if (ix == port->rx_inp)
ix = ACCESS_ONCE(port->rx_outp);
if (CIRC_CNT(port->rx_inp, ix, MNSC_BUFFER_SIZE) == 0)
return NO_POLL_CHAR;

smp_read_barrier_depends();
ch = port->rx_buffer[ix++];
st = port->rx_buffer[ix++];
smp_rmb();
smp_mb();
port->rx_outp = ix & (MNSC_BUFFER_SIZE - 1);

} while (st & (SC01STR_FEF | SC01STR_PEF | SC01STR_OEF));
Expand Down

0 comments on commit c98c406

Please sign in to comment.