diff --git a/shared/source/os_interface/linux/ioctl_helper_prelim.cpp b/shared/source/os_interface/linux/ioctl_helper_prelim.cpp index 93eb836226..92da0e8624 100644 --- a/shared/source/os_interface/linux/ioctl_helper_prelim.cpp +++ b/shared/source/os_interface/linux/ioctl_helper_prelim.cpp @@ -590,7 +590,7 @@ bool IoctlHelperPrelim20::perfOpenEuStallStream(uint32_t euStallFdParameter, std I915_PERF_FLAG_FD_NONBLOCK; param.num_properties = sizeof(properties) / 16; param.properties_ptr = reinterpret_cast(properties.data()); - *stream = ioctl(DrmIoctl::perfOpen, ¶m); + *stream = ioctl(this->drm.getFileDescriptor(), DrmIoctl::perfOpen, ¶m); if (*stream < 0) { PRINT_DEBUG_STRING(NEO::debugManager.flags.PrintDebugMessages.get() && (*stream < 0), stderr, "%s failed errno = %d | ret = %d \n", "DRM_IOCTL_I915_PERF_OPEN", errno, *stream); diff --git a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp index 08edec272c..e85af6ee75 100644 --- a/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp +++ b/shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp @@ -387,14 +387,6 @@ TEST_F(IoctlPrelimHelperTests, givenPrelimWhenGettingEuStallPropertiesThenCorrec EXPECT_EQ(properties[11], 20u); } -TEST_F(IoctlPrelimHelperTests, givenPrelimWhenCallingPerfOpenEuStallStreamWithInvalidArgumentsThenFailureReturned) { - std::array properties = {}; - int32_t invalidStream = -1; - DrmMock *mockDrm = reinterpret_cast(drm.get()); - mockDrm->failPerfOpen = true; - EXPECT_FALSE(ioctlHelper.perfOpenEuStallStream(0u, properties, &invalidStream)); -} - TEST_F(IoctlPrelimHelperTests, givenPrelimWhenGettingEuStallFdParameterThenCorrectIoctlValueIsReturned) { EXPECT_EQ(static_cast(PRELIM_I915_PERF_FLAG_FD_EU_STALL), ioctlHelper.getEuStallFdParameter()); } @@ -444,6 +436,11 @@ struct MockIoctlHelperPrelim20 : IoctlHelperPrelim20 { return -1; } } + if (request == DrmIoctl::perfOpen) { + if (failPerfOpen) { + return -1; + } + } return IoctlHelperPrelim20::ioctl(fd, request, arg); } bool checkWhetherGemCreateExtContainsMemPolicy(void *arg) { @@ -469,6 +466,7 @@ struct MockIoctlHelperPrelim20 : IoctlHelperPrelim20 { bool lastGemCreateContainedMemPolicy = false; bool failPerfDisable = false; bool failPerfEnable = false; + bool failPerfOpen = false; std::optional overrideGemCreateExtReturnValue{}; uint32_t lastPolicyMode = 0; uint32_t lastPolicyFlags = 0; @@ -565,6 +563,18 @@ TEST(IoctlPrelimHelperPerfTests, givenCalltoPerfDisableEuStallStreamWithInvalidS EXPECT_FALSE(mockIoctlHelper.perfDisableEuStallStream(&invalidFd)); } +TEST(IoctlPrelimHelperPerfTests, givenPrelimWhenCallingPerfOpenEuStallStreamWithInvalidArgumentsThenFailureReturned) { + auto executionEnvironment = std::make_unique(); + auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); + MockIoctlHelperPrelim20 mockIoctlHelper{*drm}; + + mockIoctlHelper.initialize(); + int32_t invalidFd = -1; + mockIoctlHelper.failPerfOpen = true; + std::array properties = {}; + EXPECT_FALSE(mockIoctlHelper.perfOpenEuStallStream(0u, properties, &invalidFd)); +} + TEST(IoctlPrelimHelperPerfTests, givenCalltoPerfOpenEuStallStreamWithInvalidStreamWithEnableSetToFailThenFailureReturned) { auto executionEnvironment = std::make_unique(); auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]);