All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: zhangqiumiao1@huwei.com
Cc: jirislaby@kernel.org, linux-kernel@vger.kernel.org,
	zhangqiumiao <zhangqiumiao1@huawei.com>
Subject: Re: [PATCH] tty: fix timeout equals to 0 problem in tty_ioctl
Date: Sat, 19 Dec 2020 08:50:47 +0100	[thread overview]
Message-ID: <X92w15bOlII1X0Pw@kroah.com> (raw)
In-Reply-To: <1608348451-24082-1-git-send-email-zhangqiumiao1@huwei.com>

On Sat, Dec 19, 2020 at 11:27:31AM +0800, zhangqiumiao1@huwei.com wrote:
> From: zhangqiumiao <zhangqiumiao1@huawei.com>
> 
> Fix the problem that tty buffer data was not flushed when timeout=0.
> 
> Signed-off-by: zhangqiumiao <zhangqiumiao1@huawei.com>
> ---
>  drivers/tty/tty_ioctl.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
> index 4de1c6ddb8ff..f9d4b6e22308 100644
> --- a/drivers/tty/tty_ioctl.c
> +++ b/drivers/tty/tty_ioctl.c
> @@ -220,13 +220,21 @@ void tty_wait_until_sent(struct tty_struct *tty, long timeout)
>  	tty_debug_wait_until_sent(tty, "wait until sent, timeout=%ld\n", timeout);
>  
>  	if (!timeout)
> -		timeout = MAX_SCHEDULE_TIMEOUT;
> +		timeout = 60 * HZ;

Why change this?

>  
>  	timeout = wait_event_interruptible_timeout(tty->write_wait,
>  			!tty_chars_in_buffer(tty), timeout);
> -	if (timeout <= 0)
> +	if (timeout < 0)
>  		return;

How can timeout be 0 here?

> +	if (timeout == 0) {
> +		if (tty->ops->flush_buffer) {
> +			pr_info("%s: flush buffer\n", __func__);

Debugging code?

> +			tty->ops->flush_buffer(tty);
> +		}
> +		return;
> +	}
> +

thanks,

greg k-h

       reply	other threads:[~2020-12-19  7:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1608348451-24082-1-git-send-email-zhangqiumiao1@huwei.com>
2020-12-19  7:50 ` Greg KH [this message]
2021-01-07 15:28 ` [PATCH] tty: fix timeout equals to 0 problem in tty_ioctl Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X92w15bOlII1X0Pw@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zhangqiumiao1@huawei.com \
    --cc=zhangqiumiao1@huwei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.