Do not initiate limited range allocator if range above max64 bit address.

Change-Id: If7b0a83c5e5326f2b16d32533d8631ff6ff877cc
Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:
Mrozek, Michal
2019-06-26 09:56:24 +02:00
committed by sys_ocldev
parent 1bc5f7b142
commit 840d81c9fc
3 changed files with 18 additions and 1 deletions

View File

@ -85,7 +85,7 @@ DrmMemoryManager::~DrmMemoryManager() {
}
void DrmMemoryManager::initInternalRangeAllocator(size_t gpuRange) {
if (gpuRange < MemoryConstants::max48BitAddress || !DebugManager.flags.EnableHostPtrTracking.get()) {
if (gpuRange < MemoryConstants::max64BitAppAddress || !DebugManager.flags.EnableHostPtrTracking.get()) {
// set the allocator with the whole reduced address space range - pageSize (base address) to
// avoid starting address of the heap to be 0, which could be interpreted as invalid address
// nullPtr.

View File

@ -103,6 +103,7 @@ class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
DrmGemCloseWorker *getgemCloseWorker() { return this->gemCloseWorker.get(); }
void forceLimitedRangeAllocator(uint64_t range) { initInternalRangeAllocator(range); }
void releaseLimitedAddressRangeAllocator() { limitedGpuAddressRangeAllocator.reset(nullptr); }
Allocator32bit *getDrmInternal32BitAllocator() const { return internal32bitAllocator.get(); }
AllocatorLimitedRange *getDrmLimitedRangeAllocator() const { return limitedGpuAddressRangeAllocator.get(); }

View File

@ -3115,6 +3115,22 @@ TEST_F(DrmMemoryManagerBasic, ifLimitedRangeAllocatorAvailableWhenAskedForAlloca
limitedRangeAllocator->free(ptr, size);
}
TEST_F(DrmMemoryManagerBasic, givenAddressRangeBelowMax64BitAddressThenLimitedRangeAllocatorIsInitialized) {
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false, false, false, executionEnvironment));
memoryManager->releaseLimitedAddressRangeAllocator();
EXPECT_EQ(nullptr, memoryManager->getDrmLimitedRangeAllocator());
memoryManager->forceLimitedRangeAllocator(MemoryConstants::max64BitAppAddress - 1);
EXPECT_NE(nullptr, memoryManager->getDrmLimitedRangeAllocator());
}
TEST_F(DrmMemoryManagerBasic, givenAddressRangeMax64BitWhenMemoryManagerIsCreatedThenLimitedRangeAllocatorIsNotInitialized) {
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false, false, false, executionEnvironment));
memoryManager->releaseLimitedAddressRangeAllocator();
EXPECT_EQ(nullptr, memoryManager->getDrmLimitedRangeAllocator());
memoryManager->forceLimitedRangeAllocator(MemoryConstants::max64BitAppAddress);
EXPECT_EQ(nullptr, memoryManager->getDrmLimitedRangeAllocator());
}
TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWithNonZeroBaseAndSizeWhenAskedForBaseThenCorrectBaseIsReturned) {
uint64_t size = 100u;
uint64_t base = 0x23000;