All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Tony Lindgren <tony@atomide.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andy Shevchenko <andriy.shevchenko@intel.com>,
	Jiri Slaby <jirislaby@kernel.org>,
	Johan Hovold <johan@kernel.org>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	"open list:SERIAL DRIVERS" <linux-serial@vger.kernel.org>,
	Linux OMAP Mailing List <linux-omap@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/6] n_tty: Start making use of -EAGAIN returned from process_output_block()
Date: Tue, 21 Sep 2021 14:58:55 +0300	[thread overview]
Message-ID: <CAHp75VeBM-k39HJWe8cyiz+7sKbgMwJLivOGSs_8=nMADUbukw@mail.gmail.com> (raw)
In-Reply-To: <20210921103346.64824-2-tony@atomide.com>

On Tue, Sep 21, 2021 at 1:34 PM Tony Lindgren <tony@atomide.com> wrote:
>
> We check for -EAGAIN in n_tty_write() but never currently get it from
> process_output_block(). Let's add -EAGAIN handling and break out with 0
> bytes processed. Note that if we return -EAGAIN from n_tty_write(), it
> will be treated as error by the caller rather than a retry.
>
> Looking at the patch description for commit 9ef8927f45f2 ("n_tty: check
> for negative and zero space return from tty_write_room") it looks like we
> have not made use of -EGAIN from process_output_block() so far, so this

-EGAIN?

> does not seem like it's currently needed as a fix.
>
> We can use -EAGAIN for serial layer power management changes as we now
> will make use of write_room() returning 0 for an idled serial port.
>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/tty/n_tty.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
> --- a/drivers/tty/n_tty.c
> +++ b/drivers/tty/n_tty.c
> @@ -549,6 +549,8 @@ static ssize_t process_output_block(struct tty_struct *tty,
>         space = tty_write_room(tty);
>         if (space <= 0) {
>                 mutex_unlock(&ldata->output_lock);
> +               if (!space)
> +                       space = -EAGAIN;
>                 return space;
>         }
>         if (nr > space)
> @@ -2287,8 +2289,10 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
>                         while (nr > 0) {
>                                 ssize_t num = process_output_block(tty, b, nr);
>                                 if (num < 0) {
> -                                       if (num == -EAGAIN)
> -                                               break;
> +                                       if (num == -EAGAIN) {
> +                                               retval = 0;
> +                                               goto break_out;
> +                                       }
>                                         retval = num;
>                                         goto break_out;
>                                 }
> --
> 2.33.0



-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2021-09-21 11:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 10:33 [PATCH 0/6] Get rid of pm_runtime_irq_safe() for 8250_omap Tony Lindgren
2021-09-21 10:33 ` [PATCH 1/6] n_tty: Start making use of -EAGAIN returned from process_output_block() Tony Lindgren
2021-09-21 11:58   ` Andy Shevchenko [this message]
2021-09-21 10:33 ` [PATCH 2/6] tty: n_gsm: Don't ignore write return value in gsmld_output() Tony Lindgren
2021-09-21 10:33 ` [PATCH 3/6] serial: core: Add new prep_tx for power management Tony Lindgren
2021-09-23 12:45   ` Johan Hovold
2021-09-23 15:02     ` Tony Lindgren
2021-09-24 14:37       ` Johan Hovold
2021-09-24 15:09         ` Tony Lindgren
2021-09-27 14:05           ` Johan Hovold
2021-09-21 10:33 ` [PATCH 4/6] serial: 8250: Implement " Tony Lindgren
2021-09-23 12:49   ` Johan Hovold
2021-09-23 15:05     ` Tony Lindgren
2021-09-24 14:44       ` Johan Hovold
2021-09-24 15:16         ` Tony Lindgren
2021-09-21 10:33 ` [PATCH 5/6] serial: 8250_omap: Require a valid wakeirq for deeper idle states Tony Lindgren
2021-09-21 10:33 ` [PATCH 6/6] serial: 8250_omap: Drop the use of pm_runtime_irq_safe() Tony Lindgren
2021-09-21 12:03 ` [PATCH 0/6] Get rid of pm_runtime_irq_safe() for 8250_omap Andy Shevchenko

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='CAHp75VeBM-k39HJWe8cyiz+7sKbgMwJLivOGSs_8=nMADUbukw@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=tony@atomide.com \
    --cc=vigneshr@ti.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.