gpu: pvr: fix init script handling for pdump/non-pdump
authorLuc Verhaegen <libv@codethink.co.uk>
Tue, 5 Apr 2011 12:41:25 +0000 (14:41 +0200)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 20 May 2012 18:43:05 +0000 (21:43 +0300)
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 <libv@codethink.co.uk>
Signed-off-by: Imre Deak <imre.deak@nokia.com>
pvr/sgxinit.c
pvr/sgxscript.h

index c1f0f53..3cd70ec 100644 (file)
@@ -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;
                }
 
        }
index 2bbb0ba..5e02216 100644 (file)
 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 {