All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@codeaurora.org>
To: Pramod Gurav <pramod.gurav@linaro.org>
Cc: linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org,
	gregkh@linuxfoundation.org, jslaby@suse.com,
	andy.gross@linaro.org, david.brown@linaro.org,
	ulf.hansson@linaro.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty: serial: msm: Add runtime PM and system sleep support
Date: Thu, 25 Aug 2016 15:50:09 -0700	[thread overview]
Message-ID: <20160825225009.GV19826@codeaurora.org> (raw)
In-Reply-To: <1466158618-6702-1-git-send-email-pramod.gurav@linaro.org>

On 06/17, Pramod Gurav wrote:
> @@ -1220,12 +1293,26 @@ static void msm_power(struct uart_port *port, unsigned int state,
>  
>  	switch (state) {
>  	case 0:
> -		clk_prepare_enable(msm_port->clk);
> -		clk_prepare_enable(msm_port->pclk);
> +		/*
> +		 * UART clk must be kept enabled to
> +		 * avoid losing received character
> +		 */

Don't we have a wakeup irq? Two wire interfaces probably don't
work though (like the debug uart).

> +		if (clk_prepare_enable(msm_port->clk))
> +			return;
> +		if (clk_prepare(msm_port->pclk)) {
> +			clk_disable_unprepare(msm_port->clk);
> +			return;
> +		}
> +		if (pm_runtime_get_sync(port->dev) < 0) {
> +			clk_unprepare(msm_port->pclk);
> +			clk_disable_unprepare(msm_port->clk);

I guess that's why we gate the interface clk and not the core clk
during runtime PM? core clk goes off and then device is basically
suspended unless it can wakeup with an irq.

> +			return;
> +		}
>  		break;
>  	case 3:
> +		pm_runtime_put(port->dev);
> +		clk_unprepare(msm_port->pclk);
>  		clk_disable_unprepare(msm_port->clk);
> -		clk_disable_unprepare(msm_port->pclk);
>  		break;
>  	default:
>  		pr_err("msm_serial: Unknown PM state %d\n", state);
> @@ -1465,7 +1552,11 @@ static void msm_console_write(struct console *co, const char *s,
>  	port = msm_get_port_from_line(co->index);
>  	msm_port = UART_TO_MSM(port);
>  
> +	if (pm_runtime_get_sync(port->dev) < 0)
> +		return;
>  	__msm_console_write(port, s, count, msm_port->is_uartdm);
> +	pm_runtime_mark_last_busy(port->dev);
> +	pm_runtime_put_autosuspend(port->dev);

Hmm ok, perhaps we should differentiate runtime PM for devices
that use the console and ones that are being used for other
things? I would guess that console can only turn off the
interface clk while idle, but the non-console devices could turn
off everything at runtime and rely on some out of band signaling
to wakeup when something comes over the rx wire?

>  }
>  
>  static int __init msm_console_setup(struct console *co, char *options)
> @@ -1484,7 +1575,7 @@ static int __init msm_console_setup(struct console *co, char *options)
>  	if (unlikely(!port->membase))
>  		return -ENXIO;
>  
> -	msm_init_clock(port);
> +	msm_serial_set_mnd_regs(port);
>  
>  	if (options)
>  		uart_parse_options(options, &baud, &parity, &bits, &flow);

Doesn't uart_set_options() go and touch hardware registers during
termios settings? The clks are no longer enabled here though so I
hope this isn't relying on the fact that the clks are enabled in
the bootloader?

> @@ -1627,6 +1718,12 @@ static int msm_serial_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, port);
>  
> +	pm_runtime_use_autosuspend(&pdev->dev);
> +	pm_runtime_set_autosuspend_delay(&pdev->dev, 500);
> +	pm_runtime_irq_safe(&pdev->dev);

So this means irqs are always disabled while runtime PM
callbacks are run....

> +	pm_runtime_enable(&pdev->dev);
> +	pm_runtime_set_suspended(&pdev->dev);
> +
>  	return uart_add_one_port(&msm_uart_driver, port);
>  }
>  
> @@ -1645,12 +1743,67 @@ static const struct of_device_id msm_match_table[] = {
>  	{}
>  };
>  
> +#ifdef CONFIG_PM
> +static int msm_serial_runtime_suspend(struct device *dev)
> +{
> +	struct uart_port *port = dev_get_drvdata(dev);
> +	struct msm_port *msm_port = UART_TO_MSM(port);
> +
> +	if (msm_port->is_uartdm)
> +		clk_disable(msm_port->pclk);

... so we can't unprepare clks here. That's unfortunate because
clks that are ancestors of these clks will be kept prepared and
that could lead to things like PLLs being kept enabled, etc.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  parent reply	other threads:[~2016-08-25 22:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-17 10:16 [PATCH] tty: serial: msm: Add runtime PM and system sleep support Pramod Gurav
2016-08-25  4:24 ` Pramod Gurav
2016-08-25  4:35 ` Andy Gross
2016-08-25  4:40   ` Pramod Gurav
2016-08-25 22:50 ` Stephen Boyd [this message]
2016-08-29 12:15   ` Pramod Gurav

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=20160825225009.GV19826@codeaurora.org \
    --to=sboyd@codeaurora.org \
    --cc=andy.gross@linaro.org \
    --cc=david.brown@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=pramod.gurav@linaro.org \
    --cc=ulf.hansson@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.