* [PATCH] serial: core: Fix runtime PM handling for pending tx
@ 2023-10-23 7:48 Tony Lindgren
2023-10-23 9:40 ` Richard Purdie
0 siblings, 1 reply; 2+ messages in thread
From: Tony Lindgren @ 2023-10-23 7:48 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko
Cc: Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness,
Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra,
linux-kernel, linux-serial, Richard Purdie, Bruce Ashfield,
Mikko Rapeli, Paul Gortmaker, Randy MacLeod
Richard reported that a serial port may end up sometimes with tx data
pending in the buffer for long periods of time.
Turns out we bail out early on any errors from pm_runtime_get(),
including -EINPROGRESS. To fix the issue, we need to ignore -EINPROGRESS
as we only care about the runtime PM usage count at this point. We check
for an active runtime PM state later on for tx.
Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
Reported-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Cc: Bruce Ashfield <bruce.ashfield@gmail.com>
Cc: Mikko Rapeli <mikko.rapeli@linaro.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Randy MacLeod <randy.macleod@windriver.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/tty/serial/serial_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -146,7 +146,7 @@ static void __uart_start(struct uart_state *state)
/* Increment the runtime PM usage count for the active check below */
err = pm_runtime_get(&port_dev->dev);
- if (err < 0) {
+ if (err < 0 && err != -EINPROGRESS) {
pm_runtime_put_noidle(&port_dev->dev);
return;
}
--
2.42.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] serial: core: Fix runtime PM handling for pending tx
2023-10-23 7:48 [PATCH] serial: core: Fix runtime PM handling for pending tx Tony Lindgren
@ 2023-10-23 9:40 ` Richard Purdie
0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2023-10-23 9:40 UTC (permalink / raw)
To: Tony Lindgren, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko
Cc: Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness,
Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra,
linux-kernel, linux-serial, Bruce Ashfield, Mikko Rapeli,
Paul Gortmaker, Randy MacLeod
On Mon, 2023-10-23 at 10:48 +0300, Tony Lindgren wrote:
> Richard reported that a serial port may end up sometimes with tx data
> pending in the buffer for long periods of time.
>
> Turns out we bail out early on any errors from pm_runtime_get(),
> including -EINPROGRESS. To fix the issue, we need to ignore -EINPROGRESS
> as we only care about the runtime PM usage count at this point. We check
> for an active runtime PM state later on for tx.
>
> Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
> Reported-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Tested-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Thanks, I can confirm that since we added this into our builds/tests
we've not seen the serial data go missing.
Cheers,
Richard
> Cc: Bruce Ashfield <bruce.ashfield@gmail.com>
> Cc: Mikko Rapeli <mikko.rapeli@linaro.org>
> Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
> Cc: Randy MacLeod <randy.macleod@windriver.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
> drivers/tty/serial/serial_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -146,7 +146,7 @@ static void __uart_start(struct uart_state *state)
>
> /* Increment the runtime PM usage count for the active check below */
> err = pm_runtime_get(&port_dev->dev);
> - if (err < 0) {
> + if (err < 0 && err != -EINPROGRESS) {
> pm_runtime_put_noidle(&port_dev->dev);
> return;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-23 9:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-23 7:48 [PATCH] serial: core: Fix runtime PM handling for pending tx Tony Lindgren
2023-10-23 9:40 ` Richard Purdie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox