mirror of https://github.com/intel/gmmlib.git
PVC PAT table implementations
This commit is contained in:
parent
6f0e57a4f6
commit
9e9f8c7dda
|
@ -25,14 +25,14 @@ project(igfx_gmmumd)
|
|||
|
||||
# GmmLib Api Version used for so naming
|
||||
set(GMMLIB_API_MAJOR_VERSION 12)
|
||||
set(GMMLIB_API_MINOR_VERSION 1)
|
||||
set(GMMLIB_API_MINOR_VERSION 2)
|
||||
|
||||
if(NOT DEFINED MAJOR_VERSION)
|
||||
set(MAJOR_VERSION 12)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED MINOR_VERSION)
|
||||
set(MINOR_VERSION 1)
|
||||
set(MINOR_VERSION 2)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED PATCH_VERSION)
|
||||
|
|
|
@ -117,6 +117,25 @@ MEMORY_OBJECT_CONTROL_STATE GMM_STDCALL GmmLib::GmmCachePolicyCommon::CachePolic
|
|||
|
||||
return CachePolicy[GMM_RESOURCE_USAGE_UNKNOWN].MemoryObjectOverride;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
/// A simple getter function returning the PAT (cache policy) for a given
|
||||
/// use Usage of the named resource pResInfo.
|
||||
/// Typically used to populate PPGTT/GGTT.
|
||||
///
|
||||
/// @param[in] pResInfo: Resource info for resource, can be NULL.
|
||||
/// @param[in] Usage: Current usage for resource.
|
||||
///
|
||||
/// @return PATIndex
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
uint32_t GMM_STDCALL GmmLib::GmmCachePolicyCommon::CachePolicyGetPATIndex(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE Usage, bool *pCompressionEnable, bool IsCpuCacheable)
|
||||
{
|
||||
GMM_UNREFERENCED_PARAMETER(pResInfo);
|
||||
GMM_UNREFERENCED_PARAMETER(Usage);
|
||||
GMM_UNREFERENCED_PARAMETER(pCompressionEnable);
|
||||
GMM_UNREFERENCED_PARAMETER(IsCpuCacheable);
|
||||
|
||||
return GMM_PAT_ERROR;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Generates PTE based on resource usage
|
||||
|
|
|
@ -95,6 +95,7 @@ GMM_STATUS GmmLib::GmmGen12dGPUCachePolicy::InitCachePolicy()
|
|||
|
||||
#define L3_UNCACHEABLE (0x1)
|
||||
#define L3_WB_CACHEABLE (0x3)
|
||||
#define L3_PAT_UNCACHEABLE (0x0)
|
||||
|
||||
#define DISABLE_SKIP_CACHING_CONTROL (0x0)
|
||||
#define ENABLE_SKIP_CACHING_CONTROL (0x1)
|
||||
|
@ -105,6 +106,11 @@ GMM_STATUS GmmLib::GmmGen12dGPUCachePolicy::InitCachePolicy()
|
|||
{
|
||||
SetUpMOCSTable();
|
||||
}
|
||||
|
||||
if(GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform) == IGFX_PVC)
|
||||
{
|
||||
SetupPAT();
|
||||
}
|
||||
|
||||
{
|
||||
// Define index of cache element
|
||||
|
@ -121,11 +127,12 @@ GMM_STATUS GmmLib::GmmGen12dGPUCachePolicy::InitCachePolicy()
|
|||
{
|
||||
bool CachePolicyError = false;
|
||||
bool SpecialMOCS = false;
|
||||
int32_t CPTblIdx = -1;
|
||||
uint32_t j = 0;
|
||||
uint64_t PTEValue = 0;
|
||||
GMM_CACHE_POLICY_TBL_ELEMENT UsageEle = {0};
|
||||
uint32_t StartMocsIdx = 0;
|
||||
int32_t CPTblIdx = -1, PATIdx = -1;
|
||||
uint32_t j = 0, i = 0;
|
||||
uint64_t PTEValue = 0;
|
||||
GMM_CACHE_POLICY_TBL_ELEMENT UsageEle = {0};
|
||||
uint32_t StartMocsIdx = 0;
|
||||
GMM_PRIVATE_PAT UsagePATElement = {0};
|
||||
|
||||
|
||||
switch(GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform))
|
||||
|
@ -278,6 +285,44 @@ GMM_STATUS GmmLib::GmmGen12dGPUCachePolicy::InitCachePolicy()
|
|||
{
|
||||
GMM_ASSERTDPF("Cache Policy Init Error: Invalid Cache Programming - Element %d", Usage);
|
||||
}
|
||||
|
||||
if(GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform) == IGFX_PVC)
|
||||
{
|
||||
// PAT data
|
||||
{
|
||||
UsagePATElement.Xe_HPC.Reserved = 0;
|
||||
|
||||
UsagePATElement.Xe_HPC.MemoryType = pCachePolicy[Usage].L3 ? L3_WB_CACHEABLE : L3_PAT_UNCACHEABLE;
|
||||
|
||||
// try to find a match in static PAT table
|
||||
for(i = 0; i <= CurrentMaxPATIndex; i++)
|
||||
{
|
||||
GMM_PRIVATE_PAT PAT = GetPrivatePATEntry(i);
|
||||
if(UsagePATElement.Xe_HPC.MemoryType == PAT.Xe_HPC.MemoryType)
|
||||
{
|
||||
PATIdx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(PATIdx == -1)
|
||||
{
|
||||
GMM_ASSERTDPF(
|
||||
"Cache Policy Init Error: Invalid Cache Programming, too many unique caching combinations"
|
||||
"(we only support NumPATRegisters = %d)",
|
||||
CurrentMaxPATIndex);
|
||||
CachePolicyError = true;
|
||||
// add rterror here <ToDo>
|
||||
PATIdx = PAT0; // default to uncached PAT index 0: GMM_CP_NON_COHERENT_UC
|
||||
// Log Error using regkey to indicate the above error
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pCachePolicy[Usage].PATIndex = PATIdx;
|
||||
pCachePolicy[Usage].PTE.DwordValue = GMM_GET_PTE_BITS_FROM_PAT_IDX(PATIdx) & 0xFFFFFFFF;
|
||||
pCachePolicy[Usage].PTE.HighDwordValue = GMM_GET_PTE_BITS_FROM_PAT_IDX(PATIdx) >> 32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,3 +460,92 @@ void GmmLib::GmmGen12dGPUCachePolicy::SetUpMOCSTable()
|
|||
|
||||
#undef GMM_DEFINE_MOCS
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Function: SetupPAT
|
||||
//
|
||||
// Desc:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Return: GMM_STATUS
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
GMM_STATUS GmmLib::GmmGen12dGPUCachePolicy::SetupPAT()
|
||||
{
|
||||
GMM_PRIVATE_PAT *pPATTlbElement = &(pGmmLibContext->GetPrivatePATTable()[0]);
|
||||
|
||||
#define L3_UC (0x0)
|
||||
#define L3_WC (0x1)
|
||||
#define L3_WT (0x2)
|
||||
#define L3_WB (0x3)
|
||||
|
||||
#define GMM_DEFINE_PAT_ELEMENT(indx, CLOS, L3Caching) \
|
||||
{ \
|
||||
pPATTlbElement[indx].Xe_HPC.MemoryType = L3Caching; \
|
||||
pPATTlbElement[indx].Xe_HPC.L3CLOS = CLOS; \
|
||||
pPATTlbElement[indx].Xe_HPC.Reserved = 0; \
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
||||
// Default PAT Table
|
||||
for (uint32_t i = 0; i < NumPATRegisters; i++)
|
||||
{ // Index CLOS CachingPolicy
|
||||
GMM_DEFINE_PAT_ELEMENT( i, 0 , L3_UC );
|
||||
}
|
||||
|
||||
// Fixed PAT Table
|
||||
// Group: CLOS0
|
||||
// Index CLOS CachingPolicy
|
||||
GMM_DEFINE_PAT_ELEMENT( 0 , 0 , L3_UC ) // PATRegValue = 0x0
|
||||
GMM_DEFINE_PAT_ELEMENT( 1 , 0 , L3_WC ) // PATRegValue = 0x1
|
||||
GMM_DEFINE_PAT_ELEMENT( 2 , 0 , L3_WT ) // PATRegValue = 0x2
|
||||
GMM_DEFINE_PAT_ELEMENT( 3 , 0 , L3_WB ) // PATRegValue = 0x3
|
||||
//Group: CLOS1
|
||||
GMM_DEFINE_PAT_ELEMENT( 4 , 1 , L3_WT ) // PATRegValue = 0x6
|
||||
GMM_DEFINE_PAT_ELEMENT( 5 , 1 , L3_WB ) // PATRegValue = 0x7
|
||||
//Group: CLOS2
|
||||
GMM_DEFINE_PAT_ELEMENT( 6 , 2 , L3_WT ) // PATRegValue = 0xA
|
||||
GMM_DEFINE_PAT_ELEMENT( 7 , 2 , L3_WB ) // PATRegValue = 0xB
|
||||
|
||||
CurrentMaxPATIndex = 7;
|
||||
|
||||
// clang-format on
|
||||
#undef GMM_DEFINE_PAT_ELEMENT
|
||||
#undef L3_UC
|
||||
#undef L3_WC
|
||||
#undef L3_WT
|
||||
#undef L3_WB
|
||||
return GMM_SUCCESS;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
/// A simple getter function returning the PAT (cache policy) for a given
|
||||
/// use Usage of the named resource pResInfo.
|
||||
/// Typically used to populate PPGTT/GGTT.
|
||||
///
|
||||
/// @param[in] pResInfo: Resource info for resource, can be NULL.
|
||||
/// @param[in] Usage: Current usage for resource.
|
||||
///
|
||||
/// @return PATIndex
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
uint32_t GMM_STDCALL GmmLib::GmmGen12dGPUCachePolicy::CachePolicyGetPATIndex(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE Usage, bool *pCompressionEnable, bool IsCpuCacheable)
|
||||
{
|
||||
__GMM_ASSERT(pGmmLibContext->GetCachePolicyElement(Usage).Initialized);
|
||||
GMM_UNREFERENCED_PARAMETER(pCompressionEnable);
|
||||
GMM_UNREFERENCED_PARAMETER(IsCpuCacheable);
|
||||
|
||||
|
||||
// Prevent wrong Usage for XAdapter resources. UMD does not call GetMemoryObject on shader resources but,
|
||||
// when they add it someone could call it without knowing the restriction.
|
||||
if(pResInfo &&
|
||||
pResInfo->GetResFlags().Info.XAdapter &&
|
||||
Usage != GMM_RESOURCE_USAGE_XADAPTER_SHARED_RESOURCE)
|
||||
{
|
||||
__GMM_ASSERT(false);
|
||||
}
|
||||
|
||||
return pGmmLibContext->GetCachePolicyElement(Usage).PATIndex;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,19 @@ MEMORY_OBJECT_CONTROL_STATE GMM_STDCALL GmmLib::GmmClientContext::CachePolicyGet
|
|||
return pGmmLibContext->GetCachePolicyObj()->CachePolicyGetOriginalMemoryObject(pResInfo);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Member function of ClientContext class for returning
|
||||
/// PAT Index for a given Resource Usage Type
|
||||
///
|
||||
/// @param[in] GMM_RESOURCE_INFO : Pointer to ResInfo object
|
||||
/// @param[in] GMM_RESOURCE_USAGE_TYPE : Resource Usage Type
|
||||
/// @return PAT index for the resource of "Usage" type.
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
uint32_t GMM_STDCALL GmmLib::GmmClientContext::CachePolicyGetPATIndex(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE Usage, bool *pCompressionEnable, bool IsCpuCacheable)
|
||||
{
|
||||
return pGmmLibContext->GetCachePolicyObj()->CachePolicyGetPATIndex(pResInfo, Usage, pCompressionEnable, IsCpuCacheable);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Member function of ClientContext class for checking if PTE is cached for a
|
||||
/// given resource usage type
|
||||
|
|
|
@ -218,5 +218,22 @@ TEST_F(CTestXe_HP_CachePolicy, Test_PVC_CachePolicy)
|
|||
{
|
||||
SetUpPlatformVariant(IGFX_PVC);
|
||||
CheckL3CachePolicy();
|
||||
CheckPAT();
|
||||
TearDownPlatformVariant();
|
||||
}
|
||||
|
||||
void CTestXe_HP_CachePolicy::CheckPAT()
|
||||
{
|
||||
// Check Usage PAT index against PAT settings
|
||||
for(unsigned long Usage = GMM_RESOURCE_USAGE_UNKNOWN; Usage < GMM_RESOURCE_USAGE_MAX; Usage++)
|
||||
{
|
||||
GMM_CACHE_POLICY_ELEMENT ClientRequest = pGmmULTClientContext->GetCachePolicyElement((GMM_RESOURCE_USAGE_TYPE)Usage);
|
||||
if(ClientRequest.Initialized == false) // undefined resource in platform
|
||||
{
|
||||
continue;
|
||||
}
|
||||
unsigned long PATIndex = pGmmULTClientContext->CachePolicyGetPATIndex(NULL, (GMM_RESOURCE_USAGE_TYPE)Usage, NULL, false);
|
||||
//printf("Xe HPG: Usage: %d --> PAT Index: [%d]\n", Usage, PATIndex);
|
||||
EXPECT_NE(PATIndex, GMM_PAT_ERROR) << "Usage# " << Usage << ": No matching PAT Index";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ protected:
|
|||
virtual void SetUpPlatformVariant(PRODUCT_FAMILY);
|
||||
virtual void TearDownPlatformVariant();
|
||||
virtual void CheckL3CachePolicy();
|
||||
virtual void CheckPAT();
|
||||
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
|
|
|
@ -24,17 +24,22 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|||
#ifdef __cplusplus
|
||||
#include "../GmmCachePolicyCommon.h"
|
||||
|
||||
#define GMM_NUM_PAT_ENTRIES_Xe_HPC (8)
|
||||
namespace GmmLib
|
||||
{
|
||||
class NON_PAGED_SECTION GmmGen12dGPUCachePolicy :
|
||||
public GmmGen12CachePolicy
|
||||
{
|
||||
protected:
|
||||
uint32_t CurrentMaxPATIndex;
|
||||
public:
|
||||
|
||||
/* Constructors */
|
||||
GmmGen12dGPUCachePolicy(GMM_CACHE_POLICY_ELEMENT *pCachePolicy, Context *pGmmLibContext)
|
||||
: GmmGen12CachePolicy(pCachePolicy, pGmmLibContext)
|
||||
{
|
||||
NumPATRegisters = GMM_NUM_PAT_ENTRIES_Xe_HPC;
|
||||
CurrentMaxPATIndex = 0;
|
||||
}
|
||||
virtual ~GmmGen12dGPUCachePolicy()
|
||||
{
|
||||
|
@ -44,7 +49,8 @@ namespace GmmLib
|
|||
GMM_STATUS InitCachePolicy();
|
||||
void SetUpMOCSTable();
|
||||
int32_t IsSpecialMOCSUsage(GMM_RESOURCE_USAGE_TYPE Usage, bool& UpdateMOCS);
|
||||
|
||||
GMM_STATUS SetupPAT();
|
||||
uint32_t GMM_STDCALL CachePolicyGetPATIndex(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE Usage, bool *pCompressionEnable, bool IsCpuCacheable);
|
||||
};
|
||||
}
|
||||
#endif // #ifdef __cplusplus
|
||||
|
|
|
@ -64,10 +64,17 @@ typedef struct GMM_CACHE_POLICY_ELEMENT_REC
|
|||
};
|
||||
|
||||
MEMORY_OBJECT_CONTROL_STATE MemoryObjectOverride;
|
||||
MEMORY_OBJECT_CONTROL_STATE MemoryObjectNoOverride;
|
||||
GMM_PTE_CACHE_CONTROL_BITS PTE;
|
||||
|
||||
union
|
||||
{
|
||||
MEMORY_OBJECT_CONTROL_STATE MemoryObjectNoOverride;
|
||||
uint32_t PATIndex;
|
||||
};
|
||||
|
||||
GMM_PTE_CACHE_CONTROL_BITS PTE;
|
||||
uint32_t Override;
|
||||
uint32_t IsOverridenByRegkey; // Flag to indicate If usage settings are overridden by regkey
|
||||
|
||||
}GMM_CACHE_POLICY_ELEMENT;
|
||||
|
||||
// One entry in the SKL/CNL cache lookup table
|
||||
|
@ -182,6 +189,13 @@ typedef union GMM_PRIVATE_PAT_REC {
|
|||
uint32_t MemoryType : 2;
|
||||
uint32_t Reserved : 30;
|
||||
}Gen12;
|
||||
|
||||
struct
|
||||
{
|
||||
uint32_t MemoryType : 2; //L3
|
||||
uint32_t L3CLOS : 2;
|
||||
uint32_t Reserved : 28;
|
||||
} Xe_HPC;
|
||||
|
||||
uint32_t Value;
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ namespace GmmLib
|
|||
public GmmMemAllocator
|
||||
{
|
||||
protected:
|
||||
Context * pGmmLibContext;
|
||||
Context * pGmmLibContext;
|
||||
uint32_t NumPATRegisters;
|
||||
|
||||
public:
|
||||
GMM_CACHE_POLICY_ELEMENT *pCachePolicy;
|
||||
|
@ -98,6 +99,7 @@ namespace GmmLib
|
|||
virtual ~GmmCachePolicyCommon()
|
||||
{
|
||||
}
|
||||
virtual uint32_t GMM_STDCALL CachePolicyGetPATIndex(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE Usage, bool *pCompressionEnable, bool IsCpuCacheable);
|
||||
};
|
||||
}
|
||||
#endif // #ifdef __cplusplus
|
||||
|
|
|
@ -171,9 +171,13 @@ namespace GmmLib
|
|||
GmmClientAllocationCallbacks* pAllocCbs);
|
||||
GMM_VIRTUAL GMM_STATUS GMM_STDCALL GmmSetDeviceInfo(GMM_DEVICE_INFO* DeviceInfo);
|
||||
GMM_VIRTUAL GMM_RESOURCE_INFO* GMM_STDCALL CreateCustomResInfoObject(GMM_RESCREATE_CUSTOM_PARAMS* pCreateParams);
|
||||
|
||||
|
||||
#ifndef __GMM_KMD__
|
||||
GMM_VIRTUAL GMM_RESOURCE_INFO *GMM_STDCALL CreateCustomResInfoObject_2(GMM_RESCREATE_CUSTOM_PARAMS_2 *pCreateParams);
|
||||
#endif
|
||||
|
||||
GMM_VIRTUAL uint32_t GMM_STDCALL CachePolicyGetPATIndex(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE Usage, bool *pCompressionEnable, bool IsCpuCacheable);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -135,6 +135,11 @@ typedef uint32_t GMM_GLOBAL_GFX_ADDRESS, GMM_GLOBAL_GFX_SIZE_T;
|
|||
|
||||
#define GMM_BIT_RANGE(endbit, startbit) ((endbit)-(startbit)+1)
|
||||
#define GMM_BIT(bit) (1)
|
||||
#define GMM_GET_PTE_BITS_FROM_PAT_IDX(idx) ((((idx)&__BIT(4)) ? __BIT64(61) : 0) | \
|
||||
(((idx)&__BIT(3)) ? __BIT64(62) : 0) | \
|
||||
(((idx)&__BIT(2)) ? __BIT64(7) : 0) | \
|
||||
(((idx)&__BIT(1)) ? __BIT64(4) : 0) | \
|
||||
(((idx)&__BIT(0)) ? __BIT64(3) : 0) )
|
||||
|
||||
//===========================================================================
|
||||
// typedef:
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace GmmLib
|
|||
// Mutex Object used for synchronization of ProcessSingleton Context
|
||||
static GMM_MUTEX_HANDLE SingletonContextSyncMutex;
|
||||
#endif
|
||||
|
||||
GMM_PRIVATE_PAT PrivatePATTable[GMM_NUM_PAT_ENTRIES];
|
||||
public :
|
||||
//Constructors and destructors
|
||||
Context();
|
||||
|
@ -560,9 +560,20 @@ namespace GmmLib
|
|||
GMM_CACHE_POLICY* GMM_STDCALL CreateCachePolicyCommon();
|
||||
GMM_TEXTURE_CALC* GMM_STDCALL CreateTextureCalc(PLATFORM Platform, bool Override);
|
||||
GMM_PLATFORM_INFO_CLASS *GMM_STDCALL CreatePlatformInfo(PLATFORM Platform, bool Override);
|
||||
|
||||
|
||||
private:
|
||||
void GMM_STDCALL OverrideSkuWa();
|
||||
|
||||
public:
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
/// Returns private PAT table array ptr
|
||||
/// @return PAT array ptr
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
GMM_INLINE GMM_PRIVATE_PAT *GMM_STDCALL GetPrivatePATTable()
|
||||
{
|
||||
return (&PrivatePATTable[0]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Max number of Multi-Adapters allowed in the system
|
||||
|
|
Loading…
Reference in New Issue