Add preemption WA to make CSR surface uncacheable

Change-Id: Ia468c6f5df16522c3bc9aae22802895f2badc431
This commit is contained in:
Zdanowicz, Zbigniew
2018-01-04 17:48:46 +01:00
committed by sys_ocldev
parent e9fd40db13
commit 21f92d8258
24 changed files with 149 additions and 64 deletions

View File

@ -155,7 +155,8 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo,
if (pDevice->preemptionMode == PreemptionMode::MidThread) {
size_t requiredSize = pHwInfo->pSysInfo->CsrSizeInMb * MemoryConstants::megaByte;
size_t alignment = 256 * MemoryConstants::kiloByte;
auto preemptionAllocation = outDevice.memoryManager->allocateGraphicsMemory(requiredSize, alignment);
bool uncacheable = pDevice->getWaTable()->waCSRUncachable;
auto preemptionAllocation = outDevice.memoryManager->allocateGraphicsMemory(requiredSize, alignment, false, uncacheable);
if (!preemptionAllocation) {
return false;
}

View File

@ -89,6 +89,9 @@ int HwInfoConfigHw<IGFX_SKYLAKE>::configureHardwareCustom(HardwareInfo *hwInfo,
pWaTable->waDisablePerCtxtPreemptionGranularityControl = 1;
pWaTable->waModifyVFEStateAfterGPGPUPreemption = 1;
}
if ((1 << hwInfo->pPlatform->usRevId) & 0x3f) {
pWaTable->waCSRUncachable = 1;
}
if (hwInfo->pPlatform->usDeviceID == ISKL_GT3e_ULT_DEVICE_F0_ID_540 ||
hwInfo->pPlatform->usDeviceID == ISKL_GT3e_ULT_DEVICE_F0_ID_550 ||

View File

@ -100,8 +100,7 @@ uint32_t Gmm::getMOCS(uint32_t type) {
return static_cast<uint32_t>(mocs.DwordValue);
}
Gmm *Gmm::create(const void *alignedPtr, size_t alignedSize) {
Gmm *Gmm::create(const void *alignedPtr, size_t alignedSize, bool uncacheable) {
auto gmm = new Gmm();
gmm->resourceParams.Type = RESOURCE_BUFFER;
@ -109,7 +108,11 @@ Gmm *Gmm::create(const void *alignedPtr, size_t alignedSize) {
gmm->resourceParams.BaseWidth = (uint32_t)alignedSize;
gmm->resourceParams.BaseHeight = 1;
gmm->resourceParams.Depth = 1;
gmm->resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER;
if (!uncacheable) {
gmm->resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER;
} else {
gmm->resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC;
}
gmm->resourceParams.Flags.Info.Linear = 1;
gmm->resourceParams.Flags.Info.Cacheable = 1;
gmm->resourceParams.Flags.Gpu.Texture = 1;

View File

@ -55,7 +55,7 @@ class Gmm {
virtual ~Gmm() = default;
void create();
static Gmm *create(const void *alignedPtr, size_t alignedSize);
static Gmm *create(const void *alignedPtr, size_t alignedSize, bool uncacheable);
static Gmm *create(GMM_RESOURCE_INFO *inputGmm);
static bool initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo);

View File

@ -156,6 +156,7 @@ struct WorkaroundTable {
bool waLLCCachingUnsupported = false;
bool waUseVAlign16OnTileXYBpp816 = false;
bool waModifyVFEStateAfterGPGPUPreemption = false;
bool waCSRUncachable = false;
};
struct HardwareInfo {

View File

@ -81,10 +81,10 @@ class MemoryManager {
}
virtual GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment) {
return allocateGraphicsMemory(size, alignment, false);
return allocateGraphicsMemory(size, alignment, false, false);
}
virtual GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) = 0;
virtual GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) = 0;
virtual GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) = 0;
@ -172,7 +172,7 @@ class MemoryManager {
if (enable64kbpages) {
return allocateGraphicsMemory64kb(size, MemoryConstants::pageSize64k, forcePin);
} else {
return allocateGraphicsMemory(size, MemoryConstants::pageSize, forcePin);
return allocateGraphicsMemory(size, MemoryConstants::pageSize, forcePin, false);
}
}
}

View File

@ -40,7 +40,7 @@ OsAgnosticMemoryManager::~OsAgnosticMemoryManager() {
struct OsHandle {
};
GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) {
GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) {
auto sizeAligned = alignUp(size, MemoryConstants::pageSize);
MemoryAllocation *memoryAllocation = nullptr;
@ -49,6 +49,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory(size_t size,
memoryAllocation = new MemoryAllocation(true, 1, (void *)dummyAddress, static_cast<uint64_t>(dummyAddress), size, counter);
counter++;
memoryAllocation->dummyAllocation = true;
memoryAllocation->uncacheable = uncacheable;
return memoryAllocation;
}
auto ptr = allocateSystemMemory(sizeAligned, alignment ? alignUp(alignment, MemoryConstants::pageSize) : MemoryConstants::pageSize);
@ -59,6 +60,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory(size_t size,
alignedFree(ptr);
return nullptr;
}
memoryAllocation->uncacheable = uncacheable;
allocationMap.insert(std::pair<void *, MemoryAllocation>(ptr, *memoryAllocation));
}
counter++;
@ -66,7 +68,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory(size_t size,
}
GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) {
return allocateGraphicsMemory(alignUp(size, MemoryConstants::pageSize64k), MemoryConstants::pageSize64k, forcePin);
return allocateGraphicsMemory(alignUp(size, MemoryConstants::pageSize64k), MemoryConstants::pageSize64k, forcePin, false);
}
GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemory(size_t size, void *ptr) {

View File

@ -38,6 +38,7 @@ class MemoryAllocation : public GraphicsAllocation {
bool allowAubFileWrite = true;
size_t sizeToFree = 0;
bool dummyAllocation = false;
bool uncacheable = false;
void setSharedHandle(osHandle handle) { this->sharedHandle = handle; }
@ -62,7 +63,7 @@ class OsAgnosticMemoryManager : public MemoryManager {
allocator32Bit = std::unique_ptr<Allocator32bit>(new Allocator32bit(heap32Base, GB - 2 * 4096));
};
~OsAgnosticMemoryManager() override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override;
GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override;
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, void *ptr) override;
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness, bool reuseBO) override;

View File

@ -167,7 +167,7 @@ DrmAllocation *DrmMemoryManager::createGraphicsAllocation(OsHandleStorage &handl
return allocation;
}
DrmAllocation *DrmMemoryManager::allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) {
DrmAllocation *DrmMemoryManager::allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) {
const size_t minAlignment = MemoryConstants::allocationAlignment;
size_t cAlignment = alignUp(std::max(alignment, minAlignment), minAlignment);
// When size == 0 allocate allocationAlignment

View File

@ -43,9 +43,9 @@ class DrmMemoryManager : public MemoryManager {
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
DrmAllocation *allocateGraphicsMemory(size_t size, size_t alignment) override {
return allocateGraphicsMemory(size, alignment, false);
return allocateGraphicsMemory(size, alignment, false, false);
}
DrmAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) override;
DrmAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override;
DrmAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override;
DrmAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override {
return allocateGraphicsMemory(size, ptr, false);

View File

@ -203,6 +203,7 @@ void Wddm::setupWorkaroundTableFromAdapterInfo(WorkaroundTable *table, ADAPTER_I
COPY_WA(waLLCCachingUnsupported, WaLLCCachingUnsupported);
COPY_WA(waUseVAlign16OnTileXYBpp816, WaUseVAlign16OnTileXYBpp816);
COPY_WA(waModifyVFEStateAfterGPGPUPreemption, WaModifyVFEStateAfterGPGPUPreemption);
COPY_WA(waCSRUncachable, WaCSRUncachable);
#undef COPY_WA
}

View File

@ -83,7 +83,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(size_t size, s
WddmAllocation allocation(nullptr, sizeAligned, nullptr, sizeAligned);
gmm = Gmm::create(nullptr, sizeAligned);
gmm = Gmm::create(nullptr, sizeAligned, false);
while (success) {
allocation.gmm = gmm;
@ -108,7 +108,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(size_t size, s
return nullptr;
}
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) {
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) {
size_t newAlignment = alignment ? alignUp(alignment, MemoryConstants::pageSize) : MemoryConstants::pageSize;
size_t sizeAligned = size ? alignUp(size, MemoryConstants::pageSize) : MemoryConstants::pageSize;
void *pSysMem = allocateSystemMemory(sizeAligned, newAlignment);
@ -122,7 +122,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, size_
WddmAllocation allocation(pSysMem, sizeAligned, pSysMem, sizeAligned);
allocation.cpuPtrAllocated = true;
gmm = Gmm::create(pSysMem, sizeAligned);
gmm = Gmm::create(pSysMem, sizeAligned, uncacheable);
while (success) {
allocation.gmm = gmm;
@ -178,7 +178,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemory(size_t size,
allocation.cpuPtrAllocated = cpuPtrAllocated;
allocation.is32BitAllocation = true;
gmm = Gmm::create(ptrAligned, sizeAligned);
gmm = Gmm::create(ptrAligned, sizeAligned, false);
while (success) {
allocation.gmm = gmm;
@ -328,7 +328,7 @@ bool WddmMemoryManager::populateOsHandles(OsHandleStorage &handleStorage) {
handleStorage.fragmentStorageData[i].osHandleStorage = new OsHandle();
handleStorage.fragmentStorageData[i].residency = new ResidencyData();
handleStorage.fragmentStorageData[i].osHandleStorage->gmm = Gmm::create(handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize);
handleStorage.fragmentStorageData[i].osHandleStorage->gmm = Gmm::create(handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize, false);
hostPtrManager.storeFragment(handleStorage.fragmentStorageData[i]);
}
}

View File

@ -44,7 +44,7 @@ class WddmMemoryManager : public MemoryManager {
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override;
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, void *ptr) override;
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness, bool reuseBO) override;