Skip to contentSkip to conversation

ARM: tegra: cpuidle: replace LP3 with ARM_CPUIDLE_WFI_STATE

PATCH New Joseph Lo 2 participants 4 messages Oct 8, 2012 – Oct 18, 2012

Subsystems (3)
lore
Share & tools
lore

Joseph Lo

author
#0 lore raw

PATCH 1/1 ARM: tegra: cpuidle: replace LP3 with ARM_CPUIDLE_WFI_STATE

The Tegra CPU idle LP3 state is doing ARM WFI only. So it's same with the common ARM_CPUIDLE_WFI_STATE. Using it to replace LP3 now.

---
 arch/arm/mach-tegra/cpuidle.c |   44 ++--------------------------------------
 1 files changed, 3 insertions(+), 41 deletions(-)
arch/arm/mach-tegra/cpuidle.c +3 -41
index 566e2f8..4e0b07c 100644
@@ -23,60 +23,22 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/cpu.h>
 #include <linux/cpuidle.h>
-#include <linux/hrtimer.h>
 
-#include <asm/proc-fns.h>
-
-#include <mach/iomap.h>
-
-static int tegra_idle_enter_lp3(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int index);
+#include <asm/cpuidle.h>
 
 struct cpuidle_driver tegra_idle_driver = {
 	.name = "tegra_idle",
 	.owner = THIS_MODULE,
+	.en_core_tk_irqen = 1,
 	.state_count = 1,
 	.states = {
-		[0] = {
-			.enter			= tegra_idle_enter_lp3,
-			.exit_latency		= 10,
-			.target_residency	= 10,
-			.power_usage		= 600,
-			.flags			= CPUIDLE_FLAG_TIME_VALID,
-			.name			= "LP3",
-			.desc			= "CPU flow-controlled",
-		},
+		[0] = ARM_CPUIDLE_WFI_STATE_PWR(600),
 	},
 };
 
 static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
 
-static int tegra_idle_enter_lp3(struct cpuidle_device *dev,
-	struct cpuidle_driver *drv, int index)
-{
-	ktime_t enter, exit;
-	s64 us;
-
-	local_irq_disable();
-	local_fiq_disable();
-
-	enter = ktime_get();
-
-	cpu_do_idle();
-
-	exit = ktime_sub(ktime_get(), enter);
-	us = ktime_to_us(exit);
-
-	local_fiq_enable();
-	local_irq_enable();
-
-	dev->last_residency = us;
-
-	return index;
-}
-
 static int __init tegra_cpuidle_init(void)
 {
 	int ret;
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 ARM: tegra: cpuidle: replace LP3 with ARM_CPUIDLE_WFI_STATE

Quoted 2 lines · Joseph Lo

The Tegra CPU idle LP3 state is doing ARM WFI only. So it's same with the common ARM_CPUIDLE_WFI_STATE. Using it to replace LP3 now.

Hmm. This changes the exit_latency/target_residency fields of the cpuidle state definition from 10 to 1, and also replaces tegra_idle_enter_lp3() with just a dsb/wfi as far as I can tell. What are the implications of removing the irq/fiq_disable/enable and ktim-related code? It might be worth explaining why this change is valid in the commit description.

author
#2 lore raw

PATCH 1/1 ARM: tegra: cpuidle: replace LP3 with ARM_CPUIDLE_WFI_STATE

Hi Stephen,

Thanks for your review.

Quoted 11 lines · Stephen Warren
Quoted 2 lines · Joseph Lo

The Tegra CPU idle LP3 state is doing ARM WFI only. So it's same with the common ARM_CPUIDLE_WFI_STATE. Using it to replace LP3 now.

Hmm. This changes the exit_latency/target_residency fields of the cpuidle state definition from 10 to 1, and also replaces tegra_idle_enter_lp3() with just a dsb/wfi as far as I can tell. What are the implications of removing the irq/fiq_disable/enable and ktim-related code? It might be worth explaining why this change is valid in the commit description.
--

There were some histories about the latency. The legacy LP3 mode called to "tegra_cpu_wfi". This func was been removed. We called to "cpu_do_idle" right now. In the old "tegra_cpu_wfi", we did back up the current flow controller register and set up flow controller to CPU_WFE state. It did wait for CPU running to WFI and clock gate it externally. We need a time duration to make flow controller to do that.

When any event or interrupt been triggered, it resume the CPU clock. And CPU runs after WFI and restore the flow controller. We found this may hurt performance, so we drop that. The latency is not true anymore.

Now we just using WFI to enter low-power CPU standby state where most clocks gated.

About the missing irq/fiq disable/enable call, we enable the "en_core_tk_irqen" in this patch. That means we enable time keeping and irq enabling in the core cpuidle code. So the cpuidle enter code will use the "cpuidle_wrap_enter" in "drivers/cpuidle/cpuidle.c".

After merging these concepts, I think we can use the common ARM_CPUIDLE_WFI_STATE to replace the current LP3 code.

Thanks,
Joseph

#3 lore raw

PATCH 1/1 ARM: tegra: cpuidle: replace LP3 with ARM_CPUIDLE_WFI_STATE

In reply to Joseph Lo
Quoted 2 lines · Joseph Lo

The Tegra CPU idle LP3 state is doing ARM WFI only. So it's same with the common ARM_CPUIDLE_WFI_STATE. Using it to replace LP3 now.

Applied to Tegra's for-3.8/cpuidle branch (I created that branch in anticipation of there being a bunch of other cpuidle work for 3.8).