Re: [PATCH v7 1/1] serial: core: Start managing serial controllers to enable runtime PM

From: Andy Shevchenko
Date: Tue Mar 14 2023 - 11:41:11 EST


On Tue, Mar 14, 2023 at 03:38:10PM +0200, Tony Lindgren wrote:
> * Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> [230314 13:25]:
> > On Tue, Mar 14, 2023 at 09:35:59AM +0200, Tony Lindgren wrote:

...

> > > + /* Increment the runtime PM usage count for the active check below */
> > > + err = pm_runtime_get(port_dev);
> >
> > The question here is why don't we need to actually turn on the device immediately
> > (sync) if it's not already powered?

> Doing it would require the use of pm_runtime_irq_safe() at least currently.

> > > + if (err < 0) {
> > > + pm_runtime_put_noidle(port_dev);
> > > + return;
> > > + }
> >
> > > + /*
> > > + * Start TX if enabled, and kick runtime PM. Otherwise we must
> > > + * wait for a retry. See also serial_port.c for runtime PM
> > > + * autosuspend timeout.
> > > + */
> >
> > I.o.w. does the start_tx() require device to be powered on at this point?
>
> Yes. And if the device is not enabled, serial_port.c runtime_resume()
> calls this function again after the hardware is enabled.

Ah, that makes sense.

> > > + if (pm_runtime_active(port_dev))
> > > port->ops->start_tx(port);
> > > + pm_runtime_mark_last_busy(port_dev);
> > > + pm_runtime_put_autosuspend(port_dev);
>
> For your other comments, I'll take a look thanks.

--
With Best Regards,
Andy Shevchenko