All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] clk: tegra20/30: Optimize PLLX configuration restoring
@ 2019-09-22 21:52 Dmitry Osipenko
  2019-10-28 14:47   ` Peter De Schrijver
  2019-10-29 13:17 ` Thierry Reding
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Osipenko @ 2019-09-22 21:52 UTC (permalink / raw)
  To: Michael Turquette, Thierry Reding, Jonathan Hunter,
	Peter De Schrijver, Prashant Gaikwad, Stephen Boyd
  Cc: linux-clk, linux-tegra, linux-kernel

There is no need to re-configure PLLX if its configuration in unchanged
on return from suspend / cpuidle, this saves 300us if PLLX is already
enabled (common case for cpuidle).

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/clk/tegra/clk-tegra20.c | 25 ++++++++++++++++---------
 drivers/clk/tegra/clk-tegra30.c | 25 ++++++++++++++++---------
 2 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/drivers/clk/tegra/clk-tegra20.c b/drivers/clk/tegra/clk-tegra20.c
index cceefbd67a3b..4d8222f5c638 100644
--- a/drivers/clk/tegra/clk-tegra20.c
+++ b/drivers/clk/tegra/clk-tegra20.c
@@ -955,6 +955,7 @@ static void tegra20_cpu_clock_suspend(void)
 static void tegra20_cpu_clock_resume(void)
 {
 	unsigned int reg, policy;
+	u32 misc, base;
 
 	/* Is CPU complex already running on PLLX? */
 	reg = readl(clk_base + CCLK_BURST_POLICY);
@@ -968,15 +969,21 @@ static void tegra20_cpu_clock_resume(void)
 		BUG();
 
 	if (reg != CCLK_BURST_POLICY_PLLX) {
-		/* restore PLLX settings if CPU is on different PLL */
-		writel(tegra20_cpu_clk_sctx.pllx_misc,
-					clk_base + PLLX_MISC);
-		writel(tegra20_cpu_clk_sctx.pllx_base,
-					clk_base + PLLX_BASE);
-
-		/* wait for PLL stabilization if PLLX was enabled */
-		if (tegra20_cpu_clk_sctx.pllx_base & (1 << 30))
-			udelay(300);
+		misc = readl_relaxed(clk_base + PLLX_MISC);
+		base = readl_relaxed(clk_base + PLLX_BASE);
+
+		if (misc != tegra20_cpu_clk_sctx.pllx_misc ||
+		    base != tegra20_cpu_clk_sctx.pllx_base) {
+			/* restore PLLX settings if CPU is on different PLL */
+			writel(tegra20_cpu_clk_sctx.pllx_misc,
+						clk_base + PLLX_MISC);
+			writel(tegra20_cpu_clk_sctx.pllx_base,
+						clk_base + PLLX_BASE);
+
+			/* wait for PLL stabilization if PLLX was enabled */
+			if (tegra20_cpu_clk_sctx.pllx_base & (1 << 30))
+				udelay(300);
+		}
 	}
 
 	/*
diff --git a/drivers/clk/tegra/clk-tegra30.c b/drivers/clk/tegra/clk-tegra30.c
index a19840fac716..3b5bca44b7aa 100644
--- a/drivers/clk/tegra/clk-tegra30.c
+++ b/drivers/clk/tegra/clk-tegra30.c
@@ -1135,6 +1135,7 @@ static void tegra30_cpu_clock_suspend(void)
 static void tegra30_cpu_clock_resume(void)
 {
 	unsigned int reg, policy;
+	u32 misc, base;
 
 	/* Is CPU complex already running on PLLX? */
 	reg = readl(clk_base + CLK_RESET_CCLK_BURST);
@@ -1148,15 +1149,21 @@ static void tegra30_cpu_clock_resume(void)
 		BUG();
 
 	if (reg != CLK_RESET_CCLK_BURST_POLICY_PLLX) {
-		/* restore PLLX settings if CPU is on different PLL */
-		writel(tegra30_cpu_clk_sctx.pllx_misc,
-					clk_base + CLK_RESET_PLLX_MISC);
-		writel(tegra30_cpu_clk_sctx.pllx_base,
-					clk_base + CLK_RESET_PLLX_BASE);
-
-		/* wait for PLL stabilization if PLLX was enabled */
-		if (tegra30_cpu_clk_sctx.pllx_base & (1 << 30))
-			udelay(300);
+		misc = readl_relaxed(clk_base + CLK_RESET_PLLX_MISC);
+		base = readl_relaxed(clk_base + CLK_RESET_PLLX_BASE);
+
+		if (misc != tegra30_cpu_clk_sctx.pllx_misc ||
+		    base != tegra30_cpu_clk_sctx.pllx_base) {
+			/* restore PLLX settings if CPU is on different PLL */
+			writel(tegra30_cpu_clk_sctx.pllx_misc,
+						clk_base + CLK_RESET_PLLX_MISC);
+			writel(tegra30_cpu_clk_sctx.pllx_base,
+						clk_base + CLK_RESET_PLLX_BASE);
+
+			/* wait for PLL stabilization if PLLX was enabled */
+			if (tegra30_cpu_clk_sctx.pllx_base & (1 << 30))
+				udelay(300);
+		}
 	}
 
 	/*
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] clk: tegra20/30: Optimize PLLX configuration restoring
  2019-09-22 21:52 [PATCH v1] clk: tegra20/30: Optimize PLLX configuration restoring Dmitry Osipenko
@ 2019-10-28 14:47   ` Peter De Schrijver
  2019-10-29 13:17 ` Thierry Reding
  1 sibling, 0 replies; 4+ messages in thread
From: Peter De Schrijver @ 2019-10-28 14:47 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Michael Turquette, Thierry Reding, Jonathan Hunter,
	Prashant Gaikwad, Stephen Boyd, linux-clk, linux-tegra,
	linux-kernel

On Mon, Sep 23, 2019 at 12:52:03AM +0300, Dmitry Osipenko wrote:
> There is no need to re-configure PLLX if its configuration in unchanged
> on return from suspend / cpuidle, this saves 300us if PLLX is already
> enabled (common case for cpuidle).
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

Acked-by: Peter De Schrijver <pdeschrijver@nvidia.com>

> ---
>  drivers/clk/tegra/clk-tegra20.c | 25 ++++++++++++++++---------
>  drivers/clk/tegra/clk-tegra30.c | 25 ++++++++++++++++---------
>  2 files changed, 32 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/clk/tegra/clk-tegra20.c b/drivers/clk/tegra/clk-tegra20.c
> index cceefbd67a3b..4d8222f5c638 100644
> --- a/drivers/clk/tegra/clk-tegra20.c
> +++ b/drivers/clk/tegra/clk-tegra20.c
> @@ -955,6 +955,7 @@ static void tegra20_cpu_clock_suspend(void)
>  static void tegra20_cpu_clock_resume(void)
>  {
>  	unsigned int reg, policy;
> +	u32 misc, base;
>  
>  	/* Is CPU complex already running on PLLX? */
>  	reg = readl(clk_base + CCLK_BURST_POLICY);
> @@ -968,15 +969,21 @@ static void tegra20_cpu_clock_resume(void)
>  		BUG();
>  
>  	if (reg != CCLK_BURST_POLICY_PLLX) {
> -		/* restore PLLX settings if CPU is on different PLL */
> -		writel(tegra20_cpu_clk_sctx.pllx_misc,
> -					clk_base + PLLX_MISC);
> -		writel(tegra20_cpu_clk_sctx.pllx_base,
> -					clk_base + PLLX_BASE);
> -
> -		/* wait for PLL stabilization if PLLX was enabled */
> -		if (tegra20_cpu_clk_sctx.pllx_base & (1 << 30))
> -			udelay(300);
> +		misc = readl_relaxed(clk_base + PLLX_MISC);
> +		base = readl_relaxed(clk_base + PLLX_BASE);
> +
> +		if (misc != tegra20_cpu_clk_sctx.pllx_misc ||
> +		    base != tegra20_cpu_clk_sctx.pllx_base) {
> +			/* restore PLLX settings if CPU is on different PLL */
> +			writel(tegra20_cpu_clk_sctx.pllx_misc,
> +						clk_base + PLLX_MISC);
> +			writel(tegra20_cpu_clk_sctx.pllx_base,
> +						clk_base + PLLX_BASE);
> +
> +			/* wait for PLL stabilization if PLLX was enabled */
> +			if (tegra20_cpu_clk_sctx.pllx_base & (1 << 30))
> +				udelay(300);
> +		}
>  	}
>  
>  	/*
> diff --git a/drivers/clk/tegra/clk-tegra30.c b/drivers/clk/tegra/clk-tegra30.c
> index a19840fac716..3b5bca44b7aa 100644
> --- a/drivers/clk/tegra/clk-tegra30.c
> +++ b/drivers/clk/tegra/clk-tegra30.c
> @@ -1135,6 +1135,7 @@ static void tegra30_cpu_clock_suspend(void)
>  static void tegra30_cpu_clock_resume(void)
>  {
>  	unsigned int reg, policy;
> +	u32 misc, base;
>  
>  	/* Is CPU complex already running on PLLX? */
>  	reg = readl(clk_base + CLK_RESET_CCLK_BURST);
> @@ -1148,15 +1149,21 @@ static void tegra30_cpu_clock_resume(void)
>  		BUG();
>  
>  	if (reg != CLK_RESET_CCLK_BURST_POLICY_PLLX) {
> -		/* restore PLLX settings if CPU is on different PLL */
> -		writel(tegra30_cpu_clk_sctx.pllx_misc,
> -					clk_base + CLK_RESET_PLLX_MISC);
> -		writel(tegra30_cpu_clk_sctx.pllx_base,
> -					clk_base + CLK_RESET_PLLX_BASE);
> -
> -		/* wait for PLL stabilization if PLLX was enabled */
> -		if (tegra30_cpu_clk_sctx.pllx_base & (1 << 30))
> -			udelay(300);
> +		misc = readl_relaxed(clk_base + CLK_RESET_PLLX_MISC);
> +		base = readl_relaxed(clk_base + CLK_RESET_PLLX_BASE);
> +
> +		if (misc != tegra30_cpu_clk_sctx.pllx_misc ||
> +		    base != tegra30_cpu_clk_sctx.pllx_base) {
> +			/* restore PLLX settings if CPU is on different PLL */
> +			writel(tegra30_cpu_clk_sctx.pllx_misc,
> +						clk_base + CLK_RESET_PLLX_MISC);
> +			writel(tegra30_cpu_clk_sctx.pllx_base,
> +						clk_base + CLK_RESET_PLLX_BASE);
> +
> +			/* wait for PLL stabilization if PLLX was enabled */
> +			if (tegra30_cpu_clk_sctx.pllx_base & (1 << 30))
> +				udelay(300);
> +		}
>  	}
>  
>  	/*
> -- 
> 2.23.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] clk: tegra20/30: Optimize PLLX configuration restoring
@ 2019-10-28 14:47   ` Peter De Schrijver
  0 siblings, 0 replies; 4+ messages in thread
From: Peter De Schrijver @ 2019-10-28 14:47 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Michael Turquette, Thierry Reding, Jonathan Hunter,
	Prashant Gaikwad, Stephen Boyd, linux-clk, linux-tegra,
	linux-kernel

On Mon, Sep 23, 2019 at 12:52:03AM +0300, Dmitry Osipenko wrote:
> There is no need to re-configure PLLX if its configuration in unchanged
> on return from suspend / cpuidle, this saves 300us if PLLX is already
> enabled (common case for cpuidle).
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

Acked-by: Peter De Schrijver <pdeschrijver@nvidia.com>

> ---
>  drivers/clk/tegra/clk-tegra20.c | 25 ++++++++++++++++---------
>  drivers/clk/tegra/clk-tegra30.c | 25 ++++++++++++++++---------
>  2 files changed, 32 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/clk/tegra/clk-tegra20.c b/drivers/clk/tegra/clk-tegra20.c
> index cceefbd67a3b..4d8222f5c638 100644
> --- a/drivers/clk/tegra/clk-tegra20.c
> +++ b/drivers/clk/tegra/clk-tegra20.c
> @@ -955,6 +955,7 @@ static void tegra20_cpu_clock_suspend(void)
>  static void tegra20_cpu_clock_resume(void)
>  {
>  	unsigned int reg, policy;
> +	u32 misc, base;
>  
>  	/* Is CPU complex already running on PLLX? */
>  	reg = readl(clk_base + CCLK_BURST_POLICY);
> @@ -968,15 +969,21 @@ static void tegra20_cpu_clock_resume(void)
>  		BUG();
>  
>  	if (reg != CCLK_BURST_POLICY_PLLX) {
> -		/* restore PLLX settings if CPU is on different PLL */
> -		writel(tegra20_cpu_clk_sctx.pllx_misc,
> -					clk_base + PLLX_MISC);
> -		writel(tegra20_cpu_clk_sctx.pllx_base,
> -					clk_base + PLLX_BASE);
> -
> -		/* wait for PLL stabilization if PLLX was enabled */
> -		if (tegra20_cpu_clk_sctx.pllx_base & (1 << 30))
> -			udelay(300);
> +		misc = readl_relaxed(clk_base + PLLX_MISC);
> +		base = readl_relaxed(clk_base + PLLX_BASE);
> +
> +		if (misc != tegra20_cpu_clk_sctx.pllx_misc ||
> +		    base != tegra20_cpu_clk_sctx.pllx_base) {
> +			/* restore PLLX settings if CPU is on different PLL */
> +			writel(tegra20_cpu_clk_sctx.pllx_misc,
> +						clk_base + PLLX_MISC);
> +			writel(tegra20_cpu_clk_sctx.pllx_base,
> +						clk_base + PLLX_BASE);
> +
> +			/* wait for PLL stabilization if PLLX was enabled */
> +			if (tegra20_cpu_clk_sctx.pllx_base & (1 << 30))
> +				udelay(300);
> +		}
>  	}
>  
>  	/*
> diff --git a/drivers/clk/tegra/clk-tegra30.c b/drivers/clk/tegra/clk-tegra30.c
> index a19840fac716..3b5bca44b7aa 100644
> --- a/drivers/clk/tegra/clk-tegra30.c
> +++ b/drivers/clk/tegra/clk-tegra30.c
> @@ -1135,6 +1135,7 @@ static void tegra30_cpu_clock_suspend(void)
>  static void tegra30_cpu_clock_resume(void)
>  {
>  	unsigned int reg, policy;
> +	u32 misc, base;
>  
>  	/* Is CPU complex already running on PLLX? */
>  	reg = readl(clk_base + CLK_RESET_CCLK_BURST);
> @@ -1148,15 +1149,21 @@ static void tegra30_cpu_clock_resume(void)
>  		BUG();
>  
>  	if (reg != CLK_RESET_CCLK_BURST_POLICY_PLLX) {
> -		/* restore PLLX settings if CPU is on different PLL */
> -		writel(tegra30_cpu_clk_sctx.pllx_misc,
> -					clk_base + CLK_RESET_PLLX_MISC);
> -		writel(tegra30_cpu_clk_sctx.pllx_base,
> -					clk_base + CLK_RESET_PLLX_BASE);
> -
> -		/* wait for PLL stabilization if PLLX was enabled */
> -		if (tegra30_cpu_clk_sctx.pllx_base & (1 << 30))
> -			udelay(300);
> +		misc = readl_relaxed(clk_base + CLK_RESET_PLLX_MISC);
> +		base = readl_relaxed(clk_base + CLK_RESET_PLLX_BASE);
> +
> +		if (misc != tegra30_cpu_clk_sctx.pllx_misc ||
> +		    base != tegra30_cpu_clk_sctx.pllx_base) {
> +			/* restore PLLX settings if CPU is on different PLL */
> +			writel(tegra30_cpu_clk_sctx.pllx_misc,
> +						clk_base + CLK_RESET_PLLX_MISC);
> +			writel(tegra30_cpu_clk_sctx.pllx_base,
> +						clk_base + CLK_RESET_PLLX_BASE);
> +
> +			/* wait for PLL stabilization if PLLX was enabled */
> +			if (tegra30_cpu_clk_sctx.pllx_base & (1 << 30))
> +				udelay(300);
> +		}
>  	}
>  
>  	/*
> -- 
> 2.23.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] clk: tegra20/30: Optimize PLLX configuration restoring
  2019-09-22 21:52 [PATCH v1] clk: tegra20/30: Optimize PLLX configuration restoring Dmitry Osipenko
  2019-10-28 14:47   ` Peter De Schrijver
@ 2019-10-29 13:17 ` Thierry Reding
  1 sibling, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2019-10-29 13:17 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Michael Turquette, Jonathan Hunter, Peter De Schrijver,
	Prashant Gaikwad, Stephen Boyd, linux-clk, linux-tegra,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 551 bytes --]

On Mon, Sep 23, 2019 at 12:52:03AM +0300, Dmitry Osipenko wrote:
> There is no need to re-configure PLLX if its configuration in unchanged
> on return from suspend / cpuidle, this saves 300us if PLLX is already
> enabled (common case for cpuidle).
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/clk/tegra/clk-tegra20.c | 25 ++++++++++++++++---------
>  drivers/clk/tegra/clk-tegra30.c | 25 ++++++++++++++++---------
>  2 files changed, 32 insertions(+), 18 deletions(-)

Applied to for-5.5/clk, thanks.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-29 13:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-22 21:52 [PATCH v1] clk: tegra20/30: Optimize PLLX configuration restoring Dmitry Osipenko
2019-10-28 14:47 ` Peter De Schrijver
2019-10-28 14:47   ` Peter De Schrijver
2019-10-29 13:17 ` Thierry Reding

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.