From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: "Kevin Hilman" <khilman@kernel.org>,
"Tony Lindgren" <tony@atomide.com>,
"Thomas Richard" <thomas.richard@bootlin.com>
Cc: <gregkh@linuxfoundation.org>, <jirislaby@kernel.org>,
<linux-serial@vger.kernel.org>, <gregory.clement@bootlin.com>,
<u-kumar1@ti.com>, <d-gole@ti.com>,
<thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH] serial: 8250_omap: Set the console genpd always on if no console suspend
Date: Wed, 22 Nov 2023 15:47:16 +0100 [thread overview]
Message-ID: <CX5F88JLWFUW.Z36KQB2PX554@tleb-bootlin-xps13-01> (raw)
In-Reply-To: <7h34xqitl0.fsf@baylibre.com>
Hi Kevin Hilman, Tony Lindgren & Thomas Richard,
On Tue Oct 31, 2023 at 6:34 PM CET, Kevin Hilman wrote:
> Tony Lindgren <tony@atomide.com> writes:
> > * Thomas Richard <thomas.richard@bootlin.com> [231031 10:15]:
> >> Please find below the logs of the test you asked me.
> >
> > OK great thanks!
> >
> >> I added the call of pm_runtime_get_usage_count at the end of the suspend
> >> function.
> >> The console is attached on 2800000.serial, it has usage_count=4.
> >> Other serial has usage_count=3.
> >
> > So as suspected, it seems the power domain gets force suspended
> > somewhere despite the usage_count.
>
> I think the only way this could happen (excluding any bugs, of course)
> would be for pm_runtime_force_suspend() to be getting called somewhere,
> but I thought the earlier patch made that call conditional, so maybe
> there is another path where that is getting called?
I'm coming back on this topic as the upstream fix is less than ideal, as
everyone here was agreeing.
I've had a look at the genpd code & power-domains get powered-off at
suspend_noirq without caring about runtime PM refcounting. See
genpd_suspend_noirq & genpd_finish_suspend.
Behavior is:
- In all cases, call suspend_noirq on the underlying device.
- Stop now if device is in wakeup path & PD has the
GENPD_FLAG_ACTIVE_WAKEUP flag.
- If the PD has start & stop callbacks & is not runtime suspended, call
the stop callback on the device.
- Increment the count of suspended devices on this PD.
- If PD is already off or always on, stop.
- If this is the last device on this PD (and some other checks), then
do the PD power off (and maybe parent PDs).
The current patch sets the PD as always on at suspend. That would not
work if our PD driver registered start/stop callbacks as those would
get called.
The right solution to avoid getting the PD cut would be to mark the
serials we want to keep alive as on the wakeup path using
device_set_wakeup_path(dev) at suspend. That also requires the PD to be
marked using the GENPD_FLAG_ACTIVE_WAKEUP flag, which is currently not
the case.
That last aspect is what I'm unsure of: should we add this flag to all
power-domains created by ti_sci_pm_domains? Should we pass something
from devicetree? I don't see the reason for not enabling this behavior
by default?
I've tested this approach & it works. See below for diff.
Regards,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
8< -------------------------------
diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c
index c091d569ecd5..b0d473776278 100644
--- a/drivers/pmdomain/ti/ti_sci_pm_domains.c
+++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c
@@ -168,6 +168,7 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
pd->pd.power_off = ti_sci_pd_power_off;
pd->pd.power_on = ti_sci_pd_power_on;
+ pd->pd.flags |= GENPD_FLAG_ACTIVE_WAKEUP;
pd->idx = args.args[0];
pd->parent = pd_provider;
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index 4b33f4529aed..ab2f8b7927c3 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -1633,8 +1633,12 @@ static int omap8250_suspend(struct device *dev)
if (!device_may_wakeup(dev))
priv->wer = 0;
serial_out(up, UART_OMAP_WER, priv->wer);
- if (uart_console(&up->port) && console_suspend_enabled)
- err = pm_runtime_force_suspend(dev);
+ if (uart_console(&up->port)) {
+ if (console_suspend_enabled)
+ err = pm_runtime_force_suspend(dev);
+ else
+ device_set_wakeup_path(dev);
+ }
flush_work(&priv->qos_work);
return err;
next prev parent reply other threads:[~2023-11-22 14:47 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 13:05 [PATCH] serial: 8250_omap: Set the console genpd always on if no console suspend Thomas Richard
2023-10-23 7:44 ` Tony Lindgren
2023-10-24 14:53 ` Thomas Richard
2023-10-24 15:24 ` Greg KH
2023-10-23 21:31 ` Kevin Hilman
2023-10-24 4:51 ` Tony Lindgren
2023-10-24 18:36 ` Kevin Hilman
2023-10-25 6:41 ` Tony Lindgren
2023-10-31 10:15 ` Thomas Richard
2023-10-31 10:52 ` Tony Lindgren
2023-10-31 17:34 ` Kevin Hilman
2023-11-22 14:47 ` Théo Lebrun [this message]
2023-11-24 5:37 ` Tony Lindgren
2023-11-24 10:39 ` Théo Lebrun
2023-11-24 10:54 ` Tony Lindgren
2023-11-28 4:05 ` Kevin Hilman
2023-11-28 4:11 ` Tony Lindgren
2023-11-28 4:52 ` Kevin Hilman
2023-11-28 5:05 ` Tony Lindgren
2023-11-27 11:22 ` VAMSHI GAJJELA
2024-08-09 19:04 ` Kevin Hilman
2024-08-13 9:00 ` Greg KH
2024-08-13 17:18 ` Kevin Hilman
2024-08-20 9:15 ` Thomas Richard
2024-09-16 14:03 ` Thomas Richard
2024-10-04 19:23 ` Kevin Hilman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CX5F88JLWFUW.Z36KQB2PX554@tleb-bootlin-xps13-01 \
--to=theo.lebrun@bootlin.com \
--cc=d-gole@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=gregory.clement@bootlin.com \
--cc=jirislaby@kernel.org \
--cc=khilman@kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=thomas.richard@bootlin.com \
--cc=tony@atomide.com \
--cc=u-kumar1@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox