[Galaxy S III Android Development] spica1234:
Ok here you go.

First of all, AFTR is ARM Off Top Running Core.

Whats it?

Cortexa-9 cpu has 3 idle states.

(1) Idle

( 2) AFTR

(3) LPA

(1) IDLE:

When a cpu core becomes idle means when it has nothing to do, it falls in ARM WFI Mode, it sends chain notifier that I am now free so let kernel thread can do some regular stuff before going in to real IDLE mode. After ARM WFI mode means after cpu is free from kernel thread works, it can enter in Real Idle mode. It has 2 parameters to work on. (A) idle_residency time in ms. Means it doesnt goes in idle mode instantly but after wfi () it waits and check for the interuption in idle_residency time. If there indeed is no real work in idle_residency time. It goes in LPA (ARM POWER DOWN-LOW POWER) Mode. Like after you lock your phone it enters in LPA. Before that hotplug unplugs all 3 cores except main core (c0). It sends a notifier signal to all thread stop_machine signal. And after hotplug it turns off master switch for c1, c2, c3 and then it register a wakeup mask (address of the register to wakeup) then all power supply to core is off and only l2 cache refreshes. Idle mode has one more parameter and thats exit_latency means time in ms it will take to wakeup. (B) exit_latency the time it takes to comeout of idle state

(2) AFTR mode waits for all cpus to be offline and can only be entered in when one cpu (c0) only is on. If (cpu_online()> 1) then it enter in wfi - pre idle mode but when 3 cpus are off in cases of governors turns off all core except one it directly save current register and set it as AFTR wakeup mask and let c0 enter in LPA state directly from AFTR within AFTR's idle_residency. If (cpu_id==0) or you may say if (cpu0 only is online then) return core_c0_aftr(). It has exit latency which is 300 increasing values results in wakeup delay. Now when there is load it directly wakes up from lpa to idle mode by waking up on saved register.

AFTR is C1 Deep Sleep State.

/sys/devices/system/cpu/cpu0/cpuidle/state0/usage it will show the time it has spent in idle state.

/sys/devices/system/cpu/cpu0/cpuidle/state1/usage it will show time spent in LOW POWER state.

In short in idle+lpa mode when cpu becomes idle it sends notifier to kernel threads for routine work and when thats done it enter in lpa

While in aftr+lpa when 3 cores is off AFTR races to IDLE by skipping wfi state and if in idle mode cpus stays idle for idle_residency time then it directly enters in lpa. AFTR+LPA id kind of short cut to LPA. Now if there is any requirement in idle_residency time then it wakes up directly to saved wakeup mask register, and again as soon as 3 cores are off it directly enters in AFTR C1 deep sleep state

Now all logics can be good or bad. It depends on hotplug. Hotplug is for saving battery but the hotplugging process itself is intensive on battery. So very frequent hotplugs consumes more battery instead of it could help saving battery

May be AFTR and lpa proto type definitions are in arch/arm/mach-exynos/exynos_idle.c

But I guess there is some issue with AFTR. code seems logically right but technically seems it has some issues and not working may be.

By my observation, s2's code is more robust. It uses on demand governor. Governor itself doesnt play with hotpluging. And idle driver of exynos turns 2nd core down w/o hotpluging snd thus letting enter in AFTR w/o intence hotplug operations.

How can I know phone does enter in AFTR and LPA?

-during screen on time AFTR state is evident and after screen off (screen locked). When you wakeup you can check fallen state LPA along with AFTR as well.

Open terminsl emulator after screen unlock:

-write dmesg | grep aftr;

-write dmesg | grep lpa

:)