1
0
Fork 0

tty: Replace smp_rmb/smp_wmb with smp_load_acquire/smp_store_release

Clarify flip buffer producer/consumer operation; the use of
smp_load_acquire() and smp_store_release() more clearly indicates
which memory access requires a barrier.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
hifive-unleashed-5.1
Peter Hurley 2015-07-12 20:50:49 -04:00 committed by Greg Kroah-Hartman
parent e5eb517dd8
commit 069f38b498
1 changed files with 4 additions and 6 deletions

View File

@ -291,12 +291,11 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size,
n->flags = flags; n->flags = flags;
buf->tail = n; buf->tail = n;
b->commit = b->used; b->commit = b->used;
/* paired w/ barrier in flush_to_ldisc(); ensures the /* paired w/ acquire in flush_to_ldisc(); ensures the
* latest commit value can be read before the head is * latest commit value can be read before the head is
* advanced to the next buffer * advanced to the next buffer
*/ */
smp_wmb(); smp_store_release(&b->next, n);
b->next = n;
} else if (change) } else if (change)
size = 0; size = 0;
else else
@ -488,12 +487,11 @@ static void flush_to_ldisc(struct work_struct *work)
if (atomic_read(&buf->priority)) if (atomic_read(&buf->priority))
break; break;
next = head->next; /* paired w/ release in __tty_buffer_request_room();
/* paired w/ barrier in __tty_buffer_request_room();
* ensures commit value read is not stale if the head * ensures commit value read is not stale if the head
* is advancing to the next buffer * is advancing to the next buffer
*/ */
smp_rmb(); next = smp_load_acquire(&head->next);
count = head->commit - head->read; count = head->commit - head->read;
if (!count) { if (!count) {
if (next == NULL) { if (next == NULL) {