Stop-gap fix in xgi_submit_cmdlist
authorIan Romanick <idr@us.ibm.com>
Sat, 30 Jun 2007 04:05:16 +0000 (21:05 -0700)
committerIan Romanick <idr@us.ibm.com>
Sat, 30 Jun 2007 04:05:16 +0000 (21:05 -0700)
Comment in the code explains it.  Basically, I put an if-statement
around a block of code to prevent a NULL pointer dereference that
should never happen in the first place.  Eventually, this will need to
come out.

linux-core/xgi_cmdlist.c

index b67a40f..f8aacea 100644 (file)
@@ -198,17 +198,24 @@ void xgi_submit_cmdlist(struct xgi_info * info, struct xgi_cmd_info * pCmdInfo)
                    (U32 *) xgi_find_pcie_virt(info,
                                               s_cmdring._lastBatchStartAddr);
 
-               lastBatchVirtAddr[1] =
-                   BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize;
-               lastBatchVirtAddr[2] = pCmdInfo->_firstBeginAddr >> 4;
-               lastBatchVirtAddr[3] = 0;
-               //barrier();
-               lastBatchVirtAddr[0] =
-                   (beginPort << 22) + (BEGIN_VALID_MASK) +
-                   (0xffff & pCmdInfo->_curDebugID);
-
-               /* Jong 06/12/2006; system hang; marked for test */
-               triggerHWCommandList(info, pCmdInfo->_beginCount);
+               /* lastBatchVirtAddr should *never* be NULL.  However, there
+                * are currently some bugs that cause this to happen.  The
+                * if-statement here prevents some fatal (i.e., hard lock
+                * requiring the reset button) oopses.
+                */
+               if (lastBatchVirtAddr) {
+                       lastBatchVirtAddr[1] =
+                               BEGIN_LINK_ENABLE_MASK + pCmdInfo->_firstSize;
+                       lastBatchVirtAddr[2] = pCmdInfo->_firstBeginAddr >> 4;
+                       lastBatchVirtAddr[3] = 0;
+                       //barrier();
+                       lastBatchVirtAddr[0] =
+                               (beginPort << 22) + (BEGIN_VALID_MASK) +
+                               (0xffff & pCmdInfo->_curDebugID);
+
+                       /* Jong 06/12/2006; system hang; marked for test */
+                       triggerHWCommandList(info, pCmdInfo->_beginCount);
+               }
 
                XGI_INFO
                    ("Jong-xgi_submit_cmdlist-s_cmdring._lastBatchStartAddr != 0 - End\n");