diff --git a/shared/source/os_interface/linux/drm_buffer_object.h b/shared/source/os_interface/linux/drm_buffer_object.h index 7c60c9a8a9..978fdba16b 100644 --- a/shared/source/os_interface/linux/drm_buffer_object.h +++ b/shared/source/os_interface/linux/drm_buffer_object.h @@ -10,6 +10,7 @@ #include "shared/source/command_stream/task_count_helper.h" #include "shared/source/helpers/common_types.h" #include "shared/source/helpers/constants.h" +#include "shared/source/memory_manager/allocation_type.h" #include "shared/source/memory_manager/definitions/engine_limits.h" #include "shared/source/memory_manager/memory_operations_status.h" #include "shared/source/os_interface/linux/cache_info.h" @@ -213,6 +214,14 @@ class BufferObject { bool isChunked = false; + void setIsImage(AllocationType type) { + this->isImageAllocation = type == AllocationType::image; + } + + bool isImage() const { + return this->isImageAllocation; + } + protected: MOCKABLE_VIRTUAL MemoryOperationsStatus evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded); @@ -230,6 +239,7 @@ class BufferObject { bool allowCapture = false; bool requiresImmediateBinding = false; bool requiresExplicitResidency = false; + bool isImageAllocation = false; MOCKABLE_VIRTUAL void fillExecObject(ExecObject &execObject, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId); void printBOBindingResult(OsContext *osContext, uint32_t vmHandleId, bool bind, int retVal); diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index d9f45e9f0f..4a71b05489 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -678,6 +678,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A return nullptr; } bo->setAddress(gpuRange); + bo->setIsImage(allocationData.type); [[maybe_unused]] auto ret2 = bo->setTiling(ioctlHelper->getDrmParamValue(DrmParam::tilingY), static_cast(allocationData.imgInfo->rowPitch)); DEBUG_BREAK_IF(ret2 != true); @@ -1067,6 +1068,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o drmAllocation->setDefaultGmm(gmm); bo->setPatIndex(drm.getPatIndex(gmm, properties.allocationType, CacheRegion::defaultRegion, CachePolicy::writeBack, false, MemoryPoolHelper::isSystemMemoryPool(memoryPool))); + bo->setIsImage(properties.allocationType); } if (!reuseSharedAllocation) { @@ -1897,6 +1899,7 @@ BufferObject *DrmMemoryManager::createBufferObjectInMemoryRegion(uint32_t rootDe } bo->setAddress(gpuAddress); + bo->setIsImage(allocationType); return bo; } diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index 0d7a96f298..25f81d86af 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -688,7 +688,7 @@ uint32_t Drm::getVirtualMemoryAddressSpace(uint32_t vmId) const { } void Drm::setNewResourceBoundToVM(BufferObject *bo, uint32_t vmHandleId) { - if (!this->rootDeviceEnvironment.getProductHelper().isTlbFlushRequired()) { + if (!this->rootDeviceEnvironment.getProductHelper().isTlbFlushRequired(*this->getHardwareInfo(), bo->isImage())) { return; } const auto &engines = this->rootDeviceEnvironment.executionEnvironment.memoryManager->getRegisteredEngines(bo->getRootDeviceIndex()); diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 86cbae4a14..457c35430c 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -159,7 +159,7 @@ class ProductHelper { virtual bool isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ, TaskCountType queueTaskCount, const CommandStreamReceiver &queueCsr) const = 0; virtual bool isMidThreadPreemptionDisallowedForRayTracingKernels() const = 0; virtual bool isBufferPoolAllocatorSupported() const = 0; - virtual bool isTlbFlushRequired() const = 0; + virtual bool isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const = 0; virtual bool isDummyBlitWaRequired() const = 0; virtual bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled) const = 0; virtual bool isLinearStoragePreferred(bool isImage1d, bool forceLinearStorage) const = 0; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index 421f938b53..d2e3a4cc7a 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -61,7 +61,7 @@ void ProductHelperHw::adjustSamplerState(void *sampler, const Hardwa } template -bool ProductHelperHw::isTlbFlushRequired() const { +bool ProductHelperHw::isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const { bool tlbFlushRequired = true; if (debugManager.flags.ForceTlbFlush.get() != -1) { tlbFlushRequired = !!debugManager.flags.ForceTlbFlush.get(); diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index 4158581fe7..f51516e87e 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -112,7 +112,7 @@ class ProductHelperHw : public ProductHelper { bool isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ, TaskCountType queueTaskCount, const CommandStreamReceiver &queueCsr) const override; bool isMidThreadPreemptionDisallowedForRayTracingKernels() const override; bool isBufferPoolAllocatorSupported() const override; - bool isTlbFlushRequired() const override; + bool isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const override; bool isDummyBlitWaRequired() const override; bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled) const override; bool isLinearStoragePreferred(bool isImage1d, bool forceLinearStorage) const override; diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index 623b5e72d7..70c0ae4052 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -1349,7 +1349,7 @@ void Wddm::populateIpVersion(HardwareInfo &hwInfo) { } void Wddm::setNewResourceBoundToPageTable() { - if (!this->rootDeviceEnvironment.getProductHelper().isTlbFlushRequired()) { + if (!this->rootDeviceEnvironment.getProductHelper().isTlbFlushRequired(*this->getHardwareInfo(), true)) { return; } this->forEachContextWithinWddm([](const EngineControl &engine) { engine.osContext->setNewResourceBound(); }); diff --git a/shared/source/xe_hpc_core/pvc/os_agnostic_product_helper_pvc.inl b/shared/source/xe_hpc_core/pvc/os_agnostic_product_helper_pvc.inl index b45ba2a589..1b1ed4da15 100644 --- a/shared/source/xe_hpc_core/pvc/os_agnostic_product_helper_pvc.inl +++ b/shared/source/xe_hpc_core/pvc/os_agnostic_product_helper_pvc.inl @@ -138,7 +138,7 @@ bool ProductHelperHw::isBlitCopyRequiredForLocalMemory(const RootDev } template <> -bool ProductHelperHw::isTlbFlushRequired() const { +bool ProductHelperHw::isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const { bool tlbFlushRequired = false; if (debugManager.flags.ForceTlbFlush.get() != -1) { tlbFlushRequired = !!debugManager.flags.ForceTlbFlush.get(); diff --git a/shared/source/xe_hpg_core/linux/product_helper_dg2.cpp b/shared/source/xe_hpg_core/linux/product_helper_dg2.cpp index 59ae1fe902..ef9a38e924 100644 --- a/shared/source/xe_hpg_core/linux/product_helper_dg2.cpp +++ b/shared/source/xe_hpg_core/linux/product_helper_dg2.cpp @@ -46,6 +46,15 @@ int ProductHelperHw::configureHardwareCustom(HardwareInfo *hwInfo, O return 0; } +template <> +bool ProductHelperHw::isTlbFlushRequired(const HardwareInfo &hwInfo, bool precondition) const { + bool tlbFlushRequired = !DG2::isG10(hwInfo) && precondition; + if (debugManager.flags.ForceTlbFlush.get() != -1) { + tlbFlushRequired = !!debugManager.flags.ForceTlbFlush.get(); + } + return tlbFlushRequired; +} + template <> bool ProductHelperHw::getUuid(NEO::DriverModel *driverModel, const uint32_t subDeviceCount, const uint32_t deviceIndex, std::array &uuid) const { if (driverModel->getDriverModelType() != DriverModelType::drm) { diff --git a/shared/test/unit_test/os_interface/linux/drm_buffer_object_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_buffer_object_tests.cpp index 530a75a216..a56c647933 100644 --- a/shared/test/unit_test/os_interface/linux/drm_buffer_object_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_buffer_object_tests.cpp @@ -140,6 +140,15 @@ TEST_F(DrmBufferObjectTest, whenExecFailsThenValidateHostPtrFails) { EXPECT_EQ(EINVAL, ret); } +TEST_F(DrmBufferObjectTest, whenSetImageAllocTypeForBOThenReturnProperValue) { + TestedBufferObject bo(0u, this->mock.get()); + EXPECT_FALSE(bo.isImage()); + bo.setIsImage(AllocationType::kernelIsa); + EXPECT_FALSE(bo.isImage()); + bo.setIsImage(AllocationType::image); + EXPECT_TRUE(bo.isImage()); +} + TEST_F(DrmBufferObjectTest, givenResidentBOWhenPrintExecutionBufferIsSetToTrueThenDebugInformationAboutBOIsPrinted) { mock->ioctlExpected.total = 1; DebugManagerStateRestore restore; diff --git a/shared/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp index 2ce4a6120c..5bea7960b6 100644 --- a/shared/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp @@ -131,7 +131,7 @@ TEST_F(DrmMemoryOperationsHandlerBindMultiRootDeviceTest, whenSetNewResourceBoun for (const auto &engine : device->getAllEngines()) { auto osContexLinux = static_cast(engine.osContext); - if (osContexLinux->getDeviceBitfield().test(1u) && executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]->getProductHelper().isTlbFlushRequired()) { + if (osContexLinux->getDeviceBitfield().test(1u) && executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]->getProductHelper().isTlbFlushRequired(*executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]->getHardwareInfo(), true)) { EXPECT_TRUE(osContexLinux->isTlbFlushRequired()); } else { EXPECT_FALSE(osContexLinux->isTlbFlushRequired()); @@ -150,7 +150,7 @@ TEST_F(DrmMemoryOperationsHandlerBindMultiRootDeviceTest, whenSetNewResourceBoun for (const auto &engine : devices[1]->getAllEngines()) { auto osContexLinux = static_cast(engine.osContext); - if (osContexLinux->getDeviceBitfield().test(0u) && executionEnvironment->rootDeviceEnvironments[1]->getProductHelper().isTlbFlushRequired()) { + if (osContexLinux->getDeviceBitfield().test(0u) && executionEnvironment->rootDeviceEnvironments[1]->getProductHelper().isTlbFlushRequired(*executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]->getHardwareInfo(), true)) { EXPECT_TRUE(osContexLinux->isTlbFlushRequired()); } else { EXPECT_FALSE(osContexLinux->isTlbFlushRequired()); @@ -168,7 +168,7 @@ TEST_F(DrmMemoryOperationsHandlerBindMultiRootDeviceTest, whenSetNewResourceBoun for (const auto &engine : device->getAllEngines()) { auto osContexLinux = static_cast(engine.osContext); - if (osContexLinux->getDeviceBitfield().test(1u) && executionEnvironment->rootDeviceEnvironments[1]->getProductHelper().isTlbFlushRequired()) { + if (osContexLinux->getDeviceBitfield().test(1u) && executionEnvironment->rootDeviceEnvironments[1]->getProductHelper().isTlbFlushRequired(*executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()]->getHardwareInfo(), true)) { EXPECT_TRUE(osContexLinux->isTlbFlushRequired()); } else { EXPECT_FALSE(osContexLinux->isTlbFlushRequired()); diff --git a/shared/test/unit_test/os_interface/product_helper_tests.cpp b/shared/test/unit_test/os_interface/product_helper_tests.cpp index 8c612625cd..dca86a526b 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -455,13 +455,15 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfIsTimestampWaitSupport } HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfIsTlbFlushRequiredThenTrueIsReturned, IsNotXeHpgOrXeHpcCore) { - EXPECT_TRUE(productHelper->isTlbFlushRequired()); + EXPECT_TRUE(productHelper->isTlbFlushRequired(pInHwInfo, false)); + EXPECT_TRUE(productHelper->isTlbFlushRequired(pInHwInfo, true)); } HWTEST2_F(ProductHelperTest, givenProductHelperAndForceTlbFlushNotSetWhenAskedIfIsTlbFlushRequiredThenFalseIsReturned, IsNotPVC) { DebugManagerStateRestore restore{}; debugManager.flags.ForceTlbFlush.set(0); - EXPECT_FALSE(productHelper->isTlbFlushRequired()); + EXPECT_FALSE(productHelper->isTlbFlushRequired(pInHwInfo, true)); + EXPECT_FALSE(productHelper->isTlbFlushRequired(pInHwInfo, false)); } HWTEST_F(ProductHelperTest, givenLockableAllocationWhenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectValuesAreReturned) { diff --git a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp index 4bc4ad5641..337a9bdb22 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_tests.cpp @@ -169,7 +169,7 @@ TEST(WddmNewRsourceTest, whenSetNewResourcesBoundToPageTableThenSetInContextFrom } engines = executionEnvironment.memoryManager->getRegisteredEngines(1); for (const auto &engine : engines) { - EXPECT_EQ(engine.osContext->peekTlbFlushCounter(), executionEnvironment.rootDeviceEnvironments[1]->getProductHelper().isTlbFlushRequired()); + EXPECT_EQ(engine.osContext->peekTlbFlushCounter(), executionEnvironment.rootDeviceEnvironments[1]->getProductHelper().isTlbFlushRequired(*defaultHwInfo, true)); } executionEnvironment.memoryManager->unregisterEngineForCsr(csr1.get()); diff --git a/shared/test/unit_test/xe_hpc_core/pvc/test_product_helper_pvc.cpp b/shared/test/unit_test/xe_hpc_core/pvc/test_product_helper_pvc.cpp index 7d69f03593..2cee3aae06 100644 --- a/shared/test/unit_test/xe_hpc_core/pvc/test_product_helper_pvc.cpp +++ b/shared/test/unit_test/xe_hpc_core/pvc/test_product_helper_pvc.cpp @@ -30,13 +30,15 @@ PVCTEST_F(PvcProductHelper, whenGettingAubstreamProductFamilyThenProperEnumValue } PVCTEST_F(PvcProductHelper, whenCheckIsTlbFlushRequiredThenReturnProperValue) { - EXPECT_FALSE(productHelper->isTlbFlushRequired()); + EXPECT_FALSE(productHelper->isTlbFlushRequired(*defaultHwInfo, true)); + EXPECT_FALSE(productHelper->isTlbFlushRequired(*defaultHwInfo, false)); } PVCTEST_F(PvcProductHelper, whenForceTlbFlushSetAndCheckIsTlbFlushRequiredThenReturnProperValue) { DebugManagerStateRestore restore; debugManager.flags.ForceTlbFlush.set(1); - EXPECT_TRUE(productHelper->isTlbFlushRequired()); + EXPECT_TRUE(productHelper->isTlbFlushRequired(*defaultHwInfo, false)); + EXPECT_TRUE(productHelper->isTlbFlushRequired(*defaultHwInfo, true)); } PVCTEST_F(PvcProductHelper, givenPVCRevId3AndAboveWhenGettingThreadEuRatioForScratchThen16IsReturned) { diff --git a/shared/test/unit_test/xe_hpg_core/dg2/linux/product_helper_tests_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/linux/product_helper_tests_dg2.cpp index b56153717a..ca6ad009a6 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/linux/product_helper_tests_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/linux/product_helper_tests_dg2.cpp @@ -6,7 +6,9 @@ */ #include "shared/source/os_interface/os_interface.h" +#include "shared/source/xe_hpg_core/hw_cmds_dg2.h" #include "shared/source/xe_hpg_core/hw_info_xe_hpg_core.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/gtest_helpers.h" #include "shared/test/common/libult/linux/drm_mock.h" @@ -43,3 +45,18 @@ DG2TEST_F(Dg2ProductHelperLinux, GivenDg2WhenConfigureHardwareCustomThenKmdNotif EXPECT_TRUE(pInHwInfo.capabilityTable.kmdNotifyProperties.enableQuickKmdSleepForDirectSubmission); EXPECT_EQ(20ll, pInHwInfo.capabilityTable.kmdNotifyProperties.delayQuickKmdSleepForDirectSubmissionMicroseconds); } + +DG2TEST_F(Dg2ProductHelperLinux, whenCheckIsTlbFlushRequiredThenReturnProperValue) { + EXPECT_EQ(productHelper->isTlbFlushRequired(pInHwInfo, true), !DG2::isG10(pInHwInfo)); + EXPECT_FALSE(productHelper->isTlbFlushRequired(pInHwInfo, false)); +} + +DG2TEST_F(Dg2ProductHelperLinux, whenForceTlbFlushSetAndCheckIsTlbFlushRequiredThenReturnProperValue) { + DebugManagerStateRestore restore; + debugManager.flags.ForceTlbFlush.set(1); + EXPECT_TRUE(productHelper->isTlbFlushRequired(pInHwInfo, false)); + EXPECT_TRUE(productHelper->isTlbFlushRequired(pInHwInfo, true)); + debugManager.flags.ForceTlbFlush.set(0); + EXPECT_FALSE(productHelper->isTlbFlushRequired(pInHwInfo, false)); + EXPECT_FALSE(productHelper->isTlbFlushRequired(pInHwInfo, true)); +} \ No newline at end of file diff --git a/shared/test/unit_test/xe_hpg_core/mtl/windows/product_helper_tests_mtl_windows.cpp b/shared/test/unit_test/xe_hpg_core/mtl/windows/product_helper_tests_mtl_windows.cpp index 3cb437d01a..dfbe2fe388 100644 --- a/shared/test/unit_test/xe_hpg_core/mtl/windows/product_helper_tests_mtl_windows.cpp +++ b/shared/test/unit_test/xe_hpg_core/mtl/windows/product_helper_tests_mtl_windows.cpp @@ -14,7 +14,7 @@ using namespace NEO; using MtlProductHelperWindows = ProductHelperTestWindows; MTLTEST_F(MtlProductHelperWindows, whenCheckIsTlbFlushRequiredThenReturnProperValue) { - EXPECT_TRUE(productHelper->isTlbFlushRequired()); + EXPECT_TRUE(productHelper->isTlbFlushRequired(pInHwInfo, false)); } MTLTEST_F(MtlProductHelperWindows, whenCheckingIsTimestampWaitSupportedForEventsThenReturnTrue) {