fix: Configure scratch pages for debugger

DG2 requires scratch pages on for debugger. Other platforms do not.

Related-to: NEO-13883

Signed-off-by: Brandon Yates <brandon.yates@intel.com>
This commit is contained in:
Brandon Yates
2025-01-28 20:58:22 +00:00
committed by Compute-Runtime-Automation
parent 106e8be9a9
commit 635f69e54a
12 changed files with 68 additions and 5 deletions

View File

@@ -1155,8 +1155,11 @@ void Drm::configureScratchPagePolicy() {
return;
}
const auto &productHelper = this->getRootDeviceEnvironment().getHelper<ProductHelper>();
disableScratch = (productHelper.isDisableScratchPagesSupported() &&
!rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled());
if (rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled()) {
disableScratch = productHelper.isDisableScratchPagesRequiredForDebugger();
} else {
disableScratch = productHelper.isDisableScratchPagesSupported();
}
}
void Drm::configureGpuFaultCheckThreshold() {

View File

@@ -129,6 +129,7 @@ class ProductHelper {
virtual bool isPageFaultSupported() const = 0;
virtual bool isKmdMigrationSupported() const = 0;
virtual bool isDisableScratchPagesSupported() const = 0;
virtual bool isDisableScratchPagesRequiredForDebugger() const = 0;
virtual bool areSecondaryContextsSupported() const = 0;
virtual bool isTile64With3DSurfaceOnBCSSupported(const HardwareInfo &hwInfo) const = 0;
virtual bool isDcFlushAllowed() const = 0;

View File

@@ -441,6 +441,11 @@ bool ProductHelperHw<gfxProduct>::isDisableScratchPagesSupported() const {
return false;
}
template <PRODUCT_FAMILY gfxProduct>
bool ProductHelperHw<gfxProduct>::isDisableScratchPagesRequiredForDebugger() const {
return true;
}
template <PRODUCT_FAMILY gfxProduct>
bool ProductHelperHw<gfxProduct>::areSecondaryContextsSupported() const {
return false;

View File

@@ -71,6 +71,7 @@ class ProductHelperHw : public ProductHelper {
bool blitEnqueuePreferred(bool isWriteToImageFromBuffer) const override;
bool isKmdMigrationSupported() const override;
bool isDisableScratchPagesSupported() const override;
bool isDisableScratchPagesRequiredForDebugger() const override;
bool areSecondaryContextsSupported() const override;
bool isTile64With3DSurfaceOnBCSSupported(const HardwareInfo &hwInfo) const override;
bool isDcFlushAllowed() const override;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2024 Intel Corporation
* Copyright (C) 2021-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -67,5 +67,10 @@ bool ProductHelperHw<gfxProduct>::getUuid(NEO::DriverModel *driverModel, const u
return true;
}
template <>
bool ProductHelperHw<gfxProduct>::isDisableScratchPagesRequiredForDebugger() const {
return false;
}
template class ProductHelperHw<gfxProduct>;
} // namespace NEO

View File

@@ -31,6 +31,7 @@ class DrmMock : public Drm {
using Drm::chunkingMode;
using Drm::completionFenceSupported;
using Drm::contextDebugSupported;
using Drm::disableScratch;
using Drm::engineInfo;
using Drm::engineInfoQueried;
using Drm::fenceVal;

View File

@@ -25,5 +25,6 @@ struct MockProductHelper : ProductHelperHw<IGFX_UNKNOWN> {
ADDMETHOD_CONST_NOBASE(isHostUsmAllocationReuseSupported, bool, false, ());
ADDMETHOD_CONST_NOBASE(isUsmPoolAllocatorSupported, bool, false, ());
ADDMETHOD_CONST_NOBASE(is2MBLocalMemAlignmentEnabled, bool, false, ());
ADDMETHOD_CONST_NOBASE(isDisableScratchPagesRequiredForDebugger, bool, true, ());
};
} // namespace NEO

View File

@@ -76,6 +76,7 @@ using IsNotDG1 = IsNotWithinProducts<IGFX_DG1, IGFX_DG1>;
using IsAtLeastPVC = IsAtLeastProduct<IGFX_PVC>;
using IsAtMostPVC = IsAtMostProduct<IGFX_PVC>;
using IsNotPVC = IsNotWithinProducts<IGFX_PVC, IGFX_PVC>;
using IsNotDG2 = IsNotWithinProducts<IGFX_DG2, IGFX_DG2>;
using IsNotPvcOrDg2 = IsNotWithinProducts<IGFX_DG2, IGFX_PVC>;
using IsAtMostArl = IsAtMostProduct<IGFX_ARROWLAKE>;

View File

@@ -15,6 +15,7 @@
#include "shared/test/common/libult/linux/drm_query_mock.h"
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_product_helper.h"
#include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h"
#include "shared/test/common/test_macros/hw_test.h"
@@ -312,6 +313,42 @@ TEST(DrmBufferObjectTestPrelim, givenDisableScratchPagesWhenCreateDrmVirtualMemo
TEST(DrmBufferObjectPrelim, givenDebuggingEnabledWithoutDisableScratchPagesFlagSetWhenCreateDrmVirtualMemoryThenDisableScratchPagesFlagIsNotSet) {
DebugManagerStateRestore restorer;
debugManager.flags.UseTileMemoryBankInVirtualMemoryCreation.set(0u);
auto mockProductHelper = std::make_unique<MockProductHelper>();
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
std::unique_ptr<ProductHelper> productHelper = std::move(mockProductHelper);
executionEnvironment->rootDeviceEnvironments[0]->productHelper.reset(productHelper.release());
executionEnvironment->setDebuggingMode(NEO::DebuggingMode::online);
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
drm.configureScratchPagePolicy();
drm.configureGpuFaultCheckThreshold();
EXPECT_TRUE(drm.disableScratch);
uint32_t vmId = 0;
drm.createDrmVirtualMemory(vmId);
EXPECT_TRUE(drm.receivedGemVmControl.flags & DrmPrelimHelper::getDisableScratchVmCreateFlag());
}
TEST(DrmBufferObjectPrelim, givenDebuggingEnabledWithDisableScratchPagesFlagSetWhenCreateDrmVirtualMemoryThenDisableScratchPagesFlagIsNotSet) {
DebugManagerStateRestore restorer;
debugManager.flags.UseTileMemoryBankInVirtualMemoryCreation.set(0u);
auto mockProductHelper = std::make_unique<MockProductHelper>();
mockProductHelper->isDisableScratchPagesRequiredForDebuggerResult = false;
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
std::unique_ptr<ProductHelper> productHelper = std::move(mockProductHelper);
executionEnvironment->rootDeviceEnvironments[0]->productHelper.reset(productHelper.release());
executionEnvironment->setDebuggingMode(NEO::DebuggingMode::online);
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
drm.configureScratchPagePolicy();
drm.configureGpuFaultCheckThreshold();
EXPECT_FALSE(drm.disableScratch);
uint32_t vmId = 0;
drm.createDrmVirtualMemory(vmId);
EXPECT_FALSE(drm.receivedGemVmControl.flags & DrmPrelimHelper::getDisableScratchVmCreateFlag());
}
TEST(DrmBufferObjectTestPrelim, givenDisableScratchPagesDebugKeyOffAndDebuggingEnabledWhenCreateDrmVirtualMemoryThenEnvVariableIsPriority) {
DebugManagerStateRestore restorer;
debugManager.flags.DisableScratchPages.set(0);
debugManager.flags.UseTileMemoryBankInVirtualMemoryCreation.set(0u);
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
executionEnvironment->setDebuggingMode(NEO::DebuggingMode::online);

View File

@@ -471,6 +471,10 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfDisableScratchPagesIsS
EXPECT_FALSE(productHelper->isDisableScratchPagesSupported());
}
HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfDisableScratchPagesIsSupportedForDebuggerThenReturnTrue, IsNotDG2) {
EXPECT_TRUE(productHelper->isDisableScratchPagesRequiredForDebugger());
}
HWTEST_F(ProductHelperTest, givenProductHelperWhenCheckBlitEnqueuePreferredThenReturnTrue) {
EXPECT_TRUE(productHelper->blitEnqueuePreferred(false));
}

View File

@@ -125,4 +125,4 @@ PVCTEST_F(PvcProductHelperLinux, WhenGetDeviceMemoryMaxBandWidthInBytesPerSecond
PVCTEST_F(PvcProductHelperLinux, givenProductHelperWhenAskingForDeviceToHostCopySignalingFenceTrueReturned) {
EXPECT_TRUE(productHelper->isDeviceToHostCopySignalingFenceRequired());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2024 Intel Corporation
* Copyright (C) 2021-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -24,6 +24,10 @@ struct Dg2ProductHelperLinux : ProductHelperTestLinux {
}
};
DG2TEST_F(Dg2ProductHelperLinux, givenProductHelperWhenAskedIfDisableScratchPagesIsSupportedForDebuggerThenReturnFalse) {
EXPECT_FALSE(productHelper->isDisableScratchPagesRequiredForDebugger());
}
DG2TEST_F(Dg2ProductHelperLinux, WhenConfiguringHwInfoThenZeroIsReturned) {
auto ret = productHelper->configureHwInfoDrm(&pInHwInfo, &outHwInfo, getRootDeviceEnvironment());