Skip to content

Commit 1844875

Browse files
Disable timeout while waiting when direct submission active
Signed-off-by: Lukasz Jobczyk <[email protected]>
1 parent 15f3353 commit 1844875

File tree

7 files changed

+41
-15
lines changed

7 files changed

+41
-15
lines changed

opencl/source/os_interface/linux/drm_command_stream.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -43,6 +43,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
4343
MOCKABLE_VIRTUAL void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
4444
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
4545
bool waitForFlushStamp(FlushStamp &flushStampToWait) override;
46+
bool isAnyDirectSubmissionActive() override;
4647

4748
DrmMemoryManager *getMemoryManager() const;
4849
GmmPageTableMngr *createPageTableManager() override;

opencl/source/os_interface/linux/drm_command_stream.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,9 @@ bool DrmCommandStreamReceiver<GfxFamily>::waitForFlushStamp(FlushStamp &flushSta
175175
return true;
176176
}
177177

178+
template <typename GfxFamily>
179+
bool DrmCommandStreamReceiver<GfxFamily>::isAnyDirectSubmissionActive() {
180+
return this->drm->isDirectSubmissionActive();
181+
}
182+
178183
} // namespace NEO

opencl/test/unit_test/helpers/kmd_notify_tests.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ TEST_F(KmdNotifyTests, givenTaskCountDiffLowerThanMinimumToCheckAcLineWhenObtain
298298
EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine);
299299

300300
int64_t timeout = 0;
301-
helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false);
301+
helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false, false);
302302

303303
EXPECT_EQ(0u, helper.updateAcLineStatusCalled);
304304
}
@@ -313,11 +313,21 @@ TEST_F(KmdNotifyTests, givenTaskCountDiffGreaterThanMinimumToCheckAcLineAndDisab
313313
EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine);
314314

315315
int64_t timeout = 0;
316-
helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false);
316+
helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false, false);
317317

318318
EXPECT_EQ(1u, helper.updateAcLineStatusCalled);
319319
}
320320

321+
TEST_F(KmdNotifyTests, givenEnableDirectSubmissionWhenObtainTimeoutParamsThenFalseIsReturned) {
322+
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
323+
324+
int64_t timeout = 0;
325+
auto enableTimeout = helper.obtainTimeoutParams(timeout, false, 1, 1, 1, false, true);
326+
327+
EXPECT_FALSE(enableTimeout);
328+
EXPECT_FALSE(timeout);
329+
}
330+
321331
TEST_F(KmdNotifyTests, givenTaskCountDiffGreaterThanMinimumToCheckAcLineAndEnabledKmdNotifyWhenObtainingTimeoutPropertiesThenDontCheck) {
322332
hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify = true;
323333
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
@@ -328,7 +338,7 @@ TEST_F(KmdNotifyTests, givenTaskCountDiffGreaterThanMinimumToCheckAcLineAndEnabl
328338
EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine);
329339

330340
int64_t timeout = 0;
331-
helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false);
341+
helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false, false);
332342

333343
EXPECT_EQ(0u, helper.updateAcLineStatusCalled);
334344
}
@@ -339,7 +349,7 @@ TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenAcLineIsDisconnectedTh
339349
helper.acLineConnected = false;
340350

341351
int64_t timeout = 0;
342-
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2, false);
352+
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2, false, false);
343353

344354
EXPECT_TRUE(timeoutEnabled);
345355
EXPECT_EQ(KmdNotifyConstants::timeoutInMicrosecondsForDisconnectedAcLine, timeout);
@@ -353,7 +363,7 @@ TEST_F(KmdNotifyTests, givenEnabledKmdNotifyMechanismWhenAcLineIsDisconnectedThe
353363
helper.acLineConnected = false;
354364

355365
int64_t timeout = 0;
356-
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2, false);
366+
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2, false, false);
357367

358368
EXPECT_TRUE(timeoutEnabled);
359369
EXPECT_EQ(hwInfo->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds, timeout);
@@ -366,7 +376,7 @@ TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismAndFlushStampIsZeroWhenAcL
366376

367377
int64_t timeout = 0;
368378
FlushStamp flushStampToWait = 0;
369-
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false);
379+
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, false);
370380

371381
EXPECT_FALSE(timeoutEnabled);
372382
}
@@ -380,7 +390,7 @@ TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenPowerSavingModeIsSetTh
380390

381391
int64_t timeout = 0;
382392
FlushStamp flushStampToWait = 1;
383-
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false);
393+
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, false);
384394
EXPECT_TRUE(timeoutEnabled);
385395
EXPECT_EQ(1, timeout);
386396
}
@@ -391,7 +401,7 @@ TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenPowerSavingModeIsReque
391401

392402
int64_t timeout = 0;
393403
FlushStamp flushStampToWait = 1;
394-
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, true);
404+
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, true, false);
395405
EXPECT_TRUE(timeoutEnabled);
396406
EXPECT_EQ(1, timeout);
397407
}
@@ -405,7 +415,7 @@ TEST_F(KmdNotifyTests, givenEnabledKmdNotifyMechanismWhenPowerSavingModeIsSetAnd
405415

406416
int64_t timeout = 0;
407417
FlushStamp flushStampToWait = 0;
408-
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false);
418+
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, false);
409419
EXPECT_FALSE(timeoutEnabled);
410420
EXPECT_EQ(0, timeout);
411421
}

shared/source/command_stream/command_stream_receiver_hw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
105105
return blitterDirectSubmission.get() != nullptr;
106106
}
107107

108+
virtual bool isAnyDirectSubmissionActive() { return false; }
109+
108110
bool initDirectSubmission(Device &device, OsContext &osContext) override;
109111
GraphicsAllocation *getClearColorAllocation() override;
110112

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,9 @@ inline void CommandStreamReceiverHw<GfxFamily>::emitNoop(LinearStream &commandSt
830830
template <typename GfxFamily>
831831
inline void CommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) {
832832
int64_t waitTimeout = 0;
833-
bool enableTimeout = kmdNotifyHelper->obtainTimeoutParams(waitTimeout, useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, forcePowerSavingMode);
833+
bool enableTimeout = false;
834+
835+
enableTimeout = kmdNotifyHelper->obtainTimeoutParams(waitTimeout, useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, forcePowerSavingMode, this->isAnyDirectSubmissionActive());
834836

835837
PRINT_DEBUG_STRING(DebugManager.flags.LogWaitingForCompletion.get(), stdout,
836838
"\nWaiting for task count %u at location %p. Current value: %u\n",

shared/source/helpers/kmd_notify_properties.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2020 Intel Corporation
2+
* Copyright (C) 2018-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -18,11 +18,16 @@ bool KmdNotifyHelper::obtainTimeoutParams(int64_t &timeoutValueOutput,
1818
uint32_t currentHwTag,
1919
uint32_t taskCountToWait,
2020
FlushStamp flushStampToWait,
21-
bool forcePowerSavingMode) {
21+
bool forcePowerSavingMode,
22+
bool directSubmissionActive) {
2223
if (flushStampToWait == 0) {
2324
return false;
2425
}
2526

27+
if (directSubmissionActive) {
28+
return false;
29+
}
30+
2631
if (DebugManager.flags.PowerSavingMode.get() || forcePowerSavingMode) {
2732
timeoutValueOutput = 1;
2833
return true;

shared/source/helpers/kmd_notify_properties.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2020 Intel Corporation
2+
* Copyright (C) 2018-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -41,7 +41,8 @@ class KmdNotifyHelper {
4141
uint32_t currentHwTag,
4242
uint32_t taskCountToWait,
4343
FlushStamp flushStampToWait,
44-
bool forcePowerSavingMode);
44+
bool forcePowerSavingMode,
45+
bool directSubmissionActive);
4546

4647
bool quickKmdSleepForSporadicWaitsEnabled() const { return properties->enableQuickKmdSleepForSporadicWaits; }
4748
MOCKABLE_VIRTUAL void updateLastWaitForCompletionTimestamp();

0 commit comments

Comments
 (0)