From f2713aa461aaccf15652d1131f185b95a1b63021 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen Date: Tue, 5 Apr 2011 14:41:25 +0200 Subject: [PATCH] gpu: pvr: fix init script handling for pdump/non-pdump A PDUMP enabled build has SGX_INIT_OP_HALT shift one up in the enum, as its former position is replaced with SGX_INIT_OP_PDUMP_HW_REG. When kernel and userspace are out of sync, this leads to rather interesting results since the init script is run _before_ userspace build options are compared with the kernel build options. By moving SGX_INIT_OP_PDUMP_HW_REG, and not masking it behind #ifdef PDUMP, we get around this issue for good, without in anyway altering the behavior of a current non-pdump build. Some extra checking of the init script is now also included to catch and warn about all possible cases of kernel and userspace being out of sync, with respect to pdump support (and the new difference in OP_PDUMP_HW_REG). This way, even if we do not make it to the build option checking, we still know what went wrong. This patch requires matching userspace, but only when pdump is enabled. Signed-off-by: Luc Verhaegen Signed-off-by: Imre Deak --- pvr/sgxinit.c | 60 +++++++++++++++++++++++++++++-------------------- pvr/sgxscript.h | 5 ++--- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/pvr/sgxinit.c b/pvr/sgxinit.c index c1f0f53..3cd70ec 100644 --- a/pvr/sgxinit.c +++ b/pvr/sgxinit.c @@ -192,35 +192,47 @@ static enum PVRSRV_ERROR SGXRunScript(struct PVRSRV_SGXDEV_INFO *psDevInfo, ui32PC < ui32NumInitCommands; ui32PC++, psComm++) { switch (psComm->eOp) { case SGX_INIT_OP_WRITE_HW_REG: - { - OSWriteHWReg(psDevInfo->pvRegsBaseKM, - psComm->sWriteHWReg.ui32Offset, - psComm->sWriteHWReg.ui32Value); - PDUMPREG(psComm->sWriteHWReg.ui32Offset, - psComm->sWriteHWReg.ui32Value); - break; + OSWriteHWReg(psDevInfo->pvRegsBaseKM, + psComm->sWriteHWReg.ui32Offset, + psComm->sWriteHWReg.ui32Value); + PDUMPREG(psComm->sWriteHWReg.ui32Offset, + psComm->sWriteHWReg.ui32Value); + break; + case SGX_INIT_OP_HALT: + /* Old OP_PDUMP_HW_REG masked OP_HALT */ + if (psComm->sWriteHWReg.ui32Offset) { + pr_warning("%s: Init Script HALT command " + "contains data!\n", __func__); + pr_warning("PVR: Is userspace built with " + "incompatible PDUMP support?\n"); } -#if defined(PDUMP) + return PVRSRV_OK; case SGX_INIT_OP_PDUMP_HW_REG: - { - PDUMPREG(psComm->sPDumpHWReg.ui32Offset, - psComm->sPDumpHWReg.ui32Value); - break; - } -#endif - case SGX_INIT_OP_HALT: - { - return PVRSRV_OK; +#if defined(PDUMP) + if (!psComm->sPDumpHWReg.ui32Offset && + !psComm->sPDumpHWReg.ui32Value) { + pr_warning("%s: Init Script PDUMP command " + "contains no offset/value!\n", + __func__); + pr_warning("PVR: Is userspace built without " + "PDUMP support?\n"); } - case SGX_INIT_OP_ILLEGAL: + PDUMPREG(psComm->sPDumpHWReg.ui32Offset, + psComm->sPDumpHWReg.ui32Value); + break; +#else + pr_err("%s: Init Script contains PDUMP writes!\n", + __func__); + pr_err("PVR: ERROR: Userspace built with PDUMP " + "support!\n"); + return PVRSRV_ERROR_GENERIC; +#endif /* PDUMP */ + case SGX_INIT_OP_ILLEGAL: default: - { - PVR_DPF(PVR_DBG_ERROR, - "SGXRunScript: PC %d: Illegal command: %d", - ui32PC, psComm->eOp); - return PVRSRV_ERROR_GENERIC; - } + pr_err("PVR: ERROR: %s: PC %d: Illegal operation: " + "0x%02X\n", __func__, ui32PC, psComm->eOp); + return PVRSRV_ERROR_GENERIC; } } diff --git a/pvr/sgxscript.h b/pvr/sgxscript.h index 2bbb0ba..5e02216 100644 --- a/pvr/sgxscript.h +++ b/pvr/sgxscript.h @@ -34,10 +34,9 @@ enum SGX_INIT_OPERATION { SGX_INIT_OP_ILLEGAL = 0, SGX_INIT_OP_WRITE_HW_REG, -#if defined(PDUMP) + /* Do not move this halt, especially not for something like PDUMP. */ + SGX_INIT_OP_HALT, SGX_INIT_OP_PDUMP_HW_REG, -#endif - SGX_INIT_OP_HALT }; union SGX_INIT_COMMAND { -- 2.39.5