Graphics: Integrate IMG DDK from drop ED789263 to drop ED793010
authorgwang23 <gang.a.wang@intel.com>
Thu, 2 Feb 2012 07:28:08 +0000 (15:28 +0800)
committerbuildbot <buildbot@intel.com>
Mon, 13 Feb 2012 09:33:52 +0000 (01:33 -0800)
BZ: 22168

Change-Id: I0f27d5008c1af4382d6084e472bc25a1a86a32d7
Signed-off-by: gwang23 <gang.a.wang@intel.com>
Signed-off-by: Tong, Bo <box.tong@intel.com>
Reviewed-on: http://android.intel.com:8080/33694
Reviewed-by: Ye, John <john.ye@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
12 files changed:
drivers/staging/mrst/pvr/include4/pvrversion.h
drivers/staging/mrst/pvr/services4/include/pvr_bridge.h
drivers/staging/mrst/pvr/services4/include/servicesint.h
drivers/staging/mrst/pvr/services4/include/sgx_bridge.h
drivers/staging/mrst/pvr/services4/srvkm/bridged/bridged_pvr_bridge.c
drivers/staging/mrst/pvr/services4/srvkm/bridged/sgx/bridged_sgx_bridge.c
drivers/staging/mrst/pvr/services4/srvkm/devices/sgx/sgxpower.c
drivers/staging/mrst/pvr/services4/srvkm/devices/sgx/sgxutils.c
drivers/staging/mrst/pvr/services4/srvkm/devices/sgx/sgxutils.h
drivers/staging/mrst/pvr/services4/srvkm/hwdefs/sgxerrata.h
drivers/staging/mrst/pvr/services4/srvkm/hwdefs/sgxfeaturedefs.h
drivers/staging/mrst/pvr/services4/srvkm/include/pdump_km.h

index 5c55aa7..5982d0e 100755 (executable)
@@ -36,7 +36,7 @@
 
 #define PVRVERSION_FAMILY           "sgxddk"
 #define PVRVERSION_BRANCHNAME       "1.8"
-#define PVRVERSION_BUILD             789263
+#define PVRVERSION_BUILD             793010
 #define PVRVERSION_BSCONTROL        "intel_android_sgx_ogles1_ogles2_GPL"
 
 #define PVRVERSION_STRING           "intel_android_sgx_ogles1_ogles2_GPL sgxddk 18 1.8@" PVR_STR2(PVRVERSION_BUILD)
@@ -44,8 +44,8 @@
 
 #define COPYRIGHT_TXT               "Copyright (c) Imagination Technologies Ltd. All Rights Reserved."
 
-#define PVRVERSION_BUILD_HI          78
-#define PVRVERSION_BUILD_LO          9263
+#define PVRVERSION_BUILD_HI          79
+#define PVRVERSION_BUILD_LO          3010
 #define PVRVERSION_STRING_NUMERIC    PVR_STR2(PVRVERSION_MAJ) "." PVR_STR2(PVRVERSION_MIN) "." PVR_STR2(PVRVERSION_BUILD_HI) "." PVR_STR2(PVRVERSION_BUILD_LO)
 
 #endif /* _PVRVERSION_H_ */
index 2b2969f..149e384 100755 (executable)
@@ -192,11 +192,7 @@ extern "C" {
 #define PVRSRV_BRIDGE_UNMAP_MEMINFO_MEM                        PVRSRV_IOWR(PVRSRV_BRIDGE_SHAREDMEM_CMD_FIRST+3)
 #define PVRSRV_BRIDGE_SHAREDMEM_CMD_LAST               (PVRSRV_BRIDGE_SHAREDMEM_CMD_FIRST+3)
 
-#define PVRSRV_BRIDGE_SERVICES4_TMP_CMD_FIRST  (PVRSRV_BRIDGE_SHAREDMEM_CMD_LAST+1)
-#define PVRSRV_BRIDGE_GETMMU_PD_DEVPADDR        PVRSRV_IOWR(PVRSRV_BRIDGE_SERVICES4_TMP_CMD_FIRST+0)
-#define PVRSRV_BRIDGE_SERVICES4_TMP_CMD_LAST   (PVRSRV_BRIDGE_SERVICES4_TMP_CMD_FIRST+0)
-
-#define PVRSRV_BRIDGE_INITSRV_CMD_FIRST                        (PVRSRV_BRIDGE_SERVICES4_TMP_CMD_LAST+1)
+#define PVRSRV_BRIDGE_INITSRV_CMD_FIRST                        (PVRSRV_BRIDGE_SHAREDMEM_CMD_LAST+1)
 #define PVRSRV_BRIDGE_INITSRV_CONNECT                  PVRSRV_IOWR(PVRSRV_BRIDGE_INITSRV_CMD_FIRST+0)
 #define PVRSRV_BRIDGE_INITSRV_DISCONNECT               PVRSRV_IOWR(PVRSRV_BRIDGE_INITSRV_CMD_FIRST+1)
 #define PVRSRV_BRIDGE_INITSRV_CMD_LAST                 (PVRSRV_BRIDGE_INITSRV_CMD_FIRST+1)
@@ -1616,22 +1612,6 @@ typedef struct PVRSRV_BRIDGE_OUT_UNMAP_MEMINFO_MEM_TAG
        PVRSRV_ERROR eError;
 }PVRSRV_BRIDGE_OUT_UNMAP_MEMINFO_MEM;
 
-typedef struct PVRSRV_BRIDGE_IN_GETMMU_PD_DEVPADDR_TAG
-{
-       IMG_UINT32 ui32BridgeFlags; 
-#if defined (SUPPORT_SID_INTERFACE)
-    IMG_SID    hDevMemContext;
-#else
-    IMG_HANDLE hDevMemContext;
-#endif
-}PVRSRV_BRIDGE_IN_GETMMU_PD_DEVPADDR;
-
-typedef struct PVRSRV_BRIDGE_OUT_GETMMU_PD_DEVPADDR_TAG
-{
-    IMG_DEV_PHYADDR sPDDevPAddr;
-       PVRSRV_ERROR eError;
-}PVRSRV_BRIDGE_OUT_GETMMU_PD_DEVPADDR;
-
 typedef struct PVRSRV_BRIDGE_IN_EVENT_OBJECT_WAI_TAG
 {
        IMG_UINT32 ui32BridgeFlags; 
index e038970..79013bc 100755 (executable)
@@ -341,16 +341,6 @@ PVRSRV_ERROR PVRSRVQueueCommand(IMG_HANDLE hQueueInfo,
                                                                PVRSRV_COMMAND *psCommand);
 
 
-
-IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV
-PVRSRVGetMMUContextPDDevPAddr(const PVRSRV_CONNECTION *psConnection,
-#if defined (SUPPORT_SID_INTERFACE)
-                              IMG_SID hDevMemContext,
-#else
-                              IMG_HANDLE hDevMemContext,
-#endif
-                              IMG_DEV_PHYADDR *sPDDevPAddr);
-
 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV
 PVRSRVAllocSharedSysMem(const PVRSRV_CONNECTION *psConnection,
                                                IMG_UINT32 ui32Flags,
index 204189c..ec630a5 100755 (executable)
@@ -50,8 +50,6 @@ extern "C" {
 
 #define PVRSRV_BRIDGE_SGX_2DQUERYBLTSCOMPLETE   PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+9)
 
-#define PVRSRV_BRIDGE_SGX_GETMMUPDADDR                 PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+10)  
-
 #if defined(TRANSFER_QUEUE)
 #define PVRSRV_BRIDGE_SGX_SUBMITTRANSFER                       PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+13)
 #endif
@@ -75,20 +73,22 @@ extern "C" {
 
 #define PVRSRV_BRIDGE_SGX_SCHEDULE_PROCESS_QUEUES              PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+28)
 
-#define PVRSRV_BRIDGE_SGX_READ_HWPERF_CB                       PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+30)
+#define PVRSRV_BRIDGE_SGX_READ_HWPERF_CB                       PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+29)
+#define PVRSRV_BRIDGE_SGX_SET_RENDER_CONTEXT_PRIORITY      PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+30)
+#define PVRSRV_BRIDGE_SGX_SET_TRANSFER_CONTEXT_PRIORITY      PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+31)
 
 #if defined(PDUMP)
-#define PVRSRV_BRIDGE_SGX_PDUMP_BUFFER_ARRAY           PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+31)
-#define PVRSRV_BRIDGE_SGX_PDUMP_3D_SIGNATURE_REGISTERS PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+32)
-#define PVRSRV_BRIDGE_SGX_PDUMP_COUNTER_REGISTERS      PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+33)
-#define PVRSRV_BRIDGE_SGX_PDUMP_TA_SIGNATURE_REGISTERS PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+34)
-#define PVRSRV_BRIDGE_SGX_PDUMP_HWPERFCB                               PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+35)
-#define PVRSRV_BRIDGE_SGX_PDUMP_SAVEMEM                                        PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+36)
+#define PVRSRV_BRIDGE_SGX_PDUMP_BUFFER_ARRAY           PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+32)
+#define PVRSRV_BRIDGE_SGX_PDUMP_3D_SIGNATURE_REGISTERS PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+33)
+#define PVRSRV_BRIDGE_SGX_PDUMP_COUNTER_REGISTERS      PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+34)
+#define PVRSRV_BRIDGE_SGX_PDUMP_TA_SIGNATURE_REGISTERS PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+35)
+#define PVRSRV_BRIDGE_SGX_PDUMP_HWPERFCB                               PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+36)
+#define PVRSRV_BRIDGE_SGX_PDUMP_SAVEMEM                                        PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+37)
 #endif
 
 
 
-#define PVRSRV_BRIDGE_LAST_SGX_CMD (PVRSRV_BRIDGE_SGX_CMD_BASE+36)
+#define PVRSRV_BRIDGE_LAST_SGX_CMD (PVRSRV_BRIDGE_SGX_CMD_BASE+37)
 
  
 typedef struct PVRSRV_BRIDGE_IN_GETPHYSPAGEADDR
@@ -107,24 +107,34 @@ typedef struct PVRSRV_BRIDGE_OUT_GETPHYSPAGEADDR
 }PVRSRV_BRIDGE_OUT_GETPHYSPAGEADDR;
 
  
-typedef struct PVRSRV_BRIDGE_IN_SGX_GETMMU_PDADDR_TAG
+typedef struct PVRSRV_BRIDGE_IN_SGX_SET_TRANSFER_CONTEXT_PRIORITY_TAG
+ {
+       IMG_UINT32                              ui32BridgeFlags; 
+ #if defined (SUPPORT_SID_INTERFACE)
+       IMG_SID                                 hDevCookie;
+       IMG_SID                                 hHWTransferContext;
+ #else
+       IMG_HANDLE                              hDevCookie;
+       IMG_HANDLE                              hHWTransferContext;
+ #endif
+    IMG_UINT32              ui32Priority;
+    IMG_UINT32              ui32OffsetOfPriorityField;
+}PVRSRV_BRIDGE_IN_SGX_SET_TRANSFER_CONTEXT_PRIORITY;
+
+typedef struct PVRSRV_BRIDGE_IN_SGX_SET_RENDER_CONTEXT_PRIORITY_TAG
 {
        IMG_UINT32                              ui32BridgeFlags; 
 #if defined (SUPPORT_SID_INTERFACE)
        IMG_SID                                 hDevCookie;
-       IMG_SID                                 hDevMemContext;
+       IMG_SID                                 hHWRenderContext;
 #else
        IMG_HANDLE                              hDevCookie;
-       IMG_HANDLE                              hDevMemContext;
+       IMG_HANDLE                              hHWRenderContext;
 #endif
-}PVRSRV_BRIDGE_IN_SGX_GETMMU_PDADDR;
-
-typedef struct PVRSRV_BRIDGE_OUT_SGX_GETMMU_PDADDR_TAG
-{
-       IMG_DEV_PHYADDR                 sPDDevPAddr;
-       PVRSRV_ERROR                    eError;
-}PVRSRV_BRIDGE_OUT_SGX_GETMMU_PDADDR;
+    IMG_UINT32              ui32Priority;
+    IMG_UINT32              ui32OffsetOfPriorityField;
+}PVRSRV_BRIDGE_IN_SGX_SET_RENDER_CONTEXT_PRIORITY;
 
  
 typedef struct PVRSRV_BRIDGE_IN_GETCLIENTINFO_TAG
@@ -505,7 +515,10 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_RENDER_CONTEXT_TAG
 #else
        IMG_HANDLE hDevCookie;
 #endif
-       IMG_DEV_VIRTADDR sHWRenderContextDevVAddr;
+    IMG_CPU_VIRTADDR pHWRenderContextCpuVAddr;
+    IMG_UINT32       ui32HWRenderContextSize;
+    IMG_UINT32       ui32OffsetToPDDevPAddr;
+    IMG_HANDLE       hDevMemContext;
 }PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_RENDER_CONTEXT;
 
 typedef struct PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_RENDER_CONTEXT_TAG
@@ -516,6 +529,7 @@ typedef struct PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_RENDER_CONTEXT_TAG
 #else
        IMG_HANDLE hHWRenderContext;
 #endif
+    IMG_DEV_VIRTADDR sHWRenderContextDevVAddr;
 }PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_RENDER_CONTEXT;
 
 typedef struct PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_RENDER_CONTEXT_TAG
@@ -539,7 +553,10 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_TRANSFER_CONTEXT_TAG
 #else
        IMG_HANDLE hDevCookie;
 #endif
-       IMG_DEV_VIRTADDR sHWTransferContextDevVAddr;
+    IMG_CPU_VIRTADDR pHWTransferContextCpuVAddr;
+    IMG_UINT32       ui32HWTransferContextSize;
+    IMG_UINT32       ui32OffsetToPDDevPAddr;
+    IMG_HANDLE       hDevMemContext;
 }PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_TRANSFER_CONTEXT;
 
 typedef struct PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_TRANSFER_CONTEXT_TAG
@@ -550,6 +567,7 @@ typedef struct PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_TRANSFER_CONTEXT_TAG
 #else
        IMG_HANDLE hHWTransferContext;
 #endif
+    IMG_DEV_VIRTADDR sHWTransferContextDevVAddr;
 }PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_TRANSFER_CONTEXT;
 
 typedef struct PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_TRANSFER_CONTEXT_TAG
@@ -586,7 +604,10 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_2D_CONTEXT_TAG
 #else
        IMG_HANDLE hDevCookie;
 #endif
-       IMG_DEV_VIRTADDR sHW2DContextDevVAddr;
+    IMG_CPU_VIRTADDR pHW2DContextCpuVAddr;
+    IMG_UINT32       ui32HW2DContextSize;
+    IMG_UINT32       ui32OffsetToPDDevPAddr;
+    IMG_HANDLE       hDevMemContext;
 }PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_2D_CONTEXT;
 
 typedef struct PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_2D_CONTEXT_TAG
@@ -597,6 +618,7 @@ typedef struct PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_2D_CONTEXT_TAG
 #else
        IMG_HANDLE hHW2DContext;
 #endif
+    IMG_DEV_VIRTADDR sHW2DContextDevVAddr;
 }PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_2D_CONTEXT;
 
 typedef struct PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_2D_CONTEXT_TAG
index 8c6dac3..9aebb10 100755 (executable)
@@ -3592,40 +3592,6 @@ PVRSRVMapMemInfoMemBW(IMG_UINT32 ui32BridgeID,
 
 
 
-static IMG_INT
-MMU_GetPDDevPAddrBW(IMG_UINT32 ui32BridgeID,
-                                       PVRSRV_BRIDGE_IN_GETMMU_PD_DEVPADDR *psGetMmuPDDevPAddrIN,
-                                       PVRSRV_BRIDGE_OUT_GETMMU_PD_DEVPADDR *psGetMmuPDDevPAddrOUT,
-                                       PVRSRV_PER_PROCESS_DATA *psPerProc)
-{
-       IMG_HANDLE hDevMemContextInt;
-
-       PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_GETMMU_PD_DEVPADDR);
-
-       psGetMmuPDDevPAddrOUT->eError =
-               PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevMemContextInt,
-                                                  psGetMmuPDDevPAddrIN->hDevMemContext,
-                                                  PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT);
-       if(psGetMmuPDDevPAddrOUT->eError != PVRSRV_OK)
-       {
-               return 0;
-       }
-
-       psGetMmuPDDevPAddrOUT->sPDDevPAddr =
-               BM_GetDeviceNode(hDevMemContextInt)->pfnMMUGetPDDevPAddr(BM_GetMMUContextFromMemContext(hDevMemContextInt));
-       if(psGetMmuPDDevPAddrOUT->sPDDevPAddr.uiAddr)
-       {
-               psGetMmuPDDevPAddrOUT->eError = PVRSRV_OK;
-       }
-       else
-       {
-               psGetMmuPDDevPAddrOUT->eError = PVRSRV_ERROR_INVALID_PHYS_ADDR;
-       }
-       return 0;
-}
-
-
-
 IMG_INT
 DummyBW(IMG_UINT32 ui32BridgeID,
                IMG_VOID *psBridgeIn,
@@ -4753,9 +4719,6 @@ CommonBridgeInit(IMG_VOID)
        SetDispatchTableEntry(PVRSRV_BRIDGE_FREE_SHARED_SYS_MEM, PVRSRVFreeSharedSysMemoryBW);
        SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_MEMINFO_MEM, PVRSRVMapMemInfoMemBW);
 
-    
-       SetDispatchTableEntry(PVRSRV_BRIDGE_GETMMU_PD_DEVPADDR, MMU_GetPDDevPAddrBW);
-
        
        SetDispatchTableEntry(PVRSRV_BRIDGE_INITSRV_CONNECT,    &PVRSRVInitSrvConnectBW);
        SetDispatchTableEntry(PVRSRV_BRIDGE_INITSRV_DISCONNECT, &PVRSRVInitSrvDisconnectBW);
index f616d83..846b493 100755 (executable)
@@ -780,6 +780,90 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID,
        return 0;
 }
 
+static IMG_INT
+SGXSetTransferContextPriorityBW(IMG_UINT32 ui32BridgeID,
+                        PVRSRV_BRIDGE_IN_SGX_SET_TRANSFER_CONTEXT_PRIORITY *psSGXSetTransferContextPriorityIN,
+                        PVRSRV_BRIDGE_RETURN *psRetOUT,
+                        PVRSRV_PER_PROCESS_DATA *psPerProc)
+{
+       IMG_HANDLE hDevCookieInt;
+    IMG_HANDLE hTransferContextInt;
+
+       PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_SET_TRANSFER_CONTEXT_PRIORITY);
+
+       psRetOUT->eError =
+               PVRSRVLookupHandle(psPerProc->psHandleBase,
+                                                  &hDevCookieInt,
+                                                  psSGXSetTransferContextPriorityIN->hDevCookie,
+                                                  PVRSRV_HANDLE_TYPE_DEV_NODE);
+
+       if(psRetOUT->eError != PVRSRV_OK)
+       {
+               return 0;
+       }
+
+       psRetOUT->eError =
+               PVRSRVLookupHandle(psPerProc->psHandleBase,
+                                                  &hTransferContextInt,
+                                                  psSGXSetTransferContextPriorityIN->hHWTransferContext,
+                                                  PVRSRV_HANDLE_TYPE_SGX_HW_TRANSFER_CONTEXT);
+
+       if(psRetOUT->eError != PVRSRV_OK)
+       {
+               return 0;
+       }
+
+    psRetOUT->eError = SGXSetTransferContextPriorityKM(
+            hDevCookieInt, 
+            hTransferContextInt,
+            psSGXSetTransferContextPriorityIN->ui32Priority,
+            psSGXSetTransferContextPriorityIN->ui32OffsetOfPriorityField);
+
+    return 0;
+}
+
+static IMG_INT
+SGXSetRenderContextPriorityBW(IMG_UINT32 ui32BridgeID,
+                        PVRSRV_BRIDGE_IN_SGX_SET_RENDER_CONTEXT_PRIORITY *psSGXSetRenderContextPriorityIN,
+                        PVRSRV_BRIDGE_RETURN *psRetOUT,
+                        PVRSRV_PER_PROCESS_DATA *psPerProc)
+{
+       IMG_HANDLE hDevCookieInt;
+    IMG_HANDLE hRenderContextInt;
+
+       PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_SET_RENDER_CONTEXT_PRIORITY);
+
+       psRetOUT->eError =
+               PVRSRVLookupHandle(psPerProc->psHandleBase,
+                                                  &hDevCookieInt,
+                                                  psSGXSetRenderContextPriorityIN->hDevCookie,
+                                                  PVRSRV_HANDLE_TYPE_DEV_NODE);
+
+       if(psRetOUT->eError != PVRSRV_OK)
+       {
+               return 0;
+       }
+
+       psRetOUT->eError =
+               PVRSRVLookupHandle(psPerProc->psHandleBase,
+                                                  &hRenderContextInt,
+                                                  psSGXSetRenderContextPriorityIN->hHWRenderContext,
+                                                  PVRSRV_HANDLE_TYPE_SGX_HW_RENDER_CONTEXT);
+
+       if(psRetOUT->eError != PVRSRV_OK)
+       {
+               return 0;
+       }
+
+    psRetOUT->eError = SGXSetRenderContextPriorityKM(
+            hDevCookieInt, 
+            hRenderContextInt,
+            psSGXSetRenderContextPriorityIN->ui32Priority,
+            psSGXSetRenderContextPriorityIN->ui32OffsetOfPriorityField);
+
+    return 0;
+}
+
 
 #if defined(SGX_FEATURE_2D_HARDWARE)
 static IMG_INT
@@ -2176,8 +2260,12 @@ SGXRegisterHWRenderContextBW(IMG_UINT32 ui32BridgeID,
 
        hHWRenderContextInt =
                SGXRegisterHWRenderContextKM(hDevCookieInt,
-                                                                        &psSGXRegHWRenderContextIN->sHWRenderContextDevVAddr,
-                                                                        psPerProc);
+                                     psSGXRegHWRenderContextIN->pHWRenderContextCpuVAddr,
+                                     psSGXRegHWRenderContextIN->ui32HWRenderContextSize,
+                                     psSGXRegHWRenderContextIN->ui32OffsetToPDDevPAddr,
+                                     psSGXRegHWRenderContextIN->hDevMemContext,
+                                     &psSGXRegHWRenderContextOUT->sHWRenderContextDevVAddr,
+                                     psPerProc);
 
        if (hHWRenderContextInt == IMG_NULL)
        {
@@ -2258,7 +2346,11 @@ SGXRegisterHWTransferContextBW(IMG_UINT32 ui32BridgeID,
 
        hHWTransferContextInt =
                SGXRegisterHWTransferContextKM(hDevCookieInt,
-                                                                          &psSGXRegHWTransferContextIN->sHWTransferContextDevVAddr,
+                                                                          psSGXRegHWTransferContextIN->pHWTransferContextCpuVAddr,
+                                       psSGXRegHWTransferContextIN->ui32HWTransferContextSize,
+                                       psSGXRegHWTransferContextIN->ui32OffsetToPDDevPAddr,
+                                       psSGXRegHWTransferContextIN->hDevMemContext,
+                                       &psSGXRegHWTransferContextOUT->sHWTransferContextDevVAddr,
                                                                           psPerProc);
 
        if (hHWTransferContextInt == IMG_NULL)
@@ -2345,7 +2437,11 @@ SGXRegisterHW2DContextBW(IMG_UINT32 ui32BridgeID,
 
        hHW2DContextInt =
                SGXRegisterHW2DContextKM(hDevCookieInt,
-                                                                &psSGXRegHW2DContextIN->sHW2DContextDevVAddr,
+                                                                psSGXRegHW2DContextIN->pHW2DContextCpuVAddr,
+                                 psSGXRegHW2DContextIN->ui32HW2DContextSize,
+                                 psSGXRegHW2DContextIN->ui32OffsetToPDDevPAddr,
+                                                                psSGXRegHW2DContextIN->hDevMemContext,
+                                 &psSGXRegHW2DContextOUT->sHW2DContextDevVAddr,
                                                                 psPerProc);
 
        if (hHW2DContextInt == IMG_NULL)
@@ -3627,8 +3723,6 @@ IMG_VOID SetSGXDispatchTableEntry(IMG_VOID)
 
        SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_2DQUERYBLTSCOMPLETE, SGX2DQueryBlitsCompleteBW);
 
-       SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_GETMMUPDADDR, DummyBW);
-
 #if defined(TRANSFER_QUEUE)
        SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_SUBMITTRANSFER, SGXSubmitTransferBW);
 #endif
@@ -3653,6 +3747,8 @@ IMG_VOID SetSGXDispatchTableEntry(IMG_VOID)
        SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_SCHEDULE_PROCESS_QUEUES, SGXScheduleProcessQueuesBW);
 
        SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_READ_HWPERF_CB, SGXReadHWPerfCBBW);
+    SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_SET_RENDER_CONTEXT_PRIORITY, SGXSetRenderContextPriorityBW);
+    SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_SET_TRANSFER_CONTEXT_PRIORITY, SGXSetTransferContextPriorityBW);
 
 #if defined(PDUMP)
        SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_PDUMP_BUFFER_ARRAY, SGXPDumpBufferArrayBW);
index 696941f..b647b68 100755 (executable)
@@ -271,6 +271,7 @@ PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE                           hDevHandle,
                                                        IMG_FALSE) != PVRSRV_OK)
                {
                        PVR_DPF((PVR_DBG_ERROR,"SGXPrePowerState: Wait for SGX ukernel power transition failed."));
+                       SGXDumpDebugInfo(psDevInfo, IMG_FALSE);
                        PVR_DBG_BREAK;
                }
                #endif 
index 4d52761..7747f4b 100755 (executable)
@@ -725,8 +725,8 @@ PVRSRV_ERROR SGXCleanupRequest(PVRSRV_DEVICE_NODE *psDeviceNode,
 typedef struct _SGX_HW_RENDER_CONTEXT_CLEANUP_
 {
        PVRSRV_DEVICE_NODE *psDeviceNode;
-       IMG_DEV_VIRTADDR sHWRenderContextDevVAddr;
-       IMG_HANDLE hBlockAlloc;
+    PVRSRV_KERNEL_MEM_INFO *psHWRenderContextMemInfo;
+    IMG_HANDLE hBlockAlloc;
        PRESMAN_ITEM psResItem;
 } SGX_HW_RENDER_CONTEXT_CLEANUP;
 
@@ -741,10 +741,15 @@ static PVRSRV_ERROR SGXCleanupHWRenderContextCallback(IMG_PVOID           pvParam,
        PVR_UNREFERENCED_PARAMETER(ui32Param);
 
        eError = SGXCleanupRequest(psCleanup->psDeviceNode,
-                                         &psCleanup->sHWRenderContextDevVAddr,
+                                         &psCleanup->psHWRenderContextMemInfo->sDevVAddr,
                                          PVRSRV_CLEANUPCMD_RC,
                                          bForceCleanup);
 
+    
+    PVRSRVFreeDeviceMemKM(psCleanup->psDeviceNode,
+            psCleanup->psHWRenderContextMemInfo);
+
+    
        OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
                          sizeof(SGX_HW_RENDER_CONTEXT_CLEANUP),
                          psCleanup,
@@ -757,7 +762,7 @@ static PVRSRV_ERROR SGXCleanupHWRenderContextCallback(IMG_PVOID             pvParam,
 typedef struct _SGX_HW_TRANSFER_CONTEXT_CLEANUP_
 {
        PVRSRV_DEVICE_NODE *psDeviceNode;
-       IMG_DEV_VIRTADDR sHWTransferContextDevVAddr;
+    PVRSRV_KERNEL_MEM_INFO *psHWTransferContextMemInfo;
        IMG_HANDLE hBlockAlloc;
        PRESMAN_ITEM psResItem;
 } SGX_HW_TRANSFER_CONTEXT_CLEANUP;
@@ -773,10 +778,15 @@ static PVRSRV_ERROR SGXCleanupHWTransferContextCallback(IMG_PVOID pvParam,
        PVR_UNREFERENCED_PARAMETER(ui32Param);
 
        eError = SGXCleanupRequest(psCleanup->psDeviceNode,
-                                         &psCleanup->sHWTransferContextDevVAddr,
+                                         &psCleanup->psHWTransferContextMemInfo->sDevVAddr,
                                          PVRSRV_CLEANUPCMD_TC,
                                          bForceCleanup);
 
+    
+    PVRSRVFreeDeviceMemKM(psCleanup->psDeviceNode,
+            psCleanup->psHWTransferContextMemInfo);
+
+    
        OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
                          sizeof(SGX_HW_TRANSFER_CONTEXT_CLEANUP),
                          psCleanup,
@@ -787,13 +797,26 @@ static PVRSRV_ERROR SGXCleanupHWTransferContextCallback(IMG_PVOID pvParam,
 }
 
 IMG_EXPORT
-IMG_HANDLE SGXRegisterHWRenderContextKM(IMG_HANDLE                             psDeviceNode,
-                                                                               IMG_DEV_VIRTADDR                *psHWRenderContextDevVAddr,
+IMG_HANDLE SGXRegisterHWRenderContextKM(IMG_HANDLE                             hDeviceNode,
+                                        IMG_CPU_VIRTADDR        *psHWRenderContextCpuVAddr,
+                                        IMG_UINT32              ui32HWRenderContextSize,
+                                        IMG_UINT32              ui32OffsetToPDDevPAddr,
+                                        IMG_HANDLE              hDevMemContext,
+                                        IMG_DEV_VIRTADDR        *psHWRenderContextDevVAddr,
                                                                                PVRSRV_PER_PROCESS_DATA *psPerProc)
 {
        PVRSRV_ERROR eError;
        IMG_HANDLE hBlockAlloc;
        SGX_HW_RENDER_CONTEXT_CLEANUP *psCleanup;
+    PVRSRV_DEVICE_NODE *psDeviceNode = (PVRSRV_DEVICE_NODE *)hDeviceNode;
+       DEVICE_MEMORY_INFO      *psDevMemoryInfo;
+    DEVICE_MEMORY_HEAP_INFO *psHeapInfo;
+    IMG_HANDLE hDevMemContextInt;
+    MMU_CONTEXT *psMMUContext;
+    IMG_DEV_PHYADDR sPDDevPAddr;
+    int iPtrByte;
+    IMG_UINT8 *pSrc;
+    IMG_UINT8 *pDst;
        PRESMAN_ITEM psResItem;
 
        eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
@@ -805,12 +828,98 @@ IMG_HANDLE SGXRegisterHWRenderContextKM(IMG_HANDLE                                psDeviceNode,
        if (eError != PVRSRV_OK)
        {
                PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHWRenderContextKM: Couldn't allocate memory for SGX_HW_RENDER_CONTEXT_CLEANUP structure"));
-               return IMG_NULL;
+               goto exit0;
+       }
+
+       psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo;
+    psHeapInfo = &psDevMemoryInfo->psDeviceMemoryHeap[SGX_KERNEL_DATA_HEAP_ID];
+
+    eError = PVRSRVAllocDeviceMemKM(hDeviceNode,
+                               psPerProc,
+                               psHeapInfo->hDevMemHeap,
+                               PVRSRV_MEM_READ | PVRSRV_MEM_WRITE 
+                                 | PVRSRV_MEM_NO_SYNCOBJ | PVRSRV_MEM_EDM_PROTECT 
+                                 | PVRSRV_MEM_CACHE_CONSISTENT,
+                               ui32HWRenderContextSize,
+                               32,
+                               IMG_NULL,
+                               0,
+                               &psCleanup->psHWRenderContextMemInfo,
+                               "HW Render Context");
+
+       if (eError != PVRSRV_OK)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHWRenderContextKM: Couldn't allocate device memory for HW Render Context"));
+               goto exit1;
+       }
+
+    eError = OSCopyFromUser(psPerProc,
+                            psCleanup->psHWRenderContextMemInfo->pvLinAddrKM,
+                            psHWRenderContextCpuVAddr,
+                            ui32HWRenderContextSize);
+
+       if (eError != PVRSRV_OK)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHWRenderContextKM: Couldn't copy user-mode copy of HWContext into device memory"));
+               goto exit2;
        }
 
+    
+    psHWRenderContextDevVAddr->uiAddr = psCleanup->psHWRenderContextMemInfo->sDevVAddr.uiAddr;
+
+    
+    eError = PVRSRVLookupHandle(psPerProc->psHandleBase, 
+                           &hDevMemContextInt,
+                           hDevMemContext,
+                           PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT);
+
+    if (eError != PVRSRV_OK)
+    {
+        PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHWRenderContextKM: Can't lookup DevMem Context"));
+        goto exit2;
+    }
+
+    psMMUContext = BM_GetMMUContextFromMemContext(hDevMemContextInt);
+    sPDDevPAddr = psDeviceNode->pfnMMUGetPDDevPAddr(psMMUContext);
+
+    
+
+
+
+
+    pSrc = (IMG_UINT8 *)&sPDDevPAddr;
+    pDst = (IMG_UINT8 *)psCleanup->psHWRenderContextMemInfo->pvLinAddrKM;
+    pDst += ui32OffsetToPDDevPAddr;
+
+    for (iPtrByte = 0; iPtrByte < sizeof(IMG_DEV_PHYADDR); iPtrByte++)
+    {
+        pDst[iPtrByte] = pSrc[iPtrByte];
+    }
+
+#if defined(PDUMP)
+    
+       PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_CONTINUOUS, "HW Render context struct");
+
+       PDUMPMEM(
+        IMG_NULL, 
+        psCleanup->psHWRenderContextMemInfo,
+        0, 
+        ui32HWRenderContextSize, 
+        PDUMP_FLAGS_CONTINUOUS, 
+        MAKEUNIQUETAG(psCleanup->psHWRenderContextMemInfo));
+
+    
+       PDUMPCOMMENT("Page directory address in HW render context");
+    PDUMPPDDEVPADDR(
+            psCleanup->psHWRenderContextMemInfo,
+            ui32OffsetToPDDevPAddr,
+            sPDDevPAddr,
+            MAKEUNIQUETAG(psCleanup->psHWRenderContextMemInfo),
+            PDUMP_PD_UNIQUETAG);
+#endif
+
        psCleanup->hBlockAlloc = hBlockAlloc;
        psCleanup->psDeviceNode = psDeviceNode;
-       psCleanup->sHWRenderContextDevVAddr = *psHWRenderContextDevVAddr;
 
        psResItem = ResManRegisterRes(psPerProc->hResManContext,
                                                                  RESMAN_TYPE_HW_RENDER_CONTEXT,
@@ -818,21 +927,27 @@ IMG_HANDLE SGXRegisterHWRenderContextKM(IMG_HANDLE                                psDeviceNode,
                                                                  0,
                                                                  &SGXCleanupHWRenderContextCallback);
 
-       if (psResItem == IMG_NULL)
-       {
-               PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHWRenderContextKM: ResManRegisterRes failed"));
-               OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
-                                 sizeof(SGX_HW_RENDER_CONTEXT_CLEANUP),
-                                 psCleanup,
-                                 psCleanup->hBlockAlloc);
-               
-
-               return IMG_NULL;
-       }
+    if (psResItem == IMG_NULL)
+    {
+        PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHWRenderContextKM: ResManRegisterRes failed"));
+        goto exit2;
+    }
 
        psCleanup->psResItem = psResItem;
 
        return (IMG_HANDLE)psCleanup;
+
+exit2:
+        PVRSRVFreeDeviceMemKM(hDeviceNode,
+                           psCleanup->psHWRenderContextMemInfo);
+exit1:
+    OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
+              sizeof(SGX_HW_RENDER_CONTEXT_CLEANUP),
+              psCleanup,
+              psCleanup->hBlockAlloc);
+    
+exit0:
+    return IMG_NULL;
 }
 
 IMG_EXPORT
@@ -858,13 +973,26 @@ PVRSRV_ERROR SGXUnregisterHWRenderContextKM(IMG_HANDLE hHWRenderContext, IMG_BOO
 
 
 IMG_EXPORT
-IMG_HANDLE SGXRegisterHWTransferContextKM(IMG_HANDLE                           psDeviceNode,
-                                                                                 IMG_DEV_VIRTADDR                      *psHWTransferContextDevVAddr,
+IMG_HANDLE SGXRegisterHWTransferContextKM(IMG_HANDLE                           hDeviceNode,
+                                          IMG_CPU_VIRTADDR          *psHWTransferContextCpuVAddr,
+                                          IMG_UINT32                ui32HWTransferContextSize,
+                                          IMG_UINT32                ui32OffsetToPDDevPAddr,
+                                          IMG_HANDLE                hDevMemContext,
+                                          IMG_DEV_VIRTADDR          *psHWTransferContextDevVAddr,
                                                                                  PVRSRV_PER_PROCESS_DATA       *psPerProc)
 {
        PVRSRV_ERROR eError;
        IMG_HANDLE hBlockAlloc;
        SGX_HW_TRANSFER_CONTEXT_CLEANUP *psCleanup;
+    PVRSRV_DEVICE_NODE *psDeviceNode = (PVRSRV_DEVICE_NODE *)hDeviceNode;
+       DEVICE_MEMORY_INFO      *psDevMemoryInfo;
+    DEVICE_MEMORY_HEAP_INFO *psHeapInfo;
+    IMG_HANDLE hDevMemContextInt;
+    MMU_CONTEXT *psMMUContext;
+    IMG_DEV_PHYADDR sPDDevPAddr;
+    int iPtrByte;
+    IMG_UINT8 *pSrc;
+    IMG_UINT8 *pDst;
        PRESMAN_ITEM psResItem;
 
        eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
@@ -876,12 +1004,99 @@ IMG_HANDLE SGXRegisterHWTransferContextKM(IMG_HANDLE                             psDeviceNode,
        if (eError != PVRSRV_OK)
        {
                PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHWTransferContextKM: Couldn't allocate memory for SGX_HW_TRANSFER_CONTEXT_CLEANUP structure"));
-               return IMG_NULL;
+               goto exit0;
+       }
+
+       psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo;
+    psHeapInfo = &psDevMemoryInfo->psDeviceMemoryHeap[SGX_KERNEL_DATA_HEAP_ID];
+
+    eError = PVRSRVAllocDeviceMemKM(hDeviceNode,
+                               psPerProc,
+                               psHeapInfo->hDevMemHeap,
+                               PVRSRV_MEM_READ | PVRSRV_MEM_WRITE 
+                                 | PVRSRV_MEM_NO_SYNCOBJ | PVRSRV_MEM_EDM_PROTECT 
+                                 | PVRSRV_MEM_CACHE_CONSISTENT,
+                               ui32HWTransferContextSize,
+                               32,
+                               IMG_NULL,
+                               0,
+                               &psCleanup->psHWTransferContextMemInfo,
+                               "HW Render Context");
+
+       if (eError != PVRSRV_OK)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHWTransferContextKM: Couldn't allocate device memory for HW Render Context"));
+               goto exit1;
        }
 
+    eError = OSCopyFromUser(psPerProc,
+                            psCleanup->psHWTransferContextMemInfo->pvLinAddrKM,
+                            psHWTransferContextCpuVAddr,
+                            ui32HWTransferContextSize);
+
+       if (eError != PVRSRV_OK)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHWTransferContextKM: Couldn't copy user-mode copy of HWContext into device memory"));
+               goto exit2;
+       }
+
+    
+    psHWTransferContextDevVAddr->uiAddr = psCleanup->psHWTransferContextMemInfo->sDevVAddr.uiAddr;
+
+    
+    eError = PVRSRVLookupHandle(psPerProc->psHandleBase, 
+                           &hDevMemContextInt,
+                           hDevMemContext,
+                           PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT);
+
+    if (eError != PVRSRV_OK)
+    {
+        PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHWTransferContextKM: Can't lookup DevMem Context"));
+        goto exit2;
+    }
+
+    psMMUContext = BM_GetMMUContextFromMemContext(hDevMemContextInt);
+    sPDDevPAddr = psDeviceNode->pfnMMUGetPDDevPAddr(psMMUContext);
+
+    
+
+
+
+
+    pSrc = (IMG_UINT8 *)&sPDDevPAddr;
+    pDst = (IMG_UINT8 *)psCleanup->psHWTransferContextMemInfo->pvLinAddrKM;
+    pDst += ui32OffsetToPDDevPAddr;
+
+    for (iPtrByte = 0; iPtrByte < sizeof(IMG_DEV_PHYADDR); iPtrByte++)
+    {
+        pDst[iPtrByte] = pSrc[iPtrByte];
+    }
+
+#if defined(PDUMP)
+    
+       PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_CONTINUOUS, "HW Transfer context struct");
+
+       PDUMPMEM(
+        IMG_NULL, 
+        psCleanup->psHWTransferContextMemInfo,
+        0, 
+        ui32HWTransferContextSize, 
+        PDUMP_FLAGS_CONTINUOUS, 
+        MAKEUNIQUETAG(psCleanup->psHWTransferContextMemInfo));
+
+    
+       PDUMPCOMMENT("Page directory address in HW transfer context");
+
+    PDUMPPDDEVPADDR(
+            psCleanup->psHWTransferContextMemInfo,
+            ui32OffsetToPDDevPAddr,
+            sPDDevPAddr,
+            MAKEUNIQUETAG(psCleanup->psHWTransferContextMemInfo),
+            PDUMP_PD_UNIQUETAG);
+#endif
+
        psCleanup->hBlockAlloc = hBlockAlloc;
        psCleanup->psDeviceNode = psDeviceNode;
-       psCleanup->sHWTransferContextDevVAddr = *psHWTransferContextDevVAddr;
 
        psResItem = ResManRegisterRes(psPerProc->hResManContext,
                                                                  RESMAN_TYPE_HW_TRANSFER_CONTEXT,
@@ -892,18 +1107,25 @@ IMG_HANDLE SGXRegisterHWTransferContextKM(IMG_HANDLE                             psDeviceNode,
        if (psResItem == IMG_NULL)
        {
                PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHWTransferContextKM: ResManRegisterRes failed"));
-               OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
-                                 sizeof(SGX_HW_TRANSFER_CONTEXT_CLEANUP),
-                                 psCleanup,
-                                 psCleanup->hBlockAlloc);
-               
-
-               return IMG_NULL;
-       }
+        goto exit2;
+    }
 
        psCleanup->psResItem = psResItem;
 
        return (IMG_HANDLE)psCleanup;
+
+exit2:
+    PVRSRVFreeDeviceMemKM(hDeviceNode,
+            psCleanup->psHWTransferContextMemInfo);
+exit1:
+    OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
+              sizeof(SGX_HW_TRANSFER_CONTEXT_CLEANUP),
+              psCleanup,
+              psCleanup->hBlockAlloc);
+    
+
+exit0:
+    return IMG_NULL;
 }
 
 IMG_EXPORT
@@ -927,11 +1149,95 @@ PVRSRV_ERROR SGXUnregisterHWTransferContextKM(IMG_HANDLE hHWTransferContext, IMG
        return eError;
 }
 
+IMG_EXPORT
+PVRSRV_ERROR SGXSetTransferContextPriorityKM(
+                IMG_HANDLE hDeviceNode,
+                IMG_HANDLE hHWTransferContext,
+                IMG_UINT32 ui32Priority,
+                IMG_UINT32 ui32OffsetOfPriorityField)
+{
+       SGX_HW_TRANSFER_CONTEXT_CLEANUP *psCleanup;
+    IMG_UINT8 *pSrc;
+    IMG_UINT8 *pDst;
+    int iPtrByte;
+       PVR_UNREFERENCED_PARAMETER(hDeviceNode);
+
+    if (hHWTransferContext != IMG_NULL)
+    {
+        psCleanup = (SGX_HW_TRANSFER_CONTEXT_CLEANUP *)hHWTransferContext;
+
+        if ((ui32OffsetOfPriorityField + sizeof(ui32Priority)) 
+            >= psCleanup->psHWTransferContextMemInfo->uAllocSize)
+        {
+            PVR_DPF((
+                PVR_DBG_ERROR, 
+                "SGXSetTransferContextPriorityKM: invalid context prioirty offset"));
+
+            return PVRSRV_ERROR_INVALID_PARAMS;
+        }
+
+        
+
+
+        pDst = (IMG_UINT8 *)psCleanup->psHWTransferContextMemInfo->pvLinAddrKM;
+        pDst += ui32OffsetOfPriorityField;
+        pSrc = (IMG_UINT8 *)&ui32Priority;
+
+        for (iPtrByte = 0; iPtrByte < sizeof(ui32Priority); iPtrByte++)
+        {
+            pDst[iPtrByte] = pSrc[iPtrByte];
+        }
+    }
+    return PVRSRV_OK;
+}
+
+IMG_EXPORT
+PVRSRV_ERROR SGXSetRenderContextPriorityKM(
+                IMG_HANDLE hDeviceNode,
+                IMG_HANDLE hHWRenderContext,
+                IMG_UINT32 ui32Priority,
+                IMG_UINT32 ui32OffsetOfPriorityField)
+{
+       SGX_HW_RENDER_CONTEXT_CLEANUP *psCleanup;
+    IMG_UINT8 *pSrc;
+    IMG_UINT8 *pDst;
+    int iPtrByte;
+       PVR_UNREFERENCED_PARAMETER(hDeviceNode);
+
+    if (hHWRenderContext != IMG_NULL)
+    {
+        psCleanup = (SGX_HW_RENDER_CONTEXT_CLEANUP *)hHWRenderContext;
+        if ((ui32OffsetOfPriorityField + sizeof(ui32Priority)) 
+            >= psCleanup->psHWRenderContextMemInfo->uAllocSize)
+        {
+            PVR_DPF((
+                PVR_DBG_ERROR, 
+                "SGXSetContextPriorityKM: invalid HWRenderContext prioirty offset"));
+
+            return PVRSRV_ERROR_INVALID_PARAMS;
+        }
+
+        
+
+
+        pDst = (IMG_UINT8 *)psCleanup->psHWRenderContextMemInfo->pvLinAddrKM;
+        pDst += ui32OffsetOfPriorityField;
+
+        pSrc = (IMG_UINT8 *)&ui32Priority;
+
+        for (iPtrByte = 0; iPtrByte < sizeof(ui32Priority); iPtrByte++)
+        {
+            pDst[iPtrByte] = pSrc[iPtrByte];
+        }
+    }
+    return PVRSRV_OK;
+}
+
 #if defined(SGX_FEATURE_2D_HARDWARE)
 typedef struct _SGX_HW_2D_CONTEXT_CLEANUP_
 {
        PVRSRV_DEVICE_NODE *psDeviceNode;
-       IMG_DEV_VIRTADDR sHW2DContextDevVAddr;
+       PVRSRV_KERNEL_MEM_INFO *psHW2DContextMemInfo;
        IMG_HANDLE hBlockAlloc;
        PRESMAN_ITEM psResItem;
 } SGX_HW_2D_CONTEXT_CLEANUP;
@@ -945,28 +1251,46 @@ static PVRSRV_ERROR SGXCleanupHW2DContextCallback(IMG_PVOID  pvParam,
 
        PVR_UNREFERENCED_PARAMETER(ui32Param);
 
-       eError = SGXCleanupRequest(psCleanup->psDeviceNode,
-                                         &psCleanup->sHW2DContextDevVAddr,
+    
+    eError = SGXCleanupRequest(psCleanup->psDeviceNode,
+                                         &psCleanup->psHW2DContextMemInfo->sDevVAddr,
                                          PVRSRV_CLEANUPCMD_2DC,
                                          bForceCleanup);
 
-       OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
+    
+    PVRSRVFreeDeviceMemKM(psCleanup->psDeviceNode,
+            psCleanup->psHW2DContextMemInfo);
+
+    
+    OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
                          sizeof(SGX_HW_2D_CONTEXT_CLEANUP),
                          psCleanup,
                          psCleanup->hBlockAlloc);
-       
+                  
 
        return eError;
 }
 
-IMG_EXPORT
-IMG_HANDLE SGXRegisterHW2DContextKM(IMG_HANDLE                         psDeviceNode,
-                                                                       IMG_DEV_VIRTADDR                *psHW2DContextDevVAddr,
+IMG_HANDLE SGXRegisterHW2DContextKM(IMG_HANDLE                         hDeviceNode,
+                                    IMG_CPU_VIRTADDR        *psHW2DContextCpuVAddr,
+                                    IMG_UINT32              ui32HW2DContextSize,
+                                    IMG_UINT32              ui32OffsetToPDDevPAddr,
+                                    IMG_HANDLE              hDevMemContext,
+                                    IMG_DEV_VIRTADDR        *psHW2DContextDevVAddr,
                                                                        PVRSRV_PER_PROCESS_DATA *psPerProc)
 {
        PVRSRV_ERROR eError;
        IMG_HANDLE hBlockAlloc;
        SGX_HW_2D_CONTEXT_CLEANUP *psCleanup;
+    PVRSRV_DEVICE_NODE *psDeviceNode = (PVRSRV_DEVICE_NODE *)hDeviceNode;
+       DEVICE_MEMORY_INFO      *psDevMemoryInfo;
+    DEVICE_MEMORY_HEAP_INFO *psHeapInfo;
+    IMG_HANDLE hDevMemContextInt;
+    MMU_CONTEXT *psMMUContext;
+    IMG_DEV_PHYADDR sPDDevPAddr;
+    int iPtrByte;
+    IMG_UINT8 *pSrc;
+    IMG_UINT8 *pDst;
        PRESMAN_ITEM psResItem;
 
        eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
@@ -978,12 +1302,97 @@ IMG_HANDLE SGXRegisterHW2DContextKM(IMG_HANDLE                           psDeviceNode,
        if (eError != PVRSRV_OK)
        {
                PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHW2DContextKM: Couldn't allocate memory for SGX_HW_2D_CONTEXT_CLEANUP structure"));
-               return IMG_NULL;
+               goto exit0;
        }
 
+       psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo;
+    psHeapInfo = &psDevMemoryInfo->psDeviceMemoryHeap[SGX_KERNEL_DATA_HEAP_ID];
+
+    eError = PVRSRVAllocDeviceMemKM(hDeviceNode,
+                               psPerProc,
+                               psHeapInfo->hDevMemHeap,
+                               PVRSRV_MEM_READ | PVRSRV_MEM_WRITE 
+                                 | PVRSRV_MEM_NO_SYNCOBJ | PVRSRV_MEM_EDM_PROTECT 
+                                 | PVRSRV_MEM_CACHE_CONSISTENT,
+                               ui32HW2DContextSize,
+                               32,
+                               IMG_NULL,
+                               0,
+                               &psCleanup->psHW2DContextMemInfo,
+                               "HW 2D Context");
+
+       if (eError != PVRSRV_OK)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHW2DContextKM: Couldn't allocate device memory for HW Render Context"));
+               goto exit1;
+       }
+
+    eError = OSCopyFromUser(psPerProc,
+                            psCleanup->psHW2DContextMemInfo->pvLinAddrKM,
+                            psHW2DContextCpuVAddr,
+                            ui32HW2DContextSize);
+       if (eError != PVRSRV_OK)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHW2DContextKM: Couldn't copy user-mode copy of HWContext into device memory"));
+               goto exit2;
+       }
+    
+    psHW2DContextDevVAddr->uiAddr = psCleanup->psHW2DContextMemInfo->sDevVAddr.uiAddr;
+
+    
+    eError = PVRSRVLookupHandle(psPerProc->psHandleBase, 
+                           &hDevMemContextInt,
+                           hDevMemContext,
+                           PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT);
+
+    if (eError != PVRSRV_OK)
+    {
+        PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHW2DContextKM: Can't lookup DevMem Context"));
+        goto exit2;
+    }
+
+    psMMUContext = BM_GetMMUContextFromMemContext(hDevMemContextInt);
+    sPDDevPAddr = psDeviceNode->pfnMMUGetPDDevPAddr(psMMUContext);
+
+    
+
+
+
+
+    pSrc = (IMG_UINT8 *)&sPDDevPAddr;
+    pDst = (IMG_UINT8 *)psCleanup->psHW2DContextMemInfo->pvLinAddrKM;
+    pDst += ui32OffsetToPDDevPAddr;
+
+    for (iPtrByte = 0; iPtrByte < sizeof(IMG_DEV_PHYADDR); iPtrByte++)
+    {
+        pDst[iPtrByte] = pSrc[iPtrByte];
+    }
+
+#if defined(PDUMP)
+    
+       PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_CONTINUOUS, "HW 2D context struct");
+
+       PDUMPMEM(
+        IMG_NULL, 
+        psCleanup->psHW2DContextMemInfo,
+        0, 
+        ui32HW2DContextSize, 
+        PDUMP_FLAGS_CONTINUOUS, 
+        MAKEUNIQUETAG(psCleanup->psHW2DContextMemInfo));
+
+    
+       PDUMPCOMMENT("Page directory address in HW 2D transfer context");
+    PDUMPPDDEVPADDR(
+            psCleanup->psHW2DContextMemInfo,
+            ui32OffsetToPDDevPAddr,
+            sPDDevPAddr,
+            MAKEUNIQUETAG(psCleanup->psHW2DContextMemInfo),
+            PDUMP_PD_UNIQUETAG);
+#endif
+
        psCleanup->hBlockAlloc = hBlockAlloc;
        psCleanup->psDeviceNode = psDeviceNode;
-       psCleanup->sHW2DContextDevVAddr = *psHW2DContextDevVAddr;
 
        psResItem = ResManRegisterRes(psPerProc->hResManContext,
                                                                  RESMAN_TYPE_HW_2D_CONTEXT,
@@ -994,18 +1403,24 @@ IMG_HANDLE SGXRegisterHW2DContextKM(IMG_HANDLE                           psDeviceNode,
        if (psResItem == IMG_NULL)
        {
                PVR_DPF((PVR_DBG_ERROR, "SGXRegisterHW2DContextKM: ResManRegisterRes failed"));
-               OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
-                                 sizeof(SGX_HW_2D_CONTEXT_CLEANUP),
-                                 psCleanup,
-                                 psCleanup->hBlockAlloc);
-               
-
-               return IMG_NULL;
+        goto exit2;
        }
 
        psCleanup->psResItem = psResItem;
 
        return (IMG_HANDLE)psCleanup;
+
+exit2:
+    PVRSRVFreeDeviceMemKM(hDeviceNode,
+                         psCleanup->psHW2DContextMemInfo);
+exit1:
+    OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
+              sizeof(SGX_HW_2D_CONTEXT_CLEANUP),
+              psCleanup,
+              psCleanup->hBlockAlloc);
+    
+exit0:
+    return IMG_NULL;
 }
 
 IMG_EXPORT
index bc60fdd..98b2e45 100755 (executable)
@@ -66,13 +66,21 @@ IMG_BOOL SGXIsDevicePowered(PVRSRV_DEVICE_NODE *psDeviceNode);
 
 IMG_IMPORT
 IMG_HANDLE SGXRegisterHWRenderContextKM(IMG_HANDLE                             psDeviceNode,
-                                                                               IMG_DEV_VIRTADDR                *psHWRenderContextDevVAddr,
+                                        IMG_CPU_VIRTADDR        *psHWRenderContextCpuVAddr,
+                                        IMG_UINT32              ui32HWRenderContextSize,
+                                        IMG_UINT32              ui32OffsetToPDDevPAddr,
+                                        IMG_HANDLE              hDevMemContext,
+                                        IMG_DEV_VIRTADDR        *psHWRenderContextDevVAddr,
                                                                                PVRSRV_PER_PROCESS_DATA *psPerProc);
 
 IMG_IMPORT
-IMG_HANDLE SGXRegisterHWTransferContextKM(IMG_HANDLE                           psDeviceNode,
-                                                                                 IMG_DEV_VIRTADDR                      *psHWTransferContextDevVAddr,
-                                                                                 PVRSRV_PER_PROCESS_DATA       *psPerProc);
+IMG_HANDLE SGXRegisterHWTransferContextKM(IMG_HANDLE                 psDeviceNode,
+                                          IMG_CPU_VIRTADDR        *psHWTransferContextCpuVAddr,
+                                          IMG_UINT32              ui32HWTransferContextSize,
+                                          IMG_UINT32              ui32OffsetToPDDevPAddr,
+                                          IMG_HANDLE              hDevMemContext,
+                                          IMG_DEV_VIRTADDR        *psHWTransferContextDevVAddr,
+                                                                                 PVRSRV_PER_PROCESS_DATA *psPerProc);
 
 IMG_IMPORT
 PVRSRV_ERROR SGXFlushHWRenderTargetKM(IMG_HANDLE psSGXDevInfo,
@@ -85,10 +93,26 @@ PVRSRV_ERROR SGXUnregisterHWRenderContextKM(IMG_HANDLE hHWRenderContext, IMG_BOO
 IMG_IMPORT
 PVRSRV_ERROR SGXUnregisterHWTransferContextKM(IMG_HANDLE hHWTransferContext, IMG_BOOL bForceCleanup);
 
+IMG_IMPORT
+PVRSRV_ERROR SGXSetRenderContextPriorityKM(IMG_HANDLE       hDeviceNode,
+                                           IMG_HANDLE       hHWRenderContext,
+                                           IMG_UINT32       ui32Priority,
+                                           IMG_UINT32       ui32OffsetOfPriorityField);
+
+IMG_IMPORT
+PVRSRV_ERROR SGXSetTransferContextPriorityKM(IMG_HANDLE       hDeviceNode,
+                                             IMG_HANDLE       hHWTransferContext,
+                                             IMG_UINT32       ui32Priority,
+                                             IMG_UINT32       ui32OffsetOfPriorityField);
+
 #if defined(SGX_FEATURE_2D_HARDWARE)
 IMG_IMPORT
 IMG_HANDLE SGXRegisterHW2DContextKM(IMG_HANDLE                         psDeviceNode,
-                                                                       IMG_DEV_VIRTADDR                *psHW2DContextDevVAddr,
+                                    IMG_CPU_VIRTADDR        *psHW2DContextCpuVAddr,
+                                    IMG_UINT32              ui32HW2DContextSize,
+                                    IMG_UINT32              ui32OffsetToPDDevPAddr,
+                                    IMG_HANDLE              hDevMemContext,
+                                    IMG_DEV_VIRTADDR        *psHW2DContextDevVAddr,
                                                                        PVRSRV_PER_PROCESS_DATA *psPerProc);
 
 IMG_IMPORT
index 42c976d..50ad94f 100755 (executable)
        #else
        #if SGX_CORE_REV == 106
                #define FIX_HW_BRN_31272
-               #define FIX_HW_BRN_31780
-               #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP)
-                       #define FIX_HW_BRN_33657
-               #endif
+               #define FIX_HW_BRN_31780
                #define FIX_HW_BRN_33920
        #else
        #if SGX_CORE_REV == 110
index 2553022..054845e 100755 (executable)
        #define SGX_FEATURE_EXTENDED_PERF_COUNTERS
        #define SGX_FEATURE_EDM_VERTEX_PDSADDR_FULL_RANGE
        #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING)
-               #if defined(SGX_FEATURE_MP)
-               #define SGX_FEATURE_MASTER_VDM_CONTEXT_SWITCH
-               #endif
-               #define SGX_FEATURE_SLAVE_VDM_CONTEXT_SWITCH
+               #define SGX_FEATURE_SW_VDM_CONTEXT_SWITCH
                #define SGX_FEATURE_SW_ISP_CONTEXT_SWITCH
        #endif
 #else
index 224e922..6c516e0 100755 (executable)
@@ -337,6 +337,7 @@ extern IMG_UINT32 g_ui32EveryLineCounter;
        #define PDUMPMALLOCPAGETABLE    PDumpMallocPageTable
        #define PDUMPSETMMUCONTEXT              PDumpSetMMUContext
        #define PDUMPCLEARMMUCONTEXT    PDumpClearMMUContext
+    #define PDUMPPDDEVPADDR         PDumpPDDevPAddrKM
        #define PDUMPFREEPAGES                  PDumpFreePages
        #define PDUMPFREEPAGETABLE              PDumpFreePageTable
        #define PDUMPPDREG                              PDumpPDReg
@@ -373,6 +374,7 @@ extern IMG_UINT32 g_ui32EveryLineCounter;
                        #define PDUMPMALLOCPAGETABLE(args...)
                        #define PDUMPSETMMUCONTEXT(args...)
                        #define PDUMPCLEARMMUCONTEXT(args...)
+            #define PDUMPPDDEVPADDR(args...)
                        #define PDUMPFREEPAGES(args...)
                        #define PDUMPFREEPAGETABLE(args...)
                        #define PDUMPPDREG(args...)