ARM: tegra20: cpuidle: add power-down state
Subsystems (3)
v3 cover ARM: tegra20: cpuidle: add power-down state
This adds a "powered-down" state in cpuidle for Tegra20. It requires power gating both CPU cores. When the CPU1 requests to enter "powered-down" state, it saves its own state and then enters WFI. When the CPU0 requests the same state, it attempts to put the CPU1 into reset to prevent it from waking up. Then power down both CPUs together and turn off the CPU rail.
If the CPU1 be woken up before CPU0 entering powered-down state, then it needs to restore it's CPU state and waits for next chance.
V3:
* sqash the last 2 patches in previors version to support coupled cpuidle directly
V2:
* add a new patch for checking if there is any pending SGI
* if there is a SGI pending for the CPU, then we will abort the "powered-down" idle for the both CPUs that already in coupled state
Verified on Seaboard(Tegra20) and Cardhu(Tegra30).
Joseph Lo (5):
ARM: tegra: add pending SGI checking API
ARM: tegra20: cpuidle: add powered-down state for secondary CPU
ARM: tegra20: clocks: add CPU low-power function into
tegra_cpu_car_ops
ARM: tegra20: flowctrl: add support for cpu_suspend_enter/exit
ARM: tegra20: cpuidle: apply coupled cpuidle for powered-down mode
arch/arm/mach-tegra/Kconfig | 1 + arch/arm/mach-tegra/cpuidle-tegra20.c | 201 ++++++++++++++++++++++++++++++++- arch/arm/mach-tegra/flowctrl.c | 38 ++++++- arch/arm/mach-tegra/flowctrl.h | 4 + arch/arm/mach-tegra/irq.c | 15 +++ arch/arm/mach-tegra/irq.h | 22 ++++ arch/arm/mach-tegra/pm.c | 2 + arch/arm/mach-tegra/sleep-tegra20.S | 200 ++++++++++++++++++++++++++++++++ arch/arm/mach-tegra/sleep.S | 19 +++ arch/arm/mach-tegra/sleep.h | 26 +++++ arch/arm/mach-tegra/tegra20_clocks.c | 99 ++++++++++++++++ 11 files changed, 617 insertions(+), 10 deletions(-) create mode 100644 arch/arm/mach-tegra/irq.h
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
The "powered-down" CPU idle mode of Tegra cut off the vdd_cpu rail, it include the power of GIC. That caused the SGI (Software Generated Interrupt) been lost. Because the SGI can't wake up the CPU that in the "powered-down" CPU idle mode. We need to check if there is any pending SGI when go into "powered-down" CPU idle mode. This is important especially when applying the coupled cpuidle framework into "power-down" cpuidle dirver. Because the coupled cpuidle framework may have the chance that misses IPI_SINGLE_FUNC handling sometimes.
For the PPI or SPI, something like the legacy peripheral interrupt. It still can be maintained by Tegra legacy interrupt controller. If there is any pending PPI or SPI when CPU in "powered-down" CPU idle mode. The CPU can be woken up immediately. So we don't need to take care the same situation for PPI or SPI.
---
V3:
* move the static mapping of GIC addr into tegra_pending_sgi V2:
* new in V2
--- arch/arm/mach-tegra/irq.c | 15 +++++++++++++++ arch/arm/mach-tegra/irq.h | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-tegra/irq.h
arch/arm/mach-tegra/irq.c +15 -0
@@ -45,6 +45,8 @@#define FIRST_LEGACY_IRQ 32 +#define SGI_MASK 0xFFFF +static int num_ictlrs;static void __iomem *ictlr_reg_base[] = {
@@ -55,6 +57,19 @@ static void __iomem *ictlr_reg_base[] = { IO_ADDRESS(TEGRA_QUINARY_ICTLR_BASE), }; +bool tegra_pending_sgi (void ) +{ +u32 pending_set; +void __iomem *distbase =IO_ADDRESS (TEGRA_ARM_INT_DIST_BASE ); + + pending_set =readl_relaxed (distbase +GIC_DIST_PENDING_SET ); + +if (pending_set &SGI_MASK ) +return true; + +return false; +} +static inline void tegra_irq_write_mask (unsigned int irq,unsigned long reg) {void __iomem *base;
arch/arm/mach-tegra/irq.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (c) 2012, NVIDIA Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __TEGRA_IRQ_H +#define __TEGRA_IRQ_H + +bool tegra_pending_sgi (void ); + +#endif
Signature · 1 line
1.7.0.4
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
Quoted 8 lines · Joseph Lo
The "powered-down" CPU idle mode of Tegra cut off the
vdd_cpurail, it include the power of GIC. That caused the SGI (Software Generated Interrupt) been lost. Because the SGI can't wake up the CPU that in the "powered-down" CPU idle mode. We need to check if there is any pending SGI when go into "powered-down" CPU idle mode. This is important especially when applying the coupled cpuidle framework into "power-down" cpuidle dirver. Because the coupled cpuidle framework may have the chance that missesIPI_SINGLE_FUNChandling sometimes.
This problem exists for any GIC-based SoC, and needs to be fixed in gic_cpu_save or gic_dist_save, whichever one loses the interrupt.
Quoted 82 lines
For the PPI or SPI, something like the legacy peripheral interrupt. It still can be maintained by Tegra legacy interrupt controller. If there is any pending PPI or SPI when CPU in "powered-down" CPU idle mode. The CPU can be woken up immediately. So we don't need to take care the same situation for PPI or SPI.
Signed-off-by Joseph Lo <[email protected]>---
V3:
* move the static mapping of GIC addr intotegra_pending_sgiV2:
* new in V2--- arch/arm/mach-tegra/irq.c | 15 +++++++++++++++ arch/arm/mach-tegra/irq.h | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-tegra/irq.harch/arm/mach-tegra/irq.c +15
-0@@ -45,6 +45,8 @@#define FIRST_LEGACY_IRQ 32 +#define SGI_MASK 0xFFFF +static int num_ictlrs;static void __iomem *ictlr_reg_base[] = {@@ -55,6 +57,19 @@ static void __iomem *ictlr_reg_base[] = { IO_ADDRESS(TEGRA_QUINARY_ICTLR_BASE), }; +bool tegra_pending_sgi (void ) +{ +u32 pending_set; +void __iomem *distbase =IO_ADDRESS (TEGRA_ARM_INT_DIST_BASE ); + + pending_set =readl_relaxed (distbase +GIC_DIST_PENDING_SET ); + +if (pending_set &SGI_MASK ) +return true; + +return false; +} +static inline void tegra_irq_write_mask (unsigned int irq,unsigned long reg) {void __iomem *base;arch/arm/mach-tegra/irq.h new file +22
-1@@ -0,0 +1,22 @@ +/* +* Copyright (c) 2012, NVIDIA Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __TEGRA_IRQ_H +#define __TEGRA_IRQ_H + +bool tegra_pending_sgi (void ); + +#endif --1.7.0.4
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
Quoted 10 lines · Colin Cross
Quoted 8 lines · Joseph Lo
The "powered-down" CPU idle mode of Tegra cut off the
vdd_cpurail, it include the power of GIC. That caused the SGI (Software Generated Interrupt) been lost. Because the SGI can't wake up the CPU that in the "powered-down" CPU idle mode. We need to check if there is any pending SGI when go into "powered-down" CPU idle mode. This is important especially when applying the coupled cpuidle framework into "power-down" cpuidle dirver. Because the coupled cpuidle framework may have the chance that missesIPI_SINGLE_FUNChandling sometimes.
Quoted 3 lines
This problem exists for any GIC-based SoC, and needs to be fixed in
gic_cpu_saveorgic_dist_save, whichever one loses the interrupt.
Indeed, but may not need to be taken care for every SoC. It's depend on HW design. Different SoC had different design about it. For ex, some SoC only put CPU core to power saving mode not include GIC, or there is another irq controller can handle the case when CPU go into power saving mode. Differenc SoC had different usage here (some need to check all pending irq, some need to check SGI only and some even no need to consider this). So putting this into to common code may not a good choice.
Thanks,
Joseph
Quoted 13 lines
Quoted 13 lines
For the PPI or SPI, something like the legacy peripheral interrupt. It still can be maintained by Tegra legacy interrupt controller. If there is any pending PPI or SPI when CPU in "powered-down" CPU idle mode. The CPU can be woken up immediately. So we don't need to take care the same situation for PPI or SPI.
Signed-off-by Joseph Lo <[email protected]>---
V3:
* move the static mapping of GIC addr intotegra_pending_sgiV2:
* new in V2
---
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
In reply to Colin CrossQuoted 10 lines · Colin Cross
Quoted 8 lines · Joseph Lo
The "powered-down" CPU idle mode of Tegra cut off the
vdd_cpurail, it include the power of GIC. That caused the SGI (Software Generated Interrupt) been lost. Because the SGI can't wake up the CPU that in the "powered-down" CPU idle mode. We need to check if there is any pending SGI when go into "powered-down" CPU idle mode. This is important especially when applying the coupled cpuidle framework into "power-down" cpuidle dirver. Because the coupled cpuidle framework may have the chance that missesIPI_SINGLE_FUNChandling sometimes.
Quoted 2 lines
This problem exists for any GIC-based SoC, and needs to be fixed in
gic_cpu_saveorgic_dist_save, whichever one loses the interrupt.
Not necessarily. It depends on the SoC design. On Tegra20, the entire CPU cluster is railgated, including the GIC. This causes a pending IPI to be lost. But for example on OMAP4, only the actual CPU cores are powergated. The GIC stays alive until also the core domain hits idle. By that time a potential pending IPI has long woken up the target CPU again, so no additional checks are needed for functional correct behavior.
Cheers,
Peter.
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
Quoted 14 lines · Peter De Schrijver
Quoted 10 lines · Colin Cross
Quoted 8 lines · Joseph Lo
The "powered-down" CPU idle mode of Tegra cut off the
vdd_cpurail, it include the power of GIC. That caused the SGI (Software Generated Interrupt) been lost. Because the SGI can't wake up the CPU that in the "powered-down" CPU idle mode. We need to check if there is any pending SGI when go into "powered-down" CPU idle mode. This is important especially when applying the coupled cpuidle framework into "power-down" cpuidle dirver. Because the coupled cpuidle framework may have the chance that missesIPI_SINGLE_FUNChandling sometimes.Quoted 2 lines
This problem exists for any GIC-based SoC, and needs to be fixed in
gic_cpu_saveorgic_dist_save, whichever one loses the interrupt.
Quoted 6 lines
Not necessarily. It depends on the SoC design. On Tegra20, the entire CPU cluster is railgated, including the GIC. This causes a pending IPI to be lost. But for example on OMAP4, only the actual CPU cores are powergated. The GIC stays alive until also the core domain hits idle. By that time a potential pending IPI has long woken up the target CPU again, so no additional checks are needed for functional correct behavior.
I'm not sure that is correct for OMAP4. C2 and C3 will put the power rail for the GIC in retention, and I don't think an IPI will wake it up. I believe the same problem also exists for Exynos5. In any case, checking for an IPI early during idle and aborting won't hurt those platforms, so I still think it should be in the GIC driver and not by mapping the GIC registers into a separate driver.
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
Quoted 23 lines · Colin Cross
Quoted 14 lines · Peter De Schrijver
Quoted 10 lines · Colin Cross
Quoted 8 lines · Joseph Lo
The "powered-down" CPU idle mode of Tegra cut off the
vdd_cpurail, it include the power of GIC. That caused the SGI (Software Generated Interrupt) been lost. Because the SGI can't wake up the CPU that in the "powered-down" CPU idle mode. We need to check if there is any pending SGI when go into "powered-down" CPU idle mode. This is important especially when applying the coupled cpuidle framework into "power-down" cpuidle dirver. Because the coupled cpuidle framework may have the chance that missesIPI_SINGLE_FUNChandling sometimes.Quoted 2 lines
This problem exists for any GIC-based SoC, and needs to be fixed in
gic_cpu_saveorgic_dist_save, whichever one loses the interrupt.Quoted 6 lines
Not necessarily. It depends on the SoC design. On Tegra20, the entire CPU cluster is railgated, including the GIC. This causes a pending IPI to be lost. But for example on OMAP4, only the actual CPU cores are powergated. The GIC stays alive until also the core domain hits idle. By that time a potential pending IPI has long woken up the target CPU again, so no additional checks are needed for functional correct behavior.
Quoted 6 lines
I'm not sure that is correct for OMAP4. C2 and C3 will put the power rail for the GIC in retention, and I don't think an IPI will wake it up. I believe the same problem also exists for Exynos5. In any case, checking for an IPI early during idle and aborting won't hurt those platforms, so I still think it should be in the GIC driver and not by mapping the GIC registers into a separate driver.
Hi Colin,
If I move this code into common GIC driver, should I just take care pending SGI also?
I will try to create a RFC patch for this.
Thanks,
Joseph
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
Quoted 31 lines · Joseph Lo
Quoted 23 lines · Colin Cross
Quoted 14 lines · Peter De Schrijver
Quoted 10 lines · Colin Cross
Quoted 8 lines · Joseph Lo
The "powered-down" CPU idle mode of Tegra cut off the
vdd_cpurail, it include the power of GIC. That caused the SGI (Software Generated Interrupt) been lost. Because the SGI can't wake up the CPU that in the "powered-down" CPU idle mode. We need to check if there is any pending SGI when go into "powered-down" CPU idle mode. This is important especially when applying the coupled cpuidle framework into "power-down" cpuidle dirver. Because the coupled cpuidle framework may have the chance that missesIPI_SINGLE_FUNChandling sometimes.Quoted 2 lines
This problem exists for any GIC-based SoC, and needs to be fixed in
gic_cpu_saveorgic_dist_save, whichever one loses the interrupt.Quoted 6 lines
Not necessarily. It depends on the SoC design. On Tegra20, the entire CPU cluster is railgated, including the GIC. This causes a pending IPI to be lost. But for example on OMAP4, only the actual CPU cores are powergated. The GIC stays alive until also the core domain hits idle. By that time a potential pending IPI has long woken up the target CPU again, so no additional checks are needed for functional correct behavior.
Quoted 6 lines
I'm not sure that is correct for OMAP4. C2 and C3 will put the power rail for the GIC in retention, and I don't think an IPI will wake it up. I believe the same problem also exists for Exynos5. In any case, checking for an IPI early during idle and aborting won't hurt those platforms, so I still think it should be in the GIC driver and not by mapping the GIC registers into a separate driver.
Quoted 5 lines
If I move this code into common GIC driver, should I just take care pending SGI also?
I will try to create a RFC patch for this.
Hi Colin,
I just checked the scenario to abort cpu_pm_enter when there is any pending SGI. This may break the current CPU idle driver that already using cpu_pm_enter. If these drivers didn't handle the error return of "cpu_pm_enter", the error will cause the CPU_PM_ENTER_FAILED be triggered. Then the idle code will fail.
The other solution may just like this patch did. Adding an API "gic_pending_sgi" to check if there is a pending SGI before putting the CPU into low power mode. But I still don't think this is a common code to be put there. It's still SoC specific code. So I still prefer the current solution in this patch for Tegra.
Thanks,
Joseph
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
In reply to Colin CrossQuoted 23 lines · Colin Cross
Quoted 14 lines · Peter De Schrijver
Quoted 10 lines · Colin Cross
Quoted 8 lines · Joseph Lo
The "powered-down" CPU idle mode of Tegra cut off the
vdd_cpurail, it include the power of GIC. That caused the SGI (Software Generated Interrupt) been lost. Because the SGI can't wake up the CPU that in the "powered-down" CPU idle mode. We need to check if there is any pending SGI when go into "powered-down" CPU idle mode. This is important especially when applying the coupled cpuidle framework into "power-down" cpuidle dirver. Because the coupled cpuidle framework may have the chance that missesIPI_SINGLE_FUNChandling sometimes.Quoted 2 lines
This problem exists for any GIC-based SoC, and needs to be fixed in
gic_cpu_saveorgic_dist_save, whichever one loses the interrupt.Quoted 6 lines
Not necessarily. It depends on the SoC design. On Tegra20, the entire CPU cluster is railgated, including the GIC. This causes a pending IPI to be lost. But for example on OMAP4, only the actual CPU cores are powergated. The GIC stays alive until also the core domain hits idle. By that time a potential pending IPI has long woken up the target CPU again, so no additional checks are needed for functional correct behavior.
Quoted 7 lines
I'm not sure that is correct for OMAP4. C2 and C3 will put the power rail for the GIC in retention, and I don't think an IPI will wake it up. I believe the same problem also exists for Exynos5. In any case, checking for an IPI early during idle and aborting won't hurt those platforms, so I still think it should be in the GIC driver and not by mapping the GIC registers into a separate driver.
I second Colin on the GIC power states on OMAP.
Regards
Santosh
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
Quoted 24 lines · Santosh Shilimkar
Quoted 23 lines · Colin Cross
Quoted 20 lines · Peter De Schrijver
Quoted 10 lines · Colin Cross
Quoted 8 lines · Joseph Lo
The "powered-down" CPU idle mode of Tegra cut off the
vdd_cpurail, it include the power of GIC. That caused the SGI (Software Generated Interrupt) been lost. Because the SGI can't wake up the CPU that in the "powered-down" CPU idle mode. We need to check if there is any pending SGI when go into "powered-down" CPU idle mode. This is important especially when applying the coupled cpuidle framework into "power-down" cpuidle dirver. Because the coupled cpuidle framework may have the chance that missesIPI_SINGLE_FUNChandling sometimes.Quoted 2 lines
This problem exists for any GIC-based SoC, and needs to be fixed in
gic_cpu_saveorgic_dist_save, whichever one loses the interrupt.Not necessarily. It depends on the SoC design. On Tegra20, the entire CPU cluster is railgated, including the GIC. This causes a pending IPI to be lost. But for example on OMAP4, only the actual CPU cores are powergated. The GIC stays alive until also the core domain hits idle. By that time a potential pending IPI has long woken up the target CPU again, so no additional checks are needed for functional correct behavior.
Quoted 8 lines
Quoted 7 lines
I'm not sure that is correct for OMAP4. C2 and C3 will put the power rail for the GIC in retention, and I don't think an IPI will wake it up. I believe the same problem also exists for Exynos5. In any case, checking for an IPI early during idle and aborting won't hurt those platforms, so I still think it should be in the GIC driver and not by mapping the GIC registers into a separate driver.
I second Colin on the GIC power states on OMAP.
But even then PRCM will only trigger the transition to retention voltage after both CPUs hit off mode. I guess a pending IPI will wakeup the core before the PRCM starts the transition.
Cheers,
Peter.
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
Quoted 32 lines · Peter De Schrijver
Quoted 31 lines · Santosh Shilimkar
Quoted 30 lines · Colin Cross
Quoted 14 lines · Peter De Schrijver
Quoted 10 lines · Colin Cross
Quoted 8 lines · Joseph Lo
The "powered-down" CPU idle mode of Tegra cut off the
vdd_cpurail, it include the power of GIC. That caused the SGI (Software Generated Interrupt) been lost. Because the SGI can't wake up the CPU that in the "powered-down" CPU idle mode. We need to check if there is any pending SGI when go into "powered-down" CPU idle mode. This is important especially when applying the coupled cpuidle framework into "power-down" cpuidle dirver. Because the coupled cpuidle framework may have the chance that missesIPI_SINGLE_FUNChandling sometimes.Quoted 2 lines
This problem exists for any GIC-based SoC, and needs to be fixed in
gic_cpu_saveorgic_dist_save, whichever one loses the interrupt.Quoted 6 lines
Not necessarily. It depends on the SoC design. On Tegra20, the entire CPU cluster is railgated, including the GIC. This causes a pending IPI to be lost. But for example on OMAP4, only the actual CPU cores are powergated. The GIC stays alive until also the core domain hits idle. By that time a potential pending IPI has long woken up the target CPU again, so no additional checks are needed for functional correct behavior.
I'm not sure that is correct for OMAP4. C2 and C3 will put the power rail for the GIC in retention, and I don't think an IPI will wake it up. I believe the same problem also exists for Exynos5. In any case, checking for an IPI early during idle and aborting won't hurt those platforms, so I still think it should be in the GIC driver and not by mapping the GIC registers into a separate driver.
Quoted 6 lines
Quoted 1 line
I second Colin on the GIC power states on OMAP.
But even then PRCM will only trigger the transition to retention voltage after both CPUs hit off mode. I guess a pending IPI will wakeup the core before the PRCM starts the transition.
No it won't. You are talking about the voltage domain retention while the point is SGI becomes useless once CPU power domain transition to low power state. And btw, voltage transition also can not happen just with two CPU's in retention. It does have dependency like cluster power state to hit retention.
CPUs have their own power domain state and once they enter into any low power state apart from ON power state, SGI doesn't work. hope this is clear.
Regards
Santosh
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
Quoted 45 lines · Santosh Shilimkar
Quoted 32 lines · Peter De Schrijver
Quoted 31 lines · Santosh Shilimkar
Quoted 30 lines · Colin Cross
Quoted 14 lines · Peter De Schrijver
Quoted 10 lines · Colin Cross
Quoted 8 lines · Joseph Lo
The "powered-down" CPU idle mode of Tegra cut off the
vdd_cpurail, it include the power of GIC. That caused the SGI (Software Generated Interrupt) been lost. Because the SGI can't wake up the CPU that in the "powered-down" CPU idle mode. We need to check if there is any pending SGI when go into "powered-down" CPU idle mode. This is important especially when applying the coupled cpuidle framework into "power-down" cpuidle dirver. Because the coupled cpuidle framework may have the chance that missesIPI_SINGLE_FUNChandling sometimes.Quoted 2 lines
This problem exists for any GIC-based SoC, and needs to be fixed in
gic_cpu_saveorgic_dist_save, whichever one loses the interrupt.Quoted 6 lines
Not necessarily. It depends on the SoC design. On Tegra20, the entire CPU cluster is railgated, including the GIC. This causes a pending IPI to be lost. But for example on OMAP4, only the actual CPU cores are powergated. The GIC stays alive until also the core domain hits idle. By that time a potential pending IPI has long woken up the target CPU again, so no additional checks are needed for functional correct behavior.
I'm not sure that is correct for OMAP4. C2 and C3 will put the power rail for the GIC in retention, and I don't think an IPI will wake it up. I believe the same problem also exists for Exynos5. In any case, checking for an IPI early during idle and aborting won't hurt those platforms, so I still think it should be in the GIC driver and not by mapping the GIC registers into a separate driver.
Quoted 6 lines
Quoted 1 line
I second Colin on the GIC power states on OMAP.
But even then PRCM will only trigger the transition to retention voltage after both CPUs hit off mode. I guess a pending IPI will wakeup the core before the PRCM starts the transition.
No it won't. You are talking about the voltage domain retention while the point is SGI becomes useless once CPU power domain transition to low power state. And btw, voltage transition also can not happen just with two CPU's in retention. It does have dependency like cluster power state to hit retention.
Quoted 3 lines
CPUs have their own power domain state and once they enter into any low power state apart from ON power state, SGI doesn't work. hope this is clear.
So why does OMAP4 have working coupled idle without the SGI check then?
Cheers,
Peter.
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
Quoted 46 lines · Peter De Schrijver
Quoted 45 lines · Santosh Shilimkar
Quoted 32 lines · Peter De Schrijver
Quoted 31 lines · Santosh Shilimkar
Quoted 30 lines · Colin Cross
Quoted 14 lines · Peter De Schrijver
Quoted 10 lines · Colin Cross
Quoted 8 lines · Joseph Lo
The "powered-down" CPU idle mode of Tegra cut off the
vdd_cpurail, it include the power of GIC. That caused the SGI (Software Generated Interrupt) been lost. Because the SGI can't wake up the CPU that in the "powered-down" CPU idle mode. We need to check if there is any pending SGI when go into "powered-down" CPU idle mode. This is important especially when applying the coupled cpuidle framework into "power-down" cpuidle dirver. Because the coupled cpuidle framework may have the chance that missesIPI_SINGLE_FUNChandling sometimes.Quoted 2 lines
This problem exists for any GIC-based SoC, and needs to be fixed in
gic_cpu_saveorgic_dist_save, whichever one loses the interrupt.Quoted 6 lines
Not necessarily. It depends on the SoC design. On Tegra20, the entire CPU cluster is railgated, including the GIC. This causes a pending IPI to be lost. But for example on OMAP4, only the actual CPU cores are powergated. The GIC stays alive until also the core domain hits idle. By that time a potential pending IPI has long woken up the target CPU again, so no additional checks are needed for functional correct behavior.
I'm not sure that is correct for OMAP4. C2 and C3 will put the power rail for the GIC in retention, and I don't think an IPI will wake it up. I believe the same problem also exists for Exynos5. In any case, checking for an IPI early during idle and aborting won't hurt those platforms, so I still think it should be in the GIC driver and not by mapping the GIC registers into a separate driver.
Quoted 6 lines
Quoted 1 line
I second Colin on the GIC power states on OMAP.
But even then PRCM will only trigger the transition to retention voltage after both CPUs hit off mode. I guess a pending IPI will wakeup the core before the PRCM starts the transition.
No it won't. You are talking about the voltage domain retention while the point is SGI becomes useless once CPU power domain transition to low power state. And btw, voltage transition also can not happen just with two CPU's in retention. It does have dependency like cluster power state to hit retention.
Quoted 6 lines
Quoted 3 lines
CPUs have their own power domain state and once they enter into any low power state apart from ON power state, SGI doesn't work. hope this is clear.
So why does OMAP4 have working coupled idle without the SGI check then?
Because whenever the OMAP4 CPUs enter into any power states apart from ON, clock-domain force wakeup method us being used to wakeup secondary CPUs. And secondly CPU RET is not supported on purpose because of some known IP block issues.
Regards
Santosh
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
Quoted 8 lines
Quoted 3 lines
So why does OMAP4 have working coupled idle without the SGI check then?
Because whenever the OMAP4 CPUs enter into any power states apart from ON, clock-domain force wakeup method us being used to wakeup secondary CPUs. And secondly CPU RET is not supported on purpose because of some known IP block issues.
Aha. That explains indeed why you don't need the check.
Cheers,
Peter.
PATCH v3 1/5 ARM: tegra: add pending SGI checking API
Quoted 11 lines · Peter De Schrijver
Quoted 8 lines
Quoted 3 lines
So why does OMAP4 have working coupled idle without the SGI check then?
Because whenever the OMAP4 CPUs enter into any power states apart from ON, clock-domain force wakeup method us being used to wakeup secondary CPUs. And secondly CPU RET is not supported on purpose because of some known IP block issues.
Aha. That explains indeed why you don't need the check.
Just for the information on OMAP5 SOC, CPU RET is supported and the couple idle works on it without IPI. As I mentioned, we do use clock-domain force wakeup method for wakeup. Code is out of the tree hence i didn't mention that in first place.
Regards
Santosh
PATCH v3 2/5 ARM: tegra20: cpuidle: add powered-down state for secondary CPU
In reply to Joseph LoThe powered-down state of Tegra20 requires power gating both CPU cores. When the secondary CPU requests to enter powered-down state, it saves its own contexts and then enters WFI. The Tegra20 had a limition to power down both CPU cores. The secondary CPU must waits for CPU0 in powered-down state too. If the secondary CPU be woken up before CPU0 entering powered-down state, then it needs to restore its CPU states and waits for next chance.
Be aware of that, you may see the legacy power state "LP2" in the code which is exactly the same meaning of "CPU power down".
Based on the work by:
Colin Cross <[email protected]>
Gary King <[email protected]>
---
V3:
* dynamic checking of the number of the state counts
* fix the code sequence for aborting cpu_suspend in tegra20_sleep_cpu_secondary_finish
V2:
* no change
--- arch/arm/mach-tegra/cpuidle-tegra20.c | 94 ++++++++++++++++++++- arch/arm/mach-tegra/pm.c | 2 + arch/arm/mach-tegra/sleep-tegra20.S | 147 +++++++++++++++++++++++++++++++++ arch/arm/mach-tegra/sleep.h | 23 +++++ 4 files changed, 261 insertions(+), 5 deletions(-)
arch/arm/mach-tegra/cpuidle-tegra20.c +89 -5
@@ -22,28 +22,112 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/cpuidle.h> +#include <linux/cpu_pm.h> +#include <linux/clockchips.h> #include <asm/cpuidle.h> +#include <asm/proc-fns.h> +#include <asm/suspend.h> +#include <asm/smp_plat.h> + +#include "pm.h" +#include "sleep.h" + +#ifdef CONFIG_PM_SLEEP +static int tegra20_idle_lp2 (struct cpuidle_device *dev, +struct cpuidle_driver *drv, +int index); +#endif + +static struct cpuidle_state tegra_idle_states[] = { + [0 ] =ARM_CPUIDLE_WFI_STATE_PWR (600 ), +#ifdef CONFIG_PM_SLEEP + [1] = { + .enter = tegra20_idle_lp2, + .exit_latency =5000 , + .target_residency =10000 , + .power_usage =0 , + .flags =CPUIDLE_FLAG_TIME_VALID , + .name ="powered-down" , + .desc ="CPU power gated" , + }, +#endif +};static struct cpuidle_driver tegra_idle_driver = { .name ="tegra_idle" , .owner =THIS_MODULE , .en_core_tk_irqen =1 , - .state_count =1 , - .states = { - [0 ] =ARM_CPUIDLE_WFI_STATE_PWR (600 ), - }, }; static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device); +#ifdef CONFIG_PM_SLEEP +#ifdef CONFIG_SMP +static bool tegra20_idle_enter_lp2_cpu_1 (struct cpuidle_device *dev, +struct cpuidle_driver *drv, +int index) +{ +clockevents_notify (CLOCK_EVT_NOTIFY_BROADCAST_ENTER , &dev->cpu); + +cpu_suspend (0 , tegra20_sleep_cpu_secondary_finish); + +tegra20_cpu_clear_resettable (); + +clockevents_notify (CLOCK_EVT_NOTIFY_BROADCAST_EXIT , &dev->cpu); + +return true; +} +#else +static inline bool tegra20_idle_enter_lp2_cpu_1 (struct cpuidle_device *dev, +struct cpuidle_driver *drv, +int index) +{ +return true; +} +#endif + +static int __cpuinit tegra20_idle_lp2 (struct cpuidle_device *dev, +struct cpuidle_driver *drv, +int index) +{ +u32 cpu =is_smp () ?cpu_logical_map (dev->cpu) : dev->cpu; +bool entered_lp2 = false; + +local_fiq_disable (); + +tegra_set_cpu_in_lp2 (cpu); +cpu_pm_enter (); + +if (cpu ==0 ) +cpu_do_idle (); +else + entered_lp2 =tegra20_idle_enter_lp2_cpu_1 (dev, drv, index); + +cpu_pm_exit (); +tegra_clear_cpu_in_lp2 (cpu); + +local_fiq_enable (); + +smp_rmb (); + +return entered_lp2 ? index :0 ; +} +#endif +int __init tegra20_cpuidle_init (void ) { -int ret; +int ret, i;unsigned int cpu;struct cpuidle_device *dev;struct cpuidle_driver *drv = &tegra_idle_driver; + drv->state_count =sizeof (tegra_idle_states) / +sizeof (struct cpuidle_state ); +for (i =0 ; i < drv->state_count; i++) +memcpy (&drv->states[i], &tegra_idle_states[i], +sizeof (struct cpuidle_state )); + ret =cpuidle_register_driver (&tegra_idle_driver);if (ret) {pr_err ("CPUidle driver registration failed\n" );
arch/arm/mach-tegra/pm.c +2 -0
@@ -173,6 +173,8 @@ bool __cpuinit tegra_set_cpu_in_lp2(int phy_cpu_id)if ((phy_cpu_id ==0 ) &&cpumask_equal (cpu_lp2_mask, cpu_online_mask)) last_cpu = true; +else if (phy_cpu_id ==1 ) +tegra20_cpu_set_resettable_soon ();spin_unlock (&tegra_lp2_lock);return last_cpu;
arch/arm/mach-tegra/sleep-tegra20.S +147 -0
156 lines not on this page · raw message
arch/arm/mach-tegra/sleep.h +23 -0
@@ -25,6 +25,19 @@ + IO_PPSB_VIRT)#define TEGRA_CLK_RESET_VIRT (TEGRA_CLK_RESET_BASE - IO_PPSB_PHYS \ + IO_PPSB_VIRT) +#define TEGRA_PMC_VIRT (TEGRA_PMC_BASE - IO_APB_PHYS + IO_APB_VIRT) + +/* PMC_SCRATCH37-39 and 41 are used for tegra_pen_lock and idle */ +#define PMC_SCRATCH37 0x130 +#define PMC_SCRATCH38 0x134 +#define PMC_SCRATCH39 0x138 +#define PMC_SCRATCH41 0x140 + +#ifdef CONFIG_ARCH_TEGRA_2x_SOC +#define CPU_RESETTABLE 2 +#define CPU_RESETTABLE_SOON 1 +#define CPU_NOT_RESETTABLE 0 +#endif #ifdef __ASSEMBLY__/* returns the offset of the flow controller halt register for a cpu */
@@ -104,6 +117,8 @@ exit_l2_resume: .endm#endif /* CONFIG_CACHE_L2X0 */ #else +void tegra_pen_lock (void ); +void tegra_pen_unlock (void );void tegra_resume (void );int tegra_sleep_cpu_finish (unsigned long );
@@ -115,6 +130,14 @@ static inline void tegra20_hotplug_init(void) {}static inline void tegra30_hotplug_init (void ) {}#endif +void tegra20_cpu_clear_resettable (void ); +#ifdef CONFIG_ARCH_TEGRA_2x_SOC +void tegra20_cpu_set_resettable_soon (void ); +#else +static inline void tegra20_cpu_set_resettable_soon (void ) {} +#endif + +int tegra20_sleep_cpu_secondary_finish (unsigned long );int tegra30_sleep_cpu_secondary_finish (unsigned long );void tegra30_tear_down_cpu (void );
Signature · 1 line
1.7.0.4
PATCH v3 2/5 ARM: tegra20: cpuidle: add powered-down state for secondary CPU
Quoted 108 lines · Joseph Lo
The powered-down state of Tegra20 requires power gating both CPU cores. When the secondary CPU requests to enter powered-down state, it saves its own contexts and then enters WFI. The Tegra20 had a limition to power down both CPU cores. The secondary CPU must waits for CPU0 in powered-down state too. If the secondary CPU be woken up before CPU0 entering powered-down state, then it needs to restore its CPU states and waits for next chance.
Be aware of that, you may see the legacy power state "LP2" in the code which is exactly the same meaning of "CPU power down".
Based on the work by:
Colin Cross <[email protected]>
Gary King <[email protected]>Signed-off-by Joseph Lo <[email protected]>---
V3:
* dynamic checking of the number of the state counts
* fix the code sequence for abortingcpu_suspendintegra20_sleep_cpu_secondary_finish
V2:
* no change--- arch/arm/mach-tegra/cpuidle-tegra20.c | 94 ++++++++++++++++++++- arch/arm/mach-tegra/pm.c | 2 + arch/arm/mach-tegra/sleep-tegra20.S | 147 +++++++++++++++++++++++++++++++++ arch/arm/mach-tegra/sleep.h | 23 +++++ 4 files changed, 261 insertions(+), 5 deletions(-)arch/arm/mach-tegra/cpuidle-tegra20.c +55
-4@@ -22,28 +22,112 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/cpuidle.h> +#include <linux/cpu_pm.h> +#include <linux/clockchips.h> #include <asm/cpuidle.h> +#include <asm/proc-fns.h> +#include <asm/suspend.h> +#include <asm/smp_plat.h> + +#include "pm.h" +#include "sleep.h" + +#ifdef CONFIG_PM_SLEEP +static int tegra20_idle_lp2 (struct cpuidle_device *dev, +struct cpuidle_driver *drv, +int index); +#endif + +static struct cpuidle_state tegra_idle_states[] = { + [0 ] =ARM_CPUIDLE_WFI_STATE_PWR (600 ), +#ifdef CONFIG_PM_SLEEP + [1] = { + .enter = tegra20_idle_lp2, + .exit_latency =5000 , + .target_residency =10000 , + .power_usage =0 , + .flags =CPUIDLE_FLAG_TIME_VALID , + .name ="powered-down" , + .desc ="CPU power gated" , + }, +#endif +};static struct cpuidle_driver tegra_idle_driver = { .name ="tegra_idle" , .owner =THIS_MODULE , .en_core_tk_irqen =1 , - .state_count =1 , - .states = { - [0 ] =ARM_CPUIDLE_WFI_STATE_PWR (600 ), - }, }; static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device); +#ifdef CONFIG_PM_SLEEP +#ifdef CONFIG_SMP +static bool tegra20_idle_enter_lp2_cpu_1 (struct cpuidle_device *dev, +struct cpuidle_driver *drv, +int index) +{ +clockevents_notify (CLOCK_EVT_NOTIFY_BROADCAST_ENTER , &dev->cpu); + +cpu_suspend (0 , tegra20_sleep_cpu_secondary_finish); + +tegra20_cpu_clear_resettable (); + +clockevents_notify (CLOCK_EVT_NOTIFY_BROADCAST_EXIT , &dev->cpu); + +return true; +} +#else +static inline bool tegra20_idle_enter_lp2_cpu_1 (struct cpuidle_device *dev, +struct cpuidle_driver *drv, +int index) +{ +return true; +} +#endif + +static int __cpuinit tegra20_idle_lp2(struct cpuidle_device *dev,
arch/arm/mach-tegra/cpuidle-tegra20.c line 100
Quoted 10 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +10
-0+ struct cpuidle_driver *drv, + int index) +{ +u32 cpu =is_smp () ?cpu_logical_map (dev->cpu) : dev->cpu; +bool entered_lp2 = false; + +local_fiq_disable (); + +tegra_set_cpu_in_lp2 (cpu); +cpu_pm_enter ();
You must check the return value from cpu_pm_enter and synchronize and abort both cpus.
Quoted 24 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +18
-1+ +if (cpu ==0 ) +cpu_do_idle (); +else + entered_lp2 =tegra20_idle_enter_lp2_cpu_1 (dev, drv, index); + +cpu_pm_exit (); +tegra_clear_cpu_in_lp2 (cpu); + +local_fiq_enable (); + +smp_rmb (); + + return entered_lp2 ? index : 0; +} +#endif +int __init tegra20_cpuidle_init (void ) { -int ret; +int ret, i;unsigned int cpu;struct cpuidle_device *dev;struct cpuidle_driver *drv = &tegra_idle_driver;
arch/arm/mach-tegra/cpuidle-tegra20.c line 133
Quoted 10 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +6
-0+ drv->state_count =sizeof (tegra_idle_states) / +sizeof (struct cpuidle_state ); +for (i =0 ; i < drv->state_count; i++) +memcpy (&drv->states[i], &tegra_idle_states[i], +sizeof (struct cpuidle_state )); + ret =cpuidle_register_driver (&tegra_idle_driver);if (ret) {pr_err ("CPUidle driver registration failed\n" );
Is there a call to cpu_cluster_pm_enter/exit somewhere else?
PATCH v3 2/5 ARM: tegra20: cpuidle: add powered-down state for secondary CPU
Quoted 41 lines · Colin Cross
Quoted 40 lines · Joseph Lo
The powered-down state of Tegra20 requires power gating both CPU cores. When the secondary CPU requests to enter powered-down state, it saves its own contexts and then enters WFI. The Tegra20 had a limition to power down both CPU cores. The secondary CPU must waits for CPU0 in powered-down state too. If the secondary CPU be woken up before CPU0 entering powered-down state, then it needs to restore its CPU states and waits for next chance.
Be aware of that, you may see the legacy power state "LP2" in the code which is exactly the same meaning of "CPU power down".
Based on the work by:
Colin Cross <[email protected]>
Gary King <[email protected]>Signed-off-by Joseph Lo <[email protected]>---
V3:
* dynamic checking of the number of the state counts
* fix the code sequence for abortingcpu_suspendintegra20_sleep_cpu_secondary_finish
V2:
* no change--- arch/arm/mach-tegra/cpuidle-tegra20.c | 94 ++++++++++++++++++++- arch/arm/mach-tegra/pm.c | 2 + arch/arm/mach-tegra/sleep-tegra20.S | 147 +++++++++++++++++++++++++++++++++ arch/arm/mach-tegra/sleep.h | 23 +++++ 4 files changed, 261 insertions(+), 5 deletions(-)arch/arm/mach-tegra/cpuidle-tegra20.c +6
-0+static int __cpuinit tegra20_idle_lp2 (struct cpuidle_device *dev, +struct cpuidle_driver *drv, +int index) +{ +u32 cpu =is_smp () ?cpu_logical_map (dev->cpu) : dev->cpu; +bool entered_lp2 = false;
Quoted 9 lines
arch/arm/mach-tegra/cpuidle-tegra20.c line 100
Quoted 5 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +5
-0+ +local_fiq_disable (); + +tegra_set_cpu_in_lp2 (cpu); +cpu_pm_enter ();You must check the return value from
cpu_pm_enterand synchronize and abort both cpus.
Please check the sequence in last patch. Although it used the API that be provided by patch 1 to check the pending sgi.
Quoted 25 lines
Quoted 25 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +18
-1+ +if (cpu ==0 ) +cpu_do_idle (); +else + entered_lp2 =tegra20_idle_enter_lp2_cpu_1 (dev, drv, index); + +cpu_pm_exit (); +tegra_clear_cpu_in_lp2 (cpu); + +local_fiq_enable (); + +smp_rmb (); + + return entered_lp2 ? index : 0; +} +#endif +int __init tegra20_cpuidle_init (void ) { -int ret; +int ret, i;unsigned int cpu;struct cpuidle_device *dev;struct cpuidle_driver *drv = &tegra_idle_driver;
Quoted 11 lines
arch/arm/mach-tegra/cpuidle-tegra20.c line 133
Quoted 9 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +6
-0+ drv->state_count =sizeof (tegra_idle_states) / +sizeof (struct cpuidle_state ); +for (i =0 ; i < drv->state_count; i++) +memcpy (&drv->states[i], &tegra_idle_states[i], +sizeof (struct cpuidle_state )); + ret =cpuidle_register_driver (&tegra_idle_driver);if (ret) {pr_err ("CPUidle driver registration failed\n" );Is there a call to cpu_cluster_pm_enter/exit somewhere else?
Yes, there is. Please check the fuction "tegra_idle_lp2_last" in "pm.c", because it's a common code of "powered-down" idle state for CPU0 on Tegra20 & Tegra30.
Thanks,
Joseph
PATCH v3 2/5 ARM: tegra20: cpuidle: add powered-down state for secondary CPU
In reply to Joseph LoQuoted 12 lines · Joseph Lo
The powered-down state of Tegra20 requires power gating both CPU cores. When the secondary CPU requests to enter powered-down state, it saves its own contexts and then enters WFI. The Tegra20 had a limition to power down both CPU cores. The secondary CPU must waits for CPU0 in powered-down state too. If the secondary CPU be woken up before CPU0 entering powered-down state, then it needs to restore its CPU states and waits for next chance.
Be aware of that, you may see the legacy power state "LP2" in the code which is exactly the same meaning of "CPU power down".
arch/arm/mach-tegra/cpuidle-tegra20.c line 126
Quoted 5 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +2
-0int __init tegra20_cpuidle_init (void ) + drv->state_count = sizeof(tegra_idle_states) / +sizeof (struct cpuidle_state );
Use ARRAY_SIZE() there?
arch/arm/mach-tegra/cpuidle-tegra20.c line 129
Quoted 3 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +3
-0+for (i =0 ; i < drv->state_count; i++) +memcpy (&drv->states[i], &tegra_idle_states[i], +sizeof (struct cpuidle_state ));
Can't you call memcpy() once:
memcpy(drv->states, tegra_idle_states,
drv->state_count * sizeof(drv->states[0]));
... although I personally much preferred when all this was just static initialization directly in tegra_idle_driver, rather than all this messy copying. Really, struct cpuidle_driver should point at the array, rather than including it.
arch/arm/mach-tegra/pm.c bool __cpuinit tegra_set_cpu_in_lp2(int phy_cpu_id) · line 180
Quoted 11 lines
arch/arm/mach-tegra/pm.c +2
-0@@ -173,6 +173,8 @@ bool __cpuinit tegra_set_cpu_in_lp2(int phy_cpu_id)if ((phy_cpu_id ==0 ) &&cpumask_equal (cpu_lp2_mask, cpu_online_mask)) last_cpu = true; +else if (phy_cpu_id ==1 ) +tegra20_cpu_set_resettable_soon ();spin_unlock (&tegra_lp2_lock);return last_cpu;
Shouldn't the code in that else branch have a run-time check for whether it's running on Tegra20? When compiled without Tegra20 support, tegra20_cpu_set_resettable_soon() is a dummy static inline, but when both Tegra20 and Tegra30 are compiled in, isn't that code going to run when it shouldn't; pm.c being a common file.
(Peter again, can you please review/ack this series. Thanks)
PATCH v3 2/5 ARM: tegra20: cpuidle: add powered-down state for secondary CPU
Quoted 12 lines · Stephen Warren
Quoted 10 lines · Joseph Lo
The powered-down state of Tegra20 requires power gating both CPU cores. When the secondary CPU requests to enter powered-down state, it saves its own contexts and then enters WFI. The Tegra20 had a limition to power down both CPU cores. The secondary CPU must waits for CPU0 in powered-down state too. If the secondary CPU be woken up before CPU0 entering powered-down state, then it needs to restore its CPU states and waits for next chance.
Be aware of that, you may see the legacy power state "LP2" in the code which is exactly the same meaning of "CPU power down".
Quoted 9 lines
arch/arm/mach-tegra/cpuidle-tegra20.c line 126
Quoted 6 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +2
-0int __init tegra20_cpuidle_init (void ) + drv->state_count = sizeof(tegra_idle_states) / +sizeof (struct cpuidle_state );Use
ARRAY_SIZE()there?
OK.
Quoted 7 lines
arch/arm/mach-tegra/cpuidle-tegra20.c line 129
Quoted 4 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +3
-0+for (i =0 ; i < drv->state_count; i++) +memcpy (&drv->states[i], &tegra_idle_states[i], +sizeof (struct cpuidle_state ));Can't you call
memcpy()once:
Quoted 8 lines
memcpy(drv->states,
tegra_idle_states,drv->state_count * sizeof(drv->states[0]));... although I personally much preferred when all this was just static initialization directly in
tegra_idle_driver, rather than all this messy copying. Really, structcpuidle_drivershould point at the array, rather than including it.
I think so. If you strongly prefer the original style, I can rollback to the previous version here.
Quoted 9 lines
Quoted 9 lines
arch/arm/mach-tegra/pm.c +2
-0@@ -173,6 +173,8 @@ bool __cpuinit tegra_set_cpu_in_lp2(int phy_cpu_id)if ((phy_cpu_id ==0 ) &&cpumask_equal (cpu_lp2_mask, cpu_online_mask)) last_cpu = true; +else if (phy_cpu_id ==1 ) +tegra20_cpu_set_resettable_soon ();
Quoted 9 lines
arch/arm/mach-tegra/pm.c bool __cpuinit tegra_set_cpu_in_lp2(int phy_cpu_id) · line 180
Quoted 2 lines
arch/arm/mach-tegra/pm.c +0
-0spin_unlock (&tegra_lp2_lock);return last_cpu;Shouldn't the code in that else branch have a run-time check for whether it's running on Tegra20? When compiled without Tegra20 support,
tegra20_cpu_set_resettable_soon()is a dummy static inline, but when both Tegra20 and Tegra30 are compiled in, isn't that code going to run when it shouldn't;pm.cbeing a common file.
Because the code didn't hurt Tegra30, so I didn't add a runtime detection there. If you have concern, I can add runtime detection there.
Thanks,
Joseph
PATCH v3 2/5 ARM: tegra20: cpuidle: add powered-down state for secondary CPU
Quoted 10 lines · Joseph Lo
Quoted 9 lines · Stephen Warren
Quoted 8 lines · Joseph Lo
The powered-down state of Tegra20 requires power gating both CPU cores. When the secondary CPU requests to enter powered-down state, it saves its own contexts and then enters WFI. The Tegra20 had a limition to power down both CPU cores. The secondary CPU must waits for CPU0 in powered-down state too. If the secondary CPU be woken up before CPU0 entering powered-down state, then it needs to restore its CPU states and waits for next chance.
Quoted 4 lines
Quoted 4 lines
arch/arm/mach-tegra/cpuidle-tegra20.c
Quoted 4 lines
Be aware of that, you may see the legacy power state "LP2" in the code which is exactly the same meaning of "CPU power down".
arch/arm/mach-tegra/cpuidle-tegra20.c +0
-0
[ code to set up the idle state array]
Quoted 7 lines
Quoted 5 lines
... although I personally much preferred when all this was just static initialization directly in
tegra_idle_driver, rather than all this messy copying. Really, structcpuidle_drivershould point at the array, rather than including it.I think so. If you strongly prefer the original style, I can rollback to the previous version here.
I suppose there's little point changing it back; I know others objected to the original code:-(
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
arch/arm/mach-tegra/pm.c +2
-0@@ -173,6 +173,8 @@ bool __cpuinit tegra_set_cpu_in_lp2(int phy_cpu_id)if ((phy_cpu_id ==0 ) &&cpumask_equal (cpu_lp2_mask, cpu_online_mask)) last_cpu = true; +else if (phy_cpu_id ==1 ) +tegra20_cpu_set_resettable_soon ();Quoted 8 lines
arch/arm/mach-tegra/pm.c bool __cpuinit tegra_set_cpu_in_lp2(int phy_cpu_id) · line 180
Quoted 2 lines
arch/arm/mach-tegra/pm.c +0
-0spin_unlock (&tegra_lp2_lock);return last_cpu;Shouldn't the code in that else branch have a run-time check for whether it's running on Tegra20? When compiled without Tegra20 support,
tegra20_cpu_set_resettable_soon()is a dummy static inline, but when both Tegra20 and Tegra30 are compiled in, isn't that code going to run when it shouldn't;pm.cbeing a common file.
Quoted 2 lines
Because the code didn't hurt Tegra30, so I didn't add a runtime detection there. If you have concern, I can add runtime detection there.
The only issue I see that could happen is that tegra20_cpu_set_resettable_soon() writes to some location to maintain the CPU resettable state. Since I assume that location isn't used for that purpose on Tegra30, could this cause some conflict? It seems best to add the check to make sure there's no issue here.
PATCH v3 3/5 ARM: tegra20: clocks: add CPU low-power function into tegra_cpu_car_ops
In reply to Joseph LoAdd suspend, resume and rail_off_ready API into tegra_cpu_car_ops. These functions were used for CPU powered-down state maintenance.
---
V3:
* no change
V2:
* refine the code sequence in "tegra20_cpu_rail_off_ready"
--- arch/arm/mach-tegra/tegra20_clocks.c | 99 ++++++++++++++++++++++++++++++++++ 1 files changed, 99 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/tegra20_clocks.c +99 -0
@@ -159,6 +159,31 @@#define CPU_CLOCK (cpu) (0x1 << (8 + cpu))#define CPU_RESET (cpu) (0x1111ul << (cpu)) +#define CLK_RESET_CCLK_BURST 0x20 +#define CLK_RESET_CCLK_DIVIDER 0x24 +#define CLK_RESET_PLLX_BASE 0xe0 +#define CLK_RESET_PLLX_MISC 0xe4 + +#define CLK_RESET_SOURCE_CSITE 0x1d4 + +#define CLK_RESET_CCLK_BURST_POLICY_SHIFT 28 +#define CLK_RESET_CCLK_RUN_POLICY_SHIFT 4 +#define CLK_RESET_CCLK_IDLE_POLICY_SHIFT 0 +#define CLK_RESET_CCLK_IDLE_POLICY 1 +#define CLK_RESET_CCLK_RUN_POLICY 2 +#define CLK_RESET_CCLK_BURST_POLICY_PLLX 8 + +#ifdef CONFIG_PM_SLEEP +static struct cpu_clk_suspend_context { +u32 pllx_misc; +u32 pllx_base; + +u32 cpu_burst; +u32 clk_csite_src; +u32 cclk_divider; +} tegra20_cpu_clk_sctx; +#endif +static void __iomem *reg_clk_base =IO_ADDRESS (TEGRA_CLK_RESET_BASE );static void __iomem *reg_pmc_base =IO_ADDRESS (TEGRA_PMC_BASE );
@@ -1609,12 +1634,86 @@ static void tegra20_disable_cpu_clock(u32 cpu) reg_clk_base + TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX); } +#ifdef CONFIG_PM_SLEEP +static bool tegra20_cpu_rail_off_ready (void ) +{ +unsigned int cpu_rst_status; + + cpu_rst_status =readl (reg_clk_base + +TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET ); + +return !!(cpu_rst_status &0x2 ); +} + +static void tegra20_cpu_clock_suspend (void ) +{ +/* switch coresite to clk_m, save off original source */ + tegra20_cpu_clk_sctx.clk_csite_src = +readl (reg_clk_base +CLK_RESET_SOURCE_CSITE ); +writel (3 <<30 , reg_clk_base +CLK_RESET_SOURCE_CSITE ); + + tegra20_cpu_clk_sctx.cpu_burst = +readl (reg_clk_base +CLK_RESET_CCLK_BURST ); + tegra20_cpu_clk_sctx.pllx_base = +readl (reg_clk_base +CLK_RESET_PLLX_BASE ); + tegra20_cpu_clk_sctx.pllx_misc = +readl (reg_clk_base +CLK_RESET_PLLX_MISC ); + tegra20_cpu_clk_sctx.cclk_divider = +readl (reg_clk_base +CLK_RESET_CCLK_DIVIDER ); +} + +static void tegra20_cpu_clock_resume (void ) +{ +unsigned int reg, policy; + +/* Is CPU complex already running on PLLX? */ + reg =readl (reg_clk_base +CLK_RESET_CCLK_BURST ); + policy = (reg >>CLK_RESET_CCLK_BURST_POLICY_SHIFT ) &0xF ; + +if (policy ==CLK_RESET_CCLK_IDLE_POLICY ) + reg = (reg >>CLK_RESET_CCLK_IDLE_POLICY_SHIFT ) &0xF ; +else if (policy ==CLK_RESET_CCLK_RUN_POLICY ) + reg = (reg >>CLK_RESET_CCLK_RUN_POLICY_SHIFT ) &0xF ; +else +BUG (); + +if (reg !=CLK_RESET_CCLK_BURST_POLICY_PLLX ) { +/* restore PLLX settings if CPU is on different PLL */ +writel (tegra20_cpu_clk_sctx.pllx_misc, + reg_clk_base +CLK_RESET_PLLX_MISC ); +writel (tegra20_cpu_clk_sctx.pllx_base, + reg_clk_base +CLK_RESET_PLLX_BASE ); + +/* wait for PLL stabilization if PLLX was enabled */ +if (tegra20_cpu_clk_sctx.pllx_base & (1 <<30 )) +udelay (300 ); + } + +/* +* Restore original burst policy setting for calls resulting from CPU +* LP2 in idle or system suspend. +*/ +writel (tegra20_cpu_clk_sctx.cclk_divider, + reg_clk_base +CLK_RESET_CCLK_DIVIDER ); +writel (tegra20_cpu_clk_sctx.cpu_burst, + reg_clk_base +CLK_RESET_CCLK_BURST ); + +writel (tegra20_cpu_clk_sctx.clk_csite_src, + reg_clk_base +CLK_RESET_SOURCE_CSITE ); +} +#endif +static struct tegra_cpu_car_ops tegra20_cpu_car_ops = { .wait_for_reset = tegra20_wait_cpu_in_reset, .put_in_reset = tegra20_put_cpu_in_reset, .out_of_reset = tegra20_cpu_out_of_reset, .enable_clock = tegra20_enable_cpu_clock, .disable_clock = tegra20_disable_cpu_clock, +#ifdef CONFIG_PM_SLEEP + .rail_off_ready = tegra20_cpu_rail_off_ready, + .suspend = tegra20_cpu_clock_suspend, + .resume = tegra20_cpu_clock_resume, +#endif };void __init tegra20_cpu_car_ops_init (void )
Signature · 1 line
1.7.0.4
PATCH v3 3/5 ARM: tegra20: clocks: add CPU low-power function into tegra_cpu_car_ops
Quoted 2 lines · Joseph Lo
Add suspend, resume and
rail_off_readyAPI intotegra_cpu_car_ops. These functions were used for CPU powered-down state maintenance.
I think this isn't adding those functions into tegra_cpu_car_ops, but rather implementing the already existing function pointers for Tegra20, right?
This patch touches the clock driver and Prashant will soon be posting patches that significantly rework the clock driver. Those will conflict. How have you worked with Prashant to resolve the conflicts? Will Prashant's patches be based on top of this series? Please explicitly describe the dependencies and resolution of conflicts when you post the next version. (below the ---, along with the changelog)
PATCH v3 3/5 ARM: tegra20: clocks: add CPU low-power function into tegra_cpu_car_ops
Quoted 8 lines · Stephen Warren
Quoted 2 lines · Joseph Lo
Add suspend, resume and
rail_off_readyAPI intotegra_cpu_car_ops. These functions were used for CPU powered-down state maintenance.I think this isn't adding those functions into
tegra_cpu_car_ops, but rather implementing the already existing function pointers for Tegra20, right?
Yes, exactly.
Quoted 7 lines
This patch touches the clock driver and Prashant will soon be posting patches that significantly rework the clock driver. Those will conflict. How have you worked with Prashant to resolve the conflicts? Will Prashant's patches be based on top of this series? Please explicitly describe the dependencies and resolution of conflicts when you post the next version. (below the ---, along with the changelog)
Yes, there are many patch series may have dependency each other recently. We also want to know what the sequence you expect to merge the patch series to your tree. Evan my own patch series had dependency too. For ex, hotplug enhancement, cpuidle, SMP works on UP and suspend/resume. Currently, I think we are all work the the top of linux-next tree. If we can't expect the sequence of the patch series to be merged, we will always have some conflicts with each other.
Depend on the timing, I think it should be better to know which patch series should be going first or recently and which should go later and depend on which series. Then we can rearrange our patches on top of it. And reducing the job to fix conflict on your side.
What do you think, Prashant? If your rework of clock driver will show up soon and Stephen also expect that will be merged first, I am fine to re-base on it and re-send my next version after new clock driver be done.
Thanks,
Joseph
PATCH v3 3/5 ARM: tegra20: clocks: add CPU low-power function into tegra_cpu_car_ops
Quoted 18 lines · Joseph Lo
Quoted 8 lines · Stephen Warren
Quoted 2 lines · Joseph Lo
Add suspend, resume and
rail_off_readyAPI intotegra_cpu_car_ops. These functions were used for CPU powered-down state maintenance.I think this isn't adding those functions into
tegra_cpu_car_ops, but rather implementing the already existing function pointers for Tegra20, right?Yes, exactly.
Quoted 7 lines
This patch touches the clock driver and Prashant will soon be posting patches that significantly rework the clock driver. Those will conflict. How have you worked with Prashant to resolve the conflicts? Will Prashant's patches be based on top of this series? Please explicitly describe the dependencies and resolution of conflicts when you post the next version. (below the ---, along with the changelog)
Quoted 3 lines
Yes, there are many patch series may have dependency each other recently. We also want to know what the sequence you expect to merge the patch series to your tree.
To be honest, I don't know what order I'd like to merge things yet. There are so many conflicting/dependant patches for 3.9 flying around I'd need to re-read them all and think it through in quite some detail...
The common clock rework is something quite important. I'd certainly like to get that in early. That most likely implies everything else should be rebased on top of it.
The best thing would be if all patch authors take a look at Prashant's clock patches (and all other patches) and work out what has dependencies on what, and co-ordinate with each-other which order is the easiest to merge things in. Once 3.8-rc1 is out and I can actually start merging things, I'd like to see a list of outstanding patches from each person, with all dependencies explicitly listed. I'll use that information to decide which order to merge in.
Of course I just realized that Prashant hasn't posted his clock patches upstream yet, so it's a little difficult for anyone to rebase on top of them yet, but hopefully that will be resolved very soon now...
PATCH v3 4/5 ARM: tegra20: flowctrl: add support for cpu_suspend_enter/exit
In reply to Joseph LoThe flow controller can help CPU to go into suspend mode (powered-down state). When CPU go into powered-down state, it needs some careful settings before getting into and after leaving. The enter and exit functions do that by configuring appropriate mode for flow controller.
---
V3:
* no change
V2:
* no change
--- arch/arm/mach-tegra/flowctrl.c | 38 +++++++++++++++++++++++++++++++++----- arch/arm/mach-tegra/flowctrl.h | 4 ++++ 2 files changed, 37 insertions(+), 5 deletions(-)
arch/arm/mach-tegra/flowctrl.c +33 -5
@@ -25,6 +25,7 @@#include "flowctrl.h" #include "iomap.h" +#include "fuse.h" u8 flowctrl_offset_halt_cpu[] = {FLOW_CTRL_HALT_CPU0_EVENTS ,
@@ -75,11 +76,26 @@ void flowctrl_cpu_suspend_enter(unsigned int cpuid)int i; reg =flowctrl_read_cpu_csr (cpuid); - reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP ;/* clear wfe bitmap */ - reg &= ~TEGRA30_FLOW_CTRL_CSR_WFI_BITMAP ;/* clear wfi bitmap */ +switch (tegra_chip_id) { +case TEGRA20 : +/* clear wfe bitmap */ + reg &= ~TEGRA20_FLOW_CTRL_CSR_WFE_BITMAP ; +/* clear wfi bitmap */ + reg &= ~TEGRA20_FLOW_CTRL_CSR_WFI_BITMAP ; +/* pwr gating on wfe */ + reg |=TEGRA20_FLOW_CTRL_CSR_WFE_CPU0 << cpuid; +break ; +case TEGRA30 : +/* clear wfe bitmap */ + reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP ; +/* clear wfi bitmap */ + reg &= ~TEGRA30_FLOW_CTRL_CSR_WFI_BITMAP ; +/* pwr gating on wfi */ + reg |=TEGRA30_FLOW_CTRL_CSR_WFI_CPU0 << cpuid; +break ; + } reg |=FLOW_CTRL_CSR_INTR_FLAG ;/* clear intr flag */ reg |=FLOW_CTRL_CSR_EVENT_FLAG ;/* clear event flag */ - reg |=TEGRA30_FLOW_CTRL_CSR_WFI_CPU0 << cpuid;/* pwr gating on wfi */ reg |=FLOW_CTRL_CSR_ENABLE ;/* pwr gating */ flowctrl_write_cpu_csr (cpuid, reg);
@@ -99,8 +115,20 @@ void flowctrl_cpu_suspend_exit(unsigned int cpuid)/* Disable powergating via flow controller for CPU0 */ reg =flowctrl_read_cpu_csr (cpuid); - reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP ;/* clear wfe bitmap */ - reg &= ~TEGRA30_FLOW_CTRL_CSR_WFI_BITMAP ;/* clear wfi bitmap */ +switch (tegra_chip_id) { +case TEGRA20 : +/* clear wfe bitmap */ + reg &= ~TEGRA20_FLOW_CTRL_CSR_WFE_BITMAP ; +/* clear wfi bitmap */ + reg &= ~TEGRA20_FLOW_CTRL_CSR_WFI_BITMAP ; +break ; +case TEGRA30 : +/* clear wfe bitmap */ + reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP ; +/* clear wfi bitmap */ + reg &= ~TEGRA30_FLOW_CTRL_CSR_WFI_BITMAP ; +break ; + } reg &= ~FLOW_CTRL_CSR_ENABLE ;/* clear enable */ reg |=FLOW_CTRL_CSR_INTR_FLAG ;/* clear intr */ reg |=FLOW_CTRL_CSR_EVENT_FLAG ;/* clear event */
arch/arm/mach-tegra/flowctrl.h +4 -0
@@ -34,6 +34,10 @@#define FLOW_CTRL_HALT_CPU1_EVENTS 0x14#define FLOW_CTRL_CPU1_CSR 0x18 +#define TEGRA20_FLOW_CTRL_CSR_WFE_CPU0 (1 << 4) +#define TEGRA20_FLOW_CTRL_CSR_WFE_BITMAP (3 << 4) +#define TEGRA20_FLOW_CTRL_CSR_WFI_BITMAP 0 +#define TEGRA30_FLOW_CTRL_CSR_WFI_CPU0 (1 << 8)#define TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP (0xF << 4)#define TEGRA30_FLOW_CTRL_CSR_WFI_BITMAP (0xF << 8)
Signature · 1 line
1.7.0.4
PATCH v3 5/5 ARM: tegra20: cpuidle: apply coupled cpuidle for powered-down mode
In reply to Joseph LoThe "powered-down" cpuidle mode of Tegra20 needs the CPU0 be the last one core to go into this mode before other core. The coupled cpuidle framework can help to sync the MPCore to coupled state then go into "powered-down" idle mode together. The driver can just assume the MPCore come into "powered-down" mode at the same time. No need to take care if the CPU_0 goes into this mode along and only can put it into safe idle mode (WFI).
The powered-down state of Tegra20 requires power gating both CPU cores. When the secondary CPU requests to enter powered-down state, it saves its own contexts and then enters WFI for waiting CPU0 in the same state. When the CPU0 requests powered-down state, it attempts to put the secondary CPU into reset to prevent it from waking up. Then power down both CPUs together and power off the cpu rail.
Be aware of that, you may see the legacy power state "LP2" in the code which is exactly the same meaning of "CPU power down".
Based on the work by:
Colin Cross <[email protected]>
Gary King <[email protected]>
---
V3:
* sqash last two patch in previous version to support coupled cpuidle directly
V2:
* refine the cpu control function that dedicate for CPU_1
* rename "tegra_cpu_pllp" to "tegra_switch_cpu_to_pllp"
--- arch/arm/mach-tegra/Kconfig | 1 + arch/arm/mach-tegra/cpuidle-tegra20.c | 125 ++++++++++++++++++++++++++++++--- arch/arm/mach-tegra/sleep-tegra20.S | 53 ++++++++++++++ arch/arm/mach-tegra/sleep.S | 19 +++++ arch/arm/mach-tegra/sleep.h | 3 + 5 files changed, 192 insertions(+), 9 deletions(-)
arch/arm/mach-tegra/Kconfig +1 -0
@@ -4,6 +4,7 @@ comment "NVIDIA Tegra options" config ARCH_TEGRA_2x_SOC bool "Enable support for Tegra20 family" + select ARCH_NEEDS_CPU_IDLE_COUPLED select ARCH_REQUIRE_GPIOLIB select ARM_ERRATA_720789 select ARM_ERRATA_742230
arch/arm/mach-tegra/cpuidle-tegra20.c +116 -9
176 lines not on this page · raw message
arch/arm/mach-tegra/sleep-tegra20.S +53 -0
69 lines not on this page · raw message
arch/arm/mach-tegra/sleep.S +19 -0
@@ -34,6 +34,9 @@ #include "flowctrl.h" #include "sleep.h" +#define CLK_RESET_CCLK_BURST 0x20 +#define CLK_RESET_CCLK_DIVIDER 0x24 + #ifdef CONFIG_PM_SLEEP /* * tegra_disable_clean_inv_dcache
@@ -108,4 +111,20 @@ ENTRY(tegra_shut_off_mmu) mov pc, r0 ENDPROC(tegra_shut_off_mmu) .popsection + +/* + * tegra_switch_cpu_to_pllp + * + * In LP2 the normal cpu clock pllx will be turned off. Switch the CPU to pllp + */ +ENTRY(tegra_switch_cpu_to_pllp) + /* in LP2 idle (SDRAM active), set the CPU burst policy to PLLP */ + mov32 r5, TEGRA_CLK_RESET_BASE + mov r0, #(2 << 28) @ burst policy = run mode + orr r0, r0, #(4 << 4) @ use PLLP in run mode burst + str r0, [r5, #CLK_RESET_CCLK_BURST] + mov r0, #0 + str r0, [r5, #CLK_RESET_CCLK_DIVIDER] + mov pc, lr +ENDPROC(tegra_switch_cpu_to_pllp) #endif
arch/arm/mach-tegra/sleep.h +3 -0
@@ -130,6 +130,8 @@ static inline void tegra20_hotplug_init(void) {}static inline void tegra30_hotplug_init (void ) {}#endif +void tegra20_cpu_shutdown (int cpu); +int tegra20_cpu_is_resettable_soon (void );void tegra20_cpu_clear_resettable (void );#ifdef CONFIG_ARCH_TEGRA_2x_SOCvoid tegra20_cpu_set_resettable_soon (void );
@@ -138,6 +140,7 @@ static inline void tegra20_cpu_set_resettable_soon(void) {}#endif int tegra20_sleep_cpu_secondary_finish (unsigned long ); +void tegra20_tear_down_cpu (void );int tegra30_sleep_cpu_secondary_finish (unsigned long );void tegra30_tear_down_cpu (void );
Signature · 1 line
1.7.0.4
PATCH v3 5/5 ARM: tegra20: cpuidle: apply coupled cpuidle for powered-down mode
Quoted 21 lines · Joseph Lo
The "powered-down" cpuidle mode of Tegra20 needs the CPU0 be the last one core to go into this mode before other core. The coupled cpuidle framework can help to sync the MPCore to coupled state then go into "powered-down" idle mode together. The driver can just assume the MPCore come into "powered-down" mode at the same time. No need to take care if the
CPU_0goes into this mode along and only can put it into safe idle mode (WFI).The powered-down state of Tegra20 requires power gating both CPU cores. When the secondary CPU requests to enter powered-down state, it saves its own contexts and then enters WFI for waiting CPU0 in the same state. When the CPU0 requests powered-down state, it attempts to put the secondary CPU into reset to prevent it from waking up. Then power down both CPUs together and power off the cpu rail.
Be aware of that, you may see the legacy power state "LP2" in the code which is exactly the same meaning of "CPU power down".
Based on the work by:
Colin Cross <[email protected]>
Gary King <[email protected]>
Quoted 5 lines
Signed-off-by Joseph Lo <[email protected]>---
V3:
* sqash last two patch in previous version to support coupled cpuidle directly
nitpick - it should be 'squash'.
Cheers,
Peter.
PATCH v3 5/5 ARM: tegra20: cpuidle: apply coupled cpuidle for powered-down mode
In reply to Joseph LoQuoted 18 lines · Joseph Lo
The "powered-down" cpuidle mode of Tegra20 needs the CPU0 be the last one core to go into this mode before other core. The coupled cpuidle framework can help to sync the MPCore to coupled state then go into "powered-down" idle mode together. The driver can just assume the MPCore come into "powered-down" mode at the same time. No need to take care if the
CPU_0goes into this mode along and only can put it into safe idle mode (WFI).The powered-down state of Tegra20 requires power gating both CPU cores. When the secondary CPU requests to enter powered-down state, it saves its own contexts and then enters WFI for waiting CPU0 in the same state. When the CPU0 requests powered-down state, it attempts to put the secondary CPU into reset to prevent it from waking up. Then power down both CPUs together and power off the cpu rail.
Be aware of that, you may see the legacy power state "LP2" in the code which is exactly the same meaning of "CPU power down".
arch/arm/mach-tegra/cpuidle-tegra20.c static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device); · line 92
Quoted 2 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +1
-0+static void tegra20_wake_reset_cpu_1 (void )
Nit/bikeshe: I think tegra20_wake_from_reset_cpu_1() might be a slightly more descriptive name? I assume the function works on CPU1, which is assumed to be in reset, and removes reset from the CPU so it boots.
arch/arm/mach-tegra/cpuidle-tegra20.c int __init tegra20_cpuidle_init(void) · line 246
Quoted 7 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +3
-0@@ -137,6 +241,9 @@ int __init tegra20_cpuidle_init(void)for_each_possible_cpu (cpu) { dev = &per_cpu (tegra_idle_device, cpu); dev->cpu = cpu; +#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED + dev->coupled_cpus = *cpu_online_mask; +#endif
That CONFIG option is selected by ARCH_TEGRA_2x_SOC, which must be enabled for this file to be compiled. So, you can drop the ifdef, and make the code uncondtional.
PATCH v3 5/5 ARM: tegra20: cpuidle: apply coupled cpuidle for powered-down mode
Quoted 18 lines · Stephen Warren
Quoted 16 lines · Joseph Lo
The "powered-down" cpuidle mode of Tegra20 needs the CPU0 be the last one core to go into this mode before other core. The coupled cpuidle framework can help to sync the MPCore to coupled state then go into "powered-down" idle mode together. The driver can just assume the MPCore come into "powered-down" mode at the same time. No need to take care if the
CPU_0goes into this mode along and only can put it into safe idle mode (WFI).The powered-down state of Tegra20 requires power gating both CPU cores. When the secondary CPU requests to enter powered-down state, it saves its own contexts and then enters WFI for waiting CPU0 in the same state. When the CPU0 requests powered-down state, it attempts to put the secondary CPU into reset to prevent it from waking up. Then power down both CPUs together and power off the cpu rail.
Be aware of that, you may see the legacy power state "LP2" in the code which is exactly the same meaning of "CPU power down".
Quoted 8 lines
arch/arm/mach-tegra/cpuidle-tegra20.c static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device); · line 92
Quoted 3 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +1
-0+static void tegra20_wake_reset_cpu_1 (void )Nit/bikeshe: I think
tegra20_wake_from_reset_cpu_1()might be a slightly more descriptive name? I assume the function works on CPU1, which is assumed to be in reset, and removes reset from the CPU so it boots.
Yes.
Do you mean this function running on CPU1? It runs on CPU0 to wake up CPU1. About the function name, it looks more appropriate.
Quoted 11 lines
arch/arm/mach-tegra/cpuidle-tegra20.c int __init tegra20_cpuidle_init(void) · line 246
Quoted 7 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +3
-0@@ -137,6 +241,9 @@ int __init tegra20_cpuidle_init(void)for_each_possible_cpu (cpu) { dev = &per_cpu (tegra_idle_device, cpu); dev->cpu = cpu; +#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED + dev->coupled_cpus = *cpu_online_mask; +#endif That CONFIG option is selected by
ARCH_TEGRA_2x_SOC, which must be enabled for this file to be compiled. So, you can drop the ifdef, and make the code uncondtional.
No, I found I need this if I want to make the device works on UP case. Then I need to do something like below, when we disable SMP.
Quoted 6 lines
config
ARCH_TEGRA_2x_SOC
bool "Enable support for Tegra20 family"(quoted diff) +1
-0+ select ARCH_NEEDS_CPU_IDLE_COUPLED if SMPselect ARCH_REQUIRE_GPIOLIB select ARM_ERRATA_720789 select ARM_ERRATA_742230
This will be updated in next version as well.
Thanks,
Joseph
PATCH v3 5/5 ARM: tegra20: cpuidle: apply coupled cpuidle for powered-down mode
Quoted 23 lines · Joseph Lo
Quoted 22 lines · Stephen Warren
Quoted 20 lines · Joseph Lo
The "powered-down" cpuidle mode of Tegra20 needs the CPU0 be the last one core to go into this mode before other core. The coupled cpuidle framework can help to sync the MPCore to coupled state then go into "powered-down" idle mode together. The driver can just assume the MPCore come into "powered-down" mode at the same time. No need to take care if the
CPU_0goes into this mode along and only can put it into safe idle mode (WFI).The powered-down state of Tegra20 requires power gating both CPU cores. When the secondary CPU requests to enter powered-down state, it saves its own contexts and then enters WFI for waiting CPU0 in the same state. When the CPU0 requests powered-down state, it attempts to put the secondary CPU into reset to prevent it from waking up. Then power down both CPUs together and power off the cpu rail.
Be aware of that, you may see the legacy power state "LP2" in the code which is exactly the same meaning of "CPU power down".
arch/arm/mach-tegra/cpuidle-tegra20.c +1
-0+static void tegra20_wake_reset_cpu_1 (void )
Quoted 7 lines
Quoted 4 lines
Nit/bikeshe: I think
tegra20_wake_from_reset_cpu_1()might be a slightly more descriptive name? I assume the function works on CPU1, which is assumed to be in reset, and removes reset from the CPU so it boots.Yes.
Do you mean this function running on CPU1? It runs on CPU0 to wake up CPU1. About the function name, it looks more appropriate.
Sorry for bikeshedding even more, perhaps tegra20_wake_cpu_1_from_reset(); that makes the word-order better English.
Quoted 15 lines
Quoted 11 lines
arch/arm/mach-tegra/cpuidle-tegra20.c int __init tegra20_cpuidle_init(void) · line 246
Quoted 7 lines
arch/arm/mach-tegra/cpuidle-tegra20.c +3
-0@@ -137,6 +241,9 @@ int __init tegra20_cpuidle_init(void)for_each_possible_cpu (cpu) { dev = &per_cpu (tegra_idle_device, cpu); dev->cpu = cpu; +#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED + dev->coupled_cpus = *cpu_online_mask; +#endif That CONFIG option is selected by
ARCH_TEGRA_2x_SOC, which must be enabled for this file to be compiled. So, you can drop the ifdef, and make the code uncondtional.No, I found I need this if I want to make the device works on UP case. Then I need to do something like below, when we disable SMP.
Quoted 8 lines
Quoted 6 lines
config
ARCH_TEGRA_2x_SOC
bool "Enable support for Tegra20 family"(quoted diff) +1
-0+ select ARCH_NEEDS_CPU_IDLE_COUPLED if SMPselect ARCH_REQUIRE_GPIOLIB select ARM_ERRATA_720789 select ARM_ERRATA_742230This will be updated in next version as well.
OK, if the Kconfig looks like that, you're right - the ifdef in the .c file is needed.
v3 cover ARM: tegra20: cpuidle: add power-down state
In reply to Joseph LoQuoted 8 lines · Joseph Lo
This adds a "powered-down" state in cpuidle for Tegra20. It requires power gating both CPU cores. When the CPU1 requests to enter "powered-down" state, it saves its own state and then enters WFI. When the CPU0 requests the same state, it attempts to put the CPU1 into reset to prevent it from waking up. Then power down both CPUs together and turn off the CPU rail.
If the CPU1 be woken up before CPU0 entering powered-down state, then it needs to restore it's CPU state and waits for next chance.
Joseph,
What's the status of this series? It looks like there are quite a few comments on V3; I assume you'll post a new version to address those. Will you base the new version on top of Prashant's common clock cleanup to remove the conflicts with that?
v3 cover ARM: tegra20: cpuidle: add power-down state
Quoted 10 lines · Stephen Warren
Quoted 8 lines · Joseph Lo
This adds a "powered-down" state in cpuidle for Tegra20. It requires power gating both CPU cores. When the CPU1 requests to enter "powered-down" state, it saves its own state and then enters WFI. When the CPU0 requests the same state, it attempts to put the CPU1 into reset to prevent it from waking up. Then power down both CPUs together and turn off the CPU rail.
If the CPU1 be woken up before CPU0 entering powered-down state, then it needs to restore it's CPU state and waits for next chance.
Quoted 7 lines
Joseph,
What's the status of this series? It looks like there are quite a few comments on V3; I assume you'll post a new version to address those. Will you base the new version on top of Prashant's common clock cleanup to remove the conflicts with that?
Yes, I will re-base on top of Prashant's CCF rework in the next version. But there are some issues, I am co-working with Prashant to make sure every thing is work as usual. Will re-post this series later after everything be settled down.
Thanks,
Joseph