From 3a81dbb2504c2c54e5fdb757a56ca4f98b45d7c7 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen Date: Fri, 1 Apr 2011 13:50:10 +0200 Subject: [PATCH 01/16] gpu: pvr: fix pdumpfs_stream_buffer_clear Fix tmp[] filling loop so that size == sizeof(tmp) also functions correctly. Spotted-by: Phil Carmody Signed-off-by: Luc Verhaegen Signed-off-by: Imre Deak --- pvr/pvr_pdumpfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvr/pvr_pdumpfs.c b/pvr/pvr_pdumpfs.c index 6050fd3..c1b7df5 100644 --- a/pvr/pvr_pdumpfs.c +++ b/pvr/pvr_pdumpfs.c @@ -786,7 +786,7 @@ pdumpfs_stream_buffer_clear(char __user *buf, size_t size) if (size >= sizeof(tmp)) { int i; - for (i = 0; (i + sizeof(tmp)) < size; i += sizeof(tmp)) + for (i = 0; (i + sizeof(tmp)) <= size; i += sizeof(tmp)) if (copy_to_user(buf + i, tmp, sizeof(tmp))) return -EFAULT; return i; -- 2.39.5 From 3da17c84d6dcdb0357aa1f2fa175b86af1cef28e Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Tue, 19 Apr 2011 19:57:42 +0300 Subject: [PATCH 02/16] gpu: pvr: fix missing return value warning when CONFIG_BUG=n Although the behaviour after these functions return in a BUG() condition is undefined, we could still make things somewhat more predictable by returning the same value every time. Also this way we get rid of the warning. Signed-off-by: Imre Deak --- pvr/pvr_debugfs.c | 2 ++ pvr/sysconfig.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pvr/pvr_debugfs.c b/pvr/pvr_debugfs.c index 9636d02..32ca6c3 100644 --- a/pvr/pvr_debugfs.c +++ b/pvr/pvr_debugfs.c @@ -109,6 +109,8 @@ static int pvr_debugfs_reset_wrapper(void *data, u64 val) return pvr_debugfs_reset(data, val); BUG(); + + return -EFAULT; } DEFINE_SIMPLE_ATTRIBUTE(pvr_debugfs_reset_fops, NULL, diff --git a/pvr/sysconfig.c b/pvr/sysconfig.c index 94f18f6..2a31b70 100644 --- a/pvr/sysconfig.c +++ b/pvr/sysconfig.c @@ -160,6 +160,8 @@ unsigned long sgx_get_max_freq(void) } } BUG(); + + return 0; } #else -- 2.39.5 From 39828db15f6680fbe6beea814eea20fdf9314d97 Mon Sep 17 00:00:00 2001 From: Alex Crowther Date: Mon, 23 May 2011 12:46:17 +0100 Subject: [PATCH 03/16] 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.5 From 68eb886306bab51a43cb326ccafc0244f9f8e4e5 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen Date: Wed, 18 May 2011 10:01:40 +0200 Subject: [PATCH 04/16] gpu: pvr: kick: check for duplicate src syncs When duplicate syncs are present, we deadlock; so check and throw an error message. Was already fixed in userspace as part of #253237, this now shores up the kernel too. Fixes: NB#254225 Signed-off-by: Luc Verhaegen --- pvr/sgxkick.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/pvr/sgxkick.c b/pvr/sgxkick.c index 0a951e0..c3891a6 100644 --- a/pvr/sgxkick.c +++ b/pvr/sgxkick.c @@ -160,31 +160,50 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, } } - psTACmd->ui32NumSrcSyncs = psCCBKick->ui32NumSrcSyncs; - for (i = 0; i < SGX_MAX_SRC_SYNCS; i++) { - if (i >= psCCBKick->ui32NumSrcSyncs) { - pvr_trcmd_clear_syn(&ktrace->src_syn[i]); - continue; + /* check for duplicates while creating the new list */ + psTACmd->ui32NumSrcSyncs = 0; + for (i = 0; ((i < SGX_MAX_SRC_SYNCS) && + (i < psCCBKick->ui32NumSrcSyncs)); i++) { + int j; + + psSyncInfo = (struct PVRSRV_KERNEL_SYNC_INFO *) + psCCBKick->ahSrcKernelSyncInfo[i]; + + for (j = 0; j < i; j++) { + struct PVRSRV_KERNEL_SYNC_INFO *tmp = + psCCBKick->ahSrcKernelSyncInfo[j]; + if (tmp->psSyncData == psSyncInfo->psSyncData) { + pr_err("%s: Duplicate SRC Sync detected: %p\n", + __func__, tmp->psSyncData); + break; + } } + if (j != i) + continue; - psSyncInfo = - (struct PVRSRV_KERNEL_SYNC_INFO *)psCCBKick-> - ahSrcKernelSyncInfo[i]; + /* beat the 80 char limit. */ + j = psTACmd->ui32NumSrcSyncs; - psTACmd->asSrcSyncs[i].sWriteOpsCompleteDevVAddr = + psTACmd->asSrcSyncs[j].sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; - psTACmd->asSrcSyncs[i].sReadOpsCompleteDevVAddr = + psTACmd->asSrcSyncs[j].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; - psTACmd->asSrcSyncs[i].ui32ReadOpsPendingVal = + psTACmd->asSrcSyncs[j].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending++; - psTACmd->asSrcSyncs[i].ui32WriteOpsPendingVal = + psTACmd->asSrcSyncs[j].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; - pvr_trcmd_set_syn(&ktrace->src_syn[i], psSyncInfo); + pvr_trcmd_set_syn(&ktrace->src_syn[j], psSyncInfo); + + psTACmd->ui32NumSrcSyncs++; } + /* clear the remaining src syncs */ + for (i = psTACmd->ui32NumSrcSyncs; i < SGX_MAX_SRC_SYNCS; i++) + pvr_trcmd_clear_syn(&ktrace->src_syn[i]); + if (psCCBKick->bFirstKickOrResume && psCCBKick->ui32NumDstSyncObjects > 0) { struct PVRSRV_KERNEL_MEM_INFO *psHWDstSyncListMemInfo = -- 2.39.5 From b929baebed31b165151dd3d528d1de7e16021d0e Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Sat, 19 May 2012 18:07:57 +0300 Subject: [PATCH 05/16] merge in sgx-util.h from n900 tree --- pvr/omaplfb_displayclass.c | 39 +++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/pvr/omaplfb_displayclass.c b/pvr/omaplfb_displayclass.c index 4348b2e..ae6cce4 100644 --- a/pvr/omaplfb_displayclass.c +++ b/pvr/omaplfb_displayclass.c @@ -33,7 +33,6 @@ #include #include -#include