On Thu, 2016-11-03 at 17:29 +0100, Sebastian Andrzej Siewior wrote: > On 2016-11-03 18:14:23 [+0200], Andy Shevchenko 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. > > The old beagle board does PM put once it does not use the UART anymore > / > the UART is idle. And how can it generate interrupts? > You need to PM get the device even if the device is not yet suspended > because it might get suspended in the middle of your operation (maybe > not while you serve the IRQ but we have threaded interrupts). I grepped code and found no driver under 8250 which is using threaded IRQ handler. What did I miss? > If the HW is off then it will be woken by an RX interrupt and I think > it > is a different one (I remember Tony wanted to rework that part so that > the device/UART does not need to care about that). Rx interrupt from other device? Or OMAP UART has inbound wake source? > > This should work in general but I think that is racy with threaded > interrupts: What stops the PM core to shutdown the HW before > serial_port_in() ? Basically what I understand from this the question is: "Is pm_runtime_suspended() synchronous with regard to pm_runtime_get()/pm_runtime_suspend()?". > > Sebastian > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> > > --- > > 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 b3f00aa..0c94e82 100644 > > --- a/drivers/tty/serial/8250/8250_port.c > > +++ b/drivers/tty/serial/8250/8250_port.c > > @@ -1834,17 +1834,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.9.3 > > -- Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> Intel Finland Oy -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html