* [PATCH v1 2/2] serial: 8250_port: properly handle runtime PM in IRQ
2021-10-25 12:41 [PATCH v1 1/2] serial: 8250_pci: Remove empty stub pci_quatech_exit() Andy Shevchenko
@ 2021-10-25 12:41 ` Andy Shevchenko
2021-10-25 12:43 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2021-10-25 12:41 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-serial, linux-kernel
Cc: Jiri Slaby, Andy Shevchenko
We can't and basically don't need to call runtime PM in IRQ handler. If IRQ is
ours, device must be powered on. Otherwise check if the device is powered off
and return immediately.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/tty/serial/8250/8250_port.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 5775cbff8f6e..89387d86d495 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1939,17 +1939,19 @@ EXPORT_SYMBOL_GPL(serial8250_handle_irq);
static int serial8250_default_handle_irq(struct uart_port *port)
{
- struct uart_8250_port *up = up_to_u8250p(port);
unsigned int iir;
- int ret;
- serial8250_rpm_get(up);
+ /*
+ * The IRQ might be shared with other peripherals so we must first
+ * check that are we RPM suspended or not. If we are we assume that
+ * the IRQ was not for us (we shouldn't be RPM suspended when the
+ * interrupt is enabled).
+ */
+ if (pm_runtime_suspended(port->dev))
+ return 0;
iir = serial_port_in(port, UART_IIR);
- ret = serial8250_handle_irq(port, iir);
-
- serial8250_rpm_put(up);
- return ret;
+ return serial8250_handle_irq(port, iir);
}
/*
--
2.33.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 2/2] serial: 8250_port: properly handle runtime PM in IRQ
2021-10-25 12:41 ` [PATCH v1 2/2] serial: 8250_port: properly handle runtime PM in IRQ Andy Shevchenko
@ 2021-10-25 12:43 ` Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2021-10-25 12:43 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Greg Kroah-Hartman, open list:SERIAL DRIVERS,
Linux Kernel Mailing List, Jiri Slaby
On Mon, Oct 25, 2021 at 3:42 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> We can't and basically don't need to call runtime PM in IRQ handler. If IRQ is
> ours, device must be powered on. Otherwise check if the device is powered off
> and return immediately.
Please, ignore.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 0/2] serial: 8250_port: Update runtime PM flow
@ 2026-08-14 11:16 Andy Shevchenko
2026-08-14 11:16 ` [PATCH v1 1/2] serial: 8250_port: Remove redundant pm_runtime_mark_last_busy() call Andy Shevchenko
2026-08-14 11:16 ` [PATCH v1 2/2] serial: 8250_port: properly handle runtime PM in IRQ Andy Shevchenko
0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-08-14 11:16 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-kernel, linux-serial
Cc: Jiri Slaby, Andy Shevchenko
There are two changes, one is a straightforward drop of the duplicate
runtime PM call (which is idempotent and hence it's harmless to call,
but practically no need to do so) and the other addresses long standing
problem with potentially sleeping PM calls on some system in IRQ context.
Also the latter might lead to unneeded resume-suspend cycle when IRQ is
shared and interrupt is not ours. This mini-series to update runtime
PM flow to make sure this won't happen.
Andy Shevchenko (2):
serial: 8250_port: Remove redundant pm_runtime_mark_last_busy() call
serial: 8250_port: properly handle runtime PM in IRQ
drivers/tty/serial/8250/8250_port.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
--
2.50.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 1/2] serial: 8250_port: Remove redundant pm_runtime_mark_last_busy() call
2026-08-14 11:16 [PATCH v1 0/2] serial: 8250_port: Update runtime PM flow Andy Shevchenko
@ 2026-08-14 11:16 ` Andy Shevchenko
2026-08-14 11:16 ` [PATCH v1 2/2] serial: 8250_port: properly handle runtime PM in IRQ Andy Shevchenko
1 sibling, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-08-14 11:16 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-kernel, linux-serial
Cc: Jiri Slaby, Andy Shevchenko
The pm_runtime_mark_last_busy() call is redundant in the wrapper function
as pm_runtime_put_autosuspend() already calls pm_runtime_mark_last_busy()
internally to update the last access time of the device before queuing
autosuspend.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/tty/serial/8250/8250_port.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 38fa45e74a37..c0bcc0742a60 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -526,7 +526,6 @@ void serial8250_rpm_put(struct uart_8250_port *p)
{
if (!(p->capabilities & UART_CAP_RPM))
return;
- pm_runtime_mark_last_busy(p->port.dev);
pm_runtime_put_autosuspend(p->port.dev);
}
EXPORT_SYMBOL_GPL(serial8250_rpm_put);
@@ -667,7 +666,6 @@ static void serial8250_rpm_put_tx(struct uart_8250_port *p)
rpm_active = xchg(&p->rpm_tx_active, 0);
if (!rpm_active)
return;
- pm_runtime_mark_last_busy(p->port.dev);
pm_runtime_put_autosuspend(p->port.dev);
}
--
2.50.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 2/2] serial: 8250_port: properly handle runtime PM in IRQ
2026-08-14 11:16 [PATCH v1 0/2] serial: 8250_port: Update runtime PM flow Andy Shevchenko
2026-08-14 11:16 ` [PATCH v1 1/2] serial: 8250_port: Remove redundant pm_runtime_mark_last_busy() call Andy Shevchenko
@ 2026-08-14 11:16 ` Andy Shevchenko
1 sibling, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-08-14 11:16 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-kernel, linux-serial
Cc: Jiri Slaby, Andy Shevchenko
We can't and basically don't need to call runtime PM in IRQ handler.
If IRQ is ours, the device must be powered on. Otherwise check if
the device is powered off and return immediately.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/tty/serial/8250/8250_port.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index c0bcc0742a60..01703a707c22 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1880,11 +1880,21 @@ static int serial8250_default_handle_irq(struct uart_port *port)
{
struct uart_8250_port *up = up_to_u8250p(port);
unsigned int iir;
+ int pm_status;
+ int ret;
- guard(serial8250_rpm)(up);
+ /* if driver suspended, return, probably shared interrupt */
+ pm_status = pm_runtime_get_if_active(port->dev);
+ if (!pm_status)
+ return 0;
iir = serial_port_in(port, UART_IIR);
- return serial8250_handle_irq(port, iir);
+ ret = serial8250_handle_irq(port, iir);
+
+ if (pm_status > 0)
+ pm_runtime_put_autosuspend(port->dev);
+
+ return ret;
}
/*
--
2.50.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-08-14 11:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 11:16 [PATCH v1 0/2] serial: 8250_port: Update runtime PM flow Andy Shevchenko
2026-08-14 11:16 ` [PATCH v1 1/2] serial: 8250_port: Remove redundant pm_runtime_mark_last_busy() call Andy Shevchenko
2026-08-14 11:16 ` [PATCH v1 2/2] serial: 8250_port: properly handle runtime PM in IRQ Andy Shevchenko
-- strict thread matches above, loose matches on Subject: below --
2021-10-25 12:41 [PATCH v1 1/2] serial: 8250_pci: Remove empty stub pci_quatech_exit() Andy Shevchenko
2021-10-25 12:41 ` [PATCH v1 2/2] serial: 8250_port: properly handle runtime PM in IRQ Andy Shevchenko
2021-10-25 12:43 ` Andy Shevchenko
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.