Skip to content

Commit 593a6c5

Browse files
feature: add debug flag to ignore product specific ioctl helper creation
Related-To: NEO-13527 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent ae9a4ba commit 593a6c5

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

shared/source/debug_settings/debug_variables_base.inl

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ DECLARE_DEBUG_VARIABLE(bool, DisableGemCreateExtSetPat, false, "Do not use I915_
8989
DECLARE_DEBUG_VARIABLE(bool, SkipInOrderNonWalkerSignalingAllowed, false, "Allows for skipping non walker signalling in InOrder command lists, default: false")
9090
DECLARE_DEBUG_VARIABLE(bool, PipelinedPipelineSelect, false, "Restore usage of default pipeline select command")
9191
DECLARE_DEBUG_VARIABLE(bool, AbortHostSyncOnNonHostVisibleEvent, false, "Aborts execution when user calls zeEventHostSynchronize on event without host signal scope")
92+
DECLARE_DEBUG_VARIABLE(bool, IgnoreProductSpecificIoctlHelper, false, "When set then product specific ioctl helper is not created even if available, generic one is used")
9293
DECLARE_DEBUG_VARIABLE(std::string, ForceDeviceId, std::string("unk"), "Override device id in AUB/TBX mode")
9394
DECLARE_DEBUG_VARIABLE(std::string, FilterDeviceId, std::string("unk"), "Device id filter, adapter matching device id will be opened; ignored when unk")
9495
DECLARE_DEBUG_VARIABLE(std::string, FilterBdfPath, std::string("unk"), "Linux-only, BDF path filter, only matching paths will be opened; ignored when unk")

shared/source/os_interface/linux/drm_neo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ bool Drm::completionFenceSupport() {
10921092
void Drm::setupIoctlHelper(const PRODUCT_FAMILY productFamily) {
10931093
if (!this->ioctlHelper) {
10941094
auto productSpecificIoctlHelperCreator = ioctlHelperFactory[productFamily];
1095-
if (productSpecificIoctlHelperCreator) {
1095+
if (productSpecificIoctlHelperCreator && !debugManager.flags.IgnoreProductSpecificIoctlHelper.get()) {
10961096
this->ioctlHelper = productSpecificIoctlHelperCreator.value()(*this);
10971097
} else {
10981098
std::string prelimVersion = "";

shared/test/common/test_files/igdrcl.config

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ InjectInternalBuildOptions = unk
4646
InjectApiBuildOptions = unk
4747
OverrideCsrAllocationSize = -1
4848
AbortHostSyncOnNonHostVisibleEvent = 0
49+
IgnoreProductSpecificIoctlHelper = 0
4950
ForceL1Caching = -1
5051
UseKmdMigration = -1
5152
CreateKmdMigratedSharedAllocationWithMultipleBOs = -1

shared/test/unit_test/os_interface/linux/drm_tests.cpp

+50
Original file line numberDiff line numberDiff line change
@@ -2230,3 +2230,53 @@ TEST(DistanceInfoTest, givenDistanceInfosWhenAssignRegionsFromDistancesThenCorre
22302230
EXPECT_EQ(1024u, memoryInfo->getMemoryRegionSize(2));
22312231
EXPECT_ANY_THROW(memoryInfo->getMemoryRegionSize(4));
22322232
}
2233+
2234+
TEST(DrmTest, GivenProductSpecificIoctlHelperAvailableWhenSetupIoctlHelperThenCreateProductSpecificOne) {
2235+
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
2236+
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
2237+
drm.ioctlHelper.reset();
2238+
2239+
auto productFamily = defaultHwInfo->platform.eProductFamily;
2240+
VariableBackup<std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm & drm)>>> createFuncBackup{&ioctlHelperFactory[productFamily]};
2241+
2242+
static uint32_t customFuncCalled = 0;
2243+
2244+
ioctlHelperFactory[productFamily] = [](Drm &drm) -> std::unique_ptr<IoctlHelper> {
2245+
EXPECT_EQ(0u, customFuncCalled);
2246+
customFuncCalled++;
2247+
2248+
return std::make_unique<MockIoctlHelper>(drm);
2249+
};
2250+
2251+
customFuncCalled = 0;
2252+
2253+
drm.setupIoctlHelper(productFamily);
2254+
2255+
EXPECT_EQ(1u, customFuncCalled);
2256+
}
2257+
2258+
TEST(DrmTest, GivenProductSpecificIoctlHelperAvailableAndDebugFlagToIgnoreIsSetWhenSetupIoctlHelperThenDontCreateProductSpecificOne) {
2259+
DebugManagerStateRestore restore;
2260+
debugManager.flags.IgnoreProductSpecificIoctlHelper.set(true);
2261+
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
2262+
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
2263+
drm.ioctlHelper.reset();
2264+
2265+
auto productFamily = defaultHwInfo->platform.eProductFamily;
2266+
VariableBackup<std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm & drm)>>> createFuncBackup{&ioctlHelperFactory[productFamily]};
2267+
2268+
static uint32_t customFuncCalled = 0;
2269+
2270+
ioctlHelperFactory[productFamily] = [](Drm &drm) -> std::unique_ptr<IoctlHelper> {
2271+
EXPECT_EQ(0u, customFuncCalled);
2272+
customFuncCalled++;
2273+
2274+
return std::make_unique<MockIoctlHelper>(drm);
2275+
};
2276+
2277+
customFuncCalled = 0;
2278+
2279+
drm.setupIoctlHelper(productFamily);
2280+
2281+
EXPECT_EQ(0u, customFuncCalled);
2282+
}

0 commit comments

Comments
 (0)