summaryrefslogtreecommitdiff
path: root/drivers/tty/hvc
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2018-09-09 08:39:16 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-10 19:04:31 +0300
commit7f2bf7840b74a160f908db83bc8829f8de10629b (patch)
tree2a34c7484d8288d850e3343244f46a570bf851ce /drivers/tty/hvc
parent68b2fc714fb1e08385f9c810d84f06affd007350 (diff)
downloadlinux-7f2bf7840b74a160f908db83bc8829f8de10629b.tar.xz
tty: hvc: hvc_write() fix break condition
Commit 550ddadcc758 ("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>
Diffstat (limited to 'drivers/tty/hvc')
-rw-r--r--drivers/tty/hvc/hvc_console.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index bacf9b73ec98..27284a2dcd2b 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -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;
@@ -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);