Skip to content

Commit 840d81c

Browse files
Do not initiate limited range allocator if range above max64 bit address.
Change-Id: If7b0a83c5e5326f2b16d32533d8631ff6ff877cc Signed-off-by: Mrozek, Michal <[email protected]>
1 parent 1bc5f7b commit 840d81c

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

runtime/os_interface/linux/drm_memory_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ DrmMemoryManager::~DrmMemoryManager() {
8585
}
8686

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

unit_tests/mocks/linux/mock_drm_memory_manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
103103

104104
DrmGemCloseWorker *getgemCloseWorker() { return this->gemCloseWorker.get(); }
105105
void forceLimitedRangeAllocator(uint64_t range) { initInternalRangeAllocator(range); }
106+
void releaseLimitedAddressRangeAllocator() { limitedGpuAddressRangeAllocator.reset(nullptr); }
106107

107108
Allocator32bit *getDrmInternal32BitAllocator() const { return internal32bitAllocator.get(); }
108109
AllocatorLimitedRange *getDrmLimitedRangeAllocator() const { return limitedGpuAddressRangeAllocator.get(); }

unit_tests/os_interface/linux/drm_memory_manager_tests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3115,6 +3115,22 @@ TEST_F(DrmMemoryManagerBasic, ifLimitedRangeAllocatorAvailableWhenAskedForAlloca
31153115
limitedRangeAllocator->free(ptr, size);
31163116
}
31173117

3118+
TEST_F(DrmMemoryManagerBasic, givenAddressRangeBelowMax64BitAddressThenLimitedRangeAllocatorIsInitialized) {
3119+
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false, false, false, executionEnvironment));
3120+
memoryManager->releaseLimitedAddressRangeAllocator();
3121+
EXPECT_EQ(nullptr, memoryManager->getDrmLimitedRangeAllocator());
3122+
memoryManager->forceLimitedRangeAllocator(MemoryConstants::max64BitAppAddress - 1);
3123+
EXPECT_NE(nullptr, memoryManager->getDrmLimitedRangeAllocator());
3124+
}
3125+
3126+
TEST_F(DrmMemoryManagerBasic, givenAddressRangeMax64BitWhenMemoryManagerIsCreatedThenLimitedRangeAllocatorIsNotInitialized) {
3127+
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false, false, false, executionEnvironment));
3128+
memoryManager->releaseLimitedAddressRangeAllocator();
3129+
EXPECT_EQ(nullptr, memoryManager->getDrmLimitedRangeAllocator());
3130+
memoryManager->forceLimitedRangeAllocator(MemoryConstants::max64BitAppAddress);
3131+
EXPECT_EQ(nullptr, memoryManager->getDrmLimitedRangeAllocator());
3132+
}
3133+
31183134
TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWithNonZeroBaseAndSizeWhenAskedForBaseThenCorrectBaseIsReturned) {
31193135
uint64_t size = 100u;
31203136
uint64_t base = 0x23000;

0 commit comments

Comments
 (0)