Skip to contentSkip to conversation

clk: rockchip: Turn on "aclk_dmac1" for suspend

PATCH In review Douglas Anderson 3 participants 13 messages Apr 11, 2019 – Apr 12, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 clk: rockchip: Turn on "aclk_dmac1" for suspend

Experimentally it can be seen that going into deep sleep (specifically setting PMU_CLR_DMA and PMU_CLR_BUS in RK3288_PMU_PWRMODE_CON1) appears to fail unless "aclk_dmac1" is on. The failure is that the system never signals that it made it into suspend on the GLOBAL_PWROFF pin and it just hangs.

NOTE that it's confirmed that it's the actual suspend that fails, not one of the earlier calls to read/write registers. Specifically if you comment out the "PMU_GLOBAL_INT_DISABLE" setting in rk3288_slp_mode_set() and then comment out the "cpu_do_idle()" call in rockchip_lpmode_enter() then you can exercise the whole suspend path without any crashing.

This is currently not a problem with suspend upstream because there is no current way to exercise the deep suspend code. However, anyone trying to make it work will run into this issue.

This was not a problem on shipping rk3288-based Chromebooks because those devices all ran on an old kernel based on 3.14. On that kernel "aclk_dmac1" appears to be left on all the time.

There are several ways to skin this problem.

A) We could add "aclk_dmac1" to the list of critical clocks and that apperas to work, but presumably that wastes power.

B) We could keep a list of "struct clk" objects to enable at suspend time in clk-rk3288.c and use the standard clock APIs.

C) We could make the rk3288-pmu driver keep a list of clocks to enable at suspend time. Presumably this would require a dts and bindings change.

D) We could just whack the clock on in the existing syscore suspend function where we whack a bunch of other clocks. This is particularly easy because we know for sure that the clock's only parent ("aclk_cpu") is a critical clock so we don't need to do anything more than ungate it.

In this case I have chosen D) because it seemed like the least work, but any of the other options would presumably also work fine.

---

 drivers/clk/rockchip/clk-rk3288.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/clk/rockchip/clk-rk3288.c +11 -0
index 5a67b7869960..b245367393cd 100644
@@ -859,6 +859,9 @@ static const int rk3288_saved_cru_reg_ids[] = {
 	RK3288_CLKSEL_CON(10),
 	RK3288_CLKSEL_CON(33),
 	RK3288_CLKSEL_CON(37),
+
+	/* We turn aclk_dmac1 on for suspend; this will restore it */
+	RK3288_CLKGATE_CON(10),
 };
 
 static u32 rk3288_saved_cru_regs[ARRAY_SIZE(rk3288_saved_cru_reg_ids)];
@@ -874,6 +877,14 @@ static int rk3288_clk_suspend(void)
 				readl_relaxed(rk3288_cru_base + reg_id);
 	}
 
+	/*
+	 * Going into deep sleep (specifically setting PMU_CLR_DMA in
+	 * RK3288_PMU_PWRMODE_CON1) appears to fail unless
+	 * "aclk_dmac1" is on.
+	 */
+	writel_relaxed(1 << (12 + 16),
+		       rk3288_cru_base + RK3288_CLKGATE_CON(10));
+
 	/*
 	 * Switch PLLs other than DPLL (for SDRAM) to slow mode to
 	 * avoid crashes on resume. The Mask ROM on the system will
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
#1 lore raw

PATCH 2/5 ARM: rockchip: pm: Mark init functions __init

The functions rk3288_config_bootdata() and rk3288_suspend_init() are only called in the context of rockchip_suspend_init() which is already marked __init. We can mark them __init too.

---

 arch/arm/mach-rockchip/pm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/pm.c +2 -2
index 0592534e0b88..065b09e6f1eb 100644
@@ -59,7 +59,7 @@ static inline u32 rk3288_l2_config(void)
 	return l2ctlr;
 }
 
-static void rk3288_config_bootdata(void)
+static void __init rk3288_config_bootdata(void)
 {
 	rkpm_bootdata_cpusp = rk3288_bootram_phy + (SZ_4K - 8);
 	rkpm_bootdata_cpu_code = __pa_symbol(cpu_resume);
@@ -230,7 +230,7 @@ static void rk3288_suspend_finish(void)
 		pr_err("%s: Suspend finish failed\n", __func__);
 }
 
-static int rk3288_suspend_init(struct device_node *np)
+static int __init rk3288_suspend_init(struct device_node *np)
 {
 	struct device_node *sram_np;
 	struct resource res;
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
maintainer
#2 lore raw

Re: [PATCH 2/5] ARM: rockchip: pm: Mark init functions __init

Am Freitag, 12. April 2019, 01:21:54 CEST schrieb Douglas Anderson:

Quoted 5 lines

The functions rk3288_config_bootdata() and rk3288_suspend_init() are only called in the context of rockchip_suspend_init() which is already marked __init. We can mark them __init too.

applied for 5.2

Thanks
Heiko

#3 lore raw

PATCH 3/5 ARM: dts: rockchip: Add DDR retention/poweroff to rk3288-veyron hogs

In reply to Douglas Anderson

Even though upstream Linux doesn't yet go into deep enough suspend to get DDR into self refresh, there is no harm in setting these pins up. They'll only actually do something if we go into a deeper suspend but leaving them configed always is fine.

---

 arch/arm/boot/dts/rk3288-veyron-chromebook.dtsi | 4 ++++
 arch/arm/boot/dts/rk3288-veyron.dtsi            | 4 ++++
 2 files changed, 8 insertions(+)
arch/arm/boot/dts/rk3288-veyron-chromebook.dtsi +4 -0
index 72c4754032e9..b9cc90f0f25c 100644
@@ -229,6 +229,8 @@
 &pinctrl {
 	pinctrl-0 = <
 		/* Common for sleep and wake, but no owners */
+		&ddr0_retention
+		&ddrio_pwroff
 		&global_pwroff
 
 		/* Wake only */
@@ -236,6 +238,8 @@
 	>;
 	pinctrl-1 = <
 		/* Common for sleep and wake, but no owners */
+		&ddr0_retention
+		&ddrio_pwroff
 		&global_pwroff
 
 		/* Sleep only */
arch/arm/boot/dts/rk3288-veyron.dtsi +4 -0
index 5c67acc3e6d8..279d7f4ecce0 100644
@@ -451,10 +451,14 @@
 	pinctrl-names = "default", "sleep";
 	pinctrl-0 = <
 		/* Common for sleep and wake, but no owners */
+		&ddr0_retention
+		&ddrio_pwroff
 		&global_pwroff
 	>;
 	pinctrl-1 = <
 		/* Common for sleep and wake, but no owners */
+		&ddr0_retention
+		&ddrio_pwroff
 		&global_pwroff
 	>;
 
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
maintainer
#4 lore raw

Re: [PATCH 3/5] ARM: dts: rockchip: Add DDR retention/poweroff to rk3288-veyron hogs

Am Freitag, 12. April 2019, 01:21:55 CEST schrieb Douglas Anderson:

Quoted 6 lines

Even though upstream Linux doesn't yet go into deep enough suspend to get DDR into self refresh, there is no harm in setting these pins up. They'll only actually do something if we go into a deeper suspend but leaving them configed always is fine.

applied for 5.2

Thanks
Heiko

#5 lore raw

PATCH 4/5 ARM: dts: rockchip: vcc33_ccd off in suspend for rk3288-veyron-chromebook

In reply to Douglas Anderson

As per my comments when the device tree for rk3288-veyron-chromebook first landed:

Quoted 6 lines

Technically I think vcc33_ccd can be off since we have 'needs-reset-on-resume' down in the EHCI port (this regulator is for the USB webcam that's connected to the EHCI port).

...but leaving it on for now seems fine until we get suspend/resume
more solid.

It's probably about time to do it right.

[1] https://lore.kernel.org/linux-arm-kernel/CAD=FV=U37Yx8Mqk75_x05zxonvdc3qRMhqp8TyTDPWGHqSuRqg@mail.gmail.com/

---

 arch/arm/boot/dts/rk3288-veyron-chromebook.dtsi | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/boot/dts/rk3288-veyron-chromebook.dtsi +1 -2
index b9cc90f0f25c..fbef34578100 100644
@@ -176,8 +176,7 @@
 			regulator-min-microvolt = <3300000>;
 			regulator-max-microvolt = <3300000>;
 			regulator-state-mem {
-				regulator-on-in-suspend;
-				regulator-suspend-microvolt = <3300000>;
+				regulator-off-in-suspend;
 			};
 		};
 	};
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
Reviewed-by on v1 4/5
#6 lore raw

Re: [PATCH 4/5] ARM: dts: rockchip: vcc33_ccd off in suspend for rk3288-veyron-chromebook

hi,

Quoted 24 lines · Douglas Anderson

As per my comments when the device tree for rk3288-veyron-chromebook first landed:

Quoted 6 lines

Technically I think vcc33_ccd can be off since we have 'needs-reset-on-resume' down in the EHCI port (this regulator is for the USB webcam that's connected to the EHCI port).

...but leaving it on for now seems fine until we get suspend/resume
more solid.

It's probably about time to do it right.

[1] https://lore.kernel.org/linux-arm-kernel/CAD=FV=U37Yx8Mqk75_x05zxonvdc3qRMhqp8TyTDPWGHqSuRqg@mail.gmail.com/

---

  arch/arm/boot/dts/rk3288-veyron-chromebook.dtsi | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/boot/dts/rk3288-veyron-chromebook.dtsi +0 -0
index b9cc90f0f25c..fbef34578100 100644

arch/arm/boot/dts/rk3288-veyron-chromebook.dtsi line 182

Quoted 9 lines
arch/arm/boot/dts/rk3288-veyron-chromebook.dtsi +1 -2
@@ -176,8 +176,7 @@
  			regulator-min-microvolt = <3300000>;
  			regulator-max-microvolt = <3300000>;
  			regulator-state-mem {
-				regulator-on-in-suspend;
-				regulator-suspend-microvolt = <3300000>;
+				regulator-off-in-suspend;
  			};
  		};
  	};
maintainer
#7 lore raw

Re: [PATCH 4/5] ARM: dts: rockchip: vcc33_ccd off in suspend for rk3288-veyron-chromebook

In reply to Douglas Anderson

Am Freitag, 12. April 2019, 01:21:56 CEST schrieb Douglas Anderson:

Quoted 7 lines

As per my comments when the device tree for rk3288-veyron-chromebook first landed:

Quoted 4 lines

Technically I think vcc33_ccd can be off since we have 'needs-reset-on-resume' down in the EHCI port (this regulator is for the USB webcam that's connected to the EHCI port).

Quoted 8 lines
Quoted 2 lines

...but leaving it on for now seems fine until we get suspend/resume
more solid.

It's probably about time to do it right.

[1] https://lore.kernel.org/linux-arm-kernel/CAD=FV=U37Yx8Mqk75_x05zxonvdc3qRMhqp8TyTDPWGHqSuRqg@mail.gmail.com/

applied for 5.2

Thanks
Heiko

#8 lore raw

PATCH 5/5 ARM: dts: rockchip: vdd_gpu off in suspend for rk3288-veyron

In reply to Douglas Anderson

At some point long long ago the downstream GPU driver would crash if we turned the GPU off during suspend. For some context you can see:

https://chromium-review.googlesource.com/#/c/215780/5..6/arch/arm/boot/dts/rk3288-pinky-rev2.dts

At some point in time not too long after that got fixed.

It's unclear why the GPU is left enabled during suspend on the mainline kernel. Everything seems fine if I turn this off, so let's do it.

---

 arch/arm/boot/dts/rk3288-veyron.dtsi | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/boot/dts/rk3288-veyron.dtsi +1 -2
index 279d7f4ecce0..1252522392c7 100644
@@ -217,8 +217,7 @@
 				regulator-max-microvolt = <1250000>;
 				regulator-ramp-delay = <6001>;
 				regulator-state-mem {
-					regulator-on-in-suspend;
-					regulator-suspend-microvolt = <1000000>;
+					regulator-off-in-suspend;
 				};
 			};
 
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
Reviewed-by on v1 5/5
#9 lore raw

Re: [PATCH 5/5] ARM: dts: rockchip: vdd_gpu off in suspend for rk3288-veyron

hi,

Quoted 22 lines · Douglas Anderson

At some point long long ago the downstream GPU driver would crash if we turned the GPU off during suspend. For some context you can see:

https://chromium-review.googlesource.com/#/c/215780/5..6/arch/arm/boot/dts/rk3288-pinky-rev2.dts

At some point in time not too long after that got fixed.

It's unclear why the GPU is left enabled during suspend on the mainline kernel. Everything seems fine if I turn this off, so let's do it.

---

  arch/arm/boot/dts/rk3288-veyron.dtsi | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/boot/dts/rk3288-veyron.dtsi +0 -0
index 279d7f4ecce0..1252522392c7 100644

arch/arm/boot/dts/rk3288-veyron.dtsi line 223

Quoted 9 lines
arch/arm/boot/dts/rk3288-veyron.dtsi +1 -2
@@ -217,8 +217,7 @@
  				regulator-max-microvolt = <1250000>;
  				regulator-ramp-delay = <6001>;
  				regulator-state-mem {
-					regulator-on-in-suspend;
-					regulator-suspend-microvolt = <1000000>;
+					regulator-off-in-suspend;
  				};
  			};
 
maintainer
#10 lore raw

Re: [PATCH 5/5] ARM: dts: rockchip: vdd_gpu off in suspend for rk3288-veyron

In reply to Douglas Anderson

Am Freitag, 12. April 2019, 01:21:57 CEST schrieb Douglas Anderson:

Quoted 5 lines

At some point long long ago the downstream GPU driver would crash if we turned the GPU off during suspend. For some context you can see:

https://chromium-review.googlesource.com/#/c/215780/5..6/arch/arm/boot/dts/rk3288-pinky-rev2.dts

Quoted 7 lines

At some point in time not too long after that got fixed.

It's unclear why the GPU is left enabled during suspend on the mainline kernel. Everything seems fine if I turn this off, so let's do it.

applied for 5.2

Thanks
Heiko

Reviewed-by on v1 1/5
#11 lore raw
In reply to Douglas Anderson

hi,

Quoted 67 lines · Douglas Anderson

Experimentally it can be seen that going into deep sleep (specifically setting PMU_CLR_DMA and PMU_CLR_BUS in RK3288_PMU_PWRMODE_CON1) appears to fail unless "aclk_dmac1" is on. The failure is that the system never signals that it made it into suspend on the GLOBAL_PWROFF pin and it just hangs.

NOTE that it's confirmed that it's the actual suspend that fails, not one of the earlier calls to read/write registers. Specifically if you comment out the "PMU_GLOBAL_INT_DISABLE" setting in rk3288_slp_mode_set() and then comment out the "cpu_do_idle()" call in rockchip_lpmode_enter() then you can exercise the whole suspend path without any crashing.

This is currently not a problem with suspend upstream because there is no current way to exercise the deep suspend code. However, anyone trying to make it work will run into this issue.

This was not a problem on shipping rk3288-based Chromebooks because those devices all ran on an old kernel based on 3.14. On that kernel "aclk_dmac1" appears to be left on all the time.

There are several ways to skin this problem.

A) We could add "aclk_dmac1" to the list of critical clocks and that apperas to work, but presumably that wastes power.

B) We could keep a list of "struct clk" objects to enable at suspend time in clk-rk3288.c and use the standard clock APIs.

C) We could make the rk3288-pmu driver keep a list of clocks to enable at suspend time. Presumably this would require a dts and bindings change.

D) We could just whack the clock on in the existing syscore suspend function where we whack a bunch of other clocks. This is particularly easy because we know for sure that the clock's only parent ("aclk_cpu") is a critical clock so we don't need to do anything more than ungate it.

In this case I have chosen D) because it seemed like the least work, but any of the other options would presumably also work fine.

---

  drivers/clk/rockchip/clk-rk3288.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
drivers/clk/rockchip/clk-rk3288.c +4 -0
index 5a67b7869960..b245367393cd 100644
@@ -859,6 +859,9 @@ static const int rk3288_saved_cru_reg_ids[] = {
  	RK3288_CLKSEL_CON(10),
  	RK3288_CLKSEL_CON(33),
  	RK3288_CLKSEL_CON(37),
+
+	/* We turn aclk_dmac1 on for suspend; this will restore it */
+	RK3288_CLKGATE_CON(10),
  };
 
  static u32 rk3288_saved_cru_regs[ARRAY_SIZE(rk3288_saved_cru_reg_ids)];
@@ -874,6 +877,14 @@ static int rk3288_clk_suspend(void)
  				readl_relaxed(rk3288_cru_base + reg_id);
  	}
 
+	/*

drivers/clk/rockchip/clk-rk3288.c static int rk3288_clk_suspend(void) · line 890

Quoted 10 lines
drivers/clk/rockchip/clk-rk3288.c +7 -0
+	 * Going into deep sleep (specifically setting PMU_CLR_DMA in
+	 * RK3288_PMU_PWRMODE_CON1) appears to fail unless
+	 * "aclk_dmac1" is on.
+	 */
+	writel_relaxed(1 << (12 + 16),
+		       rk3288_cru_base + RK3288_CLKGATE_CON(10));
+
  	/*
  	 * Switch PLLs other than DPLL (for SDRAM) to slow mode to
  	 * avoid crashes on resume. The Mask ROM on the system will

Thank you for your correction.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#12 lore raw
In reply to Douglas Anderson

Am Freitag, 12. April 2019, 01:21:53 CEST schrieb Douglas Anderson:

Quoted 39 lines

Experimentally it can be seen that going into deep sleep (specifically setting PMU_CLR_DMA and PMU_CLR_BUS in RK3288_PMU_PWRMODE_CON1) appears to fail unless "aclk_dmac1" is on. The failure is that the system never signals that it made it into suspend on the GLOBAL_PWROFF pin and it just hangs.

NOTE that it's confirmed that it's the actual suspend that fails, not one of the earlier calls to read/write registers. Specifically if you comment out the "PMU_GLOBAL_INT_DISABLE" setting in rk3288_slp_mode_set() and then comment out the "cpu_do_idle()" call in rockchip_lpmode_enter() then you can exercise the whole suspend path without any crashing.

This is currently not a problem with suspend upstream because there is no current way to exercise the deep suspend code. However, anyone trying to make it work will run into this issue.

This was not a problem on shipping rk3288-based Chromebooks because those devices all ran on an old kernel based on 3.14. On that kernel "aclk_dmac1" appears to be left on all the time.

There are several ways to skin this problem.

A) We could add "aclk_dmac1" to the list of critical clocks and that apperas to work, but presumably that wastes power.

B) We could keep a list of "struct clk" objects to enable at suspend time in clk-rk3288.c and use the standard clock APIs.

C) We could make the rk3288-pmu driver keep a list of clocks to enable at suspend time. Presumably this would require a dts and bindings change.

D) We could just whack the clock on in the existing syscore suspend function where we whack a bunch of other clocks. This is particularly easy because we know for sure that the clock's only parent ("aclk_cpu") is a critical clock so we don't need to do anything more than ungate it.

Quoted 4 lines

In this case I have chosen D) because it seemed like the least work, but any of the other options would presumably also work fine.

applied for 5.2 with Elaine's rb

Thanks
Heiko