From 39828db15f6680fbe6beea814eea20fdf9314d97 Mon Sep 17 00:00:00 2001 From: Alex Crowther Date: Mon, 23 May 2011 12:46:17 +0100 Subject: [PATCH] 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 --- pvr/sgxutils.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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( -- 2.39.2