From: Alex Crowther Date: Mon, 23 May 2011 11:46:17 +0000 (+0100) Subject: gpu: pvr: V2: Find and fix all incorrect sync counter completion checks X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39828db15f6680fbe6beea814eea20fdf9314d97;p=sgx.git gpu: pvr: V2: Find and fix all incorrect sync counter completion checks 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 --- diff --git a/pvr/sgxutils.c b/pvr/sgxutils.c index 860cbb6..b5e5b7d 100644 --- a/pvr/sgxutils.c +++ b/pvr/sgxutils.c @@ -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(