gpu: pvr: Increase the max number of 3D TA status vals in kick requests
authorImre Deak <imre.deak@nokia.com>
Wed, 15 Sep 2010 10:54:29 +0000 (13:54 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 20 May 2012 18:09:42 +0000 (21:09 +0300)
This is needed to support the to-be-added fence sync mechanism in
the user space part. The change involves an ABI change, to make
the transition smooth keep support for the old format as well.

Signed-off-by: Imre Deak <imre.deak@nokia.com>
pvr/bridged_sgx_bridge.c
pvr/sgx_bridge_km.h
pvr/sgxapi_km.h
pvr/sgxinfo.h
pvr/sgxkick.c

index 67040a6..ff80932 100644 (file)
@@ -129,6 +129,30 @@ int SGXGetInternalDevInfoBW(u32 ui32BridgeID,
        return 0;
 }
 
+/* Convert the IOCTL parameter from "old" to "new" format. */
+static int kick_compat_conv(struct PVRSRV_BRIDGE_IN_DOKICK *kick,
+                           size_t in_size)
+{
+       struct SGX_CCB_KICK *ccb;
+       size_t diff;
+
+       ccb = &kick->sCCBKick;
+
+       diff = sizeof(ccb->ah3DStatusSyncInfo[0]) *
+               (SGX_MAX_3D_STATUS_VALS - SGX_MAX_3D_STATUS_VALS_OLD);
+       if (sizeof(*kick) - in_size != diff)
+               return -EINVAL;
+
+       /* Trailing size at the end of struct to move. */
+       diff = sizeof(*kick) - offsetof(typeof(*kick),
+                       sCCBKick.ah3DStatusSyncInfo[SGX_MAX_3D_STATUS_VALS]);
+       memmove(&kick->sCCBKick.ah3DStatusSyncInfo[SGX_MAX_3D_STATUS_VALS],
+               &kick->sCCBKick.ah3DStatusSyncInfo[SGX_MAX_3D_STATUS_VALS_OLD],
+               diff);
+
+       return 0;
+}
+
 int SGXDoKickBW(u32 ui32BridgeID,
                       struct PVRSRV_BRIDGE_IN_DOKICK *psDoKickIN,
                       struct PVRSRV_BRIDGE_RETURN *psRetOUT,
@@ -136,10 +160,20 @@ int SGXDoKickBW(u32 ui32BridgeID,
                       struct PVRSRV_PER_PROCESS_DATA *psPerProc)
 {
        void *hDevCookieInt;
+       int max_3dstat_vals;
        u32 i;
 
        PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_DOKICK);
 
+       max_3dstat_vals = SGX_MAX_3D_STATUS_VALS;
+       if (unlikely(in_size) != sizeof(*psDoKickIN)) {
+               max_3dstat_vals = SGX_MAX_3D_STATUS_VALS_OLD;
+               if (kick_compat_conv(psDoKickIN, in_size) != 0) {
+                       psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
+                       return -EINVAL;
+               }
+
+       }
        psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
                                              &hDevCookieInt,
                                              psDoKickIN->hDevCookie,
@@ -255,7 +289,8 @@ int SGXDoKickBW(u32 ui32BridgeID,
                        return 0;
        }
 
-       psRetOUT->eError = SGXDoKickKM(hDevCookieInt, &psDoKickIN->sCCBKick);
+       psRetOUT->eError = SGXDoKickKM(hDevCookieInt, &psDoKickIN->sCCBKick,
+                                       max_3dstat_vals);
 
        return 0;
 }
index 2819a7e..3389b0c 100644 (file)
@@ -39,8 +39,8 @@ enum PVRSRV_ERROR SGXSubmitTransferKM(void *hDevHandle,
                struct PVRSRV_TRANSFER_SGX_KICK *psKick);
 
 
-enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle,
-                                 struct SGX_CCB_KICK *psCCBKick);
+enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick,
+                             int max_3dstat_val);
 
 enum PVRSRV_ERROR SGXGetPhysPageAddrKM(void *hDevMemHeap,
                struct IMG_DEV_VIRTADDR sDevVAddr,
index a1ac0fe..8ca76ff 100644 (file)
@@ -50,7 +50,8 @@
 #define SGX_MAX_HEAP_ID                                        10
 
 #define SGX_MAX_TA_STATUS_VALS                         32
-#define SGX_MAX_3D_STATUS_VALS                         2
+#define SGX_MAX_3D_STATUS_VALS_OLD                     2
+#define SGX_MAX_3D_STATUS_VALS                         4
 
 #define SGX_MAX_SRC_SYNCS                              4
 
index 1245140..11f599f 100644 (file)
@@ -246,6 +246,10 @@ struct SGXMKIF_CMDTA_SHARED {
        struct PVRSRV_DEVICE_SYNC_OBJECT asSrcSyncs[SGX_MAX_SRC_SYNCS];
 
        struct CTL_STATUS sCtlTAStatusInfo[SGX_MAX_TA_STATUS_VALS];
+       /*
+        * Note that the actual size of sCtl3DStatusInfo changes based
+        * on the IOCTL ABI version used.
+        */
        struct CTL_STATUS sCtl3DStatusInfo[SGX_MAX_3D_STATUS_VALS];
 
        struct PVRSRV_DEVICE_SYNC_OBJECT sTA3DDependency;
index d6ccb1f..3232526 100644 (file)
@@ -37,8 +37,8 @@
 #include "pvr_debug.h"
 #include "sgxutils.h"
 
-enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle,
-                                 struct SGX_CCB_KICK *psCCBKick)
+enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick,
+                             int max_3dstat_vals)
 {
        enum PVRSRV_ERROR eError;
        struct PVRSRV_KERNEL_SYNC_INFO *psSyncInfo;
@@ -67,12 +67,26 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle,
                                 psCCBKick, ui32CCBOffset);
 
        if (psCCBKick->hTA3DSyncInfo) {
+               struct PVRSRV_DEVICE_SYNC_OBJECT *ta3d_dep;
+
                psSyncInfo =
                    (struct PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->hTA3DSyncInfo;
-               psTACmd->sTA3DDependency.sWriteOpsCompleteDevVAddr =
+
+               ta3d_dep = &psTACmd->sTA3DDependency;
+               /*
+                * Ugly hack to account for the two possible sizes of
+                * struct SGXMKIF_CMDTA_SHARED which is based on the
+                * corresponding IOCTL ABI version used.
+                */
+               if (max_3dstat_vals != SGX_MAX_3D_STATUS_VALS)
+                       ta3d_dep =  (struct PVRSRV_DEVICE_SYNC_OBJECT *)
+                               ((u8 *)ta3d_dep - sizeof(struct CTL_STATUS) *
+                                (SGX_MAX_3D_STATUS_VALS - max_3dstat_vals));
+
+               ta3d_dep->sWriteOpsCompleteDevVAddr =
                    psSyncInfo->sWriteOpsCompleteDevVAddr;
 
-               psTACmd->sTA3DDependency.ui32WriteOpsPendingVal =
+               ta3d_dep->ui32WriteOpsPendingVal =
                    psSyncInfo->psSyncData->ui32WriteOpsPending;
 
                if (psCCBKick->bTADependency)