diff options
Diffstat (limited to 'drivers/mxc/gpu-viv/hal/os')
4 files changed, 311 insertions, 5 deletions
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 4c04efa308e3..b15399271f8d 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 @@ -214,6 +214,8 @@ struct _gckOS int gpu_clk_on[3]; struct mutex gpu_clk_mutex; + + gctPOINTER vidmemMutex; }; typedef struct _gcsSIGNAL * gcsSIGNAL_PTR; @@ -1116,6 +1118,8 @@ gckOS_Construct( mutex_init(&os->gpu_clk_mutex); + gcmkONERROR(gckOS_CreateMutex(os, &os->vidmemMutex)); + /* Return pointer to the gckOS object. */ *Os = os; @@ -1239,6 +1243,9 @@ gckOS_Destroy( /* Destroy debug lock mutex. */ gcmkVERIFY_OK(gckOS_DeleteMutex(Os, Os->debugLock)); + /* Destroy video memory mutex. */ + gcmkVERIFY_OK(gckOS_DeleteMutex(Os, Os->vidmemMutex)); + /* Wait for all works done. */ flush_workqueue(Os->workqueue); @@ -2024,6 +2031,21 @@ gckOS_AllocateNonPagedMemory( &mdl->dmaHandle, GFP_KERNEL | gcdNOWARN); } +#if gcdUSE_NON_PAGED_MEMORY_CACHE + if(addr == gcvNULL) + { + MEMORY_UNLOCK(Os); + locked = gcvFALSE; + /*Free all cache and try again*/ + _FreeAllNonPagedMemoryCache(Os); + MEMORY_LOCK(Os); + locked = gcvTRUE; + addr = dma_alloc_coherent(gcvNULL, + mdl->numPages * PAGE_SIZE, + &mdl->dmaHandle, + GFP_KERNEL | gcdNOWARN); + } +#endif #else size = mdl->numPages * PAGE_SIZE; order = get_order(size); @@ -3992,6 +4014,9 @@ gckOS_AllocatePagedMemoryEx( gctSIZE_T bytes; gctBOOL locked = gcvFALSE; gceSTATUS status; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) + gctPOINTER addr = gcvNULL; +#endif gcmkHEADER_ARG("Os=0x%X Contiguous=%d Bytes=%lu", Os, Contiguous, Bytes); @@ -4022,14 +4047,27 @@ gckOS_AllocatePagedMemoryEx( gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) + addr = + alloc_pages_exact(numPages * PAGE_SIZE, GFP_KERNEL | gcdNOWARN | __GFP_NORETRY); + + mdl->u.contiguousPages = addr + ? virt_to_page(addr) + : gcvNULL; + + mdl->exact = gcvTRUE; +#else mdl->u.contiguousPages = alloc_pages(GFP_KERNEL | gcdNOWARN | __GFP_NORETRY, order); - +#endif if (mdl->u.contiguousPages == gcvNULL) { mdl->u.contiguousPages = alloc_pages(GFP_KERNEL | __GFP_HIGHMEM | gcdNOWARN, order); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) + mdl->exact = gcvFALSE; +#endif } } else @@ -4174,7 +4212,16 @@ gckOS_FreePagedMemory( if (mdl->contiguous) { - __free_pages(mdl->u.contiguousPages, GetOrder(mdl->numPages)); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) + if (mdl->exact == gcvTRUE) + { + free_pages_exact(page_address(mdl->u.contiguousPages), mdl->numPages * PAGE_SIZE); + } + else +#endif + { + __free_pages(mdl->u.contiguousPages, GetOrder(mdl->numPages)); + } } else { @@ -6987,14 +7034,12 @@ gckOS_SetGPUPower( if((Power == gcvTRUE) && (oldPowerState == gcvFALSE)) { #if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) - mutex_lock(&set_cpufreq_lock); if(!IS_ERR(Os->device->gpu_regulator)) { ret = regulator_enable(Os->device->gpu_regulator); if (ret != 0) gckOS_Print("%s(%d): fail to enable pu regulator %d!\n", __FUNCTION__, __LINE__, ret); } - mutex_unlock(&set_cpufreq_lock); #else imx_gpc_power_up_pu(true); #endif @@ -7122,7 +7167,6 @@ gckOS_SetGPUPower( #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) - mutex_lock(&set_cpufreq_lock); if(!IS_ERR(Os->device->gpu_regulator)) regulator_disable(Os->device->gpu_regulator); #else @@ -8696,6 +8740,20 @@ gckOS_GetProcessNameByPid( return gcvSTATUS_OK; } +gceSTATUS +gckOS_GetVideoMemoryMutex( + IN gckOS Os, + OUT gctPOINTER *Mutex + ) +{ + gcmkHEADER_ARG("Mutex=x%X", Mutex); + + *Mutex = Os->vidmemMutex; + + gcmkFOOTER_NO(); + return gcvSTATUS_OK; +} + #if gcdANDROID_NATIVE_FENCE_SYNC gceSTATUS diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.h b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.h index ad2dac0b540a..b22081740fdb 100644 --- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.h +++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.h @@ -55,6 +55,9 @@ typedef struct _LINUX_MDL gctINT numPages; gctINT pagedMem; gctBOOL contiguous; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) + gctBOOL exact; +#endif dma_addr_t dmaHandle; PLINUX_MDL_MAP maps; struct _LINUX_MDL * prev; diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_sync.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_sync.c new file mode 100644 index 000000000000..7efae1c74bbe --- /dev/null +++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_sync.c @@ -0,0 +1,174 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2013 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + +#include <linux/kernel.h> +#include <linux/file.h> +#include <linux/fs.h> +#include <linux/miscdevice.h> +#include <linux/module.h> +#include <linux/syscalls.h> +#include <linux/uaccess.h> + +#include "gc_hal_kernel_sync.h" + +#if gcdANDROID_NATIVE_FENCE_SYNC + +static struct sync_pt * +viv_sync_pt_dup( + struct sync_pt * sync_pt + ) +{ + gceSTATUS status; + struct viv_sync_pt *pt; + struct viv_sync_pt *src; + struct viv_sync_timeline *obj; + + src = (struct viv_sync_pt *) sync_pt; + obj = (struct viv_sync_timeline *) sync_pt->parent; + + /* Create the new sync_pt. */ + pt = (struct viv_sync_pt *) + sync_pt_create(&obj->obj, sizeof(struct viv_sync_pt)); + + pt->stamp = src->stamp; + pt->sync = src->sync; + + /* Reference sync point. */ + status = gckOS_ReferenceSyncPoint(obj->os, pt->sync); + + if (gcmIS_ERROR(status)) + { + sync_pt_free((struct sync_pt *)pt); + return NULL; + } + + return (struct sync_pt *)pt; +} + +static int +viv_sync_pt_has_signaled( + struct sync_pt * sync_pt + ) +{ + gceSTATUS status; + gctBOOL state; + struct viv_sync_pt * pt; + struct viv_sync_timeline * obj; + + pt = (struct viv_sync_pt *)sync_pt; + obj = (struct viv_sync_timeline *)sync_pt->parent; + + status = gckOS_QuerySyncPoint(obj->os, pt->sync, &state); + + if (gcmIS_ERROR(status)) + { + /* Error. */ + return -1; + } + + return state; +} + +static int +viv_sync_pt_compare( + struct sync_pt * a, + struct sync_pt * b + ) +{ + int ret; + struct viv_sync_pt * pt1 = (struct viv_sync_pt *) a; + struct viv_sync_pt * pt2 = (struct viv_sync_pt *) b; + + ret = (pt1->stamp < pt2->stamp) ? -1 + : (pt1->stamp == pt2->stamp) ? 0 + : 1; + + return ret; +} + +static void +viv_sync_pt_free( + struct sync_pt * sync_pt + ) +{ + struct viv_sync_pt * pt; + struct viv_sync_timeline * obj; + + pt = (struct viv_sync_pt *) sync_pt; + obj = (struct viv_sync_timeline *) sync_pt->parent; + + gckOS_DestroySyncPoint(obj->os, pt->sync); +} + +static struct sync_timeline_ops viv_timeline_ops = +{ + .driver_name = "viv_sync", + .dup = viv_sync_pt_dup, + .has_signaled = viv_sync_pt_has_signaled, + .compare = viv_sync_pt_compare, + .free_pt = viv_sync_pt_free, +}; + +struct viv_sync_timeline * +viv_sync_timeline_create( + const char * name, + gckOS os + ) +{ + struct viv_sync_timeline * obj; + + obj = (struct viv_sync_timeline *) + sync_timeline_create(&viv_timeline_ops, sizeof(struct viv_sync_timeline), name); + + obj->os = os; + obj->stamp = 0; + + return obj; +} + +struct sync_pt * +viv_sync_pt_create( + struct viv_sync_timeline * obj, + gctSYNC_POINT SyncPoint + ) +{ + gceSTATUS status; + struct viv_sync_pt * pt; + + pt = (struct viv_sync_pt *) + sync_pt_create(&obj->obj, sizeof(struct viv_sync_pt)); + + pt->stamp = obj->stamp++; + pt->sync = SyncPoint; + + /* Dup signal. */ + status = gckOS_ReferenceSyncPoint(obj->os, SyncPoint); + + if (gcmIS_ERROR(status)) + { + sync_pt_free((struct sync_pt *)pt); + return NULL; + } + + return (struct sync_pt *) pt; +} + +#endif diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_sync.h b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_sync.h new file mode 100644 index 000000000000..6fc12e5d0832 --- /dev/null +++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_sync.h @@ -0,0 +1,71 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2013 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + +#ifndef __gc_hal_kernel_sync_h_ +#define __gc_hal_kernel_sync_h_ + +#include <linux/types.h> + +#include <linux/sync.h> + +#include <gc_hal.h> +#include <gc_hal_base.h> + +struct viv_sync_timeline +{ + /* Parent object. */ + struct sync_timeline obj; + + /* Timestamp when sync_pt is created. */ + gctUINT stamp; + + /* Pointer to os struct. */ + gckOS os; +}; + + +struct viv_sync_pt +{ + /* Parent object. */ + struct sync_pt pt; + + /* Reference sync point*/ + gctSYNC_POINT sync; + + /* Timestamp when sync_pt is created. */ + gctUINT stamp; +}; + +/* Create viv_sync_timeline object. */ +struct viv_sync_timeline * +viv_sync_timeline_create( + const char * Name, + gckOS Os + ); + +/* Create viv_sync_pt object. */ +struct sync_pt * +viv_sync_pt_create( + struct viv_sync_timeline * Obj, + gctSYNC_POINT SyncPoint + ); + +#endif /* __gc_hal_kernel_sync_h_ */ |