Skip to content

Commit

Permalink
tty: hvc_dcc: Fix duplicate character inputs
Browse files Browse the repository at this point in the history
Reading from the DCC grabs a character from the buffer and
clears the status bit. Since this is a context-changing
operation, instructions following the character read that rely on
the status bit being accurate need to be synchronized with an
ISB.

In this case, the status bit check needs to execute after the
character read otherwise we run the risk of reading the character
and checking the status bit before the read can clear the status
bit in the first place. When this happens, the user will see the
same character they typed twice, instead of once.

Add an ISB after the read and the write, so that the status check
is synchronized with the read/write operations.

Signed-off-by: Stephen Boyd <[email protected]>
Cc: stable <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
bebarino authored and gregkh committed Nov 15, 2011
1 parent 52b3bfc commit c2a3e84
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/tty/hvc/hvc_dcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static inline char __dcc_getchar(void)

asm volatile("mrc p14, 0, %0, c0, c5, 0 @ read comms data reg"
: "=r" (__c));
isb();

return __c;
}
Expand All @@ -55,6 +56,7 @@ static inline void __dcc_putchar(char c)
asm volatile("mcr p14, 0, %0, c0, c5, 0 @ write a char"
: /* no output register */
: "r" (c));
isb();
}

static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count)
Expand Down

0 comments on commit c2a3e84

Please sign in to comment.