refactor: unify and simplify Drm CSR methods

Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2023-07-20 09:14:08 +00:00
committed by Compute-Runtime-Automation
parent 8c155a2e89
commit 31d351cd53
16 changed files with 107 additions and 141 deletions

View File

@@ -321,7 +321,8 @@ template <typename GfxFamily>
bool DrmCommandStreamReceiver<GfxFamily>::waitForFlushStamp(FlushStamp &flushStamp) {
auto waitValue = static_cast<uint32_t>(flushStamp);
if (isUserFenceWaitActive()) {
waitUserFence(waitValue);
uint64_t tagAddress = castToUint64(const_cast<TagAddressType *>(getTagAddress()));
return waitUserFence(waitValue, tagAddress, kmdWaitTimeout);
} else {
this->drm->waitHandle(waitValue, kmdWaitTimeout);
}
@@ -329,6 +330,74 @@ bool DrmCommandStreamReceiver<GfxFamily>::waitForFlushStamp(FlushStamp &flushSta
return true;
}
template <typename GfxFamily>
SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) {
if (drm->useVMBindImmediate()) {
auto osContextLinux = static_cast<OsContextLinux *>(this->osContext);
osContextLinux->waitForPagingFence();
}
auto &drmContextIds = static_cast<const OsContextLinux *>(osContext)->getDrmContextIds();
uint32_t contextIndex = 0;
for (auto tileIterator = 0u; tileIterator < this->osContext->getDeviceBitfield().size(); tileIterator++) {
if (this->osContext->getDeviceBitfield().test(tileIterator)) {
if (DebugManager.flags.ForceExecutionTile.get() != -1 && this->osContext->getDeviceBitfield().count() > 1) {
tileIterator = contextIndex = DebugManager.flags.ForceExecutionTile.get();
}
auto processResidencySuccess = this->processResidency(allocationsForResidency, tileIterator);
if (processResidencySuccess != SubmissionStatus::SUCCESS) {
return processResidencySuccess;
}
if (DebugManager.flags.PrintDeviceAndEngineIdOnSubmission.get()) {
printf("%u: Drm Submission of contextIndex: %u, with context id %u\n", SysCalls::getProcessId(), contextIndex, drmContextIds[contextIndex]);
}
int ret = this->exec(batchBuffer, tileIterator, drmContextIds[contextIndex], contextIndex);
if (ret) {
return Drm::getSubmissionStatusFromReturnCode(ret);
}
contextIndex++;
if (DebugManager.flags.EnableWalkerPartition.get() == 0) {
return SubmissionStatus::SUCCESS;
}
}
}
return SubmissionStatus::SUCCESS;
}
template <typename GfxFamily>
bool DrmCommandStreamReceiver<GfxFamily>::waitUserFence(TaskCountType waitValue, uint64_t hostAddress, int64_t timeout) {
int ret = 0;
StackVec<uint32_t, 32> ctxIds;
if (useContextForUserFenceWait) {
for (auto tileIterator = 0u; tileIterator < this->osContext->getDeviceBitfield().size(); tileIterator++) {
uint32_t ctxId = 0u;
if (this->osContext->getDeviceBitfield().test(tileIterator)) {
ctxId = static_cast<const OsContextLinux *>(osContext)->getDrmContextIds()[tileIterator];
ctxIds.push_back(ctxId);
}
}
UNRECOVERABLE_IF(ctxIds.size() != this->activePartitions);
}
for (uint32_t i = 0; i < this->activePartitions; i++) {
ret |= this->drm->waitUserFence(useContextForUserFenceWait ? ctxIds[i] : 0, hostAddress, waitValue, Drm::ValueWidth::U64, timeout, 0u);
if (ret != 0) {
break;
}
hostAddress += this->immWritePostSyncWriteOffset;
}
return (ret == 0);
}
template <typename GfxFamily>
bool DrmCommandStreamReceiver<GfxFamily>::isKmdWaitModeActive() {
if (this->drm->isVmBindAvailable()) {