gcmkVERIFY_OBJECT(Hardware, gcvOBJ_HARDWARE);
gcmkVERIFY_ARGUMENT(State != gcvNULL);
+ gckOS_AcquireMutex(Hardware->os, Hardware->powerMutex, gcvINFINITE);
+
/* Return the statue. */
*State = Hardware->chipPowerState;
+ gckOS_ReleaseMutex(Hardware->os, Hardware->powerMutex);
+
/* Success. */
gcmkFOOTER_ARG("*State=%d", *State);
return gcvSTATUS_OK;
# define gcdGPU_TIMEOUT 0
#endif
-/*=============================== add by dkm ==================================== */
+/* ============================== add by rockchip ===================================*/
/*
- dkm: gcdENABLE_AUTO_FREQ
+ dkm : gcdENABLE_AUTO_FREQ
0: ¹Ø±Õ×Ô¶¯µ÷Ƶ
1: ¸ù¾ÝGPU¸ººÉ×Ô¶¯µ÷½ÚGPUµÄCOREƵÂÊ
2: ¸ù¾ÝÊÇ·ñÓÐ3DÓ¦ÓÃ×Ô¶¯µ÷Ƶ(ÓÐ3DÓ¦ÓÃÔÚÅÜʱ¸ßƵ£¬·ñÔòµÍƵ)
/*
- dkm: gcdENABLE_MEM_CACHE
+ dkm : gcdENABLE_MEM_CACHE
ÅäÖÃGPUËùʹÓõÄmemoryÊÇ·ñ±»ARM Cache»òWriteCombineס
1: Cached
/*
- dkm: gcdENABLE_DELAY_EARLY_SUSPEND
+ dkm : gcdENABLE_DELAY_EARLY_SUSPEND
ÔÚgpu_early_suspendÖÐʹÓÃÑÓʱ¹¤×÷¶ÓÁÐÀ´Ö´ÐÐsuspend,
±ÜÃâgpu_early_suspend¹ýÔçÖ´Ðе¼ÖÂÓû§Ï̵߳ÄÊÂÇ黹´¦Àí¸É¾»
/*
- dkm: gcdENABLE_LONG_IDLE_POWEROFF
+ dkm : gcdENABLE_LONG_IDLE_POWEROFF
³¤Ê±¼äIDLEºó½øÈëPowerOff, ¸Ã¹¦ÄÜ¿ªÆôºóÐèÒª°ÑEarlySuspend¹¦Äܹصô
ÕâÑù¿ÉÒÔʹijЩ²»Ê¹ÓÃGPUµÄ³¡¾°µÄ¹¦ºÄ½øÒ»²½½µµÍ£¬ÈçÊÓÆµ²¥·Åʱ£¬Ò»¼¶´ý»úʱ£¬
/*
- dkm: gcdOPTIMIZE_HEAP_SAMESIZE
+ dkm : gcdPAGE_ALLOC_LIMIT & gcdPAGE_ALLOC_LIMIT_SIZE
+
+ ÏÞÖÆgckOS_AllocatePagedMemoryExÏòϵͳÉêÇëpageµÄ´óС£¬±ÜÃâϵͳpage²»×ãʱ»áµ¼ÖÂϵͳ¿¨¶Ù
+ gcdPAGE_ALLOC_LIMIT ÏÞÖÆPageÉêÇë
+ gcdPAGE_ALLOC_LIMIT_SIZE ÏÞÖÆPageÉêÇëµÄ´óС,µ¥Î»ÎªM
+*/
+#define gcdPAGE_ALLOC_LIMIT 1
+#define gcdPAGE_ALLOC_LIMIT_SIZE 0
+
+
+/*
+ dkm : gcdOPTIMIZE_HEAP_SAMESIZE
optimize for heap alloc when alloc the same size
*/
-#define gcdOPTIMIZE_HEAP_SAMESIZE 1
+#define gcdOPTIMIZE_HEAP_SAMESIZE 1
+
+
+/*
+ dkm : gcdkUSE_MAPED_NONPAGE_CACHE
+
+ use cache to avoid alloc & map & free frequently for non page memory.
+ gcdkUSE_MAPED_NONPAGE_CACHE :
+ 0 - no use cache
+ m - The maximum number of cache unit
+*/
+#define gcdkUSE_MAPED_NONPAGE_CACHE 100
#endif /* __gc_hal_options_h_ */
/* Heap list. */
gcskHEAP_PTR heap;
+
+// dkm : gcdOPTIMIZE_HEAP_SAMESIZE
+#if gcdOPTIMIZE_HEAP_SAMESIZE
+ gctSIZE_T lastbytes;
+ gcskNODE_PTR lastnode;
+#endif
+
#if gcdDEBUG
gctUINT64 timeStamp;
#endif
{
/* Convert the pointer. */
gcskNODE_PTR node = (gcskNODE_PTR) p;
+ gctSIZE_T bytes = node->bytes;
gcmkASSERT(p <= (gctPOINTER) ((gctUINT8_PTR) (heap + 1) + heap->size));
if (node->next != gcdIN_USE)
{
/* Test if this is the end of the heap. */
- if (node->bytes == 0)
+ if (bytes == 0)
{
break;
}
if ((gctUINT8_PTR) lastFree + lastFree->bytes == p)
{
/* Just increase the size of the previous free node. */
- lastFree->bytes += node->bytes;
+ lastFree->bytes += bytes;
}
else
{
}
}
+// dkm : add check bytes for loop
+#if gcdOPTIMIZE_HEAP_SAMESIZE
+ else {
+ /* Test if this is the end of the heap. */
+ if (bytes == 0)
+ {
+ break;
+ }
+ }
+#endif
+
/* Move to next node. */
- p = (gctUINT8_PTR) node + node->bytes;
+ p = (gctUINT8_PTR) node + bytes;
}
/* Mark the end of the chain. */
heap->os = Os;
heap->allocationSize = AllocationSize;
heap->heap = gcvNULL;
+
+// dkm : gcdOPTIMIZE_HEAP_SAMESIZE
+#if gcdOPTIMIZE_HEAP_SAMESIZE
+ heap->lastbytes = 0;
+ heap->lastnode = gcvNULL;
+#endif
+
#if gcdDEBUG
heap->timeStamp = 0;
#endif
gctSIZE_T bytes;
gcskNODE_PTR node, used, prevFree = gcvNULL;
gctPOINTER memory = gcvNULL;
-// dkm : gcdOPTIMIZE_HEAP_SAMESIZE
-#if gcdOPTIMIZE_HEAP_SAMESIZE
- static gctSIZE_T lastbytes = 0;
- static gcskNODE_PTR lastnode = gcvNULL;
-#endif
gcmkHEADER_ARG("Heap=0x%x Bytes=%lu", Heap, Bytes);
prevFree = gcvNULL;
// dkm : gcdOPTIMIZE_HEAP_SAMESIZE
#if gcdOPTIMIZE_HEAP_SAMESIZE
- if(bytes>=lastbytes && heap==Heap->heap && lastnode) {
- node = lastnode;
+ if(heap==Heap->heap && bytes>=Heap->lastbytes && Heap->lastnode) {
+ node = Heap->lastnode;
} else {
node = heap->freeList;
}
if (i == 0)
{
+// dkm : gcdOPTIMIZE_HEAP_SAMESIZE
+#if gcdOPTIMIZE_HEAP_SAMESIZE
+ Heap->lastbytes = 0;
+ Heap->lastnode = gcvNULL;
+#endif
/* Compact the heap. */
gcmkVERIFY_OK(_CompactKernelHeap(Heap));
gcmkASSERT(node->bytes >= gcmSIZEOF(gcskNODE));
// dkm : gcdOPTIMIZE_HEAP_SAMESIZE
#if gcdOPTIMIZE_HEAP_SAMESIZE
- lastbytes = bytes;
- lastnode = node;
+ Heap->lastbytes = bytes;
+ Heap->lastnode = node;
#endif
}
else
}
// dkm : gcdOPTIMIZE_HEAP_SAMESIZE
#if gcdOPTIMIZE_HEAP_SAMESIZE
- lastbytes = bytes;
- lastnode = node->next;
+ Heap->lastbytes = bytes;
+ Heap->lastnode = node->next;
#endif
/* Consume the entire free node. */
used = (gcskNODE_PTR) node;
#define _GC_OBJ_ZONE gcvZONE_OS
-// dkm: add
-#define PAGE_ALLOC_LIMIT 1 // ÏÞÖÆPageÉêÇë
-#define PAGE_ALLOC_LIMIT_SIZE 0 // ÏÞÖÆPageÉêÇëµÄ´óС,µ¥Î»ÎªM
-
-// dkm: PAGE_ALLOC_LIMIT
-#if PAGE_ALLOC_LIMIT
+// dkm: gcdPAGE_ALLOC_LIMIT
+#if gcdPAGE_ALLOC_LIMIT
int g_pages_alloced = 0;
#endif
#define MEMORY_MAP_UNLOCK(os) \
gcmkVERIFY_OK(gckOS_ReleaseMutex((os), (os)->memoryMapLock))
-// dkm : use cache to avoid alloc & map & free frequently for non page memory.
-// gcdkUSE_MAPED_NONPAGE_CACHE :
-// 0 - no use cache
-// m - The maximum number of cache unit
-#define gcdkUSE_MAPED_NONPAGE_CACHE 100
// dkm : gcdkUSE_MAPED_NONPAGE_CACHE
#if gcdkUSE_MAPED_NONPAGE_CACHE
}
gcsMapedNonPagedCache;
+static void _FreeAllMapedNonPagedCache(gckOS Os, gctINT pid);
+#endif
+
gceSTATUS gckOS_FreeNonPagedMemoryRealy(
IN gckOS Os,
IN gctSIZE_T Bytes,
IN gctPOINTER Logical
);
-static void _FreeAllMapedNonPagedCache(gckOS Os, gctINT pid);
-#endif
-
/******************************************************************************\
********************************** Structures **********************************
if (Contiguous)
{
-// dkm: PAGE_ALLOC_LIMIT
-#if PAGE_ALLOC_LIMIT
- if( (g_pages_alloced + numPages) > (256*PAGE_ALLOC_LIMIT_SIZE) ) {
+// dkm: gcdPAGE_ALLOC_LIMIT
+#if gcdPAGE_ALLOC_LIMIT
+ if( (g_pages_alloced + numPages) > (256*gcdPAGE_ALLOC_LIMIT_SIZE) ) {
//printk("full %d! \n", g_pages_alloced);
addr = NULL;
} else {
g_pages_alloced += numPages;
//printk("alloc %d / %d \n", numPages, g_pages_alloced);
} else {
- printk("gpu : alloc %d fail! (%d/%d)\n", numPages, g_pages_alloced, (256*PAGE_ALLOC_LIMIT_SIZE) );
+ printk("gpu : alloc %d fail! (%d/%d)\n", numPages, g_pages_alloced, (256*gcdPAGE_ALLOC_LIMIT_SIZE) );
}
}
#else
if (mdl->contiguous)
{
free_pages((unsigned long)mdl->addr, GetOrder(mdl->numPages));
-// dkm: PAGE_ALLOC_LIMIT
-#if PAGE_ALLOC_LIMIT
+// dkm: gcdPAGE_ALLOC_LIMIT
+#if gcdPAGE_ALLOC_LIMIT
g_pages_alloced -= mdl->numPages;
//printk("free %d / %d \n", mdl->numPages, g_pages_alloced);
if(g_pages_alloced<0) g_pages_alloced = 0;