Skip to content

Commit

Permalink
tty: hvc: hvc_write() fix break condition
Browse files Browse the repository at this point in the history
Commit 550ddad ("tty: hvc: hvc_write() may sleep") broke the
termination condition in case the driver stops accepting characters.
This can result in unnecessary polling of the busy driver.

Restore it by testing the hvc_push return code.

Tested-by: Matteo Croce <mcroce@redhat.com>
Tested-by: Jason Gunthorpe <jgg@mellanox.com>
Tested-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
npiggin authored and gregkh committed Sep 10, 2018
1 parent 68b2fc7 commit 7f2bf78
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/tty/hvc/hvc_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
return -EIO;

while (count > 0) {
int ret = 0;

spin_lock_irqsave(&hp->lock, flags);

rsize = hp->outbuf_size - hp->n_outbuf;
Expand All @@ -537,10 +539,13 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
}

if (hp->n_outbuf > 0)
hvc_push(hp);
ret = hvc_push(hp);

spin_unlock_irqrestore(&hp->lock, flags);

if (!ret)
break;

if (count) {
if (hp->n_outbuf > 0)
hvc_flush(hp);
Expand Down

0 comments on commit 7f2bf78

Please sign in to comment.