clk: rockchip: Turn on "aclk_dmac1" for suspend
Subsystems (5)
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
@@ -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
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
@@ -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
Heiko Stübner
maintainerRe: [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()andrk3288_suspend_init()are only called in the context ofrockchip_suspend_init()which is already marked__init. We can mark them__inittoo.Signed-off-by Douglas Anderson <[email protected]>
applied for 5.2
Thanks
Heiko
PATCH 3/5 ARM: dts: rockchip: Add DDR retention/poweroff to rk3288-veyron hogs
In reply to Douglas AndersonEven 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
@@ -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
@@ -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
Heiko Stübner
maintainerRe: [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.
Signed-off-by Douglas Anderson <[email protected]>
applied for 5.2
Thanks
Heiko
PATCH 4/5 ARM: dts: rockchip: vcc33_ccd off in suspend for rk3288-veyron-chromebook
In reply to Douglas AndersonAs per my comments when the device tree for rk3288-veyron-chromebook first landed:
Quoted 6 lines
Technically I think
vcc33_ccdcan 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.
---
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
@@ -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
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_ccdcan 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.
Signed-off-by Douglas Anderson <[email protected]>---
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
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; }; }; };
Heiko Stübner
maintainerRe: [PATCH 4/5] ARM: dts: rockchip: vcc33_ccd off in suspend for rk3288-veyron-chromebook
In reply to Douglas AndersonAm 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_ccdcan 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.
Signed-off-by Douglas Anderson <[email protected]>
applied for 5.2
Thanks
Heiko
PATCH 5/5 ARM: dts: rockchip: vdd_gpu off in suspend for rk3288-veyron
In reply to Douglas AndersonAt 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
@@ -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
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.
Signed-off-by Douglas Anderson <[email protected]>---
arch/arm/boot/dts/rk3288-veyron.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/arm/boot/dts/rk3288-veyron.dtsi +0
-0
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; }; };
Heiko Stübner
maintainerRe: [PATCH 5/5] ARM: dts: rockchip: vdd_gpu off in suspend for rk3288-veyron
In reply to Douglas AndersonAm 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.
Signed-off-by Douglas Anderson <[email protected]>
applied for 5.2
Thanks
Heiko
hi,
Quoted 67 lines · Douglas Anderson
Experimentally it can be seen that going into deep sleep (specifically setting
PMU_CLR_DMAandPMU_CLR_BUSinRK3288_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 theGLOBAL_PWROFFpin 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 inrk3288_slp_mode_set()and then comment out the "cpu_do_idle()" call inrockchip_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.cand 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.
Signed-off-by Douglas Anderson <[email protected]>---
drivers/clk/rockchip/clk-rk3288.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/clk/rockchip/clk-rk3288.c +4
-0@@ -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
Heiko Stübner
maintainerAm 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_DMAandPMU_CLR_BUSinRK3288_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 theGLOBAL_PWROFFpin 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 inrk3288_slp_mode_set()and then comment out the "cpu_do_idle()" call inrockchip_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.cand 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.
Signed-off-by Douglas Anderson <[email protected]>
applied for 5.2 with Elaine's rb
Thanks
Heiko