Enable KMD fallback for User Fence wait call

Related-To: NEO-5845

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2021-06-15 11:31:12 +00:00
committed by Compute-Runtime-Automation
parent 6c7ccddae0
commit ad18099ed8
16 changed files with 154 additions and 59 deletions

View File

@@ -45,7 +45,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
MOCKABLE_VIRTUAL void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override; MOCKABLE_VIRTUAL void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
void makeNonResident(GraphicsAllocation &gfxAllocation) override; void makeNonResident(GraphicsAllocation &gfxAllocation) override;
bool waitForFlushStamp(FlushStamp &flushStampToWait) override; bool waitForFlushStamp(FlushStamp &flushStampToWait) override;
bool isNewResidencyModelActive() override; bool isKmdWaitModeActive() override;
DrmMemoryManager *getMemoryManager() const; DrmMemoryManager *getMemoryManager() const;
GmmPageTableMngr *createPageTableManager() override; GmmPageTableMngr *createPageTableManager() override;
@@ -71,6 +71,6 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
gemCloseWorkerMode gemCloseWorkerOperationMode; gemCloseWorkerMode gemCloseWorkerOperationMode;
bool useUserFenceWait = false; bool useUserFenceWait = false;
bool useContextForUserFenceWait = false; bool useContextForUserFenceWait = true;
}; };
} // namespace NEO } // namespace NEO

View File

@@ -52,11 +52,13 @@ DrmCommandStreamReceiver<GfxFamily>::DrmCommandStreamReceiver(ExecutionEnvironme
if (DebugManager.flags.CsrDispatchMode.get()) { if (DebugManager.flags.CsrDispatchMode.get()) {
this->dispatchMode = static_cast<DispatchMode>(DebugManager.flags.CsrDispatchMode.get()); this->dispatchMode = static_cast<DispatchMode>(DebugManager.flags.CsrDispatchMode.get());
} }
if (DebugManager.flags.EnableUserFenceForCompletionWait.get() == 1) { int overrideUserFenceForCompletionWait = DebugManager.flags.EnableUserFenceForCompletionWait.get();
useUserFenceWait = true; if (overrideUserFenceForCompletionWait != -1) {
useUserFenceWait = !!(overrideUserFenceForCompletionWait);
} }
if (DebugManager.flags.EnableUserFenceUseCtxId.get() == 1) { int overrideUserFenceUseCtxId = DebugManager.flags.EnableUserFenceUseCtxId.get();
useContextForUserFenceWait = true; if (overrideUserFenceUseCtxId != -1) {
useContextForUserFenceWait = !!(overrideUserFenceUseCtxId);
} }
} }
@@ -207,15 +209,18 @@ bool DrmCommandStreamReceiver<GfxFamily>::waitForFlushStamp(FlushStamp &flushSta
if (useUserFenceWait) { if (useUserFenceWait) {
waitUserFence(waitValue); waitUserFence(waitValue);
} else { } else {
this->drm->waitHandle(waitValue); this->drm->waitHandle(waitValue, -1);
} }
return true; return true;
} }
template <typename GfxFamily> template <typename GfxFamily>
bool DrmCommandStreamReceiver<GfxFamily>::isNewResidencyModelActive() { bool DrmCommandStreamReceiver<GfxFamily>::isKmdWaitModeActive() {
return this->drm->isVmBindAvailable(); if (this->drm->isVmBindAvailable()) {
return useUserFenceWait && useContextForUserFenceWait;
}
return true;
} }
} // namespace NEO } // namespace NEO

View File

@@ -23,7 +23,7 @@ int DrmCommandStreamReceiver<GfxFamily>::waitUserFence(uint32_t waitValue) {
if (useContextForUserFenceWait) { if (useContextForUserFenceWait) {
ctxId = static_cast<const OsContextLinux *>(osContext)->getDrmContextIds()[0]; ctxId = static_cast<const OsContextLinux *>(osContext)->getDrmContextIds()[0];
} }
return this->drm->waitUserFence(ctxId, getTagAllocation()->getGpuAddress(), waitValue, Drm::ValueWidth::U32); return this->drm->waitUserFence(ctxId, getTagAllocation()->getGpuAddress(), waitValue, Drm::ValueWidth::U32, -1);
} }
} // namespace NEO } // namespace NEO

View File

@@ -298,7 +298,7 @@ TEST_F(KmdNotifyTests, givenTaskCountDiffLowerThanMinimumToCheckAcLineWhenObtain
EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine); EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine);
int64_t timeout = 0; int64_t timeout = 0;
helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false, false); helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false, true);
EXPECT_EQ(0u, helper.updateAcLineStatusCalled); EXPECT_EQ(0u, helper.updateAcLineStatusCalled);
} }
@@ -313,16 +313,16 @@ TEST_F(KmdNotifyTests, givenTaskCountDiffGreaterThanMinimumToCheckAcLineAndDisab
EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine); EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine);
int64_t timeout = 0; int64_t timeout = 0;
helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false, false); helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false, true);
EXPECT_EQ(1u, helper.updateAcLineStatusCalled); EXPECT_EQ(1u, helper.updateAcLineStatusCalled);
} }
TEST_F(KmdNotifyTests, givenNewResidencyModelAvailableWhenObtainTimeoutParamsThenFalseIsReturned) { TEST_F(KmdNotifyTests, givenKmdWaitModeNotActiveWhenObtainTimeoutParamsThenFalseIsReturned) {
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties)); MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
int64_t timeout = 0; int64_t timeout = 0;
auto enableTimeout = helper.obtainTimeoutParams(timeout, false, 1, 1, 1, false, true); auto enableTimeout = helper.obtainTimeoutParams(timeout, false, 1, 1, 1, false, false);
EXPECT_FALSE(enableTimeout); EXPECT_FALSE(enableTimeout);
EXPECT_FALSE(timeout); EXPECT_FALSE(timeout);
@@ -338,7 +338,7 @@ TEST_F(KmdNotifyTests, givenTaskCountDiffGreaterThanMinimumToCheckAcLineAndEnabl
EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine); EXPECT_EQ(10u, KmdNotifyConstants::minimumTaskCountDiffToCheckAcLine);
int64_t timeout = 0; int64_t timeout = 0;
helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false, false); helper.obtainTimeoutParams(timeout, false, hwTag, taskCountToWait, 1, false, true);
EXPECT_EQ(0u, helper.updateAcLineStatusCalled); EXPECT_EQ(0u, helper.updateAcLineStatusCalled);
} }
@@ -349,7 +349,7 @@ TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenAcLineIsDisconnectedTh
helper.acLineConnected = false; helper.acLineConnected = false;
int64_t timeout = 0; int64_t timeout = 0;
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2, false, false); bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2, false, true);
EXPECT_TRUE(timeoutEnabled); EXPECT_TRUE(timeoutEnabled);
EXPECT_EQ(KmdNotifyConstants::timeoutInMicrosecondsForDisconnectedAcLine, timeout); EXPECT_EQ(KmdNotifyConstants::timeoutInMicrosecondsForDisconnectedAcLine, timeout);
@@ -363,7 +363,7 @@ TEST_F(KmdNotifyTests, givenEnabledKmdNotifyMechanismWhenAcLineIsDisconnectedThe
helper.acLineConnected = false; helper.acLineConnected = false;
int64_t timeout = 0; int64_t timeout = 0;
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2, false, false); bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, 2, false, true);
EXPECT_TRUE(timeoutEnabled); EXPECT_TRUE(timeoutEnabled);
EXPECT_EQ(hwInfo->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds, timeout); EXPECT_EQ(hwInfo->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds, timeout);
@@ -376,7 +376,7 @@ TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismAndFlushStampIsZeroWhenAcL
int64_t timeout = 0; int64_t timeout = 0;
FlushStamp flushStampToWait = 0; FlushStamp flushStampToWait = 0;
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, false); bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, true);
EXPECT_FALSE(timeoutEnabled); EXPECT_FALSE(timeoutEnabled);
} }
@@ -390,7 +390,7 @@ TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenPowerSavingModeIsSetTh
int64_t timeout = 0; int64_t timeout = 0;
FlushStamp flushStampToWait = 1; FlushStamp flushStampToWait = 1;
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, false); bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, true);
EXPECT_TRUE(timeoutEnabled); EXPECT_TRUE(timeoutEnabled);
EXPECT_EQ(1, timeout); EXPECT_EQ(1, timeout);
} }
@@ -401,7 +401,7 @@ TEST_F(KmdNotifyTests, givenDisabledKmdNotifyMechanismWhenPowerSavingModeIsReque
int64_t timeout = 0; int64_t timeout = 0;
FlushStamp flushStampToWait = 1; FlushStamp flushStampToWait = 1;
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, true, false); bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, true, true);
EXPECT_TRUE(timeoutEnabled); EXPECT_TRUE(timeoutEnabled);
EXPECT_EQ(1, timeout); EXPECT_EQ(1, timeout);
} }
@@ -415,7 +415,7 @@ TEST_F(KmdNotifyTests, givenEnabledKmdNotifyMechanismWhenPowerSavingModeIsSetAnd
int64_t timeout = 0; int64_t timeout = 0;
FlushStamp flushStampToWait = 0; FlushStamp flushStampToWait = 0;
bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, false); bool timeoutEnabled = helper.obtainTimeoutParams(timeout, false, 1, 2, flushStampToWait, false, true);
EXPECT_FALSE(timeoutEnabled); EXPECT_FALSE(timeoutEnabled);
EXPECT_EQ(0, timeout); EXPECT_EQ(0, timeout);
} }

View File

@@ -356,18 +356,37 @@ class DrmMockCustom : public Drm {
uint64_t value = 0u; uint64_t value = 0u;
uint32_t ctxId = 0u; uint32_t ctxId = 0u;
ValueWidth dataWidth = ValueWidth::U8; ValueWidth dataWidth = ValueWidth::U8;
int64_t timeout = 0;
uint32_t called = 0u; uint32_t called = 0u;
}; };
WaitUserFenceCall waitUserFenceCall{}; WaitUserFenceCall waitUserFenceCall{};
int waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth) override { int waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout) override {
waitUserFenceCall.called++; waitUserFenceCall.called++;
waitUserFenceCall.ctxId = ctxId; waitUserFenceCall.ctxId = ctxId;
waitUserFenceCall.address = address; waitUserFenceCall.address = address;
waitUserFenceCall.dataWidth = dataWidth; waitUserFenceCall.dataWidth = dataWidth;
waitUserFenceCall.value = value; waitUserFenceCall.value = value;
return Drm::waitUserFence(ctxId, address, value, dataWidth); waitUserFenceCall.timeout = timeout;
return Drm::waitUserFence(ctxId, address, value, dataWidth, timeout);
}
struct IsVmBindAvailableCall {
bool callParent = true;
bool returnValue = true;
uint32_t called = 0u;
};
IsVmBindAvailableCall isVmBindAvailableCall{};
bool isVmBindAvailable() override {
isVmBindAvailableCall.called++;
if (isVmBindAvailableCall.callParent) {
return Drm::isVmBindAvailable();
} else {
return isVmBindAvailableCall.returnValue;
}
} }
}; };

View File

@@ -1691,32 +1691,26 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenWaitUserFenceFlagSetWhenDr
mm->freeGraphicsMemory(commandBuffer); mm->freeGraphicsMemory(commandBuffer);
} }
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenWaitUserFenceFlagSetWhenDrmCsrThenExpectUseDrmWaitUserFenceCallWithZeroContext) { HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenWaitUserFenceFlagNotSetWhenDrmCsrWaitsForFlushStampThenExpectUseDrmGemWaitCall) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableUserFenceForCompletionWait.set(1);
TestedDrmCommandStreamReceiver<FamilyType> *testedCsr = TestedDrmCommandStreamReceiver<FamilyType> *testedCsr =
new TestedDrmCommandStreamReceiver<FamilyType>(gemCloseWorkerMode::gemCloseWorkerInactive, new TestedDrmCommandStreamReceiver<FamilyType>(gemCloseWorkerMode::gemCloseWorkerInactive,
*this->executionEnvironment, *this->executionEnvironment,
1); 1);
EXPECT_TRUE(testedCsr->useUserFenceWait); EXPECT_FALSE(testedCsr->useUserFenceWait);
EXPECT_FALSE(testedCsr->useContextForUserFenceWait); EXPECT_TRUE(testedCsr->useContextForUserFenceWait);
device->resetCommandStreamReceiver(testedCsr); device->resetCommandStreamReceiver(testedCsr);
mock->ioctl_cnt.gemWait = 0;
FlushStamp handleToWait = 123; FlushStamp handleToWait = 123;
testedCsr->waitForFlushStamp(handleToWait); testedCsr->waitForFlushStamp(handleToWait);
EXPECT_EQ(1u, testedCsr->waitUserFenceResult.called); EXPECT_EQ(1, mock->ioctl_cnt.gemWait);
EXPECT_EQ(123u, testedCsr->waitUserFenceResult.waitValue); EXPECT_EQ(0u, testedCsr->waitUserFenceResult.called);
EXPECT_EQ(0u, mock->waitUserFenceCall.ctxId);
EXPECT_EQ(1u, mock->waitUserFenceCall.called);
EXPECT_EQ(Drm::ValueWidth::U32, mock->waitUserFenceCall.dataWidth);
} }
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenWaitUserFenceAndUseCtxFlagsSetWhenDrmCsrThenExpectUseDrmWaitUserFenceCallWithNonZeroContext) { HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenWaitUserFenceFlagSetWhenDrmCsrWaitsForFlushStampThenExpectUseDrmWaitUserFenceCallWithNonZeroContext) {
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
DebugManager.flags.EnableUserFenceForCompletionWait.set(1); DebugManager.flags.EnableUserFenceForCompletionWait.set(1);
DebugManager.flags.EnableUserFenceUseCtxId.set(1);
TestedDrmCommandStreamReceiver<FamilyType> *testedCsr = TestedDrmCommandStreamReceiver<FamilyType> *testedCsr =
new TestedDrmCommandStreamReceiver<FamilyType>(gemCloseWorkerMode::gemCloseWorkerInactive, new TestedDrmCommandStreamReceiver<FamilyType>(gemCloseWorkerMode::gemCloseWorkerInactive,
@@ -1725,6 +1719,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenWaitUserFenceAndUseCtxFlag
EXPECT_TRUE(testedCsr->useUserFenceWait); EXPECT_TRUE(testedCsr->useUserFenceWait);
EXPECT_TRUE(testedCsr->useContextForUserFenceWait); EXPECT_TRUE(testedCsr->useContextForUserFenceWait);
device->resetCommandStreamReceiver(testedCsr); device->resetCommandStreamReceiver(testedCsr);
mock->ioctl_cnt.gemWait = 0;
auto osContextLinux = static_cast<const OsContextLinux *>(device->getDefaultEngine().osContext); auto osContextLinux = static_cast<const OsContextLinux *>(device->getDefaultEngine().osContext);
std::vector<uint32_t> &drmCtxIds = const_cast<std::vector<uint32_t> &>(osContextLinux->getDrmContextIds()); std::vector<uint32_t> &drmCtxIds = const_cast<std::vector<uint32_t> &>(osContextLinux->getDrmContextIds());
@@ -1736,9 +1731,87 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenWaitUserFenceAndUseCtxFlag
FlushStamp handleToWait = 123; FlushStamp handleToWait = 123;
testedCsr->waitForFlushStamp(handleToWait); testedCsr->waitForFlushStamp(handleToWait);
EXPECT_EQ(0, mock->ioctl_cnt.gemWait);
EXPECT_EQ(1u, testedCsr->waitUserFenceResult.called); EXPECT_EQ(1u, testedCsr->waitUserFenceResult.called);
EXPECT_EQ(123u, testedCsr->waitUserFenceResult.waitValue); EXPECT_EQ(123u, testedCsr->waitUserFenceResult.waitValue);
EXPECT_NE(0u, mock->waitUserFenceCall.ctxId);
EXPECT_EQ(1u, mock->waitUserFenceCall.called); EXPECT_EQ(1u, mock->waitUserFenceCall.called);
EXPECT_NE(0u, mock->waitUserFenceCall.ctxId);
EXPECT_EQ(-1, mock->waitUserFenceCall.timeout);
EXPECT_EQ(Drm::ValueWidth::U32, mock->waitUserFenceCall.dataWidth); EXPECT_EQ(Drm::ValueWidth::U32, mock->waitUserFenceCall.dataWidth);
} }
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenWaitUserFenceSetAndUseCtxFlagsNotSetWhenDrmCsrWaitsForFlushStampThenExpectUseDrmWaitUserFenceCallWithZeroContext) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableUserFenceForCompletionWait.set(1);
DebugManager.flags.EnableUserFenceUseCtxId.set(0);
TestedDrmCommandStreamReceiver<FamilyType> *testedCsr =
new TestedDrmCommandStreamReceiver<FamilyType>(gemCloseWorkerMode::gemCloseWorkerInactive,
*this->executionEnvironment,
1);
EXPECT_TRUE(testedCsr->useUserFenceWait);
EXPECT_FALSE(testedCsr->useContextForUserFenceWait);
device->resetCommandStreamReceiver(testedCsr);
mock->ioctl_cnt.gemWait = 0;
FlushStamp handleToWait = 123;
testedCsr->waitForFlushStamp(handleToWait);
EXPECT_EQ(0, mock->ioctl_cnt.gemWait);
EXPECT_EQ(1u, testedCsr->waitUserFenceResult.called);
EXPECT_EQ(123u, testedCsr->waitUserFenceResult.waitValue);
EXPECT_EQ(1u, mock->waitUserFenceCall.called);
EXPECT_EQ(0u, mock->waitUserFenceCall.ctxId);
EXPECT_EQ(-1, mock->waitUserFenceCall.timeout);
EXPECT_EQ(Drm::ValueWidth::U32, mock->waitUserFenceCall.dataWidth);
}
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenVmBindNotAvailableWhenCheckingForKmdWaitModeActiveThenReturnTrue) {
auto testDrmCsr = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr);
mock->isVmBindAvailableCall.called = 0u;
mock->isVmBindAvailableCall.callParent = false;
mock->isVmBindAvailableCall.returnValue = false;
EXPECT_TRUE(testDrmCsr->isKmdWaitModeActive());
EXPECT_EQ(1u, mock->isVmBindAvailableCall.called);
}
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenVmBindAvailableUseWaitCallAndUseContextIdTrueWhenCheckingForKmdWaitModeActiveThenReturnTrue) {
auto testDrmCsr = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr);
mock->isVmBindAvailableCall.called = 0u;
mock->isVmBindAvailableCall.callParent = false;
mock->isVmBindAvailableCall.returnValue = true;
testDrmCsr->useUserFenceWait = true;
testDrmCsr->useContextForUserFenceWait = true;
EXPECT_TRUE(testDrmCsr->isKmdWaitModeActive());
EXPECT_EQ(1u, mock->isVmBindAvailableCall.called);
}
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenVmBindAvailableUseWaitCallFalseAndUseContextIdTrueWhenCheckingForKmdWaitModeActiveThenReturnFalse) {
auto testDrmCsr = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr);
mock->isVmBindAvailableCall.called = 0u;
mock->isVmBindAvailableCall.callParent = false;
mock->isVmBindAvailableCall.returnValue = true;
testDrmCsr->useUserFenceWait = false;
testDrmCsr->useContextForUserFenceWait = true;
EXPECT_FALSE(testDrmCsr->isKmdWaitModeActive());
EXPECT_EQ(1u, mock->isVmBindAvailableCall.called);
}
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenVmBindAvailableUseWaitCallTrueAndUseContextIdFalseWhenCheckingForKmdWaitModeActiveThenReturnFalse) {
auto testDrmCsr = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr);
mock->isVmBindAvailableCall.called = 0u;
mock->isVmBindAvailableCall.callParent = false;
mock->isVmBindAvailableCall.returnValue = true;
testDrmCsr->useUserFenceWait = true;
testDrmCsr->useContextForUserFenceWait = false;
EXPECT_FALSE(testDrmCsr->isKmdWaitModeActive());
EXPECT_EQ(1u, mock->isVmBindAvailableCall.called);
}

View File

@@ -118,7 +118,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
return blitterDirectSubmission.get() != nullptr; return blitterDirectSubmission.get() != nullptr;
} }
virtual bool isNewResidencyModelActive() { return false; } virtual bool isKmdWaitModeActive() { return true; }
bool initDirectSubmission(Device &device, OsContext &osContext) override; bool initDirectSubmission(Device &device, OsContext &osContext) override;
GraphicsAllocation *getClearColorAllocation() override; GraphicsAllocation *getClearColorAllocation() override;

View File

@@ -843,7 +843,7 @@ inline void CommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNotifyFal
int64_t waitTimeout = 0; int64_t waitTimeout = 0;
bool enableTimeout = false; bool enableTimeout = false;
enableTimeout = kmdNotifyHelper->obtainTimeoutParams(waitTimeout, useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, forcePowerSavingMode, this->isNewResidencyModelActive()); enableTimeout = kmdNotifyHelper->obtainTimeoutParams(waitTimeout, useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, forcePowerSavingMode, this->isKmdWaitModeActive());
PRINT_DEBUG_STRING(DebugManager.flags.LogWaitingForCompletion.get(), stdout, PRINT_DEBUG_STRING(DebugManager.flags.LogWaitingForCompletion.get(), stdout,
"\nWaiting for task count %u at location %p. Current value: %u\n", "\nWaiting for task count %u at location %p. Current value: %u\n",

View File

@@ -232,7 +232,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, WaitLoopCount, -1, "-1: use default, >=0: number
DECLARE_DEBUG_VARIABLE(int32_t, GTPinAllocateBufferInSharedMemory, -1, "Force GTPin to allocate buffer in shared memory") DECLARE_DEBUG_VARIABLE(int32_t, GTPinAllocateBufferInSharedMemory, -1, "Force GTPin to allocate buffer in shared memory")
DECLARE_DEBUG_VARIABLE(int32_t, AlignLocalMemoryVaTo2MB, -1, "Allow 2MB pages for allocations with size>=2MB. On Linux it means aligned VA, on Windows it means aligned size. -1: default, 0: disabled, 1: enabled") DECLARE_DEBUG_VARIABLE(int32_t, AlignLocalMemoryVaTo2MB, -1, "Allow 2MB pages for allocations with size>=2MB. On Linux it means aligned VA, on Windows it means aligned size. -1: default, 0: disabled, 1: enabled")
DECLARE_DEBUG_VARIABLE(int32_t, EnableUserFenceForCompletionWait, -1, "-1: default (disabled), 0: disable, 1: enable : Use Wait User Fence instead Gem Wait") DECLARE_DEBUG_VARIABLE(int32_t, EnableUserFenceForCompletionWait, -1, "-1: default (disabled), 0: disable, 1: enable : Use Wait User Fence instead Gem Wait")
DECLARE_DEBUG_VARIABLE(int32_t, EnableUserFenceUseCtxId, -1, "-1: default (disabled), 0: disable, 1: enable : Use Context Id in Wait User Fence when waiting for completion tag") DECLARE_DEBUG_VARIABLE(int32_t, EnableUserFenceUseCtxId, -1, "-1: default (enabled), 0: disable, 1: enable : Use Context Id in Wait User Fence when waiting for completion tag")
/*EXPERIMENTAL TOGGLES*/ /*EXPERIMENTAL TOGGLES*/
DECLARE_DEBUG_VARIABLE(int32_t, ExperimentalEnableCustomLocalMemoryAlignment, 0, "Align local memory allocations to a given value. Works only with allocations at least as big as the value. 0: no effect, 2097152: 2 megabytes, 1073741824: 1 gigabyte") DECLARE_DEBUG_VARIABLE(int32_t, ExperimentalEnableCustomLocalMemoryAlignment, 0, "Align local memory allocations to a given value. Works only with allocations at least as big as the value. 0: no effect, 2097152: 2 megabytes, 1073741824: 1 gigabyte")

View File

@@ -19,12 +19,12 @@ bool KmdNotifyHelper::obtainTimeoutParams(int64_t &timeoutValueOutput,
uint32_t taskCountToWait, uint32_t taskCountToWait,
FlushStamp flushStampToWait, FlushStamp flushStampToWait,
bool forcePowerSavingMode, bool forcePowerSavingMode,
bool newResidencyModelActive) { bool kmdWaitModeActive) {
if (flushStampToWait == 0) { if (flushStampToWait == 0) {
return false; return false;
} }
if (newResidencyModelActive) { if (!kmdWaitModeActive) {
return false; return false;
} }

View File

@@ -42,7 +42,7 @@ class KmdNotifyHelper {
uint32_t taskCountToWait, uint32_t taskCountToWait,
FlushStamp flushStampToWait, FlushStamp flushStampToWait,
bool forcePowerSavingMode, bool forcePowerSavingMode,
bool newResidencyModelActive); bool kmdWaitModeActive);
bool quickKmdSleepForSporadicWaitsEnabled() const { return properties->enableQuickKmdSleepForSporadicWaits; } bool quickKmdSleepForSporadicWaitsEnabled() const { return properties->enableQuickKmdSleepForSporadicWaits; }
MOCKABLE_VIRTUAL void updateLastWaitForCompletionTimestamp(); MOCKABLE_VIRTUAL void updateLastWaitForCompletionTimestamp();

View File

@@ -76,15 +76,7 @@ int BufferObject::wait(int64_t timeoutNs) {
return 0; return 0;
} }
drm_i915_gem_wait wait = {}; int ret = this->drm->waitHandle(this->handle, -1);
wait.bo_handle = this->handle;
wait.timeout_ns = -1;
int ret = this->drm->ioctl(DRM_IOCTL_I915_GEM_WAIT, &wait);
if (ret != 0) {
int err = errno;
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_WAIT) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
}
UNRECOVERABLE_IF(ret != 0); UNRECOVERABLE_IF(ret != 0);
return ret; return ret;

View File

@@ -743,12 +743,18 @@ const std::vector<int> &Drm::getSliceMappings(uint32_t deviceIndex) {
return topologyMap[deviceIndex].sliceIndices; return topologyMap[deviceIndex].sliceIndices;
} }
int Drm::waitHandle(uint32_t waitHandle) { int Drm::waitHandle(uint32_t waitHandle, int64_t timeout) {
drm_i915_gem_wait wait = {}; drm_i915_gem_wait wait = {};
wait.bo_handle = waitHandle; wait.bo_handle = waitHandle;
wait.timeout_ns = -1; wait.timeout_ns = timeout;
return ioctl(DRM_IOCTL_I915_GEM_WAIT, &wait); int ret = ioctl(DRM_IOCTL_I915_GEM_WAIT, &wait);
if (ret != 0) {
int err = errno;
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(I915_GEM_WAIT) failed with %d. errno=%d(%s)\n", ret, err, strerror(err));
}
return ret;
} }
} // namespace NEO } // namespace NEO

View File

@@ -204,14 +204,14 @@ class Drm : public DriverModel {
uint64_t getNextFenceVal(uint32_t vmHandleId) { return ++fenceVal[vmHandleId]; } uint64_t getNextFenceVal(uint32_t vmHandleId) { return ++fenceVal[vmHandleId]; }
uint64_t *getFenceAddr(uint32_t vmHandleId) { return &pagingFence[vmHandleId]; } uint64_t *getFenceAddr(uint32_t vmHandleId) { return &pagingFence[vmHandleId]; }
int waitHandle(uint32_t waitHandle); int waitHandle(uint32_t waitHandle, int64_t timeout);
enum class ValueWidth : uint32_t { enum class ValueWidth : uint32_t {
U8, U8,
U16, U16,
U32, U32,
U64 U64
}; };
MOCKABLE_VIRTUAL int waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth); MOCKABLE_VIRTUAL int waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout);
void setNewResourceBound(bool value) { this->newResourceBound = value; }; void setNewResourceBound(bool value) { this->newResourceBound = value; };
bool getNewResourceBound() { return this->newResourceBound; }; bool getNewResourceBound() { return this->newResourceBound; };

View File

@@ -75,7 +75,7 @@ int Drm::unbindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObj
void Drm::waitForBind(uint32_t vmHandleId) { void Drm::waitForBind(uint32_t vmHandleId) {
} }
int Drm::waitUserFence(uint32_t ctx, uint64_t address, uint64_t value, ValueWidth dataWidth) { int Drm::waitUserFence(uint32_t ctx, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout) {
return 0; return 0;
} }

View File

@@ -84,7 +84,7 @@ int Drm::unbindBufferObject(OsContext *osContext, uint32_t vmHandleId, BufferObj
void Drm::waitForBind(uint32_t vmHandleId) { void Drm::waitForBind(uint32_t vmHandleId) {
} }
int Drm::waitUserFence(uint32_t ctx, uint64_t address, uint64_t value, ValueWidth dataWidth) { int Drm::waitUserFence(uint32_t ctx, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout) {
return 0; return 0;
} }