diff options
author | Xianzhong <b07117@freescale.com> | 2013-03-15 06:11:02 +0800 |
---|---|---|
committer | Xianzhong <b07117@freescale.com> | 2013-03-15 08:15:41 +0800 |
commit | 26495a16b17737d79dd8d26d1a06193e6b3442c1 (patch) | |
tree | e02c79b25303ecad8cf46d65328774ce1ad19a20 /drivers/mxc/gpu-viv/hal/os/linux | |
parent | d7c09f8578c110ad5be539e3e77084066c268ffc (diff) |
ENGR00254378 Upgrade gpu4.6.9p11.1 for Android JB4.2.2_GA
This is linux kernel part of gpu4.6.9p11.1 upgrade.
Signed-off-by: Xianzhong <b07117@freescale.com>
Acked-by: Lily Zhang
Diffstat (limited to 'drivers/mxc/gpu-viv/hal/os/linux')
3 files changed, 81 insertions, 9 deletions
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c index 4e3819ce9897..2ed3d0e1fc8f 100644 --- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c +++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_driver.c @@ -663,7 +663,7 @@ static int drv_mmap( #if !gcdPAGED_MEMORY_CACHEABLE vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); - vma->vm_flags |= VM_IO | VM_DONTCOPY | VM_DONTEXPAND; + vma->vm_flags |= gcdVM_FLAGS; #endif vma->vm_pgoff = 0; diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_linux.h b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_linux.h index 9c0bcd506a67..3c148f6e3323 100644 --- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_linux.h +++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_linux.h @@ -73,6 +73,12 @@ #define GetPageCount(size, offset) ((((size) + ((offset) & ~PAGE_CACHE_MASK)) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT) +#if LINUX_VERSION_CODE >= KERNEL_VERSION (3,7,0) +#define gcdVM_FLAGS (VM_IO | VM_DONTCOPY | VM_DONTEXPAND | VM_DONTDUMP) +#else +#define gcdVM_FLAGS (VM_IO | VM_DONTCOPY | VM_DONTEXPAND | VM_RESERVED) +#endif + static inline gctINT GetOrder( IN gctINT numPages diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c index c07ded8f54a0..9c2bae63da7a 100644 --- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c +++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c @@ -869,6 +869,60 @@ _UnmapUserLogical( #endif } +gceSTATUS +_QueryProcessPageTable( + IN gctPOINTER Logical, + OUT gctUINT32 * Address + ) +{ + spinlock_t *lock; + gctUINTPTR_T logical = (gctUINTPTR_T)Logical; + pgd_t *pgd; + pud_t *pud; + pmd_t *pmd; + pte_t *pte; + + if (!current->mm) + { + return gcvSTATUS_NOT_FOUND; + } + + pgd = pgd_offset(current->mm, logical); + if (pgd_none(*pgd) || pgd_bad(*pgd)) + { + return gcvSTATUS_NOT_FOUND; + } + + pud = pud_offset(pgd, logical); + if (pud_none(*pud) || pud_bad(*pud)) + { + return gcvSTATUS_NOT_FOUND; + } + + pmd = pmd_offset(pud, logical); + if (pmd_none(*pmd) || pmd_bad(*pmd)) + { + return gcvSTATUS_NOT_FOUND; + } + + pte = pte_offset_map_lock(current->mm, pmd, logical, &lock); + if (!pte) + { + return gcvSTATUS_NOT_FOUND; + } + + if (!pte_present(*pte)) + { + pte_unmap_unlock(pte, lock); + return gcvSTATUS_NOT_FOUND; + } + + *Address = (pte_pfn(*pte) << PAGE_SHIFT) | (logical & ~PAGE_MASK); + pte_unmap_unlock(pte, lock); + + return gcvSTATUS_OK; +} + /******************************************************************************* ** ** gckOS_Construct @@ -1106,6 +1160,9 @@ _CreateKernelVirtualMapping( numPages, 0, PAGE_KERNEL); + + /* Trigger a page fault. */ + memset(addr, 0, numPages * PAGE_SIZE); } #else struct page ** pages; @@ -1136,6 +1193,9 @@ _CreateKernelVirtualMapping( /* ioremap() can't work on system memory since 2.6.38. */ addr = vmap(pages, numPages, 0, gcmkNONPAGED_MEMROY_PROT(PAGE_KERNEL)); + /* Trigger a page fault. */ + memset(addr, 0, numPages * PAGE_SIZE); + if (free) { kfree(pages); @@ -1540,7 +1600,7 @@ gckOS_MapMemory( #else #if !gcdPAGED_MEMORY_CACHEABLE mdlMap->vma->vm_page_prot = gcmkPAGED_MEMROY_PROT(mdlMap->vma->vm_page_prot); - mdlMap->vma->vm_flags |= VM_IO | VM_DONTCOPY | VM_DONTEXPAND | VM_RESERVED; + mdlMap->vma->vm_flags |= gcdVM_FLAGS; # endif mdlMap->vma->vm_pgoff = 0; @@ -1987,7 +2047,7 @@ gckOS_AllocateNonPagedMemory( } #else mdlMap->vma->vm_page_prot = gcmkNONPAGED_MEMROY_PROT(mdlMap->vma->vm_page_prot); - mdlMap->vma->vm_flags |= VM_IO | VM_DONTCOPY | VM_DONTEXPAND | VM_RESERVED; + mdlMap->vma->vm_flags |= gcdVM_FLAGS; mdlMap->vma->vm_pgoff = 0; if (remap_pfn_range(mdlMap->vma, @@ -2367,12 +2427,18 @@ gckOS_GetPhysicalAddress( gcmkVERIFY_OBJECT(Os, gcvOBJ_OS); gcmkVERIFY_ARGUMENT(Address != gcvNULL); - /* Get current process ID. */ - processID = _GetProcessID(); + /* Query page table of current process first. */ + status = _QueryProcessPageTable(Logical, Address); - /* Route through other function. */ - gcmkONERROR( - gckOS_GetPhysicalAddressProcess(Os, Logical, processID, Address)); + if (gcmIS_ERROR(status)) + { + /* Get current process ID. */ + processID = _GetProcessID(); + + /* Route through other function. */ + gcmkONERROR( + gckOS_GetPhysicalAddressProcess(Os, Logical, processID, Address)); + } /* Success. */ gcmkFOOTER_ARG("*Address=0x%08x", *Address); @@ -4139,7 +4205,7 @@ gckOS_LockPages( return gcvSTATUS_OUT_OF_RESOURCES; } - mdlMap->vma->vm_flags |= VM_RESERVED; + mdlMap->vma->vm_flags |= gcdVM_FLAGS; #if !gcdPAGED_MEMORY_CACHEABLE if (Cacheable == gcvFALSE) { |