Skip to content
Snippets Groups Projects
Commit 147b0cc7 authored by yuan.tian's avatar yuan.tian Committed by Gianfranco Mariotti
Browse files

MGS-6681 [#imx-2760] 0068-IMX-2865-CL484996-KERNEL-SPACE-64x_234062-merge-imx-


64x_234062: merge
 imx-2865 to 234062 for adding tracepointer gpu_mem_total.[liu.shuai]

Signed-off-by: default avatarKe Feng <ke.feng@verisilicon.com>

Signed-off-by: default avataryuan.tian <yuan.tian@nxp.com>
parent 74969f40
No related branches found
No related tags found
1 merge request!156Draft: [i.MX] mxc: gpu-viv: apply patches
...@@ -67,6 +67,14 @@ extern const uint64_t slogLowWaterFPC; ...@@ -67,6 +67,14 @@ extern const uint64_t slogLowWaterFPC;
#define _GC_OBJ_ZONE gcvZONE_VIDMEM #define _GC_OBJ_ZONE gcvZONE_VIDMEM
#if (defined LINUX_VERSION_CODE) && (defined CONFIG_TRACE_GPU_MEM)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
#include <trace/events/gpu_mem.h>
gctUINT64 totalMem;
#endif
#endif
/******************************************************************************\ /******************************************************************************\
******************************* Private Functions ****************************** ******************************* Private Functions ******************************
\******************************************************************************/ \******************************************************************************/
...@@ -209,6 +217,34 @@ _Merge( ...@@ -209,6 +217,34 @@ _Merge(
return status; return status;
} }
#if (defined LINUX_VERSION_CODE) && (defined CONFIG_TRACE_GPU_MEM)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
static gceSTATUS
_TraceGpuMem(IN gctUINT32 ProcessID, IN gctINT64 Delta)
{
gctUINT32 pid = 0;
if (ProcessID == -1)
gckOS_GetProcessID(&pid);
else
pid = ProcessID;
if (trace_gpu_mem_total_enabled())
{
totalMem += Delta;
if (Delta < 0)
Delta = -Delta;
trace_gpu_mem_total(0, 0, (gctUINT64)totalMem);
trace_gpu_mem_total(0, ProcessID, (gctUINT64)Delta);
}
return gcvSTATUS_OK;
}
#endif
#endif
/******************************************************************************\ /******************************************************************************\
******************************* gckVIDMEM API Code ****************************** ******************************* gckVIDMEM API Code ******************************
\******************************************************************************/ \******************************************************************************/
...@@ -897,6 +933,12 @@ gckVIDMEM_AllocateLinear( ...@@ -897,6 +933,12 @@ gckVIDMEM_AllocateLinear(
/* Adjust the number of free bytes. */ /* Adjust the number of free bytes. */
Memory->freeBytes -= node->VidMem.bytes; Memory->freeBytes -= node->VidMem.bytes;
#if (defined LINUX_VERSION_CODE) && (defined CONFIG_TRACE_GPU_MEM)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
_TraceGpuMem((gctINT32)node->VidMem.processID, node->VidMem.bytes);
#endif
#endif
if (Memory->freeBytes < Memory->minFreeBytes) if (Memory->freeBytes < Memory->minFreeBytes)
{ {
Memory->minFreeBytes = Memory->freeBytes; Memory->minFreeBytes = Memory->freeBytes;
...@@ -1019,6 +1061,12 @@ gckVIDMEM_AllocateVirtual( ...@@ -1019,6 +1061,12 @@ gckVIDMEM_AllocateVirtual(
&node->Virtual.gid, &node->Virtual.gid,
&node->Virtual.physical)); &node->Virtual.physical));
#if (defined LINUX_VERSION_CODE) && (defined CONFIG_TRACE_GPU_MEM)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
_TraceGpuMem(-1, node->Virtual.bytes);
#endif
#endif
/* Calculate required GPU page (4096) count. */ /* Calculate required GPU page (4096) count. */
/* Assume start address is 4096 aligned. */ /* Assume start address is 4096 aligned. */
node->Virtual.pageCount = (gctSIZE_T)(((gctUINT64)node->Virtual.bytes + (4096 - 1)) >> 12); node->Virtual.pageCount = (gctSIZE_T)(((gctUINT64)node->Virtual.bytes + (4096 - 1)) >> 12);
...@@ -1805,6 +1853,12 @@ gckVIDMEM_AllocateVirtualChunk( ...@@ -1805,6 +1853,12 @@ gckVIDMEM_AllocateVirtualChunk(
&Bytes, &Bytes,
&node)); &node));
#if (defined LINUX_VERSION_CODE) && (defined CONFIG_TRACE_GPU_MEM)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
_TraceGpuMem(-1, Bytes);
#endif
#endif
/* Return pointer to the gcuVIDMEM_NODE union. */ /* Return pointer to the gcuVIDMEM_NODE union. */
*Node = node; *Node = node;
...@@ -1958,6 +2012,12 @@ gckVIDMEM_Free( ...@@ -1958,6 +2012,12 @@ gckVIDMEM_Free(
/* Update the number of free bytes. */ /* Update the number of free bytes. */
memory->freeBytes += Node->VidMem.bytes; memory->freeBytes += Node->VidMem.bytes;
#if (defined LINUX_VERSION_CODE) && (defined CONFIG_TRACE_GPU_MEM)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
_TraceGpuMem((gctINT32)Node->VidMem.processID, -(gctINT64)Node->VidMem.bytes);
#endif
#endif
/* Find the next free node. */ /* Find the next free node. */
for (node = Node->VidMem.next; for (node = Node->VidMem.next;
node != gcvNULL && node->VidMem.nextFree == gcvNULL; node != gcvNULL && node->VidMem.nextFree == gcvNULL;
...@@ -2051,6 +2111,12 @@ gckVIDMEM_Free( ...@@ -2051,6 +2111,12 @@ gckVIDMEM_Free(
vidMemBlock->freeBytes += Node->VirtualChunk.bytes; vidMemBlock->freeBytes += Node->VirtualChunk.bytes;
#if (defined LINUX_VERSION_CODE) && (defined CONFIG_TRACE_GPU_MEM)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
_TraceGpuMem(-1, -(gctINT64)Node->VirtualChunk.bytes);
#endif
#endif
/* Find the next free chunk. */ /* Find the next free chunk. */
for (node = Node->VirtualChunk.next; for (node = Node->VirtualChunk.next;
node != gcvNULL && node->VirtualChunk.nextFree == gcvNULL; node != gcvNULL && node->VirtualChunk.nextFree == gcvNULL;
...@@ -2149,6 +2215,12 @@ gckVIDMEM_Free( ...@@ -2149,6 +2215,12 @@ gckVIDMEM_Free(
Node->Virtual.physical, Node->Virtual.physical,
Node->Virtual.bytes)); Node->Virtual.bytes));
#if (defined LINUX_VERSION_CODE) && (defined CONFIG_TRACE_GPU_MEM)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
_TraceGpuMem(-1, -(gctINT64)Node->Virtual.bytes);
#endif
#endif
/* Delete the gcuVIDMEM_NODE union. */ /* Delete the gcuVIDMEM_NODE union. */
gcmkVERIFY_OK(gcmkOS_SAFE_FREE(kernel->os, Node)); gcmkVERIFY_OK(gcmkOS_SAFE_FREE(kernel->os, Node));
...@@ -4579,6 +4651,12 @@ gckVIDMEM_NODE_WrapUserMemory( ...@@ -4579,6 +4651,12 @@ gckVIDMEM_NODE_WrapUserMemory(
referenced = gcvTRUE; referenced = gcvTRUE;
found = gcvTRUE; found = gcvTRUE;
#if (defined LINUX_VERSION_CODE) && (defined CONFIG_TRACE_GPU_MEM)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
_TraceGpuMem(-1, dmabuf->size);
#endif
#endif
*NodeObject = nodeObject; *NodeObject = nodeObject;
*Bytes = (gctUINT64)dmabuf->size; *Bytes = (gctUINT64)dmabuf->size;
} }
...@@ -4640,6 +4718,12 @@ gckVIDMEM_NODE_WrapUserMemory( ...@@ -4640,6 +4718,12 @@ gckVIDMEM_NODE_WrapUserMemory(
node->Virtual.pageCount = (pageCountCpu * pageSizeCpu - node->Virtual.pageCount = (pageCountCpu * pageSizeCpu -
(physicalAddress & (pageSizeCpu - 1) & ~(4096 - 1))) >> 12; (physicalAddress & (pageSizeCpu - 1) & ~(4096 - 1))) >> 12;
#if (defined LINUX_VERSION_CODE) && (defined CONFIG_TRACE_GPU_MEM)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
_TraceGpuMem(-1, node->Virtual.bytes);
#endif
#endif
*NodeObject = nodeObject; *NodeObject = nodeObject;
*Bytes = (gctUINT64)node->Virtual.bytes; *Bytes = (gctUINT64)node->Virtual.bytes;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment