From 3d9e95d177a39ef07f2401b9a1f870b98621f107 Mon Sep 17 00:00:00 2001 From: Maciej Plewka Date: Wed, 27 Mar 2024 16:34:14 +0000 Subject: [PATCH] feature: Bind isa allocations as read only Related-To: NEO-10398 Signed-off-by: Maciej Plewka --- shared/source/memory_manager/graphics_allocation.cpp | 4 ++++ .../memory_manager/graphics_allocation_tests.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/shared/source/memory_manager/graphics_allocation.cpp b/shared/source/memory_manager/graphics_allocation.cpp index d0ea3fd342..73f90dc52e 100644 --- a/shared/source/memory_manager/graphics_allocation.cpp +++ b/shared/source/memory_manager/graphics_allocation.cpp @@ -139,6 +139,10 @@ void GraphicsAllocation::updateCompletionDataForAllocationAndFragments(uint64_t } bool GraphicsAllocation::hasAllocationReadOnlyType() { + if (allocationType == AllocationType::kernelIsa || + allocationType == AllocationType::kernelIsaInternal) { + return true; + } if (debugManager.flags.ReadOnlyAllocationsTypeMask.get() != 0) { UNRECOVERABLE_IF(allocationType == AllocationType::unknown); auto maskVal = debugManager.flags.ReadOnlyAllocationsTypeMask.get(); diff --git a/shared/test/unit_test/memory_manager/graphics_allocation_tests.cpp b/shared/test/unit_test/memory_manager/graphics_allocation_tests.cpp index 7feb3831cf..ac981bacb2 100644 --- a/shared/test/unit_test/memory_manager/graphics_allocation_tests.cpp +++ b/shared/test/unit_test/memory_manager/graphics_allocation_tests.cpp @@ -604,24 +604,24 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationsWhenAllocationTypeIsLinearS graphicsAllocation.allocationType = AllocationType::linearStream; EXPECT_TRUE(graphicsAllocation.hasAllocationReadOnlyType()); } -TEST(GraphicsAllocationTest, givenGraphicsAllocationsWhenAllocationTypeIsKernelIsaAndMaskDoesNotSupportItThenAllocationHasNotReadonlyType) { +TEST(GraphicsAllocationTest, givenGraphicsAllocationsWhenAllocationTypeIsKernelIsaAndMaskDoesNotSupportItThenAllocationHasReadonlyType) { DebugManagerStateRestore restorer; auto mask = 1llu << (static_cast(AllocationType::linearStream) - 1); debugManager.flags.ReadOnlyAllocationsTypeMask.set(mask); MockGraphicsAllocation graphicsAllocation; graphicsAllocation.hasAllocationReadOnlyTypeCallBase = true; graphicsAllocation.allocationType = AllocationType::kernelIsa; - EXPECT_FALSE(graphicsAllocation.hasAllocationReadOnlyType()); + EXPECT_TRUE(graphicsAllocation.hasAllocationReadOnlyType()); } -TEST(GraphicsAllocationTest, givenGraphicsAllocationsWhenAllocationTypeIsInternalIsaAndMaskDoesNotSupportItThenAllocationHasNotReadonlyType) { +TEST(GraphicsAllocationTest, givenGraphicsAllocationsWhenAllocationTypeIsInternalIsaAndMaskDoesNotSupportItThenAllocationHasReadonlyType) { DebugManagerStateRestore restorer; auto mask = 1llu << (static_cast(AllocationType::kernelIsa) - 1); debugManager.flags.ReadOnlyAllocationsTypeMask.set(mask); MockGraphicsAllocation graphicsAllocation; graphicsAllocation.hasAllocationReadOnlyTypeCallBase = true; graphicsAllocation.allocationType = AllocationType::kernelIsaInternal; - EXPECT_FALSE(graphicsAllocation.hasAllocationReadOnlyType()); + EXPECT_TRUE(graphicsAllocation.hasAllocationReadOnlyType()); } TEST(GraphicsAllocationTest, givenGraphicsAllocationsWhenAllocationTypeIsCommandBufferAndMaskDoesNotSupportItThenAllocationHasNotReadonlyType) { DebugManagerStateRestore restorer;