[Mesa-dev] [PATCH 021/140] amdgpu/addrlib: Fix invalid access to m_tileTable

Marek Olšák maraeo at gmail.com
Mon Mar 20 22:42:31 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Sometimes client driver passes valid tile info into address library,
in this case, the tile index is computed in function
HwlPostCheckTileIndex instead of CiAddrLib::HwlSetupTileCfg.
We need to call HwlPostCheckTileIndex to calculate the correct tile
index to get tile split bytes for this case.
---
 src/amd/addrlib/r800/ciaddrlib.cpp | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/amd/addrlib/r800/ciaddrlib.cpp b/src/amd/addrlib/r800/ciaddrlib.cpp
index 57416dc..ccb0528 100644
--- a/src/amd/addrlib/r800/ciaddrlib.cpp
+++ b/src/amd/addrlib/r800/ciaddrlib.cpp
@@ -1270,28 +1270,39 @@ VOID CiAddrLib::HwlSetupTileInfo(
         pOut->tileIndex = 8;
         *pTileInfo = m_tileTable[8].info;
     }
 
     // Turn off tcCompatible for color surface if tileSplit happens. Depth/stencil is
     // handled at tileIndex selecting time.
     if (pOut->tcCompatible && (inTileType != ADDR_DEPTH_SAMPLE_ORDER))
     {
         if (IsMacroTiled(tileMode))
         {
-            // Non-depth entries store a split factor
-            UINT_32 sampleSplit = m_tileTable[pOut->tileIndex].info.tileSplitBytes;
-            UINT_32 tileBytes1x = BITS_TO_BYTES(bpp * MicroTilePixels * thickness);
-            UINT_32 colorTileSplit = Max(256u, sampleSplit * tileBytes1x);
+            UINT_32 tileIndex = static_cast<UINT_32>(pOut->tileIndex);
 
-            if (m_rowSize < colorTileSplit)
+            if ((tileIndex == TileIndexInvalid) && (IsTileInfoAllZero(pTileInfo) == FALSE))
             {
-                pOut->tcCompatible = FALSE;
+                tileIndex = HwlPostCheckTileIndex(pTileInfo, tileMode, inTileType, tileIndex);
+            }
+
+            if (tileIndex != TileIndexInvalid)
+            {
+                ADDR_ASSERT(tileIndex < TileTableSize);
+                // Non-depth entries store a split factor
+                UINT_32 sampleSplit = m_tileTable[tileIndex].info.tileSplitBytes;
+                UINT_32 tileBytes1x = BITS_TO_BYTES(bpp * MicroTilePixels * thickness);
+                UINT_32 colorTileSplit = Max(256u, sampleSplit * tileBytes1x);
+
+                if (m_rowSize < colorTileSplit)
+                {
+                    pOut->tcCompatible = FALSE;
+                }
             }
         }
         else
         {
             // Client should not enable tc compatible for linear and 1D tile modes.
             pOut->tcCompatible = FALSE;
         }
     }
 }
 
-- 
2.7.4



More information about the mesa-dev mailing list