As some of you will know, I have been working on a port of Samsungs IDLE2 / LPAUDIO feature from their 2.6.32 P1000 kernel to the 3.0.x i902x kernel.
This implements the same thing as deep idle attempts to do, but it has several benefits over the original deep-idle patch, as will be explained below.
I’m pleased to say that I am going to release the source and a kernel with it included today.
This release comes after a large amount of debugging of lockups caused by interactions with the coresight tracing driver and general other breakage, including some asm issues. I did get to a point where I couldn’t get it stable at all, I wasn’t getting any useful output from last_kmsg and I was almost about to give up, but thanks to a decent last_kmsg trace or 2 and gdb <3 I was able to find the problem, fix the issue and get it stable. :) Myself and several others have been running it for about 2 days now, so altogether we have probably amassed about 500 hours of testing, with no issues reported so far.
Differences / Advantages compared to deep-idle:
- Enabled by default and automatically invoked whenever the conditions are right.
- When the screen is on, the idle mode is set to NORMAL, which skips all the idle2 code and works as normal, so no change there.
- When the screen is turned off (earlysuspend), the mode is switched to IDLE2 which is used when all the following conditions are met:
- PowerManagerService is holding a wakelock
- USB is not plugged in
- GPU is not running
- MMC & NAND aren’t in use
- DMA is clock gated
- Audio DMA is not in use
- No RTC interrupts pending
- It also checks the Vector Interrupt Controller status immediately before saving register state / calling WFI and bails if an interrupt is active
- Cleaner code paths, optimised for the most likely scenario to save some cycles on branching. Many critical functions inlined to make their execution quicker and cheaper. Many int type functions modified to use the cheapest type possible, normally bool or void.
- No expensive stat collecting sysfs interface chewing up cpu cycles. I know people will moan that this stops you seeing what it is doing, but, does it really matter if it is working? Just accept that it *is* working. If you really want to check what it is doing, recompile the kernel with the debugging messages enabled and it will spam dmesg with everything that idle2 is doing. :)
- ASM modified to use existing generic platform cache flush and idle routines rather than duplicate them. Certainly more could be done here, and that is something for a future version, but I’ve made a good start at it.
- It doesn’t require the CPU to be forced to an artificial frequency for stability. The CPU scales as normal and ranges 100 <> 1000 whilst idle2 is active.
- DEEP-IDLE TOP OFF mode is default. TOP-ON is not used.
- There is no requirement for the config_bluetooth_adapter_quick_switch disabling patch as it works perfectly without it.
- Due to it being hooked into a wakelock, it cannot be invoked at the same time as suspend is called, so it has no way of racing with the suspend code.
- It seems to be completely stable (so far anyway).
I think that is about it for the advantages, but as you can see, it is a worthwhile improvement.
- More code cleanups.
- Try to make some code paths cheaper.
- Try to use generic platform asm or unify with platform asm.
Patches and improvement suggestions are welcome. This is one of the most complex things I have released, so there will be improvements to be made and suggestions and patches are more than welcome, specially for any of the todo items.
Wilful kanging, not clearly giving proper credits and not contributing back is extremely unwelcome. Open source is not about copying other peoples work, a principle which some developers don’t get, The GPL was never designed for the purpose of copying code verbatim and riding on other peoples work, it was designed to allow freedom of code, a continual cycle of improvement and peer review, so consider that please.