linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andy Shevchenko <andriy.shevchenko@intel.com>,
	Jiri Slaby <jirislaby@kernel.org>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	linux-serial@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/6] serial: core: Add new prep_tx for power management
Date: Fri, 24 Sep 2021 18:09:18 +0300	[thread overview]
Message-ID: <YU3qHiMNHVz/JX/y@atomide.com> (raw)
In-Reply-To: <YU3isENYUb+aE4qi@hovoldconsulting.com>

* Johan Hovold <johan@kernel.org> [210924 14:38]:
> On Thu, Sep 23, 2021 at 06:02:27PM +0300, Tony Lindgren wrote:
> > * Johan Hovold <johan@kernel.org> [210923 12:46]:
> > > On Tue, Sep 21, 2021 at 01:33:43PM +0300, Tony Lindgren wrote:
> > > > If the serial driver implements PM runtime with autosuspend, the port may
> > > > be powered off for TX. To wake up the port, let's add new prep_tx() call
> > > > for serial drivers to implement as needed. We call it from serial
> > > > write_room() and write() functions. If the serial port is not enabled,
> > > > we just return 0.
> > > 
> > > This isn't right. If there's room in the driver buffer, there's no
> > > reason to not accept those characters.
> > 
> > Maybe. We might get away with returning zero bytes written in write().
> > But to me it seems better to stop things early when write is known
> > to not succeed.
> 
> But you shouldn't return zero from write() either. If there's room in
> the write buffer we accept the data.

And then waking up the serial port takes several tens of ms and the
buffer is full and we still need to deal with it :) But yeah I see
your point for the write buffer.

> > > It's the drivers responsibility to resume writing when write() is
> > > called and that me need to be done in a runtime resume callback in case
> > > the device is suspended.
> > 
> > I think we currently need to return zero bytes written from write()
> > when the serial port is not usable.
> > 
> > I don't think we can return a fake number of bytes written from write().
> 
> It's not a fake number. It's similar to if you have a port that is
> stalled due to flow control. We buffer the data and continue writing
> when the other end is ready to accept more.

OK. So based on what you suggested earlier I'll take a look at moving
the wake-up to __uart_start(), then have the device driver runtime PM
resume call uart_start() again. Looks like uart_start() is a void
function anyways.. If you have some better ideas there, please let me
know.

> > > No need to be patching line disciplines for this.
> > 
> > Do you see issues with handling the errors in line disciplines?
> 
> It's just conceptually wrong to push retrying up the stack, possible all
> the way to user space in case of non-blocking opens, just because the
> device isn't already runtime active.

Yes, I don't see a way around that currently. Maybe if we start making
use of uart_tx_stopped() or something similar that could be simplified.
And we'll be still hit these line discipline error handling cases
anyways depending on how long the serial port wake up takes.

Regards,

Tony

  reply	other threads:[~2021-09-24 15:09 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
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 [this message]
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=YU3qHiMNHVz/JX/y@atomide.com \
    --to=tony@atomide.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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).