Skip to content

Commit 3521d89

Browse files
Add debug flag to print called ioctls
Signed-off-by: Lukasz Jobczyk <[email protected]>
1 parent 8deb4bc commit 3521d89

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

opencl/test/unit_test/linux/main_linux_dll.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,23 @@ TEST(DrmTest, GivenSelectedExistingDeviceWhenOpenDirFailsThenRetryOpeningRenderD
157157
EXPECT_STREQ("00:03.0", hwDeviceIds[1]->getPciPath());
158158
}
159159

160+
TEST(DrmTest, givenPrintIoctlEntriesWhenCallIoctlThenIoctlIsPrinted) {
161+
::testing::internal::CaptureStdout();
162+
163+
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
164+
executionEnvironment->prepareRootDeviceEnvironments(1);
165+
auto drm = DrmWrap::createDrm(*executionEnvironment->rootDeviceEnvironments[0]);
166+
167+
DebugManagerStateRestore restorer;
168+
DebugManager.flags.PrintIoctlEntries.set(true);
169+
170+
uint32_t contextId = 1u;
171+
drm->destroyDrmContext(contextId);
172+
173+
std::string output = ::testing::internal::GetCapturedStdout();
174+
EXPECT_STREQ(output.c_str(), "IOCTL 1074291822 called\nIOCTL 1074291822 returns 0, errno 9\n");
175+
}
176+
160177
TEST(DrmTest, givenPrintIoctlTimesWhenCallIoctlThenStatisticsAreGathered) {
161178
struct DrmMock : public Drm {
162179
using Drm::ioctlStatistics;

opencl/test/unit_test/test_files/igdrcl.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ EnableHostUsmSupport = -1
220220
ForceBtpPrefetchMode = -1
221221
OverrideProfilingTimerResolution = -1
222222
PrintIoctlTimes = 0
223+
PrintIoctlEntries = 0
223224
UpdateTaskCountFromWait = -1
224225
PreferCopyEngineForCopyBufferToBuffer = -1
225226
EnableStaticPartitioning = -1

shared/source/debug_settings/debug_variables_base.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ DECLARE_DEBUG_VARIABLE(bool, PrintTagAllocationAddress, false, "Print tag alloca
129129
DECLARE_DEBUG_VARIABLE(bool, ProvideVerboseImplicitFlush, false, "provides verbose messages about implicit flush mechanism")
130130
DECLARE_DEBUG_VARIABLE(bool, PrintBlitDispatchDetails, false, "Print blit dispatch details")
131131
DECLARE_DEBUG_VARIABLE(bool, PrintIoctlTimes, false, "Print ioctl times")
132+
DECLARE_DEBUG_VARIABLE(bool, PrintIoctlEntries, false, "Print ioctl being called")
132133

133134
/*PERFORMANCE FLAGS*/
134135
DECLARE_DEBUG_VARIABLE(bool, DisableZeroCopyForBuffers, false, "When active all buffer allocations will not share memory with CPU.")

shared/source/os_interface/linux/drm_neo.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,18 @@ int Drm::ioctl(unsigned long request, void *arg) {
7777
start = std::chrono::steady_clock::now();
7878
}
7979

80+
auto printIoctl = DebugManager.flags.PrintIoctlEntries.get();
81+
82+
if (printIoctl) {
83+
printf("IOCTL %lu called\n", request);
84+
}
85+
8086
ret = SysCalls::ioctl(getFileDescriptor(), request, arg);
8187

88+
if (printIoctl) {
89+
printf("IOCTL %lu returns %d, errno %d\n", request, ret, errno);
90+
}
91+
8292
if (measureTime) {
8393
end = std::chrono::steady_clock::now();
8494
auto elapsedTime = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();

0 commit comments

Comments
 (0)