gpu: pvr: V2: Find and fix all incorrect sync counter completion checks
authorAlex Crowther <alex.crowther@imgtec.com>
Mon, 23 May 2011 11:46:17 +0000 (12:46 +0100)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 20 May 2012 18:43:05 +0000 (21:43 +0300)
Bugfix for a very rare buffer wrap issue on sync counters
though the use of the wrap safe sync_cnt_after_eq function

Fixes: NB#233069
Signed-off-by: Alex Crowther <alex.crowther@imgtec.com>
pvr/sgxutils.c

index 860cbb6..b5e5b7d 100644 (file)
@@ -644,16 +644,26 @@ enum PVRSRV_ERROR SGXUnregisterHWTransferContextKM(void *hHWTransferContext)
        return PVRSRV_OK;
 }
 
+
+
+static inline int sync_cnt_after_eq(u32 c1, u32 c2)
+{
+       return (int)(c1 - c2) >= 0;
+}
+
+
+
 static inline IMG_BOOL SGX2DQuerySyncOpsComplete(
                                struct PVRSRV_KERNEL_SYNC_INFO *psSyncInfo,
                                u32 ui32ReadOpsPending, u32 ui32WriteOpsPending)
 {
        struct PVRSRV_SYNC_DATA *psSyncData = psSyncInfo->psSyncData;
 
-       return (IMG_BOOL)((psSyncData->ui32ReadOpsComplete >=
-                               ui32ReadOpsPending) &&
-                          (psSyncData->ui32WriteOpsComplete >=
-                               ui32WriteOpsPending));
+       return (IMG_BOOL)(
+               sync_cnt_after_eq(
+                       psSyncData->ui32ReadOpsComplete, ui32ReadOpsPending) &&
+               sync_cnt_after_eq(
+                       psSyncData->ui32WriteOpsComplete, ui32WriteOpsPending));
 }
 
 enum PVRSRV_ERROR SGX2DQueryBlitsCompleteKM(