From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4252hJ6r5VzF36T for ; Wed, 5 Sep 2018 22:14:56 +1000 (AEST) Received: by mail-pf1-f193.google.com with SMTP id j26-v6so3385067pfi.10 for ; Wed, 05 Sep 2018 05:14:56 -0700 (PDT) From: Nicholas Piggin To: Greg Kroah-Hartman Cc: Nicholas Piggin , Jiri Slaby , Michael Ellerman , Matteo Croce , Jason Gunthorpe , Leon Romanovsky , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org (op) Subject: [PATCH 1/3] tty: hvc: hvc_poll() fix read loop hang Date: Wed, 5 Sep 2018 22:14:37 +1000 Message-Id: <20180905121439.23809-2-npiggin@gmail.com> In-Reply-To: <20180905121439.23809-1-npiggin@gmail.com> References: <20180905121439.23809-1-npiggin@gmail.com> List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Patch ec97eaad1383 ("tty: hvc: hvc_poll() break hv read loop") causes the virtio console to hang at times (e.g., if you paste a bunch of characters to it. The reason is that get_chars must return 0 before we can be sure the driver will kick or poll input again, but this change only scheduled a poll if get_chars had returned a full count. Change this to poll on any > 0 count. Fixes: ec97eaad1383 ("tty: hvc: hvc_poll() break hv read loop") Reported-by: Matteo Croce Reported-by: Jason Gunthorpe Tested-by: Matteo Croce Tested-by: Leon Romanovsky Signed-off-by: Nicholas Piggin --- drivers/tty/hvc/hvc_console.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index 5414c4a87bea..c917749708d2 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c @@ -717,10 +717,13 @@ static int __hvc_poll(struct hvc_struct *hp, bool may_sleep) #endif /* CONFIG_MAGIC_SYSRQ */ tty_insert_flip_char(&hp->port, buf[i], 0); } - if (n == count) - poll_mask |= HVC_POLL_READ; read_total = n; + /* + * Latency break, schedule another poll immediately. + */ + poll_mask |= HVC_POLL_READ; + out: /* Wakeup write queue if necessary */ if (hp->do_wakeup) { -- 2.18.0