fix: use full size for HEAP_EXTENDED initialization

Related-To: GSD-8948
Signed-off-by: Jaroslaw Warchulski <jaroslaw.warchulski@intel.com>
This commit is contained in:
Jaroslaw Warchulski
2024-10-18 16:46:00 +00:00
committed by Compute-Runtime-Automation
parent 0e2c5c0129
commit 5afc63df93
5 changed files with 13 additions and 21 deletions

View File

@@ -102,14 +102,15 @@ GfxPartition::~GfxPartition() {
osMemory->releaseCpuAddressRange(reservedCpuAddressRangeForHeapExtended); osMemory->releaseCpuAddressRange(reservedCpuAddressRangeForHeapExtended);
} }
void GfxPartition::Heap::init(uint64_t base, uint64_t size, size_t allocationAlignment) { void GfxPartition::Heap::init(HeapIndex heapIndex, uint64_t base, uint64_t size, size_t allocationAlignment) {
this->base = base; this->base = base;
this->size = size; this->size = size;
auto heapGranularity = GfxPartition::heapGranularity; auto heapGranularity = GfxPartition::heapGranularity;
if (allocationAlignment > heapGranularity) { if (heapIndex == HeapIndex::heapExtended)
heapGranularity = 0;
else if (allocationAlignment > heapGranularity)
heapGranularity = GfxPartition::heapGranularity2MB; heapGranularity = GfxPartition::heapGranularity2MB;
}
// Exclude very first and very last 64K from GPU address range allocation // Exclude very first and very last 64K from GPU address range allocation
if (size > 2 * heapGranularity) { if (size > 2 * heapGranularity) {

View File

@@ -42,11 +42,11 @@ class GfxPartition {
MOCKABLE_VIRTUAL bool init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToReserve, uint32_t rootDeviceIndex, size_t numRootDevices, bool useExternalFrontWindowPool, uint64_t systemMemorySize, uint64_t gfxTop); MOCKABLE_VIRTUAL bool init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToReserve, uint32_t rootDeviceIndex, size_t numRootDevices, bool useExternalFrontWindowPool, uint64_t systemMemorySize, uint64_t gfxTop);
void heapInit(HeapIndex heapIndex, uint64_t base, uint64_t size) { void heapInit(HeapIndex heapIndex, uint64_t base, uint64_t size) {
getHeap(heapIndex).init(base, size, MemoryConstants::pageSize); getHeap(heapIndex).init(heapIndex, base, size, MemoryConstants::pageSize);
} }
void heapInitWithAllocationAlignment(HeapIndex heapIndex, uint64_t base, uint64_t size, size_t allocationAlignment) { void heapInitWithAllocationAlignment(HeapIndex heapIndex, uint64_t base, uint64_t size, size_t allocationAlignment) {
getHeap(heapIndex).init(base, size, allocationAlignment); getHeap(heapIndex).init(heapIndex, base, size, allocationAlignment);
} }
void heapInitExternalWithFrontWindow(HeapIndex heapIndex, uint64_t base, uint64_t size) { void heapInitExternalWithFrontWindow(HeapIndex heapIndex, uint64_t base, uint64_t size) {
@@ -109,7 +109,7 @@ class GfxPartition {
class Heap { class Heap {
public: public:
Heap() = default; Heap() = default;
void init(uint64_t base, uint64_t size, size_t allocationAlignment); void init(HeapIndex heapIndex, uint64_t base, uint64_t size, size_t allocationAlignment);
void initExternalWithFrontWindow(uint64_t base, uint64_t size); void initExternalWithFrontWindow(uint64_t base, uint64_t size);
void initWithFrontWindow(uint64_t base, uint64_t size, uint64_t frontWindowSize); void initWithFrontWindow(uint64_t base, uint64_t size, uint64_t frontWindowSize);
void initFrontWindow(uint64_t base, uint64_t size); void initFrontWindow(uint64_t base, uint64_t size);

View File

@@ -68,7 +68,7 @@ class MockGfxPartition : public GfxPartition {
} }
} }
void initHeap(HeapIndex heapIndex, uint64_t base, uint64_t size, size_t allocationAlignment) { void initHeap(HeapIndex heapIndex, uint64_t base, uint64_t size, size_t allocationAlignment) {
getHeap(heapIndex).init(base, size, allocationAlignment); getHeap(heapIndex).init(heapIndex, base, size, allocationAlignment);
} }
uint32_t freeGpuAddressRangeCalled = 0u; uint32_t freeGpuAddressRangeCalled = 0u;

View File

@@ -876,7 +876,7 @@ HWTEST2_F(MemoryManagerDirectSubmissionImplicitScalingTest, givenDirectSubmissio
} }
} }
TEST(MemoryManagerTest, givenDebugVariableToToggleGpuVaBitsWhenAllocatingResourceInHeapExtendedThenSpecificBitIsToggled) { TEST(MemoryManagerTest, givenDebugVariableToToggleGpuVaBitsWhenAllocatingResourceInHeapExtendedThenCorrectGpuVaIsSet) {
if (defaultHwInfo->capabilityTable.gpuAddressSpace < maxNBitValue(57)) { if (defaultHwInfo->capabilityTable.gpuAddressSpace < maxNBitValue(57)) {
GTEST_SKIP(); GTEST_SKIP();
} }
@@ -905,10 +905,7 @@ TEST(MemoryManagerTest, givenDebugVariableToToggleGpuVaBitsWhenAllocatingResourc
ASSERT_NE(nullptr, allocation); ASSERT_NE(nullptr, allocation);
auto gpuVA = allocation->getGpuAddress(); auto gpuVA = allocation->getGpuAddress();
EXPECT_EQ(gpuVA, 0xff0000ffffff0000);
EXPECT_TRUE(isBitSet(gpuVA, 56));
EXPECT_FALSE(isBitSet(gpuVA, 55));
EXPECT_TRUE(isBitSet(gpuVA, 32));
memoryManager.freeGraphicsMemory(allocation); memoryManager.freeGraphicsMemory(allocation);
} }
@@ -919,10 +916,7 @@ TEST(MemoryManagerTest, givenDebugVariableToToggleGpuVaBitsWhenAllocatingResourc
ASSERT_NE(nullptr, allocation); ASSERT_NE(nullptr, allocation);
auto gpuVA = allocation->getGpuAddress(); auto gpuVA = allocation->getGpuAddress();
EXPECT_EQ(gpuVA, 0xff8000fffffe0000);
EXPECT_TRUE(isBitSet(gpuVA, 56));
EXPECT_TRUE(isBitSet(gpuVA, 55));
EXPECT_TRUE(isBitSet(gpuVA, 32));
memoryManager.freeGraphicsMemory(allocation); memoryManager.freeGraphicsMemory(allocation);
} }
@@ -934,10 +928,7 @@ TEST(MemoryManagerTest, givenDebugVariableToToggleGpuVaBitsWhenAllocatingResourc
ASSERT_NE(nullptr, allocation); ASSERT_NE(nullptr, allocation);
auto gpuVA = allocation->getGpuAddress(); auto gpuVA = allocation->getGpuAddress();
EXPECT_EQ(gpuVA, 0xff0000fefffd0000);
EXPECT_TRUE(isBitSet(gpuVA, 56));
EXPECT_FALSE(isBitSet(gpuVA, 55));
EXPECT_FALSE(isBitSet(gpuVA, 32));
memoryManager.freeGraphicsMemory(allocation); memoryManager.freeGraphicsMemory(allocation);
} }

View File

@@ -6717,7 +6717,7 @@ struct DrmMemoryManagerLocalMemoryAlignmentTest : DrmMemoryManagerWithLocalMemor
bool isAllocationWithinHeap(MemoryManager &memoryManager, const GraphicsAllocation &allocation, HeapIndex heap) { bool isAllocationWithinHeap(MemoryManager &memoryManager, const GraphicsAllocation &allocation, HeapIndex heap) {
const auto allocationStart = allocation.getGpuAddress(); const auto allocationStart = allocation.getGpuAddress();
const auto allocationEnd = allocationStart + allocation.getUnderlyingBufferSize(); const auto allocationEnd = allocationStart + allocation.getUnderlyingBufferSize() - 1;
const auto gmmHelper = device->getGmmHelper(); const auto gmmHelper = device->getGmmHelper();
const auto heapStart = gmmHelper->canonize(memoryManager.getGfxPartition(rootDeviceIndex)->getHeapBase(heap)); const auto heapStart = gmmHelper->canonize(memoryManager.getGfxPartition(rootDeviceIndex)->getHeapBase(heap));
const auto heapEnd = gmmHelper->canonize(memoryManager.getGfxPartition(rootDeviceIndex)->getHeapLimit(heap)); const auto heapEnd = gmmHelper->canonize(memoryManager.getGfxPartition(rootDeviceIndex)->getHeapLimit(heap));