Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ce76570a authored by Peter Hurley's avatar Peter Hurley Committed by Imran Khan
Browse files

BACKPORT: n_tty: Fix unordered accesses to lockless read buffer



Add commit_head buffer index, which the producer-side publishes
after input processing in non-canon mode. This ensures the consumer-side
observes correctly-ordered writes in non-canonical mode (ie., the buffer
data is written before the buffer index is advanced). Fix consumer-side
uses of read_cnt() to use commit_head instead.

Add required memory barriers to the tail index to guarantee
the consumer-side has completed the loads before the producer-side
begins writing new data. Open-code the producer-side receive_room()
into the i/o loop.

Remove no-longer-referenced receive_room().

Based on work by Christian Riesch <christian.riesch@omicron.at>

Cc: Christian Riesch <christian.riesch@omicron.at>
Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>

[salidoa@google.com: Modied to keep receive_room() which is called
    in many places]

BUG=b:29643166
TEST=smaug boots

(cherry picked from commit 70aca71f92ca2c111978bf676287fab5580d2598)
Signed-off-by: default avatarAdrian Salido <salidoa@google.com>
Reviewed-on: https://chromium-review.googlesource.com/356730


Commit-Ready: Adrian Salido <salidoa@chromium.org>
Tested-by: default avatarAdrian Salido <salidoa@chromium.org>
Reviewed-by: default avatarStephen Barber <smbarber@chromium.org>
CRs-Fixed: 1073011
Change-Id: I002f3eda7b1b1d06f38ee69c613ef4e90da51615
Git-repo: https://chromium.googlesource.com/chromiumos/third_party/kernel


Git-commit: 86f682dca64c3144cfcd92dce2e4423457fbf878
(kimran@codeaurora.org: resolved minor cherry-pick conflicts)
Signed-off-by: default avatarImran Khan <kimran@codeaurora.org>
parent c8234f7c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment