Skip to content

Commit a09c68f

Browse files
committed
Add Pagetable manager and auxtable support.
Change-Id: I429b52a70c77fc304c65d28d42b18f99b01116d5
1 parent b136069 commit a09c68f

26 files changed

+4403
-164
lines changed

Source/GmmLib/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ set(HEADERS_
191191
${BS_DIR_GMMLIB}/inc/External/Common/GmmConst.h
192192
${BS_DIR_GMMLIB}/inc/External/Common/GmmDebug.h
193193
${BS_DIR_GMMLIB}/inc/External/Common/GmmFormatTable.h
194+
${BS_DIR_GMMLIB}/inc/External/Common/GmmHw.h
194195
${BS_DIR_GMMLIB}/inc/External/Common/GmmInfo.h
195196
${BS_DIR_GMMLIB}/inc/External/Common/GmmInfoExt.h
196197
${BS_DIR_GMMLIB}/inc/External/Common/GmmInternal.h
@@ -205,6 +206,7 @@ set(HEADERS_
205206
${BS_DIR_GMMLIB}/inc/External/Common/GmmTextureExt.h
206207
${BS_DIR_GMMLIB}/inc/External/Common/GmmUtil.h
207208
${BS_DIR_GMMLIB}/inc/External/Linux/GmmResourceInfoLin.h
209+
${BS_DIR_GMMLIB}/inc/External/Linux/GmmResourceInfoLinExt.h
208210
${BS_DIR_GMMLIB}/inc/Internal/Common/Platform/GmmGen10Platform.h
209211
${BS_DIR_GMMLIB}/inc/Internal/Common/Platform/GmmGen11Platform.h
210212
${BS_DIR_GMMLIB}/inc/Internal/Common/Platform/GmmGen12Platform.h
@@ -225,6 +227,7 @@ set(HEADERS_
225227

226228
set(UMD_HEADERS
227229
${HEADERS_}
230+
${BS_DIR_GMMLIB}/inc/External/Common/GmmPageTableMgr.h
228231
${BS_DIR_GMMLIB}/inc/External/Common/GmmClientContext.h
229232
${BS_DIR_GMMLIB}/inc/External/Common/GmmLibDll.h
230233
${BS_DIR_GMMLIB}/inc/External/Common/GmmLibDllName.h
@@ -250,6 +253,7 @@ set(SOURCES_
250253
${BS_DIR_GMMLIB}/Resource/GmmResourceInfoCommon.cpp
251254
${BS_DIR_GMMLIB}/Resource/GmmResourceInfoCommonEx.cpp
252255
${BS_DIR_GMMLIB}/Resource/GmmRestrictions.cpp
256+
${BS_DIR_GMMLIB}/Resource/Linux/GmmResourceInfoLinCWrapper.cpp
253257
${BS_DIR_GMMLIB}/Texture/GmmGen7Texture.cpp
254258
${BS_DIR_GMMLIB}/Texture/GmmGen8Texture.cpp
255259
${BS_DIR_GMMLIB}/Texture/GmmGen9Texture.cpp
@@ -269,6 +273,9 @@ set(SOURCES_
269273

270274
set(UMD_SOURCES
271275
${SOURCES_}
276+
${BS_DIR_GMMLIB}/TranslationTable/GmmAuxTable.cpp
277+
${BS_DIR_GMMLIB}/TranslationTable/GmmPageTableMgr.cpp
278+
${BS_DIR_GMMLIB}/TranslationTable/GmmUmdTranslationTable.cpp
272279
${BS_DIR_GMMLIB}/GlobalInfo/GmmClientContext.cpp
273280
${BS_DIR_GMMLIB}/GlobalInfo/GmmOldApi.cpp
274281
${BS_DIR_GMMLIB}/GlobalInfo/GmmLibDllMain.cpp
@@ -287,13 +294,27 @@ source_group("Source Files\\Cache Policy" ${BS_DIR_GMMLIB}/CachePolicy/*.cpp)
287294
source_group("Source Files\\Global" ${BS_DIR_GMMLIB}/GlobalInfo/.*)
288295
source_group("Source Files\\Platform" ${BS_DIR_GMMLIB}/Platform/.*)
289296
source_group("Source Files\\Texture" ${BS_DIR_GMMLIB}/Texture/.*)
297+
source_group("Source Files\\Translation Table" ${BS_DIR_GMMLIB}/TranslationTable/.*)
290298
source_group("Source Files\\Utility" ${BS_DIR_GMMLIB}/Utility/.*)
291299

292300
source_group("Source Files\\Resource" FILES
293301
${BS_DIR_GMMLIB}/Resource/GmmResourceInfo.cpp
294302
${BS_DIR_GMMLIB}/Resource/GmmResourceInfoCommon.cpp
303+
${BS_DIR_GMMLIB}/Resource/GmmResourceInfoCommonEx.cpp
295304
${BS_DIR_GMMLIB}/Resource/GmmRestrictions.cpp)
296305

306+
source_group("Source Files\\Resource\\Linux" FILES
307+
${BS_DIR_GMMLIB}/Resource/Linux/GmmResourceInfoLinCWrapper.cpp
308+
)
309+
310+
source_group("Source Files\\TranslationTable\\Windows" FILES
311+
${BS_DIR_GMMLIB}/TranslationTable/GmmAuxTable.cpp
312+
${BS_DIR_GMMLIB}/TranslationTable/GmmPageTableMgr.cpp
313+
${BS_DIR_GMMLIB}/TranslationTable/GmmUmdTranslationTable.cpp)
314+
315+
source_group("Source Files\\TranslationTable" FILES
316+
${BS_DIR_GMMLIB}/TranslationTable/GmmUmdTranslationTable.h)
317+
297318
source_group("Header Files\\External\\Common" FILES
298319
${BS_DIR_GMMLIB}/inc/External/Common/GmmCachePolicy.h
299320
${BS_DIR_GMMLIB}/inc/External/Common/GmmCachePolicyCommon.h
@@ -302,6 +323,7 @@ source_group("Header Files\\External\\Common" FILES
302323
${BS_DIR_GMMLIB}/inc/External/Common/GmmConst.h
303324
${BS_DIR_GMMLIB}/inc/External/Common/GmmDebug.h
304325
${BS_DIR_GMMLIB}/inc/External/Common/GmmFormatTable.h
326+
${BS_DIR_GMMLIB}/inc/External/Common/GmmHw.h
305327
${BS_DIR_GMMLIB}/inc/External/Common/GmmInfo.h
306328
${BS_DIR_GMMLIB}/inc/External/Common/GmmInfoExt.h
307329
${BS_DIR_GMMLIB}/inc/External/Common/GmmInternal.h
@@ -331,6 +353,7 @@ source_group("Header Files\\External\\Common\\Cache Policy" FILES
331353

332354
source_group("Header Files\\External\\Linux" FILES
333355
${BS_DIR_GMMLIB}/inc/External/Linux/GmmResourceInfoLin.h
356+
${BS_DIR_GMMLIB}/inc/External/Linux/GmmResourceInfoLinExt.h
334357
)
335358

336359
source_group("Header Files\\Internal\\Common" FILES

Source/GmmLib/GlobalInfo/GmmClientContext.cpp

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
2727
#include "..\..\inc\common\gfxEscape.h"
2828
#include "..\..\..\miniport\LHDM\inc\gmmEscape.h"
2929
#include "Internal\Windows\GmmResourceInfoWinInt.h"
30+
#include "../TranslationTable/GmmUmdTranslationTable.h"
3031
#endif
3132

3233
/////////////////////////////////////////////////////////////////////////////////////
@@ -465,6 +466,40 @@ void GMM_STDCALL GmmLib::GmmClientContext::DestroyResInfoObject(GMM_RESOURCE_INF
465466
}
466467
}
467468

469+
/////////////////////////////////////////////////////////////////////////////////////
470+
/// Member function of ClientContext class for creation of PAgeTableMgr Object .
471+
/// @see GmmLib::GMM_PAGETABLE_MGR::GMM_PAGETABLE_MGR
472+
///
473+
/// @param[in] pDevCb: Pointer to GMM_DEVICE_CALLBACKS_INT
474+
/// @param[in] pTTCB: Pointer to GMM_TRANSLATIONTABLE_CALLBACKS
475+
/// @param[in] TTFags
476+
/// @return Pointer to GMM_PAGETABLE_MGR class.
477+
//TBD: move the code to new overloaded the API and remove this API once all clients are moved to new API.
478+
/////////////////////////////////////////////////////////////////////////////////////
479+
GMM_PAGETABLE_MGR* GMM_STDCALL GmmLib::GmmClientContext::CreatePageTblMgrObject(GMM_DEVICE_CALLBACKS_INT* pDevCb,
480+
uint32_t TTFlags)
481+
{
482+
GMM_PAGETABLE_MGR* pPageTableMgr = NULL;
483+
484+
pPageTableMgr = new GMM_PAGETABLE_MGR(pDevCb, TTFlags, this);
485+
486+
return pPageTableMgr;
487+
}
488+
489+
/////////////////////////////////////////////////////////////////////////////////////
490+
/// Member function of ClientContext class for destroy of PageTableMgr Object .
491+
///
492+
/// @param[in] pPageTableMgr: Pointer to GMM_PAGETABLE_MGR
493+
/// @return void.
494+
/////////////////////////////////////////////////////////////////////////////////////
495+
void GMM_STDCALL GmmLib::GmmClientContext::DestroyPageTblMgrObject(GMM_PAGETABLE_MGR* pPageTableMgr)
496+
{
497+
if (pPageTableMgr)
498+
{
499+
delete pPageTableMgr;
500+
}
501+
}
502+
468503
#ifdef GMM_LIB_DLL
469504
/////////////////////////////////////////////////////////////////////////////////////
470505
/// Member function of ClientContext class for creation of ResourceInfo Object .
@@ -568,6 +603,48 @@ void GMM_STDCALL GmmLib::GmmClientContext::DestroyResInfoObject(GMM_RESOURCE_INF
568603
}
569604
}
570605
#endif
606+
/////////////////////////////////////////////////////////////////////////////////////
607+
/// Member function of ClientContext class for creation of PAgeTableMgr Object .
608+
/// @see GmmLib::GMM_PAGETABLE_MGR::GMM_PAGETABLE_MGR
609+
///
610+
/// @param[in] pDevCb: Pointer to GMM_DEVICE_CALLBACKS_INT
611+
/// @param[in] pTTCB: Pointer to GMM_TRANSLATIONTABLE_CALLBACKS
612+
/// @param[in] TTFags
613+
/// @return Pointer to GMM_PAGETABLE_MGR class.
614+
/// TBD: move the code to new overloaded the API and remove this API once all clients are moved to new API.
615+
/////////////////////////////////////////////////////////////////////////////////////
616+
GMM_PAGETABLE_MGR* GMM_STDCALL GmmLib::GmmClientContext::CreatePageTblMgrObject(
617+
GMM_DEVICE_CALLBACKS_INT* pDevCb,
618+
uint32_t TTFlags,
619+
GmmClientAllocationCallbacks* pAllocCbs)
620+
{
621+
if (!pAllocCbs || !pAllocCbs->pfnAllocation)
622+
{
623+
return CreatePageTblMgrObject(
624+
pDevCb,
625+
TTFlags);
626+
}
627+
else
628+
{
629+
GMM_PAGETABLE_MGR* pPageTableMgr = NULL;
630+
return pPageTableMgr;
631+
}
632+
}
633+
634+
/////////////////////////////////////////////////////////////////////////////////////
635+
/// Member function of ClientContext class for destroy of PageTableMgr Object .
636+
///
637+
/// @param[in] pPageTableMgr: Pointer to GMM_PAGETABLE_MGR
638+
/// @return void.
639+
/////////////////////////////////////////////////////////////////////////////////////
640+
void GMM_STDCALL GmmLib::GmmClientContext::DestroyPageTblMgrObject(GMM_PAGETABLE_MGR* pPageTableMgr,
641+
GmmClientAllocationCallbacks* pAllocCbs)
642+
{
643+
if (!pAllocCbs || !pAllocCbs->pfnFree)
644+
{
645+
return DestroyPageTblMgrObject(pPageTableMgr);
646+
}
647+
}
571648

572649
/////////////////////////////////////////////////////////////////////////////////////
573650
/// Gmm lib DLL exported C wrapper for creating GmmLib::GmmClientContext object

Source/GmmLib/Resource/GmmRestrictions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ void GmmLib::GmmTextureCalc::GetResRestrictions(GMM_TEXTURE_INFO * pTexinfo,
577577
if(pTexinfo->Flags.Info.RenderCompressed ||
578578
pTexinfo->Flags.Info.MediaCompressed)
579579
{
580-
Restrictions.Alignment = GFX_ALIGN(Restrictions.Alignment, GMM_KBYTE(64));
580+
Restrictions.Alignment = GFX_ALIGN(Restrictions.Alignment, (!WA16K ? GMM_KBYTE(64) : GMM_KBYTE(16)));
581581
}
582582

583583
GMM_DPF_EXIT;
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
/*==============================================================================
2+
Copyright(c) 2019 Intel Corporation
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a
5+
copy of this software and associated documentation files(the "Software"),
6+
to deal in the Software without restriction, including without limitation
7+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
and / or sell copies of the Software, and to permit persons to whom the
9+
Software is furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included
12+
in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
OTHER DEALINGS IN THE SOFTWARE.
21+
============================================================================*/
22+
23+
#include "Internal/Common/GmmLibInc.h"
24+
25+
#if defined(__linux__) && !LHDM
26+
#include "Internal/Linux/GmmResourceInfoLinInt.h"
27+
28+
/////////////////////////////////////////////////////////////////////////////////////
29+
/// This is an overloaded function to call DeviceCb Function for CreateAllocation
30+
///
31+
/// @param[in] ClientType
32+
/// @param[in] pDeviceCb: Pointer to GMM_DEVICE_CALLBACKS_INT Struct
33+
/// @param[in] pAllocate: Pointer to GMM_DDI_ALLOCATE Union
34+
/// @return Status of CreateAllocation call.
35+
/////////////////////////////////////////////////////////////////////////////////////
36+
int GmmDeviceCallback(GMM_CLIENT ClientType, GMM_DEVICE_CALLBACKS_INT *pDeviceCb, GMM_DDI_ALLOCATE *pAllocate)
37+
{
38+
int Status = 0;
39+
void * pBo = NULL;
40+
void * pCpuAddr = NULL;
41+
uint64_t gpuAddr = 0ULL;
42+
43+
Status = pDeviceCb->DevCbPtrs_.pfnAllocate(pDeviceCb->pBufMgr,
44+
pAllocate->size,
45+
pAllocate->alignment,
46+
&pBo,
47+
&pCpuAddr,
48+
&gpuAddr);
49+
pAllocate->bo = pBo;
50+
pAllocate->cpuAddr = pCpuAddr;
51+
pAllocate->gfxAddr = gpuAddr;
52+
53+
return Status;
54+
}
55+
56+
/////////////////////////////////////////////////////////////////////////////////////
57+
/// This is an overloaded function to call DeviceCb Function for DestroyAllocation
58+
///
59+
/// @param[in] ClientType
60+
/// @param[in] pDeviceCb: Pointer to GMM_DEVICE_CALLBACKS_INT Struct
61+
/// @param[in] pAllocate: Pointer to GMM_DDI_DEALLOCATE Union
62+
/// @return Status of DestroyAllocation call.
63+
/////////////////////////////////////////////////////////////////////////////////////
64+
int GmmDeviceCallback(GMM_CLIENT ClientType, GMM_DEVICE_CALLBACKS_INT *pDeviceCb, GMM_DDI_DEALLOCATE *pDeallocate)
65+
{
66+
int Status = 0;
67+
68+
pDeviceCb->DevCbPtrs_.pfnDeallocate(pDeallocate->bo);
69+
70+
return Status;
71+
}
72+
73+
/////////////////////////////////////////////////////////////////////////////////////
74+
/// This is an overloaded function to call DeviceCb Function for WaitForSyncObjFromCpu
75+
///
76+
/// @param[in] ClientType
77+
/// @param[in] pDeviceCb: Pointer to GMM_DEVICE_CALLBACKS_INT Struct
78+
/// @param[in] pAllocate: Pointer to GMM_DDI_WAITFORSYNCHRONIZATIONOBJECTFROMCPU Union
79+
/// @return Status of WaitForSyncObjFromCpu call.
80+
/////////////////////////////////////////////////////////////////////////////////////
81+
int GmmDeviceCallback(GMM_CLIENT ClientType, GMM_DEVICE_CALLBACKS_INT *pDeviceCb, GMM_DDI_WAITFORSYNCHRONIZATIONOBJECTFROMCPU *pWait)
82+
{
83+
int Status = 0;
84+
85+
pDeviceCb->DevCbPtrs_.pfnWaitFromCpu(pWait->bo);
86+
87+
return Status;
88+
}
89+
90+
/////////////////////////////////////////////////////////////////////////////////////
91+
/// This function checks for Null DeviceCb Function pointer
92+
///
93+
/// @param[in] ClientType
94+
/// @param[in] pDeviceCb: Pointer to GMM_DEVICE_CALLBACKS_INT Struct
95+
/// @param[in] CallBackType Enum @GMM_DEVICE_CALLBACKS_TYPE
96+
/// @return True if not Null.
97+
/////////////////////////////////////////////////////////////////////////////////////
98+
int GmmCheckForNullDevCbPfn(GMM_CLIENT ClientType, GMM_DEVICE_CALLBACKS_INT *pDeviceCb, GMM_DEVICE_CALLBACKS_TYPE CallBackType)
99+
{
100+
int Status = 0;
101+
102+
switch(CallBackType)
103+
{
104+
case GMM_DEV_CB_ALLOC:
105+
Status = (pDeviceCb->DevCbPtrs_.pfnAllocate != 0);
106+
break;
107+
case GMM_DEV_CB_DEALLOC:
108+
Status = (pDeviceCb->DevCbPtrs_.pfnDeallocate != 0);
109+
break;
110+
case GMM_DEV_CB_WAIT_FROM_CPU:
111+
Status = (pDeviceCb->DevCbPtrs_.pfnWaitFromCpu != 0);
112+
break;
113+
default:
114+
Status = 0;
115+
break;
116+
}
117+
118+
return Status;
119+
}
120+
121+
// Dummy Translation Table Callback for reusing ..
122+
static inline int DummyPrologTranslationTable(void *pDeviceHandle)
123+
{
124+
return 0;
125+
}
126+
127+
static inline int DummyWriteL1Entries(void * pDeviceHandle,
128+
const uint32_t NumEntries,
129+
GMM_GFX_ADDRESS GfxAddress,
130+
uint32_t * Data)
131+
{
132+
return 0;
133+
}
134+
135+
static inline int DummyWriteL2L3Entry(void * pDeviceHandle,
136+
GMM_GFX_ADDRESS GfxAddress,
137+
uint64_t Data)
138+
{
139+
return 0;
140+
}
141+
142+
static inline int DummyWriteFenceID(void * pDeviceHandle,
143+
GMM_GFX_ADDRESS GfxAddress,
144+
uint64_t Data)
145+
{
146+
return 0;
147+
}
148+
149+
static inline int DummyEpilogTranslationTable(void * pDeviceHandle,
150+
uint8_t ForceFlush)
151+
{
152+
return 0;
153+
}
154+
155+
static inline int DummyCopyL1Entry(void * pDeviceHandle,
156+
GMM_GFX_ADDRESS DstGfxAddress,
157+
GMM_GFX_ADDRESS SrcGfxAddress)
158+
{
159+
return 0;
160+
}
161+
162+
static inline int DummyWriteL3Adr(void * pDeviceHandle,
163+
GMM_GFX_ADDRESS L3GfxAddress,
164+
uint64_t RegOffset)
165+
{
166+
return 0;
167+
}
168+
169+
GMM_TRANSLATIONTABLE_CALLBACKS DummyTTCB = {
170+
.pfPrologTranslationTable = DummyPrologTranslationTable,
171+
.pfWriteL1Entries = DummyWriteL1Entries,
172+
.pfWriteL2L3Entry = DummyWriteL2L3Entry,
173+
.pfWriteFenceID = DummyWriteFenceID,
174+
.pfEpilogTranslationTable = DummyEpilogTranslationTable,
175+
.pfCopyL1Entry = DummyCopyL1Entry,
176+
.pfWriteL3Adr = DummyWriteL3Adr,
177+
};
178+
179+
#endif /*__linux__*/

Source/GmmLib/Texture/GmmGen11Texture.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,12 @@ void GmmLib::GmmGen11TextureCalc::FillPlanarOffsetAddress(GMM_TEXTURE_INFO *pTex
321321
GMM_GFX_SIZE_T TileHeight = pPlatform->TileInfo[pTexInfo->TileMode].LogicalTileHeight;
322322
GMM_GFX_SIZE_T TileWidth = pPlatform->TileInfo[pTexInfo->TileMode].LogicalTileWidth;
323323

324-
//U/V must be aligned to AuxT granularity, for 16K AuxT- 4x pitchalign enforces it,
325-
//add extra padding for 64K AuxT
326-
TileHeight *= 1;
324+
if(GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) > IGFX_GEN11LP_CORE)
325+
{
326+
//U/V must be aligned to AuxT granularity, for 16K AuxT- 4x pitchalign enforces it,
327+
//add extra padding for 64K AuxT
328+
TileHeight *= (!GMM_IS_64KB_TILE(pTexInfo->Flags) && !WA16K) ? 4 : 1;
329+
}
327330

328331
*pUOffsetX = GFX_ALIGN(*pUOffsetX, TileWidth);
329332
*pUOffsetY = GFX_ALIGN(*pUOffsetY, TileHeight);

Source/GmmLib/Texture/GmmGen12Texture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmGen12TextureCalc::FillTexPlanar(GMM_TEXTURE_IN
838838

839839
//U/V must be aligned to AuxT granularity, 4x pitchalign enforces 16K-align,
840840
//add extra padding for 64K AuxT
841-
TileHeight *= (!GMM_IS_64KB_TILE(pTexInfo->Flags)) ? 4 : 1;
841+
TileHeight *= (!GMM_IS_64KB_TILE(pTexInfo->Flags) && !WA16K) ? 4 : 1;
842842

843843
if(pTexInfo->Format == GMM_FORMAT_IMC2 || // IMC2, IMC4 needs even tile columns
844844
pTexInfo->Format == GMM_FORMAT_IMC4)

0 commit comments

Comments
 (0)