A2109 Kernel Experiments

WORKING (not tested well)
Yet... WOOOHOOO!!!!!!! Am VERY proud :cool:

SOURCES

This will soon need testers!! I'm going to clean up the tree first. Yet, for now -- all drivers that I ported (cameras, sensors, touchscreen, sound) appear to work without issues.

As soon as you have a ROM ready, I can install it to one of my A2109

Nice work @PJBrs
 
I can test as well. As long as it doesn't have the bricking bug any more.
 
I can test as well. As long as it doesn't have the bricking bug any more.
I don't think it does (I think the fix was included somewhere between 3.1 and 3.4 in the mainline kernel). Also, I worked around a kernel panic in the usb driver, so now adb immediately connects on boot, and no panic anymore after doing something like dmesg :) Still massive flickering in the display driver. There's a bug somewhere in the initialisation. I'll fix that first, then I'll put up a boot image.
 
Vibrator support added back, a _very_ simple patch :)

One main thing - the screen keeps flickering like mad...
 
And another main thing - charger type isn't recognised. Initial debugging did not give insight in why the screen lags and flickers so badly. However, disabling hardware overlays under development options works around the problem...
 
Flickering problem located...

This:
Code:
/sys/devices/host1x/syncpt
/sys/bus/nvhost/devices/host1x/syncpt/

moved here:
Code:
/sys/devices/platform/host1x/syncpt/
/sys/bus/platform/devices/host1x/syncpt/
/sys/bus/platform/drivers/host1x/host1x/syncpt/
 
Last edited:
Wasn't the problem after all. (Could fix it with a small binary hack, but didn't fix the flickering.)

Now, the strangest thing is when I do strace on the pid of surfaceflinger, then everything is fine?!?!?!?
 
IF YOU HAVE ANY REAL CODING EXPERIENCE AND WANT TO HELP OUT, PLEASE LET ME KNOW! (Almost any experience will exceed mine ;-) ).

Well... I've been poking at the graphics glitches _a lot_, and haven't found a real solution. Findings:
  • New blobs (grouper lollipop) appear to work without glitches and lag, but camera doesn't work
  • Old blobs give lots of glitches and lag in UI, but not in camera or some games (?!?)
    • If I do strace -p on the pid of surfaceflinger via adb, the glitches and lag are gone (!?!?!?!?)
    • If I disable hardware overlays under development options, the glitches and lags are gone
  • A small binary hack is needed in any case, to adapt to the new location of the syncpt directory in sysfs
The kernel source changes in drivers/video/tegra/ are too big to sort out for me. (I still cannot really code.) There's a point where they deviate very little from the latest 3.1 kernel, but I can't seem to get that version to boot (I had hoped to be able to find a working older version, but that didn't seem to work too well, unfortunately; I did get a version working that
reverted video / camera drivers to 1ccf168afb3dc613f88764451f9462158bc78415 and e503a08b809844b53b7737e504e9f376f4a8a1eb, but that version still had the glitches and lags. (I might go back to that version in a more careful manner and then see if I can go back any further, but this is taking a lot of time.) In sum - a workaround is possible, a solution should be possible but I haven't located the problem.

Then there's a charging issue. Somehow, charging current seems to be limited to 500uA, which takes ages for the tablet to charge. Haven't found the cause of that one either. And for practical purposes, this one's a bit of a showstopper.

I did manage to merge the google common android changes to my 3.4 kernel, which means that selinux should work with marshmallow now. Indeed, I don't get any warning about that anymore. But then again, the device doesn't boot either, something to do with the blobs needing to go to /system/vendor/lib...

So - I'll put up a 3.4 boot image for lollipop (cm) somewhere the coming week as well as the syncpt binary hack that I did. And I'll poke around the usb thing a bit more. Kernel testers can disable the HW-overlays manually under development options (and I think HW-overlays can also be disabled from boot.img, in default.prop).
 
Still more problems (I have the impression that they might be related to our proprietary blobs)... I think we're hitting some kind of race condition in the power management code, especially related to "clocks" related to 3d video. I'm getting a kernel warning that hard hangs android:

Code:
<4>[  232.178258] ------------[ cut here ]------------
<4>[  232.178434] WARNING: at arch/arm/mach-tegra/powergate.c:101 tegra_powergate_set+0x1b4/0x248()
<4>[  232.178563] Could not set powergate 13 to 1[<c0015590>] (unwind_backtrace+0x0/0x140) from [<c00573c4>] (warn_slowpath_common+0x50/0x68)
<4>[  232.178792] [<c00573c4>] (warn_slowpath_common+0x50/0x68) from [<c0057448>] (warn_slowpath_fmt+0x38/0x48)
<4>[  232.178871] [<c0057448>] (warn_slowpath_fmt+0x38/0x48) from [<c0040200>] (tegra_powergate_set+0x1b4/0x248)
<4>[  232.179028] [<c0040200>] (tegra_powergate_set+0x1b4/0x248) from [<c0040440>] (tegraxx_unpowergate_partition+0x38/0xe4)
<4>[  232.179164] [<c0040440>] (tegraxx_unpowergate_partition+0x38/0xe4) from [<c003fa20>] (tegra_unpowergate_partition+0x40/0xb4)
<4>[  232.179306] [<c003fa20>] (tegra_unpowergate_partition+0x40/0xb4) from [<c02f3ae8>] (do_unpowergate_locked+0x1c/0x40)
<4>[  232.179444] [<c02f3ae8>] (do_unpowergate_locked+0x1c/0x40) from [<c02f3e04>] (to_state_clockgated_locked+0xf8/0x12c)
<4>[  232.179579] [<c02f3e04>] (to_state_clockgated_locked+0xf8/0x12c) from [<c02f3f58>] (to_state_running_locked+0x120/0x130)
<4>[  232.179715] [<c02f3f58>] (to_state_running_locked+0x120/0x130) from [<c02f3fec>] (nvhost_module_busy+0x84/0xa0)
<4>[  232.179861] [<c02f3fec>] (nvhost_module_busy+0x84/0xa0) from [<c02eda34>] (host1x_channel_submit+0x7c/0x400)
<4>[  232.180015] [<c02eda34>] (host1x_channel_submit+0x7c/0x400) from [<c02f7570>] (nvhost_channel_submit+0x34/0x7c)
<4>[  232.180158] [<c02f7570>] (nvhost_channel_submit+0x34/0x7c) from [<c02fe758>] (nvhost_ioctl_channel_flush+0x100/0x258)
<4>[  232.180295] [<c02fe758>] (nvhost_ioctl_channel_flush+0x100/0x258) from [<c02ffe0c>] (nvhost_channelctl+0x464/0x6a0)
<4>[  232.180435] [<c02ffe0c>] (nvhost_channelctl+0x464/0x6a0) from [<c013c494>] (do_vfs_ioctl+0x84/0x254)
<4>[  232.180516] [<c013c494>] (do_vfs_ioctl+0x84/0x254) from [<c013c6dc>] (sys_ioctl+0x78/0x80)
<4>[  232.180601] [<c013c6dc>] (sys_ioctl+0x78/0x80) from [<c000ebc0>] (ret_fast_syscall+0x0/0x30)
<4>[  232.180731] ---[ end trace 1b75b31a2719ed21 ]---
<4>[  232.180802] ------------[ cut here ]------------
<4>[  232.180932] WARNING: at arch/arm/mach-tegra/powergate-ops-txx.c:95 tegraxx_unpowergate_partition+0x54/0xe4()
<4>[  232.181075] Could not Un-Powergate 13[<c0015590>] (unwind_backtrace+0x0/0x140) from [<c00573c4>] (warn_slowpath_common+0x50/0x68)
<4>[  232.181298] [<c00573c4>] (warn_slowpath_common+0x50/0x68) from [<c0057448>] (warn_slowpath_fmt+0x38/0x48)
<4>[  232.181436] [<c0057448>] (warn_slowpath_fmt+0x38/0x48) from [<c004045c>] (tegraxx_unpowergate_partition+0x54/0xe4)
<4>[  232.181516] [<c004045c>] (tegraxx_unpowergate_partition+0x54/0xe4) from [<c003fa20>] (tegra_unpowergate_partition+0x40/0xb4)
<4>[  232.181653] [<c003fa20>] (tegra_unpowergate_partition+0x40/0xb4) from [<c02f3ae8>] (do_unpowergate_locked+0x1c/0x40)
<4>[  232.181791] [<c02f3ae8>] (do_unpowergate_locked+0x1c/0x40) from [<c02f3e04>] (to_state_clockgated_locked+0xf8/0x12c)
<4>[  232.181927] [<c02f3e04>] (to_state_clockgated_locked+0xf8/0x12c) from [<c02f3f58>] (to_state_running_locked+0x120/0x130)
<4>[  232.182089] [<c02f3f58>] (to_state_running_locked+0x120/0x130) from [<c02f3fec>] (nvhost_module_busy+0x84/0xa0)
<4>[  232.182229] [<c02f3fec>] (nvhost_module_busy+0x84/0xa0) from [<c02eda34>] (host1x_channel_submit+0x7c/0x400)
<4>[  232.182367] [<c02eda34>] (host1x_channel_submit+0x7c/0x400) from [<c02f7570>] (nvhost_channel_submit+0x34/0x7c)
<4>[  232.182504] [<c02f7570>] (nvhost_channel_submit+0x34/0x7c) from [<c02fe758>] (nvhost_ioctl_channel_flush+0x100/0x258)
<4>[  232.182640] [<c02fe758>] (nvhost_ioctl_channel_flush+0x100/0x258) from [<c02ffe0c>] (nvhost_channelctl+0x464/0x6a0)
<4>[  232.182776] [<c02ffe0c>] (nvhost_channelctl+0x464/0x6a0) from [<c013c494>] (do_vfs_ioctl+0x84/0x254)
<4>[  232.182912] [<c013c494>] (do_vfs_ioctl+0x84/0x254) from [<c013c6dc>] (sys_ioctl+0x78/0x80)
<4>[  232.183069] [<c013c6dc>] (sys_ioctl+0x78/0x80) from [<c000ebc0>] (ret_fast_syscall+0x0/0x30)
<4>[  232.183215] ---[ end trace 1b75b31a2719ed22 ]---
<3>[  232.183344] do_unpowergate_locked: unpowergate failed: id = 13

Haven't been able to solve it, yet...
 
Soooooo.... I've found a value somewhere in the source tree, in drivers/video/tegra/host/nvhost_acm.c:

Code:
#define POWERGATE_DELAY                   10

I changed it to 100 and then did about an hour of web surfing and the like. Might have fixed the issue. In any case. If you want to test, then you need two libs: libnvrm.so (according to Ziyann, who ported grouper to 3.4, although I'm not sure this is necessary) and libnvrm_graphics.so. You need to copy these to /system/lib:

Code:
adb push libnvrm.so /sdcard/
adb push libnvrm_graphics.so /sdcard/
adb shell
mount -o remount /system
cp /sdcard/libnvrm* /system/lib/

Permissions need to be rw-r--r-- (if they aren't, fix it with chmod 644 /system/lib/libnvrm*).

Next, you need a boot.img:
Kernel 3.4 for AOSP
Kernel 3.4 for CM-12.1

Boot kernel 3.4 via fastboot:
Code:
fastboot -i 0x17ef boot boot-kernel-3.4-AOSP.img

(Or the CM-12.1 boot.img, if applicable; and if you want to install the kernel, do fastboot -i 0x17ef flash boot $imgname.)

To fix the ui lag, disable HW overlays in developer settings.

Please share your experiences! If you experience a hang or reboot, please see whether /proc/last_kmsg exists, and if so, post its contents here.

As always - testing is on your own risk. I did check that the patches that fix the hard brick that plagued the early Lollipop builds are included. You might want to empty cache and dalvik cache before you start. Finally, often kernel 3.4 hangs at first try, so try at least two or three times.

I REALLY HOPE THIS WORKS!!! :)
 
Last edited:
One more thing... The battery doesn't charge beyond 97-98%. It might not be wise to keep the tablet on the charger after that (overnight).

The problem is that, somehow the driver uses a set of "registers" that aren't updated in 3.4 as they were in 3.1. This resulted, for instance, in a wall charger not being distinguished from a USB charger (register 0x3E should have been set to 4 with a wall charger, but it only was set to 2). I worked around this issue by using part of the Lenovo charger code that didn't depend on this register. Perhaps I need to use all Lenovo's driver code instead...
 
By the way, problem with android hang not fixed... :mad:
 
I install the Kernel 3.4 (boot-kernel-3.4-CM-12.1) and it is booting. I desabled the HW overlays.
I will make some test and get back.
 
Last edited:
Back
Top