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

From: Tony Lindgren
Date: Tue Mar 14 2023 - 09:41:12 EST


* 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.

> > + 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.

Tony