refactor: unify and simplify Drm CSR methods
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
parent
8c155a2e89
commit
31d351cd53
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
* Copyright (C) 2019-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -9,7 +9,6 @@
|
|||
#include "shared/source/gen11/hw_cmds.h"
|
||||
#include "shared/source/os_interface/linux/device_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream_bdw_and_later.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
* Copyright (C) 2019-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -9,7 +9,6 @@
|
|||
#include "shared/source/gen12lp/hw_cmds.h"
|
||||
#include "shared/source/os_interface/linux/device_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream_bdw_and_later.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -9,7 +9,6 @@
|
|||
#include "shared/source/gen8/hw_cmds.h"
|
||||
#include "shared/source/os_interface/linux/device_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream_bdw_and_later.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -9,7 +9,6 @@
|
|||
#include "shared/source/gen9/hw_cmds.h"
|
||||
#include "shared/source/os_interface/linux/device_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream_bdw_and_later.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ set(NEO_CORE_OS_INTERFACE_LINUX
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/drm_buffer_object.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_bdw_and_later.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_debug.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_debug.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_gem_close_worker.cpp
|
||||
|
@ -94,7 +93,6 @@ set(NEO_CORE_OS_INTERFACE_LINUX
|
|||
|
||||
if(SUPPORT_XEHP_AND_LATER)
|
||||
list(APPEND NEO_CORE_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_xehp_and_later.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/product_helper_uuid_xehp_and_later.inl
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -69,7 +69,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
|
|||
protected:
|
||||
MOCKABLE_VIRTUAL SubmissionStatus flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency);
|
||||
MOCKABLE_VIRTUAL int exec(const BatchBuffer &batchBuffer, uint32_t vmHandleId, uint32_t drmContextId, uint32_t index);
|
||||
MOCKABLE_VIRTUAL int waitUserFence(TaskCountType waitValue);
|
||||
MOCKABLE_VIRTUAL bool waitUserFence(TaskCountType waitValue, uint64_t hostAddress, int64_t timeout);
|
||||
MOCKABLE_VIRTUAL void readBackAllocation(void *source);
|
||||
bool isUserFenceWaitActive();
|
||||
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/drm_allocation.h"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename GfxFamily>
|
||||
SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) {
|
||||
auto processResidencySuccess = this->processResidency(allocationsForResidency, 0u);
|
||||
if (processResidencySuccess != SubmissionStatus::SUCCESS) {
|
||||
return processResidencySuccess;
|
||||
}
|
||||
|
||||
int ret = this->exec(batchBuffer, 0u, static_cast<const OsContextLinux *>(osContext)->getDrmContextIds()[0], 0);
|
||||
|
||||
return Drm::getSubmissionStatusFromReturnCode(ret);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
int DrmCommandStreamReceiver<GfxFamily>::waitUserFence(TaskCountType waitValue) {
|
||||
uint32_t ctxId = 0u;
|
||||
uint64_t tagAddress = castToUint64(const_cast<TagAddressType *>(getTagAddress()));
|
||||
if (useContextForUserFenceWait) {
|
||||
ctxId = static_cast<const OsContextLinux *>(osContext)->getDrmContextIds()[0];
|
||||
}
|
||||
return this->drm->waitUserFence(ctxId, tagAddress, waitValue, Drm::ValueWidth::U64, kmdWaitTimeout, 0u);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/submission_status.h"
|
||||
#include "shared/source/os_interface/linux/drm_allocation.h"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/source/os_interface/sys_calls_common.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
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>
|
||||
int DrmCommandStreamReceiver<GfxFamily>::waitUserFence(TaskCountType waitValue) {
|
||||
int ret = 0;
|
||||
StackVec<uint32_t, 32> ctxIds;
|
||||
uint64_t tagAddress = castToUint64(const_cast<TagAddressType *>(getTagAddress()));
|
||||
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(ctxIds[i], tagAddress, waitValue, Drm::ValueWidth::U64, kmdWaitTimeout, 0u);
|
||||
tagAddress += this->immWritePostSyncWriteOffset;
|
||||
}
|
||||
} else {
|
||||
for (uint32_t i = 0; i < this->activePartitions; i++) {
|
||||
ret |= this->drm->waitUserFence(0u, tagAddress, waitValue, Drm::ValueWidth::U64, kmdWaitTimeout, 0u);
|
||||
tagAddress += this->immWritePostSyncWriteOffset;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -8,7 +8,6 @@
|
|||
#include "shared/source/command_stream/command_stream_receiver_with_aub_dump.inl"
|
||||
#include "shared/source/os_interface/linux/device_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream_xehp_and_later.inl"
|
||||
#include "shared/source/xe_hp_core/hw_cmds.h"
|
||||
|
||||
namespace NEO {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -8,7 +8,6 @@
|
|||
#include "shared/source/command_stream/command_stream_receiver_with_aub_dump.inl"
|
||||
#include "shared/source/os_interface/linux/device_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream_xehp_and_later.inl"
|
||||
#include "shared/source/xe_hpc_core/hw_cmds_xe_hpc_core_base.h"
|
||||
|
||||
namespace NEO {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -8,7 +8,6 @@
|
|||
#include "shared/source/command_stream/command_stream_receiver_with_aub_dump.inl"
|
||||
#include "shared/source/os_interface/linux/device_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream.inl"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream_xehp_and_later.inl"
|
||||
#include "shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h"
|
||||
|
||||
namespace NEO {
|
||||
|
|
|
@ -108,14 +108,14 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiver<GfxFamily
|
|||
|
||||
WaitUserFenceResult waitUserFenceResult;
|
||||
|
||||
int waitUserFence(TaskCountType waitValue) override {
|
||||
bool waitUserFence(TaskCountType waitValue, uint64_t hostAddress, int64_t timeout) override {
|
||||
waitUserFenceResult.called++;
|
||||
waitUserFenceResult.waitValue = waitValue;
|
||||
|
||||
if (waitUserFenceResult.callParent) {
|
||||
return BaseClass::waitUserFence(waitValue);
|
||||
return BaseClass::waitUserFence(waitValue, hostAddress, timeout);
|
||||
} else {
|
||||
return waitUserFenceResult.returnValue;
|
||||
return (waitUserFenceResult.returnValue == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -241,6 +241,10 @@ int DrmMockCustom::waitUserFence(uint32_t ctxId, uint64_t address, uint64_t valu
|
|||
waitUserFenceCall.value = value;
|
||||
waitUserFenceCall.timeout = timeout;
|
||||
waitUserFenceCall.flags = flags;
|
||||
|
||||
if (waitUserFenceCall.called == waitUserFenceCall.failSpecificCall) {
|
||||
return 123;
|
||||
}
|
||||
return Drm::waitUserFence(ctxId, address, value, dataWidth, timeout, flags);
|
||||
}
|
||||
|
||||
|
|
|
@ -113,6 +113,7 @@ class DrmMockCustom : public Drm {
|
|||
uint16_t flags = 0;
|
||||
|
||||
uint32_t called = 0u;
|
||||
uint32_t failSpecificCall = 0;
|
||||
};
|
||||
|
||||
struct IsVmBindAvailableCall {
|
||||
|
|
|
@ -227,6 +227,27 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTestDrmPrelim, givenWaitUserFenceEnab
|
|||
EXPECT_EQ(-1, mock->context.receivedGemWaitUserFence.timeout);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTestDrmPrelim, givenFailingIoctlWhenWaitingThenDoEarlyReturn) {
|
||||
if (!FamilyType::supportsCmdSet(IGFX_XE_HP_CORE)) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
auto testDrmCsr = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr);
|
||||
testDrmCsr->useUserFenceWait = true;
|
||||
testDrmCsr->useContextForUserFenceWait = false;
|
||||
testDrmCsr->activePartitions = 3u;
|
||||
|
||||
mock->waitUserFenceCall.failSpecificCall = 2;
|
||||
|
||||
FlushStamp handleToWait = 123;
|
||||
|
||||
EXPECT_EQ(0u, mock->waitUserFenceCall.called);
|
||||
|
||||
testDrmCsr->waitForFlushStamp(handleToWait);
|
||||
|
||||
EXPECT_EQ(2u, mock->waitUserFenceCall.called);
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocationWithMultipleBufferObjectsAndTileInstancedSetWhenMakeResidentIsCalledThenTheBufferObjectForDeviceCsrIsMadeResident) {
|
||||
if (!FamilyType::supportsCmdSet(IGFX_XE_HP_CORE)) {
|
||||
GTEST_SKIP();
|
||||
|
|
Loading…
Reference in New Issue