ENGR00306257 [#1027]fix system hang up issue caused by GPU

This issue happens when multiple thread is trying to idle GPU at the
same time, root cause is some wrong logic related with powerMutex which
cause cpu still access GPU AHB register after GPU is suspend(clock off),
that cause the bus lockup and make the whole system hang.

Signed-off-by: Richard Liu <r66033@freescale.com>
Acked-by: Jason Liu
ENGR00306276: iMX6: Add workaround for ARM errata 761320 and 794072

These are Category B, hence workaround is essential.

Signed-off-by: Nitin Garg <nitin.garg@freescale.com>
ENGR00306992-2 gpu:gpu2d may cause bus hang in some corner case

Vivante patch name:
fix_fsl_2d_base_on_p13.v2.rls.diff

-Updated the outstanding request limit to 12.
-Refined the 2D chip feature check.
-Refine the 2D cache flush operation
(avoid FE and PE access memory through the same port).
-Enable cache flush for filterblt.
-Dynamic enabling SPLIT_RECT by checking chip feature(disable for us)
-Use brush stretch blt for clear operation.
-Enable SplitFilterBlit to workaround the 2d hang issue in filterblit case.
-Refine 2d line operation.

Date: May 05, 2014
Signed-off-by: Loren Huang <b02279@freescale.com>
Acked-by: Shawn Guo
ENGR00294354 gpu:Using vitural memory cause AXI bus error

There are two possible reasons to cause AXI bus error
1.Allocate Tile status buffer from virtual memory. It seems gc2000
and gc880 doesn't support tile status buffer from virtual memory.
2.Stream buffer using very beginning gpu mmu address. In this condition,
a faked non gpu mmu address maybe generated and fill into gpu which cause
AXI bus error.

[DATE]09-01-2014
Signed-off-by: Loren Huang <b02279@freescale.com>
Acked-by: Shawn Guo
ENGR00303820 [#887] refine physical address check for external memory

2G above address will cause system reboot and fixed in original patch,
error check code is added based on the original logic.

Signed-off-by: Xianzhong <b07117@freescale.com>
Acked-by: Jason Liu
ENGR00306397 [#1118] use BUG_ON to check if GPU clock is off

Access GPU register will cause system hang(bus lock-up) without log when clock is off,
GPU kernel BUG_ON is added to check if GPU clock is off when read & write GPU registers,

GPU clock issue can be easily identified with the detailed kernel panic log as below:

kernel BUG at drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c:2423!
Unable to handle kernel NULL pointer dereference at virtual address 0000000
...
[<c0050008>] (__bug+0x1c/0x28) from [<c046bb3c>] (gckOS_ReadRegisterEx+0xbc/0xdc)
[<c046bb3c>] (gckOS_ReadRegisterEx+0xbc/0xdc) from [<c047eab4>] (gckHARDWARE_QueryIdle+0x4c/0xbc)
[<c047eab4>] (gckHARDWARE_QueryIdle+0x4c/0xbc) from [<c0475e0c>] (_TryToIdleGPU+0x70/0x12c)

Mutex protection is not necessary for interrupt handling, because GPU clock is only turned off
by interrupt worker thread during clock gating.

Date: Apr 11, 2014
Signed-off-by: Xianzhong <b07117@freescale.com>
Acked-by: Jason Liu
ENGR00310166 [#1157] disable GPU recovery function

Disable GPU auto recovery so that GPU can dump the stack.
GPU support auto recovery function, when GPU meet some issue
it will try to do recovery, but most of cases GPU can't really
recovery, we do find some cases GPU can recovery for example
some 2D hang, but customer is not accept such recovery, so show
the GPU stack dump and find the root cause is the correct way.

Date: Apr 24, 2014

Signed-off-by: Richard Liu <r66033@freescale.com>
ENGR00309915 [#1087] enhanced video memory mutex

this patch can fix NULL pointer issue in GPU kernel driver with the following log

[<7f240438>] (gckEVENT_AddList+0x0/0x810 [galcore]) from [<7f239ebc>] (gckCOMMAND_Commit+0xf28/0x118c [galcore])
[<7f238f94>] (gckCOMMAND_Commit+0x0/0x118c [galcore]) from [<7f2362dc>] (gckKERNEL_Dispatch+0x120c/0x24e4 [galcore])
[<7f2350d0>] (gckKERNEL_Dispatch+0x0/0x24e4 [galcore]) from [<7f222280>] (drv_ioctl+0x390/0x540 [galcore])
[<7f221ef0>] (drv_ioctl+0x0/0x540 [galcore]) from [<800facd0>] (vfs_ioctl+0x30/0x44)

The false code is at 0x217bc where the 0-pointer happens (r3 = 0)

gcuVIDMEM_NODE_PTR node = (gcuVIDMEM_NODE_PTR)(gcmUINT64_TO_PTR(Record->info.u.FreeVideoMemory.node));
   217b8:                e5953028             ldr           r3, [r5, #40]         ; 0x28

                if (node->VidMem.memory->object.type == gcvOBJ_VIDMEM)
   217bc:                e5932000             ldr           r2, [r3]
   217c0:                e5922000             ldr           r2, [r2]
   217c4:                e152000a             cmp       r2, sl
                {
                     gcmkVERIFY_OK(gckKERNEL_RemoveProcessDB(Event->kernel,

Date: Apr 23, 2014
Signed-off-by: Xianzhong <b07117@freescale.com>
Acked-by: Jason Liu
ENGR00308899 [#1087] enhanced GPU database protection

the potential risk is found in special case when application exit,
deleting record will cause the unexpected issue when process database is destoryed without atom protection

the enhanced database patch should be applied to avoid the unexpected kernel issue

Date: Apr 17, 2014
Signed-off-by: Xianzhong <b07117@freescale.com>
Acked-by: Jason Liu
ENGR00312477 [#1162] fixed gpu lower memory killer

mutex operation is performed in gckKERNEL_QueryProcessDB
remove spinlock for gckKERNEL_QueryProcessDB to avoid scheduling issue

Date: May 08, 2014
Signed-off-by: Xianzhong <b07117@freescale.com>
Acked-by: Jason Liu
ENGR00313001 separate GPU low memory killer and reserve memory account

separate GPU low memory killer and GPU reserve memory account query code,
so that we can separate control GPU low memory killer and android system
low memory killer to query the reserve memory account.

Signed-off-by: Richard Liu <r66033@freescale.com>
ENGR00313001-1 add CONFIG_GPU_LOW_MEMORY_KILLER and default enable

add CONFIG_GPU_LOW_MEMORY_KILLER and by default enable
GPU low memory killer.

Signed-off-by: Richard Liu <r66033@freescale.com>
ENGR00313001-2 disable CONFIG_ANDROID_RESERVED_MEMORY_ACCOUNT

disable CONFIG_ANDROID_RESERVED_MEMORY_ACCOUNT by default,
GPU add itself low memory killer so android system low memory
killer not need to take reserve memory into account and the
code in CONFIG_ANDROID_RESERVED_MEMORY_ACCOUNT has potential
issue to use mutex in spin_lock.

Signed-off-by: Richard Liu <r66033@freescale.com>
ENGR00327608 Revert "ENGR00278452 PU: fix system hang if run Audio loop test"

This reverts commit d3d6949649c522ae692287de2b12c744676076aa.

We didn't find the way to reproduce the issue and the changes in gpu kernel
is not in gpu repository. Revert this firstly and checked if we can find the
way to see the issue cleary.

Signed-off-by: Jay Tu <jay.tu@freescale.com>
ENGR00327608 [GPU] Integrate latest 4.6.9p13 release kernel driver

Integrate GPU latest release kernel driver for Android from imx_3.0.35_4.1.0

Signed-off-by: Jay Tu <jay.tu@freescale.com>
Acked-by: Jason Liu