gpu : modify the number of pre-alloc pages for gckOS_AllocateNonPagedMemory & add...
author杜坤明 <dkm@rockchip.com>
Tue, 13 Dec 2011 02:47:26 +0000 (10:47 +0800)
committer杜坤明 <dkm@rockchip.com>
Tue, 13 Dec 2011 02:47:26 +0000 (10:47 +0800)
drivers/staging/rk29/vivante/arch/XAQ2/hal/kernel/gc_hal_kernel_hardware.c
drivers/staging/rk29/vivante/hal/inc/gc_hal.h [changed mode: 0644->0755]
drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.c [changed mode: 0644->0755]
drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_event.c [changed mode: 0644->0755]
drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_heap.c
drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_video_memory.c [changed mode: 0644->0755]
drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_debug.c [changed mode: 0644->0755]
drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_device.c [changed mode: 0644->0755]
drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_driver.c
drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c

index 1d5c8db7774b5332c324905f3049a620089878d5..552ab0893a9baad024c0bd529c0b50200ae22531 100755 (executable)
@@ -26,6 +26,9 @@
 
 #define _GC_OBJ_ZONE    gcvZONE_HARDWARE
 
+static uint gpu_state = 0;
+module_param(gpu_state, uint, 0644);
+
 // dkm: gcdENABLE_AUTO_FREQ
 #if (1==gcdENABLE_AUTO_FREQ)
 #include <linux/time.h>
@@ -3367,6 +3370,8 @@ gckHARDWARE_SetPowerManagementState(
     /* Release the power mutex. */
     gcmkONERROR(gckOS_ReleaseMutex(os, Hardware->powerMutex));
 
+    gpu_state = State;
+
     /* Success. */
     gcmkFOOTER_NO();
     return gcvSTATUS_OK;
old mode 100644 (file)
new mode 100755 (executable)
index f1a37bd..1e9e4d9
 
 // dkm: ·½±ãµ÷ÓÃϵͳµÄº¯Êý
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include "gc_hal_types.h"
 #include "gc_hal_enum.h"
 #include "gc_hal_base.h"
 #include "gc_hal_profiler.h"
 
+enum {
+       D_ERROR = 1U << 0,
+       D_IOCTL = 1U << 1,
+       D_IRQ   = 1U << 2,
+};
+extern uint gpu_dmask;
+#define dprintk(mask, fmt, ...) do { if (mask & gpu_dmask) printk("gpu: " fmt, ##__VA_ARGS__); } while (0)
+//#define dprintk(mask, fmt, ...) do { if (mask & gpu_dmask) printk(fmt, ##__VA_ARGS__); } while (0)
+
 #ifdef __cplusplus
 extern "C" {
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index 2363d83..00e59d2
 *  
 *****************************************************************************/
 
+#include <linux/pagemap.h>
+#include <linux/mm.h>
+
+#define GetPageCount(size, offset)     ((((size) + ((offset) & ~PAGE_CACHE_MASK)) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT)
+
 
 #include <linux/string.h>
 #include "gc_hal_kernel_precomp.h"
@@ -396,13 +401,14 @@ _AllocateMemory(
     ||     (*Pool == gcvPOOL_UNIFIED)
 #if (0==gcdPAGE_ALLOC_LIMIT)
     // dkm : let gcvPOOL_SYSTEM can use contiguous memory
-    ||     ((*Pool == gcvPOOL_SYSTEM) && (pool==gcvPOOL_CONTIGUOUS))    
+    //||     ((*Pool == gcvPOOL_SYSTEM) && (pool==gcvPOOL_CONTIGUOUS))    
 #endif
     );
 
     if (gcmIS_SUCCESS(status))
     {
         /* Return pool used for allocation. */
+        //if(pool == gcvPOOL_VIRTUAL)     printk("  pool=%d->%d, Bytes=%d, Type=%d\n", *Pool, pool, (int)Bytes, Type);
         *Pool = pool;
     } else {
         printk("_AllocateMemory fail! pool=%d->%d, Bytes=%d, Type=%d\n", *Pool, pool, (int)Bytes, Type);
@@ -621,6 +627,13 @@ gckKERNEL_Dispatch(
         bytes = Interface->u.AllocateVideoMemory.width * bitsPerPixel
               * Interface->u.AllocateVideoMemory.height
               * Interface->u.AllocateVideoMemory.depth / 8;
+    /*
+        printk(" VM-> %d (%d) : %d (%d)\n", 
+            Interface->u.AllocateVideoMemory.pool, 
+            Interface->u.AllocateVideoMemory.type, 
+            (int)GetPageCount(gcmALIGN(bytes, PAGE_SIZE), 0), 
+            (int)bytes);
+    */
 
         /* Allocate memory. */
 #ifdef __QNXNTO__
@@ -644,6 +657,13 @@ gckKERNEL_Dispatch(
         break;
 
     case gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY:
+    /*
+        printk(" LVM-> %d (%d) : %d (%d)\n", 
+            Interface->u.AllocateLinearVideoMemory.pool, 
+            Interface->u.AllocateLinearVideoMemory.type, 
+            (int)GetPageCount(gcmALIGN(Interface->u.AllocateLinearVideoMemory.bytes, PAGE_SIZE), 0),
+            (int)Interface->u.AllocateLinearVideoMemory.bytes);
+     */  
         /* Allocate memory. */
 #ifdef __QNXNTO__
         gcmkONERROR(
old mode 100644 (file)
new mode 100755 (executable)
index 213f4f5..f7164e2
@@ -1007,6 +1007,8 @@ gckEVENT_Notify(
     /* Verify the arguments. */
     gcmkVERIFY_OBJECT(Event, gcvOBJ_EVENT);
 
+    dprintk(D_IRQ, "irq ");
+
     for (;;)
     {
         /* Suspend interrupts. */
@@ -1352,6 +1354,7 @@ gckEVENT_Submit(
                 if (Wait && (status == gcvSTATUS_OUT_OF_RESOURCES))
                 {
                     /* Delay a while. */
+                    printk("gpu : gckEVENT_Submit -> _GetEvent fail! Delay 1ms!\n");
                     gcmkONERROR(gckOS_Delay(Event->os, 1));
 
 #if gcdGPU_TIMEOUT
index d4ec38325e26ffb5281a095d41002a927446ad76..24f7fd4f8d4959f5227f83ed0cecd83e87057613 100755 (executable)
@@ -824,6 +824,9 @@ gckHEAP_Free(
 
        /* Mark the node as freed. */
        node->next = gcvNULL;
+
+    // dkm : clear the buffer for safe
+    //memset(Memory, 0, node->bytes - sizeof(gcskNODE));
        
 #if VIVANTE_PROFILER || gcdDEBUG
        /* Update profile counters. */
old mode 100644 (file)
new mode 100755 (executable)
index 007fe56..927a57b
@@ -822,15 +822,16 @@ gckVIDMEM_AllocateLinear(
 
     acquired = gcvTRUE;
 
-#if 0
+#if 1
     // dkm: ¶ÔÓÚ»¨ÆÁËÀ»úµÄÎÊÌ⣬¸Ð¾õVVÕâô×öÖ»Êǹæ±Ü£¬»¹ÊÇûÓÐÕÒµ½ÎÊÌâµÄÔ­Òò
        if (Type == gcvSURF_TILE_STATUS
-    && (Bytes + (1 << 20) > Memory->freeBytes)
-       )
+    && (Bytes + (1 << 20) > Memory->freeBytes))
     {
+        //printk("alloc = %d, freeBytes = %d!, return OUT_OF_MEMORY!\n", (int)Bytes, (int)Memory->freeBytes);
         /* Not enough memory. */
         gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY);
        }
+    //printk("alloc = %d, freeBytes = %d!\n", (int)Bytes, (int)Memory->freeBytes);
 #else
     // dkm : ÎªgcvSURF_TILE_STATUS±£Áô2MµÄ¿Õ¼ä
        if (Type != gcvSURF_TILE_STATUS
@@ -909,6 +910,9 @@ gckVIDMEM_AllocateLinear(
 
             /* Remove alignment. */
             alignment = 0;
+        } else {
+            // dkm : Out of memory
+            gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY);
         }
     }
 
@@ -916,7 +920,10 @@ gckVIDMEM_AllocateLinear(
     if (node->VidMem.bytes - Bytes > Memory->threshold)
     {
         /* Adjust the node size. */
-        _Split(Memory->os, node, Bytes);
+        if(!_Split(Memory->os, node, Bytes)) {
+            // dkm : Out of memory
+            gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY);
+        }
     }
 
     /* Remove the node from the free list. */
old mode 100644 (file)
new mode 100755 (executable)
index 4f1cd0c..e4f899f
@@ -74,7 +74,9 @@ OutputDebugString(
 #else
     if (String != gcvNULL)
     {
-        printk(String);
+//#define ddprintk(args...) printk(KERN_DEBUG args)
+        printk(KERN_DEBUG "%s", String);
+        //printk(String);
     }
 #endif
 }
old mode 100644 (file)
new mode 100755 (executable)
index 9440eed..5bfdab3
@@ -28,6 +28,8 @@
 #include <linux/mman.h>
 #include <linux/slab.h>
 
+extern unsigned int regAddress;
+
 #define _GC_OBJ_ZONE    gcvZONE_DEVICE
 
 #ifdef FLAREON
@@ -498,6 +500,7 @@ gckGALDEVICE_Construct(
         }
         // dkm: print te regbase
         printk("---- gpu regbase: 0x%08x ---- \n", (unsigned int)device->registerBase);
+        regAddress = (unsigned int)device->registerBase;
 
         physical += RegisterMemSize;
 
@@ -619,7 +622,7 @@ gckGALDEVICE_Construct(
         {
             /* map internal memory */
             device->externalPhysical = (gctPHYS_ADDR)physical;
-// dkm: gcdENABLE_MEM_CACHE\r
+// dkm: gcdENABLE_MEM_CACHE
 #if (1==gcdENABLE_MEM_CACHE)
             device->externalLogical = (gctPOINTER)ioremap_cached(
                     physical, device->externalSize);
@@ -738,7 +741,7 @@ gckGALDEVICE_Construct(
 
             device->contiguousPhysical = (gctPHYS_ADDR) ContiguousBase;
             device->contiguousSize     = ContiguousSize;
-// dkm: gcdENABLE_MEM_CACHE\r
+// dkm: gcdENABLE_MEM_CACHE
 #if (1==gcdENABLE_MEM_CACHE)
             device->contiguousBase     = (gctPOINTER) ioremap_cached(ContiguousBase, ContiguousSize);
 #else
index e386343e9f32b48ae5ee4d4442d0e4c2324f6fba..240340c2b8fc42dacb78d94e4c8f5082d50c72d9 100755 (executable)
@@ -91,6 +91,11 @@ unsigned long coreClock = 552*1000000;
 module_param(coreClock, ulong, 0644);
 #endif
 
+uint gpu_dmask = D_ERROR;
+module_param(gpu_dmask, uint, 0644);
+
+unsigned int regAddress = 0;
+
 // gcdkREPORT_VIDMEM_USAGE add by vv
 #if gcdkREPORT_VIDMEM_USAGE
 #include <linux/proc_fs.h>
@@ -547,6 +552,8 @@ long drv_ioctl(struct file *filp,
        }
 #endif
 
+    dprintk(D_IOCTL, "gckKERNEL_Dispatch(FromUser %d, Cmd %d)\n", (ioctlCode == IOCTL_GCHAL_INTERFACE), iface.command);
+
     status = gckKERNEL_Dispatch(device->kernel,
                (ioctlCode == IOCTL_GCHAL_INTERFACE) , &iface);
     
@@ -1299,5 +1306,142 @@ static void __exit gpu_exit(void)
 module_init(gpu_init);
 module_exit(gpu_exit);
 
+
+#ifdef CONFIG_PROC_FS
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+
+struct RegDefine {
+    char regname[35];
+    uint offset;
+};
+
+struct RegDefine reg_def[] =
+{
+    {"AQHiClockControl",        0x0000},
+    {"AQHiIdle",                0x0001},
+    {"AQAxiConfig",             0x0002},
+    {"AQAxiStatus",             0x0003},
+    {"AQIntrAcknowledge",       0x0004},
+    {"AQIntrEnbl",              0x0005},
+    {"AQIdent",                 0x0006},
+    {"GCFeatures",              0x0007},
+    {"GCChipId",                0x0008},
+    {"GCChipRev",               0x0009},
+    {"GCChipDate",              0x000A},
+    {"GCChipTime",              0x000B},
+    {"GCChipCustomer",          0x000C},
+    {"GCMinorFeatures0",        0x000D},
+    {"GCCacheControl",          0x000E},
+    {"GCResetMemCounters",      0x000F},
+    {"gcTotalReads",            0x0010},
+    {"gcTotalWrites",           0x0011},
+    {"gcChipSpecs",             0x0012},
+    {"gcTotalWriteBursts",      0x0013},
+    {"gcTotalWriteReqs",        0x0014},
+    {"gcTotalWriteLasts",       0x0015},
+    {"gcTotalReadBursts",       0x0016},
+    {"gcTotalReadReqs",         0x0017},
+    {"gcTotalReadLasts",        0x0018},
+    {"gcGpOut0",                0x0019},
+    {"gcGpOut1",                0x001A},
+    {"gcGpOut2",                0x001B},
+    {"gcAxiControl",            0x001C},
+    {"GCMinorFeatures1",        0x001D},
+    {"gcTotalCycles",           0x001E},
+    {"gcTotalIdleCycles",       0x001F},
+    
+    {"AQMemoryFePageTable",     0x0100},
+    {"AQMemoryTxPageTable",     0x0101},
+    {"AQMemoryPePageTable",     0x0102},
+    {"AQMemoryPezPageTable",    0x0103},
+    {"AQMemoryRaPageTable",     0x0104},
+    {"AQMemoryDebug",           0x0105},
+    {"AQMemoryRa",              0x0106},
+    {"AQMemoryFe",              0x0107},
+    {"AQMemoryTx",              0x0108},
+    {"AQMemoryPez",             0x0109},
+    {"AQMemoryPec",             0x010A},
+    {"AQRegisterTimingControl", 0x010B},
+    {"gcMemoryReserved",        0x010C},
+    {"gcDisplayPriority",       0x010D},
+    {"gcDbgCycleCounter",       0x010E},
+    {"gcOutstandingReads0",     0x010F},
+    {"gcOutstandingReads1",     0x0110},
+    {"gcOutstandingWrites",     0x0111},
+    {"gcDebugSignalsRa",        0x0112},
+    {"gcDebugSignalsTx",        0x0113},
+    {"gcDebugSignalsFe",        0x0114},
+    {"gcDebugSignalsPe",        0x0115},
+    {"gcDebugSignalsDe",        0x0116},
+    {"gcDebugSignalsSh",        0x0117},
+    {"gcDebugSignalsPa",        0x0118},
+    {"gcDebugSignalsSe",        0x0119},
+    {"gcDebugSignalsMc",        0x011A},
+    {"gcDebugSignalsHi",        0x011B},
+    {"gcDebugControl0",         0x011C},
+    {"gcDebugControl1",         0x011D},
+    {"gcDebugControl2",         0x011E},
+    {"gcDebugControl3",         0x011F},
+    {"gcBusControl",            0x0120},
+    {"gcregEndianness0",        0x0121},
+    {"gcregEndianness1",        0x0122},
+    {"gcregEndianness2",        0x0123},
+    {"gcregDrawPrimitiveStartTimeStamp",    0x0124},
+    {"gcregDrawPrimitiveEndTimeStamp",      0x0125},
+    {"gcregReqBankAddrMask",    0x0126},
+    {"gcregReqRowAddrMask",     0x0127},
+
+    //{"gcregReqWeight",          0x0025},
+    //{"gcregRdReqAgingThresh",   0x0013},
+    //{"gcregWrReqAgingThresh",   0x0014},
+    
+    {"AQCmdBufferAddr",         0x0195},
+    {"AQCmdBufferCtrl",         0x0196},
+    {"AQFEDebugState",          0x0198},
+    {"AQFEDebugCurCmdAdr",      0x0199},
+    {"AQFEDebugCmdLowReg",      0x019A},
+    {"AQFEDebugCmdHiReg",       0x019B},
+    
+    {"gcModulePowerControls",       0x0040},
+    {"gcModulePowerModuleControl",  0x0041},
+    {"gcModulePowerModuleStatus",   0x0042},
+};
+
+#define gpu_readl(offset)      readl(regAddress + offset*4)
+
+static int proc_gpu_show(struct seq_file *s, void *v)
+{
+    int i = 0;
+    seq_printf(s, "gpu regs:\n");
+
+    for(i=0; i<sizeof(reg_def)/sizeof(struct RegDefine); i++) {
+        seq_printf(s, "  %-35s : 0x%08x\n", reg_def[i].regname, gpu_readl(reg_def[i].offset));
+    }
+    
+    return 0;
+}
+
+static int proc_gpu_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, proc_gpu_show, NULL);
+}
+
+static const struct file_operations proc_gpu_fops = {
+       .open           = proc_gpu_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int __init gpu_proc_init(void)
+{
+       proc_create("gpu", 0, NULL, &proc_gpu_fops);
+       return 0;
+
+}
+late_initcall(gpu_proc_init);
+#endif /* CONFIG_PROC_FS */
+
 #endif
 
index ad0b60a5e3931afc149dd06e2cd19a21e73c8e64..2d6f5dc919283e38019f40894de1ef6ce038806d 100755 (executable)
@@ -556,7 +556,7 @@ gckOS_Construct(
     #endif
     }
 
-    for(os->pageNum8=0; os->pageNum8<40; os->pageNum8++) {
+    for(os->pageNum8=0; os->pageNum8<55; os->pageNum8++) {
     #if USE_DMA_COHERENT
         os->addr8[os->pageNum8] = 
         #if (2==gcdENABLE_MEM_CACHE)
@@ -3096,6 +3096,9 @@ gckOS_AllocatePagedMemory(
 **          Pointer to a variable that receives the physical address of the
 **          memory allocation.
 */
+
+//static int alloc_page = 0;
+
 gceSTATUS gckOS_AllocatePagedMemoryEx(
     IN gckOS Os,
     IN gctBOOL Contiguous,
@@ -3162,6 +3165,9 @@ gceSTATUS gckOS_AllocatePagedMemoryEx(
         return gcvSTATUS_OUT_OF_MEMORY;
     }
 
+    //alloc_page += numPages;
+    //printk("+ %d / %d addr=%p\n", numPages , alloc_page, addr);
+
     mdl = _CreateMdl(current->tgid);
 
     if (mdl == gcvNULL)
@@ -3306,6 +3312,9 @@ gceSTATUS gckOS_FreePagedMemory(
         vfree(mdl->addr);
     }
 
+    //alloc_page -= mdl->numPages;
+    //printk("- %d / %d\n", mdl->numPages , alloc_page);
+
     /* Remove the node from global list. */
     if (mdl == Os->mdlHead)
     {