linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: 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,
	Vignesh R <vigneshr@ti.com>, Kevin Hilman <khilman@baylibre.com>
Subject: Re: [PATCH] serial: 8250_omap: Set the console genpd always on if no console suspend
Date: Mon, 23 Oct 2023 10:44:40 +0300	[thread overview]
Message-ID: <20231023074440.GS27774@atomide.com> (raw)
In-Reply-To: <20231017130540.1149721-1-thomas.richard@bootlin.com>

Hi,

Adding Kevin and Vignesh too in case they have better ideas on how to
prevent the power domain from suspending for no_console_suspend kernel
parameter.

* Thomas Richard <thomas.richard@bootlin.com> [231017 13:05]:
> If the console suspend is disabled, the genpd of the console shall not
> be powered-off during suspend.
> Set the flag GENPD_FLAG_ALWAYS_ON to the corresponding genpd during
> suspend, and restore the original value during the resume.
> 
> Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
> ---
>  drivers/tty/serial/8250/8250_omap.c | 33 ++++++++++++++++++++++++-----
>  1 file changed, 28 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
> index ca972fd37725..91a483dc460c 100644
> --- a/drivers/tty/serial/8250/8250_omap.c
> +++ b/drivers/tty/serial/8250/8250_omap.c
> @@ -27,6 +27,7 @@
>  #include <linux/pm_wakeirq.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/sys_soc.h>
> +#include <linux/pm_domain.h>
>  
>  #include "8250.h"
>  
> @@ -114,6 +115,12 @@
>  /* RX FIFO occupancy indicator */
>  #define UART_OMAP_RX_LVL		0x19
>  
> +/*
> + * Copy of the genpd flags for the console.
> + * Only used if console suspend is disabled
> + */
> +static unsigned int genpd_flags_console;

This should be priv->genpd_flags_console or something similar as the
uarts in an always-on power domain may have different flags from other
power domains.

Other than that I'm fine with with unless other people have better ideas
on how to handle this.

Regards,

Tony

>  struct omap8250_priv {
>  	void __iomem *membase;
>  	int line;
> @@ -1617,6 +1624,7 @@ static int omap8250_suspend(struct device *dev)
>  {
>  	struct omap8250_priv *priv = dev_get_drvdata(dev);
>  	struct uart_8250_port *up = serial8250_get_port(priv->line);
> +	struct generic_pm_domain *genpd = pd_to_genpd(dev->pm_domain);
>  	int err = 0;
>  
>  	serial8250_suspend_port(priv->line);
> @@ -1627,8 +1635,19 @@ 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 {
> +			/*
> +			 * The pd shall not be powered-off (no console suspend).
> +			 * Make copy of genpd flags before to set it always on.
> +			 * The original value is restored during the resume.
> +			 */
> +			genpd_flags_console = genpd->flags;
> +			genpd->flags |= GENPD_FLAG_ALWAYS_ON;
> +		}
> +	}
>  	flush_work(&priv->qos_work);
>  
>  	return err;
> @@ -1638,12 +1657,16 @@ static int omap8250_resume(struct device *dev)
>  {
>  	struct omap8250_priv *priv = dev_get_drvdata(dev);
>  	struct uart_8250_port *up = serial8250_get_port(priv->line);
> +	struct generic_pm_domain *genpd = pd_to_genpd(dev->pm_domain);
>  	int err;
>  
>  	if (uart_console(&up->port) && console_suspend_enabled) {
> -		err = pm_runtime_force_resume(dev);
> -		if (err)
> -			return err;
> +		if (console_suspend_enabled) {
> +			err = pm_runtime_force_resume(dev);
> +			if (err)
> +				return err;
> +		} else
> +			genpd->flags = genpd_flags_console;
>  	}
>  
>  	serial8250_resume_port(priv->line);
> -- 
> 2.39.2
> 

  reply	other threads:[~2023-10-23  7:44 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 [this message]
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
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=20231023074440.GS27774@atomide.com \
    --to=tony@atomide.com \
    --cc=d-gole@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregory.clement@bootlin.com \
    --cc=jirislaby@kernel.org \
    --cc=khilman@baylibre.com \
    --cc=linux-serial@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=thomas.richard@bootlin.com \
    --cc=u-kumar1@ti.com \
    --cc=vigneshr@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;
as well as URLs for NNTP newsgroup(s).