[Nexus 4 Original Android Development] mrg666:
MiRaGe is a lean and efficient kernel for the stock Nexus 4 ROM with the optimizations and updates that are not included in Google's stock kernel. MiRaGe kernel fits squarely in the stock Nexus 4 ROM; all of the modules are integrated in the kernel just like the stock kernel and it should work with all AOSP ROMs that work with the stock kernel and boot image. However, only the current stock ROM is tested. If you decide to use MiRaGe, just flash and forget it since I have avoided adding more sysfs parameters. It is not my goal to enable all possible tweaking options and add every possible feature to the kernel such as multitude of governors, io schedulers, sweep2wake, fastcharge, etc. This kernel is not intended as a tweaker's kernel. You can, of course, tweak it as much as you want since that is your phone and kernel. But

please try removing your tweaks before posting any problems

. I always test the latest builds with the current stock ROM before posting here.

I am sharing exactly what I have developed for myself and posting here so that I can return at least a small part of what I have received from the open source community. I thought the amount of time I have spent for MiRaGe could be useful for others as well. In short, take it if you want it, leave it if you don't.

But comments, suggestions are always welcome when they make sense

.

Source Code:

Source code is based on Google's msm kernel source (currently android-msm-mako-3.4-lollipop-mr1.1) and a summary of my changes are below. You can find the full details of my changes and the complete source code in

my repo

.

Changes:

- synced with mainline Linux 3.4.110

- cleaned up kernel configuration and removed many unnecessary options

- removed kernel debugging options

- built with the Linaro toolchain (gcc 4.9.4 - 15.06) using standard krait and -O2 optimization

- removed AOUT and OABI support

- disabled both user-space msm_mpdecision and kernel-space msm_mpdecision

- removed msm_run_queue_stats, dcvs, and stock msm_mpdecision in the kernel

- added autosmp, a simple and efficient (by me) multi-core cpu hotplug driver

- disabled the user-space thermald and switched to kernel-based msm_thermal

- replaced CFQ with the latest BFQ as the default IO scheduler

- backported random and prandom updates from Linux 3.13 (no entropy depletion anymore)

- backported workqueue from Linux 3.8 to include many important improvements

- backported rwsem from Linux 3.11 to include lock stealing improvements

- backported mutex and rcu locking from Linux 3.10 and 3.8, respectively

- backported slub memory allocator updates from Linux 3.8

- backported cpufreq driver, ondemand, and conservative governors from Linux 3.12

- updated interactive CPU governor from AOSP and CAF

- disabled userspace CPU governor,

- enabled callback-free CPUs (RCU_NOCB_CPU)

- backported TCP Small Queues and CODEL net scheduler from Linux mainline and set as default

- updated kernel scheduler, msm-hotplug, msm-idle, msm-pm code from CAF and Linux mainline

- applied patch [v4] binfmt_elf.c: use get_random_int() to help with entropy depleting

- enabled autogroup scheduler and applied patch per-uid task group for Android

- added optimized ARM RWSEM algorithm

- added optimized ARM SHA1/AES routines

- enabled CPU-supported unaligned accesses

- disabled gentle fair sleepers in scheduler

- updated Qualcomm HW RNG driver from CAF

- enabled BPF JIT compiler for packet filters

- applied glibc patch to improve the performance of memcpy and memmove

- applied word-at-a-time ARM API patches

- enabled CPU overclocking up to 1.728 GHz with user-space vdd control

- optimized vdd curves, L2 and bus speeds for better performance and efficiency

- removed unneeded a2xx and a4xx components from kgsl driver

- modified the prima wifi driver to disable debug code

- removed PMEM completely, MiRaGe is pure ION

- add support for kernel mode NEON and NEON acceleration

- add NEON optimized SHA1, SHA256, and SHA512 crypto code

- add LoUIS API for cache maintenance ops to improve cpu hotplug latency

- added and enabled power_efficient workqueue

- added and enabled msm memutils

- added screen gamma, user space cpu voltage control, and dt2w

- backported devfreq driver from CAF and switched kgsl 3d governor to simple_ondemand

- backported many other fixes/updates/optimizations from CAF and Linux mainline, see the repo for details

- init.d supported if /etc/init.d and busybox are available

- a diff file of changes to ramdisk is here

Downloads:

Boot image for stock ROM

:

LMY standard kernel

Built: 10/25/15 MD5sum: a315cc446499d60cb4b3a61ea7bfa8f8

LMY overclock kernel

Built: 10/25/15 MD5sum: 7c72a66830f511b025968db2bb743429

Anykernel updater for custom ROM

:

Revert back to stock kernel to restore the original ramdisk and flash anykernel package of MiRaGe after that. This is not needed in the next anykernel update.

LMY standard kernel

Built: 10/25/15 MD5sum: 85b4136ac0ada793da7b80763193095a

LMY overclock kernel

Built: 10/25/15 MD5sum: 2924fb6a963b40087c296a7b1abfc1d3

KTU standard kernel

Built: 10/31/14 MD5sum: dca7d06933eb43c8da3ba7941bb6ac88

KTU overclock kernel

Built: 10/31/14 MD5sum: dca7d06933eb43c8da3ba7941bb6ac88

The only difference between the standard and overclock builds is the ~100mV undervolt in the overclock build. Both kernels have maximum CPU_freq = 1.728 GHz, default CPU_freq = 1.512 GHz, overclocking, and user space cpu voltage control enabled. Since the CPU gets hot quickly in Nexus 4, I only recommend overclocking with the overclock build that has built-in undervolt. If the phone doesn't boot with overclock kernel, it means that your CPU is not able to handle the undervolt settings. In that case, you can just reboot into recovery and flash the standard kernel. No-frills CPU Control is recommended to set the max overclock frequency.

Each CPU has different overclock/undervolt ability. Don't get disappointed if the OC build doesn't work for you.

Installation:

You can do one of the followings

- Flash the zip files in recovery, there is no need to wipe cache or dalvik-cache

- Flash the boot image in the zip file using either Flash Image GUI or fastboot

- Here is the original boot image for LMY48I build, in case needed for going back to stock. Either flash in the recovery or open the zip file to extract the boot image.

Credits:

- Special thanks to Linux, Google, CAF, Linaro developers in general.

- [MENTION=3038499]tvall[/MENTION], [MENTION=6295391]bedalus[/MENTION], [MENTION=4003363]xboxfanj[/MENTION], [MENTION=3675426]ihancioglu[/MENTION], [MENTION=3118524]xenyz[/MENTION] for collaboration

- [MENTION=3750240]stratosk[/MENTION] for the screen gamma interface and dt2w

- [MENTION=1316336]defconoi[/MENTION] for collaboration (see Unleashed Kernel Series)

- [MENTION=2677519]mathkid95[/MENTION] for the any-kernel updater package

- [MENTION=1477081]joeykrim[/MENTION] for FlashImageGUI

- [MENTION=4825437]Christopher83[/MENTION] for the optimized Linaro toolchain builds

- Other credits are given in the repo for each commit