diff options
author | Xianzhong <xianzhong.li@nxp.com> | 2017-10-13 19:15:34 +0800 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-24 12:41:33 +0300 |
commit | 5b62f5059a2fe41ac9f990edff036e28b2a1944c (patch) | |
tree | 84c034a41572538f834981c4f36a187900448fce /drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c | |
parent | aca26b1e312689ef25cf946840cf64cf5e0b1bca (diff) |
MGS-3214 gpu-viv: integrate 6.2.4 driver
add dmabuf/gem feature through drm galcore,
include more bug-fixing in gpu kernel driver.
Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
Diffstat (limited to 'drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c')
-rw-r--r-- | drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c | 545 |
1 files changed, 373 insertions, 172 deletions
diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c index 9ee3a82baa04..6726a88695e9 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c +++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c @@ -105,10 +105,10 @@ gctCONST_STRING _DispatchText[] = gcmDEFINE2TEXT(gcvHAL_WRITE_REGISTER), gcmDEFINE2TEXT(gcvHAL_GET_PROFILE_SETTING), gcmDEFINE2TEXT(gcvHAL_SET_PROFILE_SETTING), - gcmDEFINE2TEXT(gcvHAL_READ_ALL_PROFILE_REGISTERS), gcmDEFINE2TEXT(gcvHAL_PROFILE_REGISTERS_2D), - gcmDEFINE2TEXT(gcvHAL_READ_ALL_PROFILE_NEW_REGISTERS), - gcmDEFINE2TEXT(gcvHAL_READ_PROFILER_NEW_REGISTER_SETTING), + gcmDEFINE2TEXT(gcvHAL_READ_ALL_PROFILE_REGISTERS_PART1), + gcmDEFINE2TEXT(gcvHAL_READ_ALL_PROFILE_REGISTERS_PART2), + gcmDEFINE2TEXT(gcvHAL_READ_PROFILER_REGISTER_SETTING), gcmDEFINE2TEXT(gcvHAL_SET_POWER_MANAGEMENT_STATE), gcmDEFINE2TEXT(gcvHAL_QUERY_POWER_MANAGEMENT_STATE), gcmDEFINE2TEXT(gcvHAL_GET_BASE_ADDRESS), @@ -135,20 +135,29 @@ gctCONST_STRING _DispatchText[] = gcmDEFINE2TEXT(gcvHAL_FREE_VIRTUAL_COMMAND_BUFFER), gcmDEFINE2TEXT(gcvHAL_SET_FSCALE_VALUE), gcmDEFINE2TEXT(gcvHAL_GET_FSCALE_VALUE), + gcmDEFINE2TEXT(gcvHAL_EXPORT_VIDEO_MEMORY), gcmDEFINE2TEXT(gcvHAL_NAME_VIDEO_MEMORY), gcmDEFINE2TEXT(gcvHAL_IMPORT_VIDEO_MEMORY), gcmDEFINE2TEXT(gcvHAL_QUERY_RESET_TIME_STAMP), gcmDEFINE2TEXT(gcvHAL_READ_REGISTER_EX), gcmDEFINE2TEXT(gcvHAL_WRITE_REGISTER_EX), gcmDEFINE2TEXT(gcvHAL_CREATE_NATIVE_FENCE), + gcmDEFINE2TEXT(gcvHAL_WAIT_NATIVE_FENCE), gcmDEFINE2TEXT(gcvHAL_DESTROY_MMU), gcmDEFINE2TEXT(gcvHAL_SHBUF), + gcmDEFINE2TEXT(gcvHAL_GET_GRAPHIC_BUFFER_FD), gcmDEFINE2TEXT(gcvHAL_GET_VIDEO_MEMORY_FD), gcmDEFINE2TEXT(gcvHAL_CONFIG_POWER_MANAGEMENT), gcmDEFINE2TEXT(gcvHAL_WRAP_USER_MEMORY), gcmDEFINE2TEXT(gcvHAL_WAIT_FENCE), - gcmDEFINE2TEXT(gcvHAL_GET_VIDEO_MEMORY_FD), +#if gcdDEC_ENABLE_AHB + gcmDEFINE2TEXT(gcvHAL_DEC300_READ), + gcmDEFINE2TEXT(gcvHAL_DEC300_WRITE), + gcmDEFINE2TEXT(gcvHAL_DEC300_FLUSH), + gcmDEFINE2TEXT(gcvHAL_DEC300_FLUSH_WAIT), +#endif gcmDEFINE2TEXT(gcvHAL_BOTTOM_HALF_UNLOCK_VIDEO_MEMORY), + gcmDEFINE2TEXT(gcvHAL_QUERY_CHIP_OPTION), }; #endif @@ -545,11 +554,30 @@ gckKERNEL_Construct( if (Core == gcvCORE_VG) { + gctUINT32 contiguousBase; + gctUINT32 contiguousSize = 0; + /* Construct the gckMMU object. */ gcmkONERROR( gckVGKERNEL_Construct(Os, Context, kernel, &kernel->vg)); kernel->timeOut = gcdGPU_TIMEOUT; + + status = gckOS_QueryOption(Os, "contiguousBase", &contiguousBase); + + if (gcmIS_SUCCESS(status)) + { + status = gckOS_QueryOption(Os, "contiguousSize", &contiguousSize); + } + + if (gcmIS_SUCCESS(status) && contiguousSize) + { + gctUINT64 gpuContiguousBase; + + gcmkONERROR(gckOS_CPUPhysicalToGPUPhysical(Os, contiguousBase, &gpuContiguousBase)); + + gcmkSAFECASTPHYSADDRT(kernel->contiguousBaseAddress, gpuContiguousBase); + } } else #endif @@ -567,18 +595,10 @@ gckKERNEL_Construct( ; /* Initialize virtual command buffer. */ -#if (defined(LINUX) || defined(__QNXNTO__)) && !defined(EMULATOR) && !gcdALLOC_CMD_FROM_RESERVE - kernel->virtualCommandBuffer = gcvTRUE; -#else - kernel->virtualCommandBuffer = gcvFALSE; -#endif - -#if defined(UNDER_CE) && USE_KERNEL_VIRTUAL_BUFFERS - kernel->virtualCommandBuffer = gcvTRUE; -#endif - -#if gcdSECURITY || gcdDISABLE_GPU_VIRTUAL_ADDRESS +#if gcdALLOC_CMD_FROM_RESERVE || gcdSECURITY || gcdDISABLE_GPU_VIRTUAL_ADDRESS || !USE_KERNEL_VIRTUAL_BUFFERS kernel->virtualCommandBuffer = gcvFALSE; +#else + kernel->virtualCommandBuffer = kernel->hardware->options.enableMMU; #endif #if gcdSHARED_PAGETABLE @@ -609,6 +629,9 @@ gckKERNEL_Construct( gcmkVERIFY_OK(gckMMU_AttachHardware(kernel->mmu, kernel->hardware)); #endif + kernel->contiguousBaseAddress = kernel->mmu->contiguousBaseAddress; + kernel->externalBaseAddress = kernel->mmu->externalBaseAddress; + /* Construct the gckCOMMAND object. */ gcmkONERROR( gckCOMMAND_Construct(kernel, &kernel->command)); @@ -657,7 +680,6 @@ gckKERNEL_Construct( /* Initialize profile setting */ kernel->profileEnable = gcvFALSE; kernel->profileCleanRegister = gcvTRUE; - kernel->profileSyncMode = gcvTRUE; #endif #if gcdANDROID_NATIVE_FENCE_SYNC @@ -973,6 +995,8 @@ gckKERNEL_AllocateLinearMemory( gctBOOL contiguous = gcvFALSE; gctBOOL cacheable = gcvFALSE; gctBOOL secure = gcvFALSE; + gctBOOL fastPools = gcvFALSE; + gctBOOL hasFastPools = gcvFALSE; gctSIZE_T bytes = Bytes; gctUINT32 handle = 0; gceDATABASE_TYPE type; @@ -990,6 +1014,11 @@ gckKERNEL_AllocateLinearMemory( contiguous = Flag & gcvALLOC_FLAG_CONTIGUOUS; cacheable = Flag & gcvALLOC_FLAG_CACHEABLE; secure = Flag & gcvALLOC_FLAG_SECURITY; + if (Flag & gcvALLOC_FLAG_FAST_POOLS) + { + fastPools = gcvTRUE; + Flag &= ~gcvALLOC_FLAG_FAST_POOLS; + } #if gcdALLOC_ON_FAULT if (Type == gcvSURF_RENDER_TARGET) @@ -1091,6 +1120,7 @@ AllocateMemory: else #endif { + hasFastPools = gcvTRUE; status = gckVIDMEM_AllocateLinear(Kernel, videoMemory, Bytes, @@ -1126,6 +1156,13 @@ AllocateMemory: else if (pool == gcvPOOL_SYSTEM) { + /* Do not go ahead to try relative slow pools */ + if (fastPools && hasFastPools) + { + status = gcvSTATUS_OUT_OF_MEMORY; + break; + } + /* Advance to contiguous memory. */ pool = gcvPOOL_CONTIGUOUS; } @@ -1208,6 +1245,7 @@ AllocateMemory: gcvNULL, bytes)); + /* Return status. */ gcmkFOOTER_ARG("*Pool=%d *Node=0x%x", *Pool, *Node); return gcvSTATUS_OK; @@ -1225,12 +1263,6 @@ OnError: gcmkVERIFY_OK(gckVIDMEM_Free(Kernel, node)); } - /* For some case like chrome with webgl test, it needs too much memory so that it invokes oom_killer - * And the case is killed by oom_killer, the user wants not to see the crash and hope the case iteself handles the condition - * So the patch reports the out_of_memory to the case */ - if ( status == gcvSTATUS_OUT_OF_MEMORY && (Flag & gcvALLOC_FLAG_MEMLIMIT) ) - gcmkPRINT("The running case is out_of_memory"); - /* Return the status. */ gcmkFOOTER(); return status; @@ -1385,6 +1417,7 @@ gckKERNEL_LockVideoMemory( Core, FromUser, Interface->u.LockVideoMemory.address, + node->VidMem.pool, &pointer)); Interface->u.LockVideoMemory.memory = gcmPTR_TO_UINT64(pointer); @@ -1486,35 +1519,25 @@ gckKERNEL_UnlockVideoMemory( { gceSTATUS status; gckVIDMEM_NODE nodeObject; -#if gcdSECURE_USER gcuVIDMEM_NODE_PTR node; -#endif + gctSIZE_T bytes; gcmkHEADER_ARG("Kernel=0x%08X ProcessID=%d", Kernel, ProcessID); + Interface->u.UnlockVideoMemory.pool = gcvPOOL_UNKNOWN; + Interface->u.UnlockVideoMemory.bytes = 0; + gcmkONERROR(gckVIDMEM_HANDLE_Lookup( Kernel, ProcessID, (gctUINT32)Interface->u.UnlockVideoMemory.node, &nodeObject)); -#if gcdSECURE_USER node = nodeObject->node; - - /* Unlock video memory. */ - /* Save node information before it disappears. */ - if (node->VidMem.memory->object.type == gcvOBJ_VIDMEM) - { - logical = gcvNULL; - bytes = 0; - } - else - { - logical = node->Virtual.logical; - bytes = node->Virtual.bytes; - } -#endif + bytes = (node->VidMem.memory->object.type == gcvOBJ_VIDMEM) + ? node->VidMem.bytes + : node->Virtual.bytes; /* Unlock video memory. */ gcmkONERROR(gckVIDMEM_Unlock( @@ -1525,15 +1548,18 @@ gckKERNEL_UnlockVideoMemory( #if gcdSECURE_USER /* Flush the translation cache for virtual surfaces. */ - if (logical != gcvNULL) + if (node->VidMem.memory->object.type != gcvOBJ_VIDMEM) { gcmkVERIFY_OK(gckKERNEL_FlushTranslationCache(Kernel, cache, - logical, + node->Virtual.logical, bytes)); } #endif + Interface->u.UnlockVideoMemory.pool = nodeObject->pool; + Interface->u.UnlockVideoMemory.bytes = (gctUINT)bytes; + gcmkFOOTER_NO(); return gcvSTATUS_OK; @@ -1602,6 +1628,94 @@ gckKERNEL_BottomHalfUnlockVideoMemory( return gcvSTATUS_OK; } +/******************************************************************************* +** +** gckKERNEL_QueryVidMemPoolNodes +** +** Loop all databases to query used memory nodes of a specific pool. +** +** INPUT: +** +** Pool The memory pool for query. + +** TotalSize Total size of the used contiguous memory. +** +** MemoryBlocks Used contiguous memory block info. +** +** NumMaxBlock The count of memory blocks array provided by the caller. +** +** NumBlocks The actual number of memory blocks returned. +** +** OUTPUT: +** +** Error status. Should always be gcvSTATUS_SUCCESS since a query should always succeed. +*/ +gceSTATUS +gckKERNEL_QueryVidMemPoolNodes( + gckKERNEL Kernel, + gcePOOL Pool, + gctUINT32 * TotalSize, + gcsContiguousBlock * MemoryBlocks, + gctUINT32 NumMaxBlocks, + gctUINT32 * NumBlocks + ) +{ + gceSTATUS status = gcvSTATUS_OK; + gctINT i; + gctINT bcount; + gctUINT32 num_blocks = 0; + gctSIZE_T total_size = 0; + gckVIDMEM memory; + gcuVIDMEM_NODE_PTR nodes, node; + + do + { + /* Get the heap and nodes. */ + status = gckKERNEL_GetVideoMemoryPool(Kernel, Pool, &memory); + if (status != gcvSTATUS_OK) + break; + + status = gckVIDMEM_QueryNodes(Kernel, Pool, &bcount, &nodes); + if (status != gcvSTATUS_OK) + break; + + /* Iterate all nodes. */ + for (i = 0; i < bcount; i++) + { + node = nodes[i].VidMem.next; + do + { + if (node == gcvNULL) + { + break; + } + + /* Is it in the "free" list? */ + if (node->VidMem.nextFree == gcvNULL) + { + if (num_blocks < NumMaxBlocks) + { + MemoryBlocks[num_blocks].ptr = (gctUINT32)node->VidMem.offset + memory->baseAddress; + MemoryBlocks[num_blocks].size = node->VidMem.bytes; + } + total_size += node->VidMem.bytes; + num_blocks++; + } + + node = node->VidMem.next; + } while (node != &nodes[i]); + } + } + while (gcvFALSE); + + if (TotalSize != gcvNULL) + *TotalSize = (gctUINT32)total_size; + + if (NumBlocks != gcvNULL) + *NumBlocks = num_blocks; + + return status; +} gceSTATUS gckKERNEL_QueryDatabase( @@ -1703,66 +1817,6 @@ OnError: } gceSTATUS -gckKERNEL_WrapUserMemory( - IN gckKERNEL Kernel, - IN gctUINT32 ProcessID, - IN gcsUSER_MEMORY_DESC_PTR Desc, - OUT gctUINT32 * Node - ) -{ - gceSTATUS status; - gcuVIDMEM_NODE_PTR node = gcvNULL; - gctUINT32 handle; - gceDATABASE_TYPE databaseRecordType; - - gcmkHEADER_ARG("Kernel=0x%X Desc=%x", Kernel, Desc); - - gcmkONERROR(gckVIDMEM_ConstructVirtualFromUserMemory( - Kernel, - Desc, - &node - )); - - /* Allocate handle for this video memory. */ - gcmkONERROR(gckVIDMEM_NODE_Allocate( - Kernel, - node, - gcvSURF_BITMAP, - gcvPOOL_VIRTUAL, - &handle - )); - - /* Wrapped node is treated as gcvPOOL_VIRTUAL, but in statistic view, - * it is gcvPOOL_USER. - */ - databaseRecordType - = gcvDB_VIDEO_MEMORY - | (gcvSURF_BITMAP << gcdDB_VIDEO_MEMORY_TYPE_SHIFT) - | (gcvPOOL_VIRTUAL << gcdDB_VIDEO_MEMORY_POOL_SHIFT) - ; - - /* Record in process db. */ - gcmkONERROR(gckKERNEL_AddProcessDB( - Kernel, - ProcessID, - databaseRecordType, - gcmINT2PTR(handle), - gcvNULL, - node->Virtual.bytes - )); - - /* Return handle of the node. */ - *Node = handle; - - gcmkFOOTER_NO(); - return gcvSTATUS_OK; - -OnError: - gcmkFOOTER(); - return status; -} - -gceSTATUS gckKERNEL_WaitFence( IN gckKERNEL Kernel, IN gctUINT32 Handle, @@ -1835,6 +1889,127 @@ OnError: return status; } +#ifdef __linux__ + +typedef struct _gcsGRRAPHIC_BUFFER_PARCLE +{ + gcsFDPRIVATE base; + gckKERNEL kernel; + + gckVIDMEM_NODE node[3]; + gctSHBUF shBuf; + gctINT32 signal; +} +gcsGRAPHIC_BUFFER_PARCLE; + +static void +_ReleaseGraphicBuffer( + gckKERNEL Kernel, + gcsGRAPHIC_BUFFER_PARCLE * Parcle + ) +{ + gctUINT i; + + for (i = 0; i < 3; i++) + { + if (Parcle->node[i]) + { + gckVIDMEM_NODE_Dereference(Kernel, Parcle->node[i]); + } + } + + if (Parcle->shBuf) + { + gckKERNEL_DestroyShBuffer(Kernel, Parcle->shBuf); + } + + if (Parcle->signal) + { + gckOS_DestroyUserSignal(Kernel->os, Parcle->signal); + } + + gcmkOS_SAFE_FREE(Kernel->os, Parcle); +} + +static gctINT +_FdReleaseGraphicBuffer( + gcsFDPRIVATE_PTR Private + ) +{ + gcsGRAPHIC_BUFFER_PARCLE * parcle = (gcsGRAPHIC_BUFFER_PARCLE *) Private; + + _ReleaseGraphicBuffer(parcle->kernel, parcle); + return 0; +} + +static gceSTATUS +_GetGraphicBufferFd( + IN gckKERNEL Kernel, + IN gctUINT32 ProcessID, + IN gctUINT32 Node[3], + IN gctUINT64 ShBuf, + IN gctUINT64 Signal, + OUT gctINT32 * Fd + ) +{ + gceSTATUS status; + gctUINT i; + gcsGRAPHIC_BUFFER_PARCLE * parcle = gcvNULL; + + gcmkONERROR(gckOS_Allocate( + Kernel->os, + gcmSIZEOF(gcsGRAPHIC_BUFFER_PARCLE), + (gctPOINTER *)&parcle + )); + + gckOS_ZeroMemory(parcle, sizeof(gcsGRAPHIC_BUFFER_PARCLE)); + + parcle->base.release = _FdReleaseGraphicBuffer; + parcle->kernel = Kernel; + + for (i = 0; i < 3; i++) + { + if (Node[i] != 0) + { + gcmkONERROR( + gckVIDMEM_HANDLE_LookupAndReference(Kernel, Node[i], &parcle->node[i])); + } + } + + if (ShBuf) + { + gctSHBUF shBuf = gcmUINT64_TO_PTR(ShBuf); + + gcmkONERROR(gckKERNEL_MapShBuffer(Kernel, shBuf)); + parcle->shBuf = shBuf; + } + + if (Signal) + { + gctSIGNAL signal = gcmUINT64_TO_PTR(Signal); + + gcmkONERROR( + gckOS_MapSignal(Kernel->os, + signal, + (gctHANDLE)(gctUINTPTR_T)ProcessID, + &signal)); + + parcle->signal= (gctINT32)Signal; + } + + gcmkONERROR(gckOS_GetFd("viv-gr", &parcle->base, Fd)); + + return gcvSTATUS_OK; + +OnError: + if (parcle) + { + _ReleaseGraphicBuffer(Kernel, parcle); + } + return status; +} +#endif + /******************************************************************************* ** ** gckKERNEL_Dispatch @@ -2173,12 +2348,12 @@ gckKERNEL_Dispatch( } gcmkONERROR(gckEVENT_Commit( - Kernel->asyncEvent, gcmUINT64_TO_PTR(Interface->u.Event.queue))); + Kernel->asyncEvent, gcmUINT64_TO_PTR(Interface->u.Event.queue), gcvFALSE)); } else { gcmkONERROR(gckEVENT_Commit( - Kernel->eventObj, gcmUINT64_TO_PTR(Interface->u.Event.queue))); + Kernel->eventObj, gcmUINT64_TO_PTR(Interface->u.Event.queue), gcvFALSE)); } gcmkONERROR(gckOS_ReleaseMutex(Kernel->os, Kernel->device->commitMutex)); @@ -2210,12 +2385,12 @@ gckKERNEL_Dispatch( gcmkONERROR(gckEVENT_Commit( Kernel->asyncEvent, - gcmUINT64_TO_PTR(Interface->u.Commit.queue) + gcmUINT64_TO_PTR(Interface->u.Commit.queue), + gcvFALSE )); } else { - /* XXX: Workaround nxp dual GPU hang issue, bug #17898, Jira IMX-603. */ if (Interface->u.Commit.count > 1 && Interface->engine == gcvENGINE_RENDER) { gctUINT32 i; @@ -2236,7 +2411,6 @@ gckKERNEL_Dispatch( gcmNAME_TO_PTR(Interface->u.Commit.contexts[0]) : gcvNULL, gcmUINT64_TO_PTR(Interface->u.Commit.commandBuffers[0]), gcmUINT64_TO_PTR(Interface->u.Commit.deltas[0]), - gcmUINT64_TO_PTR(Interface->u.Commit.queue), processID, Interface->u.Commit.shared, Interface->u.Commit.index, @@ -2249,6 +2423,16 @@ gckKERNEL_Dispatch( gcmkONERROR(status); } + /* Force an event if powerManagement is on. */ + status = gckEVENT_Commit(Kernel->eventObj, + gcmUINT64_TO_PTR(Interface->u.Commit.queue), + Kernel->hardware->options.powerManagement); + + if (status != gcvSTATUS_INTERRUPTED) + { + gcmkONERROR(status); + } + if (Interface->u.Commit.count > 1 && Interface->engine == gcvENGINE_RENDER) { gctUINT32 i; @@ -2264,7 +2448,6 @@ gckKERNEL_Dispatch( Interface->u.Commit.commandBuffers[i] ? gcmUINT64_TO_PTR(Interface->u.Commit.commandBuffers[i]) : gcmUINT64_TO_PTR(Interface->u.Commit.commandBuffers[0]), gcmUINT64_TO_PTR(Interface->u.Commit.deltas[i]), - gcvNULL, processID, Interface->u.Commit.shared, Interface->u.Commit.commandBuffers[i] ? @@ -2277,6 +2460,16 @@ gckKERNEL_Dispatch( { gcmkONERROR(status); } + + /* Force an event if powerManagement is on. */ + status = gckEVENT_Commit(kernel->eventObj, + gcvNULL, + kernel->hardware->options.powerManagement); + + if (status != gcvSTATUS_INTERRUPTED) + { + gcmkONERROR(status); + } } } } @@ -2474,71 +2667,31 @@ gckKERNEL_Dispatch( #endif break; - case gcvHAL_READ_ALL_PROFILE_REGISTERS: -#if VIVANTE_PROFILER - if (Kernel->profileSyncMode) - { - /* Read profile data according to the context. */ - gcmkONERROR( - gckHARDWARE_QueryContextProfile( - Kernel->hardware, - Kernel->profileCleanRegister, - gcmNAME_TO_PTR(Interface->u.RegisterProfileData.context), - &Interface->u.RegisterProfileData.counters)); - } - else - { - /* Read all 3D profile registers. */ - gcmkONERROR( - gckHARDWARE_QueryProfileRegisters( - Kernel->hardware, - Kernel->profileCleanRegister, - &Interface->u.RegisterProfileData.counters)); - } -#elif VIVANTE_PROFILER - /* Read all 3D profile registers. */ + case gcvHAL_READ_ALL_PROFILE_REGISTERS_PART1: + /* Read profile data according to the context. */ gcmkONERROR( - gckHARDWARE_QueryProfileRegisters( + gckHARDWARE_QueryContextProfile( Kernel->hardware, Kernel->profileCleanRegister, - &Interface->u.RegisterProfileData.counters)); -#else - status = gcvSTATUS_OK; -#endif - break; - - case gcvHAL_READ_ALL_PROFILE_NEW_REGISTERS_PART1: - if (Kernel->profileSyncMode) - { - /* Read profile data according to the context. */ - gcmkONERROR( - gckHARDWARE_QueryContextNewProfile( - Kernel->hardware, - Kernel->profileCleanRegister, - gcmNAME_TO_PTR(Interface->u.RegisterProfileNewData_part1.context), - &Interface->u.RegisterProfileNewData_part1.newCounters, - gcvNULL)); - } + gcmNAME_TO_PTR(Interface->u.RegisterProfileData_part1.context), + &Interface->u.RegisterProfileData_part1.Counters, + gcvNULL)); break; - case gcvHAL_READ_ALL_PROFILE_NEW_REGISTERS_PART2: - if (Kernel->profileSyncMode) - { - /* Read profile data according to the context. */ - gcmkONERROR( - gckHARDWARE_QueryContextNewProfile( - Kernel->hardware, - Kernel->profileCleanRegister, - gcmNAME_TO_PTR(Interface->u.RegisterProfileNewData_part2.context), - gcvNULL, - &Interface->u.RegisterProfileNewData_part2.newCounters)); - } + case gcvHAL_READ_ALL_PROFILE_REGISTERS_PART2: + /* Read profile data according to the context. */ + gcmkONERROR( + gckHARDWARE_QueryContextProfile( + Kernel->hardware, + Kernel->profileCleanRegister, + gcmNAME_TO_PTR(Interface->u.RegisterProfileData_part2.context), + gcvNULL, + &Interface->u.RegisterProfileData_part2.Counters)); break; case gcvHAL_GET_PROFILE_SETTING: #if VIVANTE_PROFILER /* Get profile setting */ Interface->u.GetProfileSetting.enable = Kernel->profileEnable; - Interface->u.GetProfileSetting.syncMode = Kernel->profileSyncMode; #endif status = gcvSTATUS_OK; @@ -2547,10 +2700,9 @@ gckKERNEL_Dispatch( case gcvHAL_SET_PROFILE_SETTING: #if VIVANTE_PROFILER /* Set profile setting */ - if(Kernel->hardware->gpuProfiler) + if(Kernel->hardware->options.gpuProfiler) { Kernel->profileEnable = Interface->u.SetProfileSetting.enable; - Kernel->profileSyncMode = Interface->u.SetProfileSetting.syncMode; if (Kernel->profileEnable) { @@ -2568,7 +2720,7 @@ gckKERNEL_Dispatch( status = gcvSTATUS_OK; break; - case gcvHAL_READ_PROFILER_NEW_REGISTER_SETTING: + case gcvHAL_READ_PROFILER_REGISTER_SETTING: Kernel->profileCleanRegister = Interface->u.SetProfilerRegisterClear.bclear; status = gcvSTATUS_OK; break; @@ -2825,6 +2977,15 @@ gckKERNEL_Dispatch( #endif break; + case gcvHAL_EXPORT_VIDEO_MEMORY: + /* Unlock video memory. */ + gcmkONERROR(gckVIDMEM_NODE_Export(Kernel, + Interface->u.ExportVideoMemory.node, + Interface->u.ExportVideoMemory.flags, + gcvNULL, + &Interface->u.ExportVideoMemory.fd)); + break; + case gcvHAL_NAME_VIDEO_MEMORY: gcmkONERROR(gckVIDMEM_NODE_Name(Kernel, Interface->u.NameVideoMemory.handle, @@ -3006,18 +3167,36 @@ gckKERNEL_Dispatch( } break; +#ifdef __linux__ + case gcvHAL_GET_GRAPHIC_BUFFER_FD: + gcmkONERROR(_GetGraphicBufferFd( + Kernel, + processID, + Interface->u.GetGraphicBufferFd.node, + Interface->u.GetGraphicBufferFd.shBuf, + Interface->u.GetGraphicBufferFd.signal, + &Interface->u.GetGraphicBufferFd.fd + )); + break; +#endif + case gcvHAL_CONFIG_POWER_MANAGEMENT: gcmkONERROR(gckKERNEL_ConfigPowerManagement(Kernel, Interface)); break; case gcvHAL_WRAP_USER_MEMORY: - gcmkONERROR(gckKERNEL_WrapUserMemory( - Kernel, - processID, - &Interface->u.WrapUserMemory.desc, - &Interface->u.WrapUserMemory.node - )); + gcmkONERROR(gckVIDMEM_NODE_WrapUserMemory(Kernel, + &Interface->u.WrapUserMemory.desc, + &Interface->u.WrapUserMemory.node)); + + gcmkONERROR( + gckKERNEL_AddProcessDB(Kernel, + processID, + gcvDB_VIDEO_MEMORY, + gcmINT2PTR(Interface->u.WrapUserMemory.node), + gcvNULL, + 0)); break; case gcvHAL_WAIT_FENCE: @@ -3066,6 +3245,14 @@ gckKERNEL_Dispatch( #endif + case gcvHAL_QUERY_CHIP_OPTION: + /* Query chip options. */ + gcmkONERROR( + gckHARDWARE_QueryChipOptions( + Kernel->hardware, + &Interface->u.QueryChipOptions)); + break; + default: /* Invalid command. */ gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); @@ -4323,7 +4510,7 @@ gckKERNEL_AllocateVirtualMemory( &buffer->gpuAddress)); #if gcdENABLE_TRUST_APPLICATION - if (Kernel->hardware->secureMode == gcvSECURE_IN_TA) + if (Kernel->hardware->options.secureMode == gcvSECURE_IN_TA) { gcmkONERROR(gckKERNEL_MapInTrustApplicaiton( Kernel, @@ -5709,6 +5896,7 @@ gckDEVICE_Construct( { device->coreInfoArray[i].type = gcvHARDWARE_INVALID; } + device->defaultHwType = gcvHARDWARE_INVALID; gckOS_ZeroMemory(device, gcmSIZEOF(gcsDEVICE)); @@ -5749,6 +5937,7 @@ gckDEVICE_AddCore( gctUINT32 i; gcsCORE_LIST *coreList; gceHARDWARE_TYPE kernelType; + gceHARDWARE_TYPE defaultHwType; gckKERNEL kernel; gcmkASSERT(Device->coreNum < gcvCORE_COUNT); @@ -5806,15 +5995,27 @@ gckDEVICE_AddCore( /* Setup gceHARDWARE_TYPE to gceCORE mapping. */ coreList->kernels[coreList->num++] = kernel; + defaultHwType = kernelType; if (kernelType == gcvHARDWARE_3D2D) { coreList = &Device->map[gcvHARDWARE_3D]; coreList->kernels[coreList->num++] = kernel; + defaultHwType = gcvHARDWARE_3D; } /* Advance total core number. */ Device->coreNum++; + /* Default HW type was chosen: 3D > 2D > VG */ + if (Device->defaultHwType == gcvHARDWARE_INVALID) + { + Device->defaultHwType = defaultHwType; + } + else if (Device->defaultHwType > defaultHwType) + { + Device->defaultHwType = defaultHwType; + } + return gcvSTATUS_OK; OnError: |