refactor: prework to pass interrupt hint

Related-To: NEO-8179

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2024-04-26 14:39:26 +00:00
committed by Compute-Runtime-Automation
parent 96ec8e3c2e
commit 806da85ec6
21 changed files with 129 additions and 34 deletions

View File

@@ -64,7 +64,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
SubmissionStatus printBOsForSubmit(ResidencyContainer &allocationsForResidency, GraphicsAllocation &cmdBufferAllocation);
bool waitUserFence(TaskCountType waitValue, uint64_t hostAddress, int64_t timeout) override;
bool waitUserFence(TaskCountType waitValue, uint64_t hostAddress, int64_t timeout, bool userInterrupt, uint32_t externalInterruptId) override;
using CommandStreamReceiver::pageTableManager;

View File

@@ -318,7 +318,7 @@ bool DrmCommandStreamReceiver<GfxFamily>::waitForFlushStamp(FlushStamp &flushSta
auto waitValue = static_cast<uint32_t>(flushStamp);
if (isUserFenceWaitActive()) {
uint64_t tagAddress = castToUint64(const_cast<TagAddressType *>(getTagAddress()));
return waitUserFence(waitValue, tagAddress, kmdWaitTimeout);
return waitUserFence(waitValue, tagAddress, kmdWaitTimeout, false, NEO::InterruptId::notUsed);
} else {
this->drm->waitHandle(waitValue, kmdWaitTimeout);
}
@@ -368,8 +368,8 @@ SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::flushInternal(const BatchB
}
template <typename GfxFamily>
bool DrmCommandStreamReceiver<GfxFamily>::waitUserFence(TaskCountType waitValue, uint64_t hostAddress, int64_t timeout) {
int ret = drm->waitOnUserFences(static_cast<const OsContextLinux &>(*this->osContext), hostAddress, waitValue, this->activePartitions, timeout, this->immWritePostSyncWriteOffset);
bool DrmCommandStreamReceiver<GfxFamily>::waitUserFence(TaskCountType waitValue, uint64_t hostAddress, int64_t timeout, bool userInterrupt, uint32_t externalInterruptId) {
int ret = drm->waitOnUserFences(static_cast<const OsContextLinux &>(*this->osContext), hostAddress, waitValue, this->activePartitions, timeout, this->immWritePostSyncWriteOffset, userInterrupt, externalInterruptId);
return (ret == 0);
}

View File

@@ -2221,7 +2221,8 @@ void DrmMemoryManager::waitOnCompletionFence(GraphicsAllocation *allocation) {
if (allocation->isUsedByOsContext(osContextId)) {
Drm &drm = getDrm(csr->getRootDeviceIndex());
drm.waitOnUserFences(static_cast<const OsContextLinux &>(*osContext), completionFenceAddress, allocationTaskCount, csr->getActivePartitions(), -1, csr->getImmWritePostSyncWriteOffset());
drm.waitOnUserFences(static_cast<const OsContextLinux &>(*osContext), completionFenceAddress, allocationTaskCount, csr->getActivePartitions(), -1,
csr->getImmWritePostSyncWriteOffset(), false, NEO::InterruptId::notUsed);
}
}
} else {

View File

@@ -960,8 +960,8 @@ void Drm::getPrelimVersion(std::string &prelimVersion) {
ifs.close();
}
int Drm::waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout, uint16_t flags) {
return ioctlHelper->waitUserFence(ctxId, address, value, static_cast<uint32_t>(dataWidth), timeout, flags, false, NEO::InterruptId::notUsed);
int Drm::waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout, uint16_t flags, bool userInterrupt, uint32_t externalInterruptId) {
return ioctlHelper->waitUserFence(ctxId, address, value, static_cast<uint32_t>(dataWidth), timeout, flags, userInterrupt, externalInterruptId);
}
bool Drm::querySystemInfo() {
@@ -1165,7 +1165,7 @@ void Drm::waitForBind(uint32_t vmHandleId) {
auto fenceValue = this->fenceVal[vmHandleId];
lock.unlock();
waitUserFence(0u, fenceAddress, fenceValue, ValueWidth::u64, -1, ioctlHelper->getWaitUserFenceSoftFlag());
waitUserFence(0u, fenceAddress, fenceValue, ValueWidth::u64, -1, ioctlHelper->getWaitUserFenceSoftFlag(), false, NEO::InterruptId::notUsed);
}
bool Drm::isSetPairAvailable() {
@@ -1557,7 +1557,7 @@ PhysicalDevicePciSpeedInfo Drm::getPciSpeedInfo() const {
return pciSpeedInfo;
}
int Drm::waitOnUserFences(const OsContextLinux &osContext, uint64_t address, uint64_t value, uint32_t numActiveTiles, int64_t timeout, uint32_t postSyncOffset) {
int Drm::waitOnUserFences(const OsContextLinux &osContext, uint64_t address, uint64_t value, uint32_t numActiveTiles, int64_t timeout, uint32_t postSyncOffset, bool userInterrupt, uint32_t externalInterruptId) {
auto &drmContextIds = osContext.getDrmContextIds();
UNRECOVERABLE_IF(numActiveTiles > drmContextIds.size());
auto completionFenceCpuAddress = address;
@@ -1566,7 +1566,7 @@ int Drm::waitOnUserFences(const OsContextLinux &osContext, uint64_t address, uin
for (auto drmIterator = 0u; drmIterator < numActiveTiles; drmIterator++) {
if (*reinterpret_cast<uint32_t *>(completionFenceCpuAddress) < value) {
static constexpr uint16_t flags = 0;
int retVal = waitUserFence(drmContextIds[drmIterator], completionFenceCpuAddress, value, Drm::ValueWidth::u64, selectedTimeout, flags);
int retVal = waitUserFence(drmContextIds[drmIterator], completionFenceCpuAddress, value, Drm::ValueWidth::u64, selectedTimeout, flags, userInterrupt, externalInterruptId);
if (debugManager.flags.PrintCompletionFenceUsage.get()) {
std::cout << "Completion fence waited."
<< " Status: " << retVal
@@ -1583,6 +1583,11 @@ int Drm::waitOnUserFences(const OsContextLinux &osContext, uint64_t address, uin
<< ", current value: " << *reinterpret_cast<uint32_t *>(completionFenceCpuAddress)
<< ", wait value: " << value << std::endl;
}
if (externalInterruptId != NEO::InterruptId::notUsed) {
break;
}
completionFenceCpuAddress = ptrOffset(completionFenceCpuAddress, postSyncOffset);
}

View File

@@ -220,9 +220,9 @@ class Drm : public DriverModel {
u32,
u64
};
MOCKABLE_VIRTUAL int waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout, uint16_t flags);
MOCKABLE_VIRTUAL int waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout, uint16_t flags, bool userInterrupt, uint32_t externalInterruptId);
int waitOnUserFences(const OsContextLinux &osContext, uint64_t address, uint64_t value, uint32_t numActiveTiles, int64_t timeout, uint32_t postSyncOffset);
int waitOnUserFences(const OsContextLinux &osContext, uint64_t address, uint64_t value, uint32_t numActiveTiles, int64_t timeout, uint32_t postSyncOffset, bool userInterrupt, uint32_t externalInterruptId);
void setNewResourceBoundToVM(BufferObject *bo, uint32_t vmHandleId);

View File

@@ -87,7 +87,7 @@ uint32_t MemoryInfo::getLocalMemoryRegionIndex(DeviceBitfield deviceBitfield) co
auto &productHelper = this->drm.getRootDeviceEnvironment().getHelper<ProductHelper>();
bool bankOverrideRequired{gfxCoreHelper.isBankOverrideRequired(hwInfo, productHelper)};
uint32_t tileIndex{bankOverrideRequired ? 0u : Math::log2(deviceBitfield.to_ulong())};
uint32_t tileIndex{bankOverrideRequired ? 0u : Math::log2(static_cast<uint64_t>(deviceBitfield.to_ulong()))};
if (debugManager.flags.OverrideDrmRegion.get() != -1) {
tileIndex = debugManager.flags.OverrideDrmRegion.get();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -108,7 +108,7 @@ void OsContextLinux::waitForBind(uint32_t drmIterator) {
auto fenceValue = this->fenceVal[drmIterator];
lock.unlock();
drm.waitUserFence(0u, fenceAddress, fenceValue, Drm::ValueWidth::u64, -1, drm.getIoctlHelper()->getWaitUserFenceSoftFlag());
drm.waitUserFence(0u, fenceAddress, fenceValue, Drm::ValueWidth::u64, -1, drm.getIoctlHelper()->getWaitUserFenceSoftFlag(), false, NEO::InterruptId::notUsed);
} else {
drm.waitForBind(drmIterator);